/*==========================================================================*\
| _QueueDescriptor.java
|*-------------------------------------------------------------------------*|
| Created by eogenerator
| DO NOT EDIT. Make changes to QueueDescriptor.java instead.
|*-------------------------------------------------------------------------*|
| Copyright (C) 2006-2012 Virginia Tech
|
| This file is part of Web-CAT.
|
| Web-CAT is free software; you can redistribute it and/or modify
| it under the terms of the GNU Affero General Public License as published
| by the Free Software Foundation; either version 3 of the License, or
| (at your option) any later version.
|
| Web-CAT is distributed in the hope that it will be useful,
| but WITHOUT ANY WARRANTY; without even the implied warranty of
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
| GNU General Public License for more details.
|
| You should have received a copy of the GNU Affero General Public License
| along with Web-CAT; if not, see <http://www.gnu.org/licenses/>.
\*==========================================================================*/
package org.webcat.jobqueue;
import com.webobjects.eoaccess.*;
import com.webobjects.eocontrol.*;
import com.webobjects.foundation.*;
import er.extensions.eof.ERXEOControlUtilities;
import er.extensions.eof.ERXKey;
import org.apache.log4j.Logger;
import org.webcat.core.EOBasedKeyGenerator;
import org.webcat.woextensions.WCFetchSpecification;
// -------------------------------------------------------------------------
/**
* An automatically generated EOGenericRecord subclass. DO NOT EDIT.
* To change, use EOModeler, or make additions in
* QueueDescriptor.java.
*
* @author Generated by eogenerator
* @version version suppressed to control auto-generation
*/
public abstract class _QueueDescriptor
extends org.webcat.core.EOBase
{
//~ Constructors ..........................................................
// ----------------------------------------------------------
/**
* Creates a new _QueueDescriptor object.
*/
public _QueueDescriptor()
{
super();
}
// ----------------------------------------------------------
/**
* A static factory method for creating a new
* QueueDescriptor object given required
* attributes and relationships.
* @param editingContext The context in which the new object will be
* inserted
* @param jobEntityNameValue
* @param newestEntryIdValue
* @return The newly created object
*/
public static QueueDescriptor create(
EOEditingContext editingContext,
String jobEntityNameValue,
long newestEntryIdValue
)
{
QueueDescriptor eoObject = (QueueDescriptor)
EOUtilities.createAndInsertInstance(
editingContext,
_QueueDescriptor.ENTITY_NAME);
eoObject.setJobEntityName(jobEntityNameValue);
eoObject.setNewestEntryId(newestEntryIdValue);
return eoObject;
}
// ----------------------------------------------------------
/**
* Get a local instance of the given object in another editing context.
* @param editingContext The target editing context
* @param eo The object to import
* @return An instance of the given object in the target editing context
*/
public static QueueDescriptor localInstance(
EOEditingContext editingContext, QueueDescriptor eo)
{
return (eo == null)
? null
: (QueueDescriptor)EOUtilities.localInstanceOfObject(
editingContext, eo);
}
// ----------------------------------------------------------
/**
* Look up an object by id number. Assumes the editing
* context is appropriately locked.
* @param ec The editing context to use
* @param id The id to look up
* @return The object, or null if no such id exists
*/
public static QueueDescriptor forId(
EOEditingContext ec, int id)
{
QueueDescriptor obj = null;
if (id > 0)
{
NSArray<QueueDescriptor> objects =
objectsMatchingValues(ec, "id", new Integer(id));
if (objects != null && objects.count() > 0)
{
obj = objects.objectAtIndex(0);
}
}
return obj;
}
// ----------------------------------------------------------
/**
* Look up an object by id number. Assumes the editing
* context is appropriately locked.
* @param ec The editing context to use
* @param id The id to look up
* @return The object, or null if no such id exists
*/
public static QueueDescriptor forId(
EOEditingContext ec, String id)
{
return forId(ec, er.extensions.foundation.ERXValueUtilities.intValue(id));
}
//~ Constants (for key names) .............................................
// Attributes ---
public static final String CUMULATIVE_PROCESSING_TIME_KEY = "cumulativeProcessingTime";
public static final ERXKey<Long> cumulativeProcessingTime =
new ERXKey<Long>(CUMULATIVE_PROCESSING_TIME_KEY);
public static final String DEFAULT_JOB_PROCESSING_TIME_KEY = "defaultJobProcessingTime";
public static final ERXKey<Long> defaultJobProcessingTime =
new ERXKey<Long>(DEFAULT_JOB_PROCESSING_TIME_KEY);
public static final String JOB_ENTITY_NAME_KEY = "jobEntityName";
public static final ERXKey<String> jobEntityName =
new ERXKey<String>(JOB_ENTITY_NAME_KEY);
public static final String JOBS_PROCESSED_KEY = "jobsProcessed";
public static final ERXKey<Long> jobsProcessed =
new ERXKey<Long>(JOBS_PROCESSED_KEY);
public static final String MOST_RECENT_JOB_WAIT_KEY = "mostRecentJobWait";
public static final ERXKey<Long> mostRecentJobWait =
new ERXKey<Long>(MOST_RECENT_JOB_WAIT_KEY);
public static final String MOVING_AVERAGE_PROCESSING_TIME_KEY = "movingAverageProcessingTime";
public static final ERXKey<Long> movingAverageProcessingTime =
new ERXKey<Long>(MOVING_AVERAGE_PROCESSING_TIME_KEY);
public static final String NEWEST_ENTRY_ID_KEY = "newestEntryId";
public static final ERXKey<Long> newestEntryId =
new ERXKey<Long>(NEWEST_ENTRY_ID_KEY);
public static final String REQUIRES_EXCLUSIVE_HOST_ACCESS_KEY = "requiresExclusiveHostAccess";
public static final ERXKey<Integer> requiresExclusiveHostAccess =
new ERXKey<Integer>(REQUIRES_EXCLUSIVE_HOST_ACCESS_KEY);
// To-one relationships ---
// To-many relationships ---
public static final String WORKERS_KEY = "workers";
public static final ERXKey<org.webcat.jobqueue.WorkerDescriptor> workers =
new ERXKey<org.webcat.jobqueue.WorkerDescriptor>(WORKERS_KEY);
// Fetch specifications ---
public static final String DESCRIPTORS_FOR_JOB_ENTITY_NAME_FSPEC = "descriptorsForJobEntityName";
public static final String ENTITY_NAME = "QueueDescriptor";
public transient final EOBasedKeyGenerator generateKey =
new EOBasedKeyGenerator(this);
//~ Methods ...............................................................
// ----------------------------------------------------------
/**
* Get a local instance of this object in another editing context.
* @param editingContext The target editing context
* @return An instance of this object in the target editing context
*/
public QueueDescriptor localInstance(EOEditingContext editingContext)
{
return (QueueDescriptor)EOUtilities.localInstanceOfObject(
editingContext, this);
}
// ----------------------------------------------------------
/**
* Get a list of changes between this object's current state and the
* last committed version.
* @return a dictionary of the changes that have not yet been committed
*/
@SuppressWarnings("unchecked")
public NSDictionary<String, Object> changedProperties()
{
return changesFromSnapshot(
editingContext().committedSnapshotForObject(this));
}
// ----------------------------------------------------------
/**
* Retrieve this object's <code>id</code> value.
* @return the value of the attribute
*/
public Number id()
{
try
{
return (Number)EOUtilities.primaryKeyForObject(
editingContext() , this).objectForKey("id");
}
catch (Exception e)
{
return er.extensions.eof.ERXConstant.ZeroInteger;
}
}
// ----------------------------------------------------------
/**
* Retrieve this object's <code>cumulativeProcessingTime</code> value.
* @return the value of the attribute
*/
public long cumulativeProcessingTime()
{
Long returnValue =
(Long)storedValueForKey( "cumulativeProcessingTime" );
return ( returnValue == null )
? 0L
: returnValue.longValue();
}
// ----------------------------------------------------------
/**
* Change the value of this object's <code>cumulativeProcessingTime</code>
* property.
*
* @param value The new value for this property
*/
public void setCumulativeProcessingTime( long value )
{
if (log.isDebugEnabled())
{
log.debug( "setCumulativeProcessingTime("
+ value + "): was " + cumulativeProcessingTime() );
}
Long actual =
new Long( value );
setCumulativeProcessingTimeRaw( actual );
}
// ----------------------------------------------------------
/**
* Retrieve this object's <code>cumulativeProcessingTime</code> value.
* @return the value of the attribute
*/
public Long cumulativeProcessingTimeRaw()
{
return (Long)storedValueForKey( "cumulativeProcessingTime" );
}
// ----------------------------------------------------------
/**
* Change the value of this object's <code>cumulativeProcessingTime</code>
* property.
*
* @param value The new value for this property
*/
public void setCumulativeProcessingTimeRaw( Long value )
{
if (log.isDebugEnabled())
{
log.debug( "setCumulativeProcessingTimeRaw("
+ value + "): was " + cumulativeProcessingTimeRaw() );
}
takeStoredValueForKey( value, "cumulativeProcessingTime" );
}
// ----------------------------------------------------------
/**
* Retrieve this object's <code>defaultJobProcessingTime</code> value.
* @return the value of the attribute
*/
public long defaultJobProcessingTime()
{
Long returnValue =
(Long)storedValueForKey( "defaultJobProcessingTime" );
return ( returnValue == null )
? 0L
: returnValue.longValue();
}
// ----------------------------------------------------------
/**
* Change the value of this object's <code>defaultJobProcessingTime</code>
* property.
*
* @param value The new value for this property
*/
public void setDefaultJobProcessingTime( long value )
{
if (log.isDebugEnabled())
{
log.debug( "setDefaultJobProcessingTime("
+ value + "): was " + defaultJobProcessingTime() );
}
Long actual =
new Long( value );
setDefaultJobProcessingTimeRaw( actual );
}
// ----------------------------------------------------------
/**
* Retrieve this object's <code>defaultJobProcessingTime</code> value.
* @return the value of the attribute
*/
public Long defaultJobProcessingTimeRaw()
{
return (Long)storedValueForKey( "defaultJobProcessingTime" );
}
// ----------------------------------------------------------
/**
* Change the value of this object's <code>defaultJobProcessingTime</code>
* property.
*
* @param value The new value for this property
*/
public void setDefaultJobProcessingTimeRaw( Long value )
{
if (log.isDebugEnabled())
{
log.debug( "setDefaultJobProcessingTimeRaw("
+ value + "): was " + defaultJobProcessingTimeRaw() );
}
takeStoredValueForKey( value, "defaultJobProcessingTime" );
}
// ----------------------------------------------------------
/**
* Retrieve this object's <code>jobEntityName</code> value.
* @return the value of the attribute
*/
public String jobEntityName()
{
return (String)storedValueForKey( "jobEntityName" );
}
// ----------------------------------------------------------
/**
* Change the value of this object's <code>jobEntityName</code>
* property.
*
* @param value The new value for this property
*/
public void setJobEntityName( String value )
{
if (log.isDebugEnabled())
{
log.debug( "setJobEntityName("
+ value + "): was " + jobEntityName() );
}
takeStoredValueForKey( value, "jobEntityName" );
}
// ----------------------------------------------------------
/**
* Retrieve this object's <code>jobsProcessed</code> value.
* @return the value of the attribute
*/
public long jobsProcessed()
{
Long returnValue =
(Long)storedValueForKey( "jobsProcessed" );
return ( returnValue == null )
? 0L
: returnValue.longValue();
}
// ----------------------------------------------------------
/**
* Change the value of this object's <code>jobsProcessed</code>
* property.
*
* @param value The new value for this property
*/
public void setJobsProcessed( long value )
{
if (log.isDebugEnabled())
{
log.debug( "setJobsProcessed("
+ value + "): was " + jobsProcessed() );
}
Long actual =
new Long( value );
setJobsProcessedRaw( actual );
}
// ----------------------------------------------------------
/**
* Retrieve this object's <code>jobsProcessed</code> value.
* @return the value of the attribute
*/
public Long jobsProcessedRaw()
{
return (Long)storedValueForKey( "jobsProcessed" );
}
// ----------------------------------------------------------
/**
* Change the value of this object's <code>jobsProcessed</code>
* property.
*
* @param value The new value for this property
*/
public void setJobsProcessedRaw( Long value )
{
if (log.isDebugEnabled())
{
log.debug( "setJobsProcessedRaw("
+ value + "): was " + jobsProcessedRaw() );
}
takeStoredValueForKey( value, "jobsProcessed" );
}
// ----------------------------------------------------------
/**
* Retrieve this object's <code>mostRecentJobWait</code> value.
* @return the value of the attribute
*/
public long mostRecentJobWait()
{
Long returnValue =
(Long)storedValueForKey( "mostRecentJobWait" );
return ( returnValue == null )
? 0L
: returnValue.longValue();
}
// ----------------------------------------------------------
/**
* Change the value of this object's <code>mostRecentJobWait</code>
* property.
*
* @param value The new value for this property
*/
public void setMostRecentJobWait( long value )
{
if (log.isDebugEnabled())
{
log.debug( "setMostRecentJobWait("
+ value + "): was " + mostRecentJobWait() );
}
Long actual =
new Long( value );
setMostRecentJobWaitRaw( actual );
}
// ----------------------------------------------------------
/**
* Retrieve this object's <code>mostRecentJobWait</code> value.
* @return the value of the attribute
*/
public Long mostRecentJobWaitRaw()
{
return (Long)storedValueForKey( "mostRecentJobWait" );
}
// ----------------------------------------------------------
/**
* Change the value of this object's <code>mostRecentJobWait</code>
* property.
*
* @param value The new value for this property
*/
public void setMostRecentJobWaitRaw( Long value )
{
if (log.isDebugEnabled())
{
log.debug( "setMostRecentJobWaitRaw("
+ value + "): was " + mostRecentJobWaitRaw() );
}
takeStoredValueForKey( value, "mostRecentJobWait" );
}
// ----------------------------------------------------------
/**
* Retrieve this object's <code>movingAverageProcessingTime</code> value.
* @return the value of the attribute
*/
public long movingAverageProcessingTime()
{
Long returnValue =
(Long)storedValueForKey( "movingAverageProcessingTime" );
return ( returnValue == null )
? 0L
: returnValue.longValue();
}
// ----------------------------------------------------------
/**
* Change the value of this object's <code>movingAverageProcessingTime</code>
* property.
*
* @param value The new value for this property
*/
public void setMovingAverageProcessingTime( long value )
{
if (log.isDebugEnabled())
{
log.debug( "setMovingAverageProcessingTime("
+ value + "): was " + movingAverageProcessingTime() );
}
Long actual =
new Long( value );
setMovingAverageProcessingTimeRaw( actual );
}
// ----------------------------------------------------------
/**
* Retrieve this object's <code>movingAverageProcessingTime</code> value.
* @return the value of the attribute
*/
public Long movingAverageProcessingTimeRaw()
{
return (Long)storedValueForKey( "movingAverageProcessingTime" );
}
// ----------------------------------------------------------
/**
* Change the value of this object's <code>movingAverageProcessingTime</code>
* property.
*
* @param value The new value for this property
*/
public void setMovingAverageProcessingTimeRaw( Long value )
{
if (log.isDebugEnabled())
{
log.debug( "setMovingAverageProcessingTimeRaw("
+ value + "): was " + movingAverageProcessingTimeRaw() );
}
takeStoredValueForKey( value, "movingAverageProcessingTime" );
}
// ----------------------------------------------------------
/**
* Retrieve this object's <code>newestEntryId</code> value.
* @return the value of the attribute
*/
public long newestEntryId()
{
Long returnValue =
(Long)storedValueForKey( "newestEntryId" );
return ( returnValue == null )
? 0L
: returnValue.longValue();
}
// ----------------------------------------------------------
/**
* Change the value of this object's <code>newestEntryId</code>
* property.
*
* @param value The new value for this property
*/
public void setNewestEntryId( long value )
{
if (log.isDebugEnabled())
{
log.debug( "setNewestEntryId("
+ value + "): was " + newestEntryId() );
}
Long actual =
new Long( value );
setNewestEntryIdRaw( actual );
}
// ----------------------------------------------------------
/**
* Retrieve this object's <code>newestEntryId</code> value.
* @return the value of the attribute
*/
public Long newestEntryIdRaw()
{
return (Long)storedValueForKey( "newestEntryId" );
}
// ----------------------------------------------------------
/**
* Change the value of this object's <code>newestEntryId</code>
* property.
*
* @param value The new value for this property
*/
public void setNewestEntryIdRaw( Long value )
{
if (log.isDebugEnabled())
{
log.debug( "setNewestEntryIdRaw("
+ value + "): was " + newestEntryIdRaw() );
}
takeStoredValueForKey( value, "newestEntryId" );
}
// ----------------------------------------------------------
/**
* Retrieve this object's <code>requiresExclusiveHostAccess</code> value.
* @return the value of the attribute
*/
public boolean requiresExclusiveHostAccess()
{
Integer returnValue =
(Integer)storedValueForKey( "requiresExclusiveHostAccess" );
return ( returnValue == null )
? false
: ( returnValue.intValue() > 0 );
}
// ----------------------------------------------------------
/**
* Change the value of this object's <code>requiresExclusiveHostAccess</code>
* property.
*
* @param value The new value for this property
*/
public void setRequiresExclusiveHostAccess( boolean value )
{
if (log.isDebugEnabled())
{
log.debug( "setRequiresExclusiveHostAccess("
+ value + "): was " + requiresExclusiveHostAccess() );
}
Integer actual =
er.extensions.eof.ERXConstant.integerForInt( value ? 1 : 0 );
setRequiresExclusiveHostAccessRaw( actual );
}
// ----------------------------------------------------------
/**
* Retrieve this object's <code>requiresExclusiveHostAccess</code> value.
* @return the value of the attribute
*/
public Integer requiresExclusiveHostAccessRaw()
{
return (Integer)storedValueForKey( "requiresExclusiveHostAccess" );
}
// ----------------------------------------------------------
/**
* Change the value of this object's <code>requiresExclusiveHostAccess</code>
* property.
*
* @param value The new value for this property
*/
public void setRequiresExclusiveHostAccessRaw( Integer value )
{
if (log.isDebugEnabled())
{
log.debug( "setRequiresExclusiveHostAccessRaw("
+ value + "): was " + requiresExclusiveHostAccessRaw() );
}
takeStoredValueForKey( value, "requiresExclusiveHostAccess" );
}
// ----------------------------------------------------------
/**
* Retrieve the entities pointed to by the <code>workers</code>
* relationship.
* @return an NSArray of the entities in the relationship
*/
@SuppressWarnings("unchecked")
public NSArray<org.webcat.jobqueue.WorkerDescriptor> workers()
{
return (NSArray)storedValueForKey( "workers" );
}
// ----------------------------------------------------------
/**
* Replace the list of entities pointed to by the
* <code>workers</code> relationship.
*
* @param value The new set of entities to relate to
*/
public void setWorkers( NSMutableArray<org.webcat.jobqueue.WorkerDescriptor> value )
{
if (log.isDebugEnabled())
{
log.debug( "setWorkers("
+ value + "): was " + workers() );
}
takeStoredValueForKey( value, "workers" );
}
// ----------------------------------------------------------
/**
* Add a new entity to the <code>workers</code>
* relationship (DO NOT USE--instead, use
* <code>addToWorkersRelationship()</code>.
* This method is provided for WebObjects use.
*
* @param value The new entity to relate to
*/
public void addToWorkers( org.webcat.jobqueue.WorkerDescriptor value )
{
if (log.isDebugEnabled())
{
log.debug( "addToWorkers("
+ value + "): was " + workers() );
}
NSMutableArray<org.webcat.jobqueue.WorkerDescriptor> array =
(NSMutableArray<org.webcat.jobqueue.WorkerDescriptor>)workers();
willChange();
array.addObject( value );
}
// ----------------------------------------------------------
/**
* Remove a specific entity from the <code>workers</code>
* relationship (DO NOT USE--instead, use
* <code>removeFromWorkersRelationship()</code>.
* This method is provided for WebObjects use.
*
* @param value The entity to remove from the relationship
*/
public void removeFromWorkers( org.webcat.jobqueue.WorkerDescriptor value )
{
if (log.isDebugEnabled())
{
log.debug( "RemoveFromWorkers("
+ value + "): was " + workers() );
}
NSMutableArray<org.webcat.jobqueue.WorkerDescriptor> array =
(NSMutableArray<org.webcat.jobqueue.WorkerDescriptor>)workers();
willChange();
array.removeObject( value );
}
// ----------------------------------------------------------
/**
* Add a new entity to the <code>workers</code>
* relationship.
*
* @param value The new entity to relate to
*/
public void addToWorkersRelationship( org.webcat.jobqueue.WorkerDescriptor value )
{
if (log.isDebugEnabled())
{
log.debug( "addToWorkersRelationship("
+ value + "): was " + workers() );
}
addObjectToBothSidesOfRelationshipWithKey(
value, "workers" );
}
// ----------------------------------------------------------
/**
* Remove a specific entity from the <code>workers</code>
* relationship.
*
* @param value The entity to remove from the relationship
*/
public void removeFromWorkersRelationship( org.webcat.jobqueue.WorkerDescriptor value )
{
if (log.isDebugEnabled())
{
log.debug( "removeFromWorkersRelationship("
+ value + "): was " + workers() );
}
removeObjectFromBothSidesOfRelationshipWithKey(
value, "workers" );
}
// ----------------------------------------------------------
/**
* Create a brand new object that is a member of the
* <code>workers</code> relationship.
*
* @return The new entity
*/
public org.webcat.jobqueue.WorkerDescriptor createWorkersRelationship()
{
if (log.isDebugEnabled())
{
log.debug( "createWorkersRelationship()" );
}
EOClassDescription eoClassDesc = EOClassDescription
.classDescriptionForEntityName( "WorkerDescriptor" );
EOEnterpriseObject eoObject = eoClassDesc
.createInstanceWithEditingContext( editingContext(), null );
editingContext().insertObject( eoObject );
addObjectToBothSidesOfRelationshipWithKey(
eoObject, "workers" );
return (org.webcat.jobqueue.WorkerDescriptor)eoObject;
}
// ----------------------------------------------------------
/**
* Remove and then delete a specific entity that is a member of the
* <code>workers</code> relationship.
*
* @param value The entity to remove from the relationship and then delete
*/
public void deleteWorkersRelationship( org.webcat.jobqueue.WorkerDescriptor value )
{
if (log.isDebugEnabled())
{
log.debug( "deleteWorkersRelationship("
+ value + "): was " + workers() );
}
removeObjectFromBothSidesOfRelationshipWithKey(
value, "workers" );
editingContext().deleteObject( value );
}
// ----------------------------------------------------------
/**
* Remove (and then delete, if owned) all entities that are members of the
* <code>workers</code> relationship.
*/
public void deleteAllWorkersRelationships()
{
if (log.isDebugEnabled())
{
log.debug( "deleteAllWorkersRelationships(): was "
+ workers() );
}
for (org.webcat.jobqueue.WorkerDescriptor object : workers())
{
deleteWorkersRelationship(object);
}
}
// ----------------------------------------------------------
/**
* Retrieve objects using a fetch specification.
*
* @param context The editing context to use
* @param fspec The fetch specification to use
*
* @return an NSArray of the entities retrieved
*/
@SuppressWarnings("unchecked")
public static NSArray<QueueDescriptor> objectsWithFetchSpecification(
EOEditingContext context,
EOFetchSpecification fspec)
{
return context.objectsWithFetchSpecification(fspec);
}
// ----------------------------------------------------------
/**
* Retrieve all objects of this type.
*
* @param context The editing context to use
*
* @return an NSArray of the entities retrieved
*/
public static NSArray<QueueDescriptor> allObjects(
EOEditingContext context)
{
return objectsMatchingQualifier(context, null, null);
}
// ----------------------------------------------------------
/**
* Retrieve objects using a qualifier.
*
* @param context The editing context to use
* @param qualifier The qualifier to use
*
* @return an NSArray of the entities retrieved
*/
public static NSArray<QueueDescriptor> objectsMatchingQualifier(
EOEditingContext context,
EOQualifier qualifier)
{
return objectsMatchingQualifier(context, qualifier, null);
}
// ----------------------------------------------------------
/**
* Retrieve objects using a qualifier and sort orderings.
*
* @param context The editing context to use
* @param qualifier The qualifier to use
* @param sortOrderings The sort orderings to use
*
* @return an NSArray of the entities retrieved
*/
public static NSArray<QueueDescriptor> objectsMatchingQualifier(
EOEditingContext context,
EOQualifier qualifier,
NSArray<EOSortOrdering> sortOrderings)
{
@SuppressWarnings("unchecked")
EOFetchSpecification fspec = new WCFetchSpecification(
ENTITY_NAME, qualifier, sortOrderings);
fspec.setUsesDistinct(true);
return objectsWithFetchSpecification(context, fspec);
}
// ----------------------------------------------------------
/**
* Retrieve the first object that matches a qualifier, when
* sorted with the specified sort orderings.
*
* @param context The editing context to use
* @param qualifier The qualifier to use
* @param sortOrderings the sort orderings
*
* @return the first entity that was retrieved, or null if there was none
*/
public static QueueDescriptor firstObjectMatchingQualifier(
EOEditingContext context,
EOQualifier qualifier,
NSArray<EOSortOrdering> sortOrderings)
{
NSArray<QueueDescriptor> objects =
objectsMatchingQualifier(context, qualifier, sortOrderings);
return (objects.size() > 0)
? objects.get(0)
: null;
}
// ----------------------------------------------------------
/**
* Retrieve a single object using a list of keys and values to match.
*
* @param context The editing context to use
* @param qualifier The qualifier to use
*
* @return the single entity that was retrieved
*
* @throws EOUtilities.MoreThanOneException
* if there is more than one matching object
*/
public static QueueDescriptor uniqueObjectMatchingQualifier(
EOEditingContext context,
EOQualifier qualifier) throws EOUtilities.MoreThanOneException
{
NSArray<QueueDescriptor> objects =
objectsMatchingQualifier(context, qualifier);
if (objects.size() > 1)
{
String msg = "fetching QueueDescriptor";
try
{
if (qualifier != null)
{
msg += " where " + qualifier;
}
msg += ", result = " + objects;
}
catch (Exception e)
{
log.error("Exception building MoreThanOneException message, "
+ "contents so far: " + msg, e);
}
throw new EOUtilities.MoreThanOneException(msg);
}
return (objects.size() > 0)
? objects.get(0)
: null;
}
// ----------------------------------------------------------
/**
* Retrieve objects using a list of keys and values to match.
*
* @param context The editing context to use
* @param keysAndValues a list of keys and values to match, alternating
* "key", "value", "key", "value"...
*
* @return an NSArray of the entities retrieved
*/
public static NSArray<QueueDescriptor> objectsMatchingValues(
EOEditingContext context,
Object... keysAndValues)
{
if (keysAndValues.length % 2 != 0)
{
throw new IllegalArgumentException("There should a value "
+ "corresponding to every key that was passed. Args = "
+ java.util.Arrays.toString(keysAndValues));
}
NSMutableDictionary<String, Object> valueDictionary =
new NSMutableDictionary<String, Object>();
for (int i = 0; i < keysAndValues.length; i += 2)
{
Object key = keysAndValues[i];
Object value = keysAndValues[i + 1];
if (key == null)
{
throw new IllegalArgumentException(
"Found null where a String key was expected, arguments = "
+ java.util.Arrays.toString(keysAndValues));
}
else if (!(key instanceof String))
{
throw new IllegalArgumentException(
"Found a " + key.getClass().getName() + " [" + key + "]"
+ " where a String key was expected, arguments = "
+ java.util.Arrays.toString(keysAndValues));
}
valueDictionary.setObjectForKey(value, key);
}
return objectsMatchingValues(context, valueDictionary);
}
// ----------------------------------------------------------
/**
* Retrieve objects using a dictionary of keys and values to match.
*
* @param context The editing context to use
* @param keysAndValues a dictionary of keys and values to match
*
* @return an NSArray of the entities retrieved
*/
@SuppressWarnings("unchecked")
public static NSArray<QueueDescriptor> objectsMatchingValues(
EOEditingContext context,
NSDictionary<String, Object> keysAndValues)
{
return EOUtilities.objectsMatchingValues(context, ENTITY_NAME,
keysAndValues);
}
// ----------------------------------------------------------
/**
* Retrieve the first object that matches a set of keys and values, when
* sorted with the specified sort orderings.
*
* @param context The editing context to use
* @param sortOrderings the sort orderings
* @param keysAndValues a list of keys and values to match, alternating
* "key", "value", "key", "value"...
*
* @return the first entity that was retrieved, or null if there was none
*/
public static QueueDescriptor firstObjectMatchingValues(
EOEditingContext context,
NSArray<EOSortOrdering> sortOrderings,
Object... keysAndValues)
{
if (keysAndValues.length % 2 != 0)
{
throw new IllegalArgumentException("There should a value "
+ "corresponding to every key that was passed. Args = "
+ java.util.Arrays.toString(keysAndValues));
}
NSMutableDictionary<String, Object> valueDictionary =
new NSMutableDictionary<String, Object>();
for (int i = 0; i < keysAndValues.length; i += 2)
{
Object key = keysAndValues[i];
Object value = keysAndValues[i + 1];
if (key == null)
{
throw new IllegalArgumentException(
"Found null where a String key was expected, arguments = "
+ java.util.Arrays.toString(keysAndValues));
}
else if (!(key instanceof String))
{
throw new IllegalArgumentException(
"Found a " + key.getClass().getName() + " [" + key + "]"
+ " where a String key was expected, arguments = "
+ java.util.Arrays.toString(keysAndValues));
}
valueDictionary.setObjectForKey(value, key);
}
return firstObjectMatchingValues(
context, sortOrderings, valueDictionary);
}
// ----------------------------------------------------------
/**
* Retrieves the first object that matches a set of keys and values, when
* sorted with the specified sort orderings.
*
* @param context The editing context to use
* @param sortOrderings the sort orderings
* @param keysAndValues a dictionary of keys and values to match
*
* @return the first entity that was retrieved, or null if there was none
*/
public static QueueDescriptor firstObjectMatchingValues(
EOEditingContext context,
NSArray<EOSortOrdering> sortOrderings,
NSDictionary<String, Object> keysAndValues)
{
@SuppressWarnings("unchecked")
EOFetchSpecification fspec = new WCFetchSpecification(
ENTITY_NAME,
EOQualifier.qualifierToMatchAllValues(keysAndValues),
sortOrderings);
fspec.setFetchLimit(1);
NSArray<QueueDescriptor> objects =
objectsWithFetchSpecification( context, fspec );
if ( objects.count() == 0 )
{
return null;
}
else
{
return objects.objectAtIndex(0);
}
}
// ----------------------------------------------------------
/**
* Retrieve a single object using a list of keys and values to match.
*
* @param context The editing context to use
* @param keysAndValues a list of keys and values to match, alternating
* "key", "value", "key", "value"...
*
* @return the single entity that was retrieved, or null if there was none
*
* @throws EOUtilities.MoreThanOneException
* if there is more than one matching object
*/
public static QueueDescriptor uniqueObjectMatchingValues(
EOEditingContext context,
Object... keysAndValues) throws EOUtilities.MoreThanOneException
{
if (keysAndValues.length % 2 != 0)
{
throw new IllegalArgumentException("There should a value "
+ "corresponding to every key that was passed. Args = "
+ java.util.Arrays.toString(keysAndValues));
}
NSMutableDictionary<String, Object> valueDictionary =
new NSMutableDictionary<String, Object>();
for (int i = 0; i < keysAndValues.length; i += 2)
{
Object key = keysAndValues[i];
Object value = keysAndValues[i + 1];
if (key == null)
{
throw new IllegalArgumentException(
"Found null where a String key was expected, arguments = "
+ java.util.Arrays.toString(keysAndValues));
}
else if (!(key instanceof String))
{
throw new IllegalArgumentException(
"Found a " + key.getClass().getName() + " [" + key + "]"
+ " where a String key was expected, arguments = "
+ java.util.Arrays.toString(keysAndValues));
}
valueDictionary.setObjectForKey(value, key);
}
return uniqueObjectMatchingValues(context, valueDictionary);
}
// ----------------------------------------------------------
/**
* Retrieve an object using a dictionary of keys and values to match.
*
* @param context The editing context to use
* @param keysAndValues a dictionary of keys and values to match
*
* @return the single entity that was retrieved, or null if there was none
*
* @throws EOUtilities.MoreThanOneException
* if there is more than one matching object
*/
public static QueueDescriptor uniqueObjectMatchingValues(
EOEditingContext context,
NSDictionary<String, Object> keysAndValues)
throws EOUtilities.MoreThanOneException
{
try
{
return (QueueDescriptor)EOUtilities.objectMatchingValues(
context, ENTITY_NAME, keysAndValues);
}
catch (EOObjectNotAvailableException e)
{
return null;
}
}
// ----------------------------------------------------------
/**
* Retrieve the count of all objects of this type.
*
* @param context The editing context to use
*
* @return the count of all objects
*/
public static int countOfAllObjects(EOEditingContext context)
{
return countOfObjectsMatchingQualifier(context, null);
}
// ----------------------------------------------------------
/**
* Retrieve the count of objects that match a qualifier.
*
* @param context The editing context to use
* @param qualifier The qualifier to use
*
* @return the count of objects matching the qualifier
*/
public static int countOfObjectsMatchingQualifier(
EOEditingContext context, EOQualifier qualifier)
{
return ERXEOControlUtilities.objectCountWithQualifier(
context, ENTITY_NAME, qualifier);
}
// ----------------------------------------------------------
/**
* Retrieve the count of objects using a list of keys and values to match.
*
* @param context The editing context to use
* @param keysAndValues a list of keys and values to match, alternating
* "key", "value", "key", "value"...
*
* @return the count of objects that match the specified values
*/
public static int countOfObjectsMatchingValues(
EOEditingContext context,
Object... keysAndValues)
{
if (keysAndValues.length % 2 != 0)
{
throw new IllegalArgumentException("There should a value "
+ "corresponding to every key that was passed. Args = "
+ java.util.Arrays.toString(keysAndValues));
}
NSMutableDictionary<String, Object> valueDictionary =
new NSMutableDictionary<String, Object>();
for (int i = 0; i < keysAndValues.length; i += 2)
{
Object key = keysAndValues[i];
Object value = keysAndValues[i + 1];
if (key == null)
{
throw new IllegalArgumentException(
"Found null where a String key was expected, arguments = "
+ java.util.Arrays.toString(keysAndValues));
}
else if (!(key instanceof String))
{
throw new IllegalArgumentException(
"Found a " + key.getClass().getName() + " [" + key + "]"
+ " where a String key was expected, arguments = "
+ java.util.Arrays.toString(keysAndValues));
}
valueDictionary.setObjectForKey(value, key);
}
return countOfObjectsMatchingValues(context, valueDictionary);
}
// ----------------------------------------------------------
/**
* Retrieve the count of objects using a dictionary of keys and values to
* match.
*
* @param context The editing context to use
* @param keysAndValues a dictionary of keys and values to match
*
* @return the count of objects that matched the specified values
*/
public static int countOfObjectsMatchingValues(
EOEditingContext context,
NSDictionary<String, Object> keysAndValues)
{
return countOfObjectsMatchingQualifier(context,
EOQualifier.qualifierToMatchAllValues(keysAndValues));
}
// ----------------------------------------------------------
/**
* Retrieve objects according to the <code>descriptorsForJobEntityName</code>
* fetch specification.
*
* @param context The editing context to use
* @param jobEntityNameBinding fetch spec parameter
* @return an NSArray of the entities retrieved
*/
public static NSArray<QueueDescriptor> descriptorsForJobEntityName(
EOEditingContext context,
String jobEntityNameBinding)
{
EOFetchSpecification spec = WCFetchSpecification
.fetchSpecificationNamed("descriptorsForJobEntityName", "QueueDescriptor");
NSMutableDictionary<String, Object> bindings =
new NSMutableDictionary<String, Object>();
if (jobEntityNameBinding != null)
{
bindings.setObjectForKey(jobEntityNameBinding,
"jobEntityName");
}
spec = spec.fetchSpecificationWithQualifierBindings(bindings);
NSArray<QueueDescriptor> objects =
objectsWithFetchSpecification(context, spec);
if (log.isDebugEnabled())
{
log.debug("descriptorsForJobEntityName(ec"
+ ", " + jobEntityNameBinding
+ "): " + objects);
}
return objects;
}
// ----------------------------------------------------------
/**
* Produce a string representation of this object. This implementation
* calls UserPresentableDescription(), which uses WebObjects' internal
* mechanism to print out the visible fields of this object. Normally,
* subclasses would override userPresentableDescription() to change
* the way the object is printed.
*
* @return A string representation of the object's value
*/
public String toString()
{
return userPresentableDescription();
}
//~ Instance/static variables .............................................
static Logger log = Logger.getLogger(QueueDescriptor.class);
}