Project Wonder 5.0

er.extensions.eof
Class ERXEOControlUtilities

java.lang.Object
  extended by er.extensions.eof.ERXEOControlUtilities

public class ERXEOControlUtilities
extends java.lang.Object

Collection of EOF utility method centered around EOControl. EOControl provides infrastructure for creating and managing enterprise objects.


Field Summary
static org.apache.log4j.Logger log
          logging support
 
Constructor Summary
ERXEOControlUtilities()
           
 
Method Summary
static java.lang.Object _aggregateFunctionWithQualifier(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, java.lang.String attributeName, java.lang.String function, java.lang.Class valueClass, java.lang.String valueType, com.webobjects.eocontrol.EOQualifier qualifier)
           
static java.lang.Object _aggregateFunctionWithQualifierAndAggregateAttribute(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, com.webobjects.eocontrol.EOQualifier qualifier, com.webobjects.eoaccess.EOAttribute aggregateAttribute)
          Returns the number of objects in the database with the qualifier and counting attribute.
static java.lang.String _stringForPrimaryKey(java.lang.Object pk)
          Returns the propertylist-encoded string representation of the primary key for a given object.
static void addObjectToObjectOnBothSidesOfRelationshipWithKey(com.webobjects.eocontrol.EOEnterpriseObject addedObject, com.webobjects.eocontrol.EOEnterpriseObject referenceObject, java.lang.String key)
          Adds an object to another objects relationship.
static java.lang.Number aggregateFunctionWithQualifier(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, java.lang.String attributeName, java.lang.String function, com.webobjects.eocontrol.EOQualifier qualifier)
          Computes an aggregate function for a given attribute restricted by a given qualifier.
static java.lang.Number aggregateFunctionWithQualifier(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, java.lang.String attributeName, java.lang.String function, java.lang.String fetchSpecificationName, com.webobjects.foundation.NSDictionary bindings)
          Computes an aggregate function for a given attribute restricted by a given qualifier.
static com.webobjects.foundation.NSTimestamp aggregateTimestampWithQualifier(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, java.lang.String attributeName, java.lang.String function, com.webobjects.eocontrol.EOQualifier qualifier)
          Computes an aggregate function for a given attribute restricted by a given qualifier.
static com.webobjects.eocontrol.EOQualifier andQualifier(com.webobjects.eocontrol.EOQualifier q1, com.webobjects.eocontrol.EOQualifier q2)
          Joins the given qualifiers with an AND.
static com.webobjects.foundation.NSArray arrayFromDataSource(com.webobjects.eocontrol.EODataSource dataSource)
          Converts a datasource into an array.
static com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Integer> changedRegisteredObjectCount(com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Integer> currentCounts, com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Integer> oldCounts)
          Returns the changes in count registered objects in the EC grouped by entity name, which is useful for memory debugging.
static void clearSnapshotForRelationshipNamed(com.webobjects.eocontrol.EOEnterpriseObject eo, java.lang.String relationshipName)
          Clears snapshot the relaationship of a given enterprise so it will be read again when next accessed.
static void clearSnapshotForRelationshipNamedInDatabase(com.webobjects.eocontrol.EOEnterpriseObject eo, java.lang.String relationshipName, com.webobjects.eoaccess.EODatabase database)
          Clears snapshot the relationship of a given enterprise so it will be read again when next accessed.
static java.lang.Object convertEOtoGID(java.lang.Object obj)
          Given a dictionary, array, set, EO, etc, this will recursively turn EO's into GID's.
static java.lang.Object convertGIDtoEO(com.webobjects.eocontrol.EOEditingContext editingContext, java.lang.Object obj)
          Given a dictionary, array, set, EO, etc, this will recursively turn GID's into EO's.
static com.webobjects.eocontrol.EOEnterpriseObject createAndAddObjectToRelationship(com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.eocontrol.EOEnterpriseObject source, java.lang.String relationshipName, java.lang.String destinationEntityName, com.webobjects.foundation.NSDictionary objectInfo)
          Creates an object using the utility method createEO from this utility class.
static
<T extends com.webobjects.eocontrol.EOEnterpriseObject>
T
createAndInsertObject(com.webobjects.eocontrol.EOEditingContext ec, java.lang.Class<T> eoClass)
          Creates an enterprise object for the given entity name by first looking up the class description of the entity to create the enterprise object.
static com.webobjects.eocontrol.EOEnterpriseObject createAndInsertObject(com.webobjects.eocontrol.EOEditingContext editingContext, java.lang.String entityName)
          Creates an enterprise object for the given entity name by first looking up the class description of the entity to create the enterprise object.
static com.webobjects.eocontrol.EOEnterpriseObject createAndInsertObject(com.webobjects.eocontrol.EOEditingContext editingContext, java.lang.String entityName, com.webobjects.foundation.NSDictionary objectInfo)
          Creates an enterprise object for the given entity name by first looking up the class description of the entity to create the enterprise object.
static com.webobjects.eocontrol.EOArrayDataSource dataSourceForArray(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, com.webobjects.foundation.NSArray array)
          Simple utility method that will convert an array of enterprise objects into an EOArrayDataSource.

Note that the datasource that is constructed uses the class description and editing context of the first object of the array.
static com.webobjects.eocontrol.EOArrayDataSource dataSourceForArray(com.webobjects.foundation.NSArray<? extends com.webobjects.eocontrol.EOEnterpriseObject> array)
          Simple utility method that will convert an array of enterprise objects into an EOArrayDataSource.

Note that the datasource that is constructed uses the class description and editing context of the first object of the array.
static com.webobjects.eocontrol.EODetailDataSource dataSourceForObjectAndKey(com.webobjects.eocontrol.EOEnterpriseObject object, java.lang.String key)
          Creates a detail data source for a given enterprise object and a relationship key.
static com.webobjects.foundation.NSMutableArray deletedObjects(com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.foundation.NSArray<java.lang.String> entityNames, com.webobjects.eocontrol.EOQualifier qualifier)
           
static java.lang.String destinationEntityNameForKeyPath(com.webobjects.eocontrol.EOEnterpriseObject eo, java.lang.String keyPath)
          Convenience to get the destination entity name from a key path of an object.
static
<T> com.webobjects.foundation.NSArray<T>
distinctValuesForKeyPath(com.webobjects.eocontrol.EOEditingContext editingContext, java.lang.String entityName, java.lang.String keyPath, com.webobjects.eocontrol.EOQualifier qualifier, com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings)
          Returns an NSArray of distinct values available for the given entity and key path.
static
<T extends com.webobjects.eocontrol.EOEnterpriseObject>
T
editableInstanceOfObject(T eo, boolean createNestedContext)
          Creates a new, editable instance of the supplied object.
static boolean eoEquals(com.webobjects.eocontrol.EOEnterpriseObject firstEO, com.webobjects.eocontrol.EOEnterpriseObject secondEO)
          Determines if two EOs are equal by comparing their EOGlobalIDs.
static com.webobjects.foundation.NSArray faultsForGlobalIDs(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.foundation.NSArray gids)
          returns a NSArray containing EOEnterpriseObjects (actually faults...) for the provided EOGlobalIDs.
static com.webobjects.foundation.NSArray faultsForRawRowsFromEntity(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.foundation.NSArray primKeys, java.lang.String entityName)
           
static com.webobjects.eocontrol.EOFetchSpecification fetchSpecificationNamedWithBindings(java.lang.String entityName, java.lang.String fetchSpecificationName, com.webobjects.foundation.NSDictionary bindings)
          Gets a fetch specification from a given entity.
static com.webobjects.foundation.NSArray filteredObjectsWithQualifier(com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.foundation.NSArray objectsToFilter, java.lang.String entityName, com.webobjects.eocontrol.EOQualifier qualifier, com.webobjects.foundation.NSArray sortOrderings, boolean usesDistinct, boolean isDeep, boolean includeNewObjects, boolean includeNewObjectsInParentEditingContext, boolean filterUpdatedObjects, boolean removeDeletedObjects)
          Utility method used to filter an array of objects given a qualifier.
static com.webobjects.eocontrol.EOGlobalID globalIDForString(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, java.lang.String string)
          Returns the decoded global id for an propertylist encoded string representation of the primary key for a given object.
static com.webobjects.foundation.NSArray globalIDsForObjects(com.webobjects.foundation.NSArray eos)
          returns a NSArray containing EOGlobalIDs from the provided eos.
static com.webobjects.foundation.NSMutableArray insertedObjects(com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.foundation.NSArray<java.lang.String> entityNames, com.webobjects.eocontrol.EOQualifier qualifier)
           
static boolean isNewObject(com.webobjects.eocontrol.EOEnterpriseObject eo)
          Determines if an enterprise object is a new object and hasn't been saved to the database yet.
static
<T extends com.webobjects.eocontrol.EOEnterpriseObject>
T
localInstanceOfObject(com.webobjects.eocontrol.EOEditingContext ec, T eo)
          This has one advantage over the standard EOUtilites method of first checking if the editingcontexts are equal before creating a fault for the object in the editing context.
static com.webobjects.eocontrol.EOQualifier localInstancesInQualifier(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.eocontrol.EOQualifier q)
          faults every EO in the qualifiers into the specified editingContext.
static
<T extends com.webobjects.eocontrol.EOEnterpriseObject>
com.webobjects.foundation.NSArray<T>
localInstancesOfObjects(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.foundation.NSArray<T> eos)
          Provides the same functionality as the equivalent method in EOUtilities except it will use the localInstanceOfObject method from this utilities class which has a few enhancements.
static void makeQualifierTrue(com.webobjects.eocontrol.EOQualifier qualifier, java.lang.Object obj)
          Given a qualifier of EOAndQualifiers and EOKVQualifiers, make then evaluate to true on the given object.
static com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Object> newPrimaryKeyDictionaryForEntityNamed(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName)
          Utility method to generate a new primary key dictionary using the adaptor for a given entity.
static com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Object> newPrimaryKeyDictionaryForObject(com.webobjects.eocontrol.EOEnterpriseObject eo)
          Utility method to generate a new primary key for an object.
static com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Object> newPrimaryKeyDictionaryForObjectFromClassProperties(com.webobjects.eocontrol.EOEnterpriseObject eo)
          Utility method to generate a new primary key dictionary using the objects class properties.
static java.lang.Integer objectCountUniqueWithQualifierAndAttribute(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, com.webobjects.eocontrol.EOQualifier qualifier, java.lang.String attributeName)
          Returns the number of unique objects matching the given qualifier for a given entity name.
static java.lang.Integer objectCountWithQualifier(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, com.webobjects.eocontrol.EOQualifier qualifier)
          Returns the number of objects matching the given qualifier for a given entity name.
static com.webobjects.foundation.NSArray objectsForFaults(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.foundation.NSArray possibleFaults)
          Triggers all faults in an efficient manner.
static com.webobjects.foundation.NSArray objectsForFaultWithSortOrderings(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.foundation.NSArray possibleFaults, com.webobjects.foundation.NSArray sortOrderings)
          Uses ERXEOControlUtilities.objectForFaults to turn the faults into objects, then does in memory ordering with EOSortOrdering.EOSortOrdering.sortedArrayUsingKeyOrderArray()
static com.webobjects.foundation.NSArray objectsForGlobalIDs(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.foundation.NSArray globalIDs)
          Aggregate method for EOEditingContext.objectForGlobalID().
static
<T extends com.webobjects.eocontrol.EOEnterpriseObject>
com.webobjects.foundation.NSArray<T>
objectsInRange(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.eocontrol.EOFetchSpecification spec, int start, int end)
          Returns an NSArray containing the objects from the resulting rows starting at start and stopping at end using a custom SQL, derived from the SQL which the EOFetchSpecification would use normally setHints()
static
<T extends com.webobjects.eocontrol.EOEnterpriseObject>
com.webobjects.foundation.NSArray<T>
objectsInRange(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.eocontrol.EOFetchSpecification spec, int start, int end, boolean rawRowsForCustomQueries)
          Returns an NSArray containing the objects from the resulting rows starting at start and stopping at end using a custom SQL, derived from the SQL which the EOFetchSpecification would use normally setHints()
static com.webobjects.foundation.NSArray objectsWithQualifier(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, com.webobjects.eocontrol.EOQualifier qualifier, com.webobjects.foundation.NSArray prefetchKeyPaths, boolean includeNewObjects)
          Calls objectsWithQualifier(ec, entityName, qualifier, prefetchKeyPaths, includeNewObjects, false).
static com.webobjects.foundation.NSArray objectsWithQualifier(com.webobjects.eocontrol.EOEditingContext _editingContext, java.lang.String _entityName, com.webobjects.eocontrol.EOQualifier _qualifier, com.webobjects.foundation.NSArray _prefetchKeyPaths, boolean _includeNewObjects, boolean _includeNewObjectsInParentEditingContext)
           
static com.webobjects.foundation.NSArray objectsWithQualifier(com.webobjects.eocontrol.EOEditingContext editingContext, java.lang.String entityName, com.webobjects.eocontrol.EOQualifier qualifier, com.webobjects.foundation.NSArray prefetchKeyPaths, boolean includeNewObjects, boolean includeNewObjectsInParentEditingContext, boolean filterUpdatedObjects, boolean removeDeletedObjects)
          Utility method used to fetch an array of objects given a qualifier.
static com.webobjects.foundation.NSArray objectsWithQualifier(com.webobjects.eocontrol.EOEditingContext editingContext, java.lang.String entityName, com.webobjects.eocontrol.EOQualifier qualifier, com.webobjects.foundation.NSArray prefetchKeyPaths, com.webobjects.foundation.NSArray sortOrderings, boolean usesDistinct, boolean isDeep, com.webobjects.foundation.NSDictionary hints, boolean includeNewObjects, boolean includeNewObjectsInParentEditingContext, boolean filterUpdatedObjects, boolean removeDeletedObjects)
          Utility method used to fetch an array of objects given a qualifier.
static com.webobjects.foundation.NSArray objectsWithQualifier(com.webobjects.eocontrol.EOEditingContext editingContext, java.lang.String entityName, com.webobjects.eocontrol.EOQualifier qualifier, com.webobjects.foundation.NSArray prefetchKeyPaths, com.webobjects.foundation.NSArray sortOrderings, int fetchLimit, boolean usesDistinct, boolean isDeep, com.webobjects.foundation.NSDictionary hints, boolean includeNewObjects, boolean includeNewObjectsInParentEditingContext, boolean filterUpdatedObjects, boolean removeDeletedObjects)
          Utility method used to fetch an array of objects given a qualifier.
static com.webobjects.foundation.NSArray objectsWithQualifierFormat(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, java.lang.String qualifierFormat, com.webobjects.foundation.NSArray args, com.webobjects.foundation.NSArray prefetchKeyPaths, boolean includeNewObjects)
          Calls objectsWithQualifierFormat(ec, entityName, qualifierFormat, args, prefetchKeyPaths, includeNewObjects, false)
static com.webobjects.foundation.NSArray objectsWithQualifierFormat(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, java.lang.String qualifierFormat, com.webobjects.foundation.NSArray args, com.webobjects.foundation.NSArray prefetchKeyPaths, boolean includeNewObjects, boolean includeNewObjectsInParentEditingContexts)
          Enhanced version of the utility method found in EOUtilities.
static com.webobjects.eocontrol.EOEnterpriseObject objectWithPrimaryKeyValue(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, java.lang.Object primaryKeyValue, com.webobjects.foundation.NSArray prefetchingKeyPaths)
          Fetches an enterprise object based on a given primary key value.
static com.webobjects.eocontrol.EOEnterpriseObject objectWithPrimaryKeyValue(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, java.lang.Object primaryKeyValue, com.webobjects.foundation.NSArray prefetchingKeyPaths, boolean refreshRefetchedObjects)
          Fetches an enterprise object based on a given primary key value.
static com.webobjects.eocontrol.EOEnterpriseObject objectWithQualifier(com.webobjects.eocontrol.EOEditingContext editingContext, java.lang.String entityName, com.webobjects.eocontrol.EOQualifier qualifier)
          Returns the single object of the given type matching the qualifier.
static com.webobjects.eocontrol.EOQualifier orQualifier(com.webobjects.eocontrol.EOQualifier q1, com.webobjects.eocontrol.EOQualifier q2)
          Joins the given qualifiers with an OR.
static com.webobjects.eocontrol.EOQualifier orQualifierForKeyPaths(com.webobjects.foundation.NSArray keyPaths, com.webobjects.foundation.NSSelector selector, com.webobjects.foundation.NSArray values)
          Creates an OR qualifier with the given selector for all the given key paths and all the given serach terms.
static com.webobjects.eocontrol.EOQualifier orQualifierForKeyPaths(com.webobjects.foundation.NSArray keyPaths, com.webobjects.foundation.NSSelector selector, java.lang.Object value)
          Creates an OR qualifier with the given selector for all the given key paths.
static com.webobjects.foundation.NSArray primaryKeyArrayForObject(com.webobjects.eocontrol.EOEnterpriseObject obj)
          Gives the primary key array for a given enterprise object.
static com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Object> primaryKeyDictionaryForString(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, java.lang.String string)
          Returns the decoded dictionary for an propertylist encoded string representation of the primary key for a given object.
static com.webobjects.eocontrol.EOFetchSpecification primaryKeyFetchSpecificationForEntity(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, com.webobjects.eocontrol.EOQualifier eoqualifier, com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings, com.webobjects.foundation.NSArray<java.lang.String> additionalKeys)
          Constructs a fetch specification that will only fetch the primary keys for a given qualifier.
static java.lang.Object primaryKeyObjectForObject(com.webobjects.eocontrol.EOEnterpriseObject eo)
          Returns either the single object the PK consist of or the NSArray of its values if the key is compound.
static com.webobjects.foundation.NSArray primaryKeysMatchingQualifier(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, com.webobjects.eocontrol.EOQualifier eoqualifier, com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings)
          Fetches an array of primary keys matching a given qualifier and sorted with a given array of sort orderings.
static java.lang.String primaryKeyStringForGlobalID(com.webobjects.eocontrol.EOKeyGlobalID gid)
          Returns the propertylist-encoded string representation of the global ID.
static java.lang.String primaryKeyStringForObject(com.webobjects.eocontrol.EOEnterpriseObject eo)
          Returns the propertylist-encoded string representation of the primary key for a given object.
static com.webobjects.foundation.NSArray primaryKeyValuesInRange(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.eocontrol.EOFetchSpecification spec, int start, int end)
          Returns an NSArray containing the primary keys from the resulting rows starting at start and stopping at end using a custom SQL, derived from the SQL which the EOFetchSpecification would use normally setHints()
static com.webobjects.eocontrol.EOQualifier qualifierMatchingAnyKey(com.webobjects.foundation.NSArray keys, com.webobjects.foundation.NSSelector selector, java.lang.Object value)
          Creates an OR qualifier of EOKeyValueQualifiers for every keypath in the given array of keys.
static void refaultObject(com.webobjects.eocontrol.EOEnterpriseObject eo)
          Turns a given enterprise object back into a fault.
static void refreshObject(com.webobjects.eocontrol.EOEnterpriseObject eo)
          Sets the fetch time stamp of the eo's ec to now to ensure fresh data.
static com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Integer> registeredObjectCount(com.webobjects.eocontrol.EOEditingContext ec)
          Returns the count of registered objects in the EC grouped by entity name, which is useful for memory debugging.
static com.webobjects.eocontrol.EOEnterpriseObject requiredObjectWithQualifier(com.webobjects.eocontrol.EOEditingContext editingContext, java.lang.String entityName, com.webobjects.eocontrol.EOQualifier qualifier)
          Returns the single object of the given type matching the qualifier.
static com.webobjects.eoaccess.EOEntity rootEntity(com.webobjects.eocontrol.EOEnterpriseObject eo)
          Returns the root entity from the EOEnterpriseObject
static java.lang.String rootEntityName(com.webobjects.eocontrol.EOEnterpriseObject eo)
          Returns the name from the root entity from the EOEnterpriseObject
static com.webobjects.eocontrol.EOFetchSpecification schemaBasedFetchSpecification(com.webobjects.eocontrol.EOEditingContext ec, com.webobjects.eocontrol.EOFetchSpecification fetchSpecification)
          Useful for ensuring a fetch specification is safe to pass around between threads and not having to be concerned about references to EOs in the qualifier.
static com.webobjects.eocontrol.EOQualifier schemaBasedQualifier(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName, com.webobjects.eocontrol.EOQualifier qualifier)
          Useful for ensuring a qualifier is safe to pass around between threads and not having to be concerned about references to EOs in it.
static com.webobjects.eocontrol.EOEnterpriseObject sharedObjectMatchingKeyAndValue(java.lang.String entityName, java.lang.String key, java.lang.Object value)
          Finds an object in the shared editing context matching a key and value.
static com.webobjects.foundation.NSArray sharedObjectsForEntityNamed(java.lang.String entityName)
          Gets all of the shared objects for a given entity name.
static com.webobjects.foundation.NSArray sharedObjectsMatchingKeyAndValue(java.lang.String entityName, java.lang.String key, java.lang.Object value)
          Finds objects in the shared editing context matching a key and value.
static com.webobjects.foundation.NSArray sharedObjectsWithFetchSpecificationNamed(java.lang.String entityName, java.lang.String fetchSpecName)
           
static com.webobjects.eocontrol.EOEnterpriseObject sharedObjectWithFetchSpec(java.lang.String entityName, java.lang.String fetchSpec)
          Fetches a shared enterprise object for a given fetch specification from the default shared editing context.
static com.webobjects.eocontrol.EOEnterpriseObject sharedObjectWithPrimaryKey(java.lang.String entityName, java.lang.Object primaryKey)
          Gets the shared enterprise object with the given primary from the default shared editing context.
static com.webobjects.foundation.NSArray stringAttributeListForEntityNamed(com.webobjects.eocontrol.EOEditingContext ec, java.lang.String entityName)
          Calculates all of the EOAttributes of a given entity that are mapped to String objects.
static void trimSpaces(com.webobjects.eocontrol.EOEnterpriseObject object)
          Trims all values from string attributes from the given EO.
static com.webobjects.foundation.NSMutableArray updatedObjects(com.webobjects.eocontrol.EOEditingContext editingContext, com.webobjects.foundation.NSArray<java.lang.String> entityNames, com.webobjects.eocontrol.EOQualifier qualifier)
           
static void validateUniquenessOf(com.webobjects.eocontrol.EOEnterpriseObject eo, com.webobjects.eocontrol.EOQualifier restrictingQualifier, java.lang.String... keys)
          Convinience method which passes null for entityName.
static void validateUniquenessOf(com.webobjects.eocontrol.EOEnterpriseObject eo, java.lang.String... keys)
          Convinience method which passes null for restrictingQualifier and entityName.
static void validateUniquenessOf(java.lang.String entityName, com.webobjects.eocontrol.EOEnterpriseObject eo, com.webobjects.eocontrol.EOQualifier restrictingQualifier, java.lang.String... keys)
          Validates whether the values of the specified keyPaths are unique for an Entity.
static void validateUniquenessOf(java.lang.String entityName, com.webobjects.eocontrol.EOEnterpriseObject eo, java.lang.String... keys)
          Convinience method which passes null for restrictingQualifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final org.apache.log4j.Logger log
logging support

Constructor Detail

ERXEOControlUtilities

public ERXEOControlUtilities()
Method Detail

localInstancesOfObjects

public static <T extends com.webobjects.eocontrol.EOEnterpriseObject> com.webobjects.foundation.NSArray<T> localInstancesOfObjects(com.webobjects.eocontrol.EOEditingContext ec,
                                                                                                                                   com.webobjects.foundation.NSArray<T> eos)
Provides the same functionality as the equivalent method in EOUtilities except it will use the localInstanceOfObject method from this utilities class which has a few enhancements.

Parameters:
ec - editing context to pull local object copies
eos - array of enterprise objects
Returns:
an array of copies of local objects

dataSourceForArray

public static com.webobjects.eocontrol.EOArrayDataSource dataSourceForArray(com.webobjects.foundation.NSArray<? extends com.webobjects.eocontrol.EOEnterpriseObject> array)
Simple utility method that will convert an array of enterprise objects into an EOArrayDataSource.

Note that the datasource that is constructed uses the class description and editing context of the first object of the array.

Parameters:
array - collection of objects to be turned into a datasource
Returns:
an array datasource corresponding to the array of objects passed in.

dataSourceForArray

public static com.webobjects.eocontrol.EOArrayDataSource dataSourceForArray(com.webobjects.eocontrol.EOEditingContext ec,
                                                                            java.lang.String entityName,
                                                                            com.webobjects.foundation.NSArray array)
Simple utility method that will convert an array of enterprise objects into an EOArrayDataSource.

Note that the datasource that is constructed uses the class description and editing context of the first object of the array.

Parameters:
array - collection of objects to be turned into a datasource
Returns:
an array datasource corresponding to the array of objects passed in.

arrayFromDataSource

public static com.webobjects.foundation.NSArray arrayFromDataSource(com.webobjects.eocontrol.EODataSource dataSource)
Converts a datasource into an array.

Parameters:
dataSource - data source to be converted
Returns:
array of objects that the data source represents

dataSourceForObjectAndKey

public static com.webobjects.eocontrol.EODetailDataSource dataSourceForObjectAndKey(com.webobjects.eocontrol.EOEnterpriseObject object,
                                                                                    java.lang.String key)
Creates a detail data source for a given enterprise object and a relationship key. These types of datasources can be very handy when you are displaying a list of objects a la D2W style and then some objects are added or removed from the relationship. If an array datasource were used then the list would not reflect the changes made, however the detail data source will reflect changes made to the relationship.
Note: the relationship key does not have to be an eo relationship, instead it just has to return an array of enterprise objects.

Parameters:
object - that has the relationship
key - relationship key
Returns:
detail data source for the given object-key pair.

editableInstanceOfObject

public static <T extends com.webobjects.eocontrol.EOEnterpriseObject> T editableInstanceOfObject(T eo,
                                                                                                 boolean createNestedContext)
Creates a new, editable instance of the supplied object. Takes into account if the object is newly inserted, lives in a shared context and can either create a peer or nested context.

Parameters:
eo - object for the new instance
createNestedContext - true, if we should create a nested context (otherwise we create a peer context)
Returns:
new EO in new editing context

localInstanceOfObject

public static <T extends com.webobjects.eocontrol.EOEnterpriseObject> T localInstanceOfObject(com.webobjects.eocontrol.EOEditingContext ec,
                                                                                              T eo)
This has one advantage over the standard EOUtilites method of first checking if the editingcontexts are equal before creating a fault for the object in the editing context.

Parameters:
ec - editing context to get a local instance of the object in
eo - object to get a local copy of
Returns:
enterprise object local to the passed in editing contex

eoEquals

public static boolean eoEquals(com.webobjects.eocontrol.EOEnterpriseObject firstEO,
                               com.webobjects.eocontrol.EOEnterpriseObject secondEO)
Determines if two EOs are equal by comparing their EOGlobalIDs. This does not require the two EOs to be in the same EOEditingContext and will be safe when either is or both are null. This does not test the two EOs for content equality.

Parameters:
firstEO - first EO to compare
secondEO - second EO to compare
Returns:
true if firstEO and secondEO correspond to the same object or if both are null. false otherwise.

createAndInsertObject

public static <T extends com.webobjects.eocontrol.EOEnterpriseObject> T createAndInsertObject(com.webobjects.eocontrol.EOEditingContext ec,
                                                                                              java.lang.Class<T> eoClass)
Creates an enterprise object for the given entity name by first looking up the class description of the entity to create the enterprise object. The object is then inserted into the editing context and returned.

Type Parameters:
T - The enterprise object type
Parameters:
ec - editingContext to insert the created object into
eoClass - class of the enterprise object to be created
Returns:
created and inserted enterprise object of type T

createAndInsertObject

public static com.webobjects.eocontrol.EOEnterpriseObject createAndInsertObject(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                                                java.lang.String entityName)
Creates an enterprise object for the given entity name by first looking up the class description of the entity to create the enterprise object. The object is then inserted into the editing context and returned.

Parameters:
editingContext - editingContext to insert the created object into
entityName - name of the entity to be created.
Returns:
created and inserted enterprise object

createAndInsertObject

public static com.webobjects.eocontrol.EOEnterpriseObject createAndInsertObject(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                                                java.lang.String entityName,
                                                                                com.webobjects.foundation.NSDictionary objectInfo)
Creates an enterprise object for the given entity name by first looking up the class description of the entity to create the enterprise object. The object is then inserted into the editing context and returned.

Parameters:
editingContext - editingContext to insert the created object into
entityName - name of the entity to be created.
objectInfo - dictionary of values pushed onto the object before being inserted into the editing context.
Returns:
created and inserted enterprise object

createAndAddObjectToRelationship

public static com.webobjects.eocontrol.EOEnterpriseObject createAndAddObjectToRelationship(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                                                           com.webobjects.eocontrol.EOEnterpriseObject source,
                                                                                           java.lang.String relationshipName,
                                                                                           java.lang.String destinationEntityName,
                                                                                           com.webobjects.foundation.NSDictionary objectInfo)
Creates an object using the utility method createEO from this utility class. After creating the enterprise object it is added to the relationship of the enterprise object passed in. For instance:
createAndAddObjectToRelationship(ec, foo, "toBars", "Bar", dictValues);

will create an instance of Bar, set all of the key-value pairs from the dictValues dictionary, insert it into an editing context and then add it to both sides of the realtionship "toBars" off of the enterprise object foo.

Parameters:
editingContext - editing context to create the object in
source - enterprise object to whose relationship the newly created object will be added.
relationshipName - relationship name of the enterprise object that is passed in to which the newly created eo should be added.
destinationEntityName - name of the entity of the object to be created.
objectInfo - dictionary of values to be set on the newly created object before it is inserted into the editing context.
Returns:
the newly created enterprise object

addObjectToObjectOnBothSidesOfRelationshipWithKey

public static void addObjectToObjectOnBothSidesOfRelationshipWithKey(com.webobjects.eocontrol.EOEnterpriseObject addedObject,
                                                                     com.webobjects.eocontrol.EOEnterpriseObject referenceObject,
                                                                     java.lang.String key)
Adds an object to another objects relationship. Has the advantage of ensuring that the added object is in the same editing context as the reference object.

Parameters:
addedObject - object to be added to the relationship
referenceObject - object that has the relationship
key - relationship key

refaultObject

public static void refaultObject(com.webobjects.eocontrol.EOEnterpriseObject eo)
Turns a given enterprise object back into a fault.

Parameters:
eo - enterprise object to refault

refreshObject

public static void refreshObject(com.webobjects.eocontrol.EOEnterpriseObject eo)
Sets the fetch time stamp of the eo's ec to now to ensure fresh data. and refreshes the EO (which merges latest database snapshots with current unsaved changes if we have unsaved changes)

Parameters:
eo - EO to be refreshed

clearSnapshotForRelationshipNamed

public static void clearSnapshotForRelationshipNamed(com.webobjects.eocontrol.EOEnterpriseObject eo,
                                                     java.lang.String relationshipName)
Clears snapshot the relaationship of a given enterprise so it will be read again when next accessed.

Parameters:
eo - enterprise object
relationshipName - relationship name

clearSnapshotForRelationshipNamedInDatabase

public static void clearSnapshotForRelationshipNamedInDatabase(com.webobjects.eocontrol.EOEnterpriseObject eo,
                                                               java.lang.String relationshipName,
                                                               com.webobjects.eoaccess.EODatabase database)
Clears snapshot the relationship of a given enterprise so it will be read again when next accessed.

Parameters:
eo - enterprise object
relationshipName - relationship name

primaryKeyFetchSpecificationForEntity

public static com.webobjects.eocontrol.EOFetchSpecification primaryKeyFetchSpecificationForEntity(com.webobjects.eocontrol.EOEditingContext ec,
                                                                                                  java.lang.String entityName,
                                                                                                  com.webobjects.eocontrol.EOQualifier eoqualifier,
                                                                                                  com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings,
                                                                                                  com.webobjects.foundation.NSArray<java.lang.String> additionalKeys)
Constructs a fetch specification that will only fetch the primary keys for a given qualifier.

Parameters:
ec - editing context, only used to determine the entity
entityName - name of the entity, only used to determine the entity
eoqualifier - to construct the fetch spec with
sortOrderings - array of sort orderings to sort the result set with.
additionalKeys - array of additional key paths to construct the raw rows key paths to fetch.
Returns:
fetch specification that can be used to fetch primary keys for a given qualifier and sort orderings.

primaryKeysMatchingQualifier

public static com.webobjects.foundation.NSArray primaryKeysMatchingQualifier(com.webobjects.eocontrol.EOEditingContext ec,
                                                                             java.lang.String entityName,
                                                                             com.webobjects.eocontrol.EOQualifier eoqualifier,
                                                                             com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings)
Fetches an array of primary keys matching a given qualifier and sorted with a given array of sort orderings.

Parameters:
ec - editing context to fetch into
entityName - name of the entity
eoqualifier - to restrict matching primary keys
sortOrderings - array of sort orders to sort result set
Returns:
array of primary keys matching a given qualifier

objectWithPrimaryKeyValue

public static com.webobjects.eocontrol.EOEnterpriseObject objectWithPrimaryKeyValue(com.webobjects.eocontrol.EOEditingContext ec,
                                                                                    java.lang.String entityName,
                                                                                    java.lang.Object primaryKeyValue,
                                                                                    com.webobjects.foundation.NSArray prefetchingKeyPaths)
Fetches an enterprise object based on a given primary key value. This method has an advantage over the standard EOUtilities method in that you can specify prefetching key paths as well as refreshing the snapshot of the given object

Parameters:
ec - editing context to fetch into
entityName - name of the entity
primaryKeyValue - primary key value. Compound primary keys are given as NSDictionaries.
prefetchingKeyPaths - key paths to fetch off of the eo
Returns:
enterprise object matching the given value

objectWithPrimaryKeyValue

public static com.webobjects.eocontrol.EOEnterpriseObject objectWithPrimaryKeyValue(com.webobjects.eocontrol.EOEditingContext ec,
                                                                                    java.lang.String entityName,
                                                                                    java.lang.Object primaryKeyValue,
                                                                                    com.webobjects.foundation.NSArray prefetchingKeyPaths,
                                                                                    boolean refreshRefetchedObjects)
Fetches an enterprise object based on a given primary key value. This method has an advantage over the standard EOUtilities method in that you can specify prefetching key paths as well as refreshing the snapshot of the given object

Parameters:
ec - editing context to fetch into
entityName - name of the entity
primaryKeyValue - primary key value. Compound primary keys are given as NSDictionaries.
prefetchingKeyPaths - key paths to fetch off of the eo
refreshRefetchedObjects - if true, the object will be refetched and refreshed
Returns:
enterprise object matching the given value or null if none is foudn
Throws:
java.lang.IllegalStateException - if the entity has a compound key and only one key is provided or if more than one object is found matching the value.

objectsInRange

public static <T extends com.webobjects.eocontrol.EOEnterpriseObject> com.webobjects.foundation.NSArray<T> objectsInRange(com.webobjects.eocontrol.EOEditingContext ec,
                                                                                                                          com.webobjects.eocontrol.EOFetchSpecification spec,
                                                                                                                          int start,
                                                                                                                          int end)
Returns an NSArray containing the objects from the resulting rows starting at start and stopping at end using a custom SQL, derived from the SQL which the EOFetchSpecification would use normally setHints()

Parameters:
ec - editingcontext to fetch objects into
spec - fetch specification for the fetch
start -
end -
Returns:
objects in the given range

objectsInRange

public static <T extends com.webobjects.eocontrol.EOEnterpriseObject> com.webobjects.foundation.NSArray<T> objectsInRange(com.webobjects.eocontrol.EOEditingContext ec,
                                                                                                                          com.webobjects.eocontrol.EOFetchSpecification spec,
                                                                                                                          int start,
                                                                                                                          int end,
                                                                                                                          boolean rawRowsForCustomQueries)
Returns an NSArray containing the objects from the resulting rows starting at start and stopping at end using a custom SQL, derived from the SQL which the EOFetchSpecification would use normally setHints()

Parameters:
ec - editingcontext to fetch objects into
spec - fetch specification for the fetch
start -
end -
rawRowsForCustomQueries - if true, raw rows will be returned from the fetch when there is a custom query
Returns:
objects in the given range

primaryKeyValuesInRange

public static com.webobjects.foundation.NSArray primaryKeyValuesInRange(com.webobjects.eocontrol.EOEditingContext ec,
                                                                        com.webobjects.eocontrol.EOFetchSpecification spec,
                                                                        int start,
                                                                        int end)
Returns an NSArray containing the primary keys from the resulting rows starting at start and stopping at end using a custom SQL, derived from the SQL which the EOFetchSpecification would use normally setHints()

Parameters:
ec - editingcontext to fetch objects into
spec - fetch specification for the fetch
start -
end -
Returns:
primary keys in the given range

objectCountWithQualifier

public static java.lang.Integer objectCountWithQualifier(com.webobjects.eocontrol.EOEditingContext ec,
                                                         java.lang.String entityName,
                                                         com.webobjects.eocontrol.EOQualifier qualifier)
Returns the number of objects matching the given qualifier for a given entity name. Implementation wise this method will generate the correct sql to only perform a count, i.e. all of the objects wouldn't be pulled into memory.

Parameters:
ec - editing context to use for the count qualification
entityName - name of the entity to fetch
qualifier - to find the matching objects
Returns:
number of matching objects

objectCountUniqueWithQualifierAndAttribute

public static java.lang.Integer objectCountUniqueWithQualifierAndAttribute(com.webobjects.eocontrol.EOEditingContext ec,
                                                                           java.lang.String entityName,
                                                                           com.webobjects.eocontrol.EOQualifier qualifier,
                                                                           java.lang.String attributeName)
Returns the number of unique objects matching the given qualifier for a given entity name. Implementation wise this method will generate the correct sql to only perform a count, i.e. all of the objects wouldn't be pulled into memory.

Parameters:
ec - editing context to use for the count qualification
entityName - name of the entity to fetch
qualifier - to find the matching objects
attributeName - name of attribute in same entity to consider in order to determine uniqueness
Returns:
number of matching objects

_aggregateFunctionWithQualifierAndAggregateAttribute

public static java.lang.Object _aggregateFunctionWithQualifierAndAggregateAttribute(com.webobjects.eocontrol.EOEditingContext ec,
                                                                                    java.lang.String entityName,
                                                                                    com.webobjects.eocontrol.EOQualifier qualifier,
                                                                                    com.webobjects.eoaccess.EOAttribute aggregateAttribute)
Returns the number of objects in the database with the qualifier and counting attribute. This implementation queries the database directly without loading the objects into memory.

Parameters:
ec - the editing context
entityName - the name of the entity
qualifier - the qualifier to filter with
aggregateAttribute - the attribute that contains the "count(*)" definition
Returns:
the number of objects

aggregateFunctionWithQualifier

public static java.lang.Number aggregateFunctionWithQualifier(com.webobjects.eocontrol.EOEditingContext ec,
                                                              java.lang.String entityName,
                                                              java.lang.String attributeName,
                                                              java.lang.String function,
                                                              java.lang.String fetchSpecificationName,
                                                              com.webobjects.foundation.NSDictionary bindings)
Computes an aggregate function for a given attribute restricted by a given qualifier. For instance select MAX(AGE) from User where name like 'M*'

Parameters:
ec - editing context used for the fetch
entityName - name of the entity
attributeName - attribute for the function to be performed on
function - name, ie MAX, MIN, AVG, etc.
Returns:
aggregate result of the fuction call

aggregateFunctionWithQualifier

public static java.lang.Number aggregateFunctionWithQualifier(com.webobjects.eocontrol.EOEditingContext ec,
                                                              java.lang.String entityName,
                                                              java.lang.String attributeName,
                                                              java.lang.String function,
                                                              com.webobjects.eocontrol.EOQualifier qualifier)
Computes an aggregate function for a given attribute restricted by a given qualifier. For instance select MAX(AGE) from User where name like 'M*'

Parameters:
ec - editing context used for the fetch
entityName - name of the entity
attributeName - attribute for the function to be performed on
function - name, ie MAX, MIN, AVG, etc.
qualifier - to restrict data set
Returns:
aggregate result of the fuction call

aggregateTimestampWithQualifier

public static com.webobjects.foundation.NSTimestamp aggregateTimestampWithQualifier(com.webobjects.eocontrol.EOEditingContext ec,
                                                                                    java.lang.String entityName,
                                                                                    java.lang.String attributeName,
                                                                                    java.lang.String function,
                                                                                    com.webobjects.eocontrol.EOQualifier qualifier)
Computes an aggregate function for a given attribute restricted by a given qualifier. For instance select MAX(AGE) from User where name like 'M*'

Parameters:
ec - editing context used for the fetch
entityName - name of the entity
attributeName - attribute for the function to be performed on
function - name, ie MAX, MIN, AVG, etc.
qualifier - to restrict data set
Returns:
aggregate result of the fuction call

_aggregateFunctionWithQualifier

public static java.lang.Object _aggregateFunctionWithQualifier(com.webobjects.eocontrol.EOEditingContext ec,
                                                               java.lang.String entityName,
                                                               java.lang.String attributeName,
                                                               java.lang.String function,
                                                               java.lang.Class valueClass,
                                                               java.lang.String valueType,
                                                               com.webobjects.eocontrol.EOQualifier qualifier)

sharedObjectMatchingKeyAndValue

public static com.webobjects.eocontrol.EOEnterpriseObject sharedObjectMatchingKeyAndValue(java.lang.String entityName,
                                                                                          java.lang.String key,
                                                                                          java.lang.Object value)
Finds an object in the shared editing context matching a key and value. This has the benifit of not requiring a database round trip if the entity is shared.

Parameters:
entityName - name of the shared entity
key - to match against
value - value to match
Returns:
matching shared object

sharedObjectsMatchingKeyAndValue

public static com.webobjects.foundation.NSArray sharedObjectsMatchingKeyAndValue(java.lang.String entityName,
                                                                                 java.lang.String key,
                                                                                 java.lang.Object value)
Finds objects in the shared editing context matching a key and value. This has the benifit of not requiring a database round trip if the entity is shared.

Parameters:
entityName - name of the shared entity
key - to match against
value - value to match
Returns:
array of shared objects matching key and value

sharedObjectsForEntityNamed

public static com.webobjects.foundation.NSArray sharedObjectsForEntityNamed(java.lang.String entityName)
Gets all of the shared objects for a given entity name. Note that if the shared objects for the corresponding model have not been loaded yet, this method will trigger their loading (unless automatic loading has been disabled via a call to EODatabaseContext.setSharedObjectLoadingEnabled(boolean)). Returns an empty array if no shared objects were found.

Parameters:
entityName - name of the shared entity
Returns:
array of bound shared objects for the given entity name, or an empty array

sharedObjectWithFetchSpec

public static com.webobjects.eocontrol.EOEnterpriseObject sharedObjectWithFetchSpec(java.lang.String entityName,
                                                                                    java.lang.String fetchSpec)
Fetches a shared enterprise object for a given fetch specification from the default shared editing context.

Parameters:
fetchSpec - name of the fetch specification on the shared object.
entityName - name of the shared entity
Returns:
the shared enterprise object fetch by the fetch spec named.

sharedObjectsWithFetchSpecificationNamed

public static com.webobjects.foundation.NSArray sharedObjectsWithFetchSpecificationNamed(java.lang.String entityName,
                                                                                         java.lang.String fetchSpecName)

sharedObjectWithPrimaryKey

public static com.webobjects.eocontrol.EOEnterpriseObject sharedObjectWithPrimaryKey(java.lang.String entityName,
                                                                                     java.lang.Object primaryKey)
Gets the shared enterprise object with the given primary from the default shared editing context. This has the advantage of not requiring a roundtrip to the database to lookup the object. But, it will fetch if the object is not found in the default shared editing context.

Parameters:
entityName - name of the entity
primaryKey - primary key of object to be found
Returns:
the shared object registered in the default shared editing context

fetchSpecificationNamedWithBindings

public static com.webobjects.eocontrol.EOFetchSpecification fetchSpecificationNamedWithBindings(java.lang.String entityName,
                                                                                                java.lang.String fetchSpecificationName,
                                                                                                com.webobjects.foundation.NSDictionary bindings)
Gets a fetch specification from a given entity. If qualifier binding variables are passed in then the fetchspecification is cloned and the binding variables are substituted returning a fetch specification that can be used.

Parameters:
entityName - name of the entity that the fetch specification is bound to
fetchSpecificationName - name of the fetch specification
bindings - dictionary of qualifier bindings
Returns:
fetch specification identified by name and potentially with the qualifier bindings replaced.

newPrimaryKeyDictionaryForObjectFromClassProperties

public static com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Object> newPrimaryKeyDictionaryForObjectFromClassProperties(com.webobjects.eocontrol.EOEnterpriseObject eo)
Utility method to generate a new primary key dictionary using the objects class properties. Use it when your PKs are class properties.

Parameters:
eo - object in question
Returns:
new primary key dictionary or null if one of the properties is null or one of the primary key attributes is not a class property.

newPrimaryKeyDictionaryForObject

public static com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Object> newPrimaryKeyDictionaryForObject(com.webobjects.eocontrol.EOEnterpriseObject eo)
Utility method to generate a new primary key for an object. Calls #newPrimaryKeyForObjectFromClassProperties(EOEnterpriseObject) and if that returns null, newPrimaryKeyDictionaryForEntityNamed(EOEditingContext, String)

Returns:
new primary key dictionary or null if a failure occured.

newPrimaryKeyDictionaryForEntityNamed

public static com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Object> newPrimaryKeyDictionaryForEntityNamed(com.webobjects.eocontrol.EOEditingContext ec,
                                                                                                                              java.lang.String entityName)
Utility method to generate a new primary key dictionary using the adaptor for a given entity. This is can be handy if you need to have a primary key for an object before it is saved to the database. This method uses the same method that EOF uses by default for generating primary keys. See ERXGeneratesPrimaryKeyInterface for more information about using a newly created dictionary as the primary key for an enterprise object.

Parameters:
ec - editing context
entityName - name of the entity to generate the primary key dictionary for.
Returns:
a dictionary containing a new primary key for the given entity.

primaryKeyStringForObject

public static java.lang.String primaryKeyStringForObject(com.webobjects.eocontrol.EOEnterpriseObject eo)
Returns the propertylist-encoded string representation of the primary key for a given object.

Parameters:
eo - object to get the primary key for.
Returns:
string representation of the primary key of the object.

primaryKeyStringForGlobalID

public static java.lang.String primaryKeyStringForGlobalID(com.webobjects.eocontrol.EOKeyGlobalID gid)
Returns the propertylist-encoded string representation of the global ID.

Parameters:
gid - the global id of the oject to get the primary key for.
Returns:
string representation of the primary key of the object.

_stringForPrimaryKey

public static java.lang.String _stringForPrimaryKey(java.lang.Object pk)
Returns the propertylist-encoded string representation of the primary key for a given object. Made public only for ERXGenericRecord.

Parameters:
pk - the primary key
Returns:
string representation of the primary key.

primaryKeyDictionaryForString

public static com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Object> primaryKeyDictionaryForString(com.webobjects.eocontrol.EOEditingContext ec,
                                                                                                                      java.lang.String entityName,
                                                                                                                      java.lang.String string)
Returns the decoded dictionary for an propertylist encoded string representation of the primary key for a given object.

Returns:
string representation of the primary key of the object.

globalIDForString

public static com.webobjects.eocontrol.EOGlobalID globalIDForString(com.webobjects.eocontrol.EOEditingContext ec,
                                                                    java.lang.String entityName,
                                                                    java.lang.String string)
Returns the decoded global id for an propertylist encoded string representation of the primary key for a given object.


primaryKeyObjectForObject

public static java.lang.Object primaryKeyObjectForObject(com.webobjects.eocontrol.EOEnterpriseObject eo)
Returns either the single object the PK consist of or the NSArray of its values if the key is compound.

Parameters:
eo - object to get the primary key for.
Returns:
single object or NSArray

primaryKeyArrayForObject

public static com.webobjects.foundation.NSArray primaryKeyArrayForObject(com.webobjects.eocontrol.EOEnterpriseObject obj)
Gives the primary key array for a given enterprise object. This has the advantage of not firing the fault of the object, unlike the method in EOUtilities.

Parameters:
obj - enterprise object to get the primary key array from.
Returns:
array of all the primary key values for the object.

objectsWithQualifierFormat

public static com.webobjects.foundation.NSArray objectsWithQualifierFormat(com.webobjects.eocontrol.EOEditingContext ec,
                                                                           java.lang.String entityName,
                                                                           java.lang.String qualifierFormat,
                                                                           com.webobjects.foundation.NSArray args,
                                                                           com.webobjects.foundation.NSArray prefetchKeyPaths,
                                                                           boolean includeNewObjects)
Calls objectsWithQualifierFormat(ec, entityName, qualifierFormat, args, prefetchKeyPaths, includeNewObjects, false)

That is, passes false for includeNewObjectsInParentEditingContexts. This method exists to maintain API compatability.


objectsWithQualifierFormat

public static com.webobjects.foundation.NSArray objectsWithQualifierFormat(com.webobjects.eocontrol.EOEditingContext ec,
                                                                           java.lang.String entityName,
                                                                           java.lang.String qualifierFormat,
                                                                           com.webobjects.foundation.NSArray args,
                                                                           com.webobjects.foundation.NSArray prefetchKeyPaths,
                                                                           boolean includeNewObjects,
                                                                           boolean includeNewObjectsInParentEditingContexts)
Enhanced version of the utility method found in EOUtilities. Adds support for including newly created objects in the fetch as well as prefetching key paths.

Parameters:
ec - editing context to fetch it into
entityName - name of the entity
qualifierFormat - format of the qualifier string
args - qualifier arguments
prefetchKeyPaths - prefetching key paths
includeNewObjects - option to include newly inserted objects in the result set
includeNewObjectsInParentEditingContexts - option to include newly inserted objects in parent editing contexts
Returns:
array of objects matching the constructed qualifier

objectsWithQualifier

public static com.webobjects.foundation.NSArray objectsWithQualifier(com.webobjects.eocontrol.EOEditingContext ec,
                                                                     java.lang.String entityName,
                                                                     com.webobjects.eocontrol.EOQualifier qualifier,
                                                                     com.webobjects.foundation.NSArray prefetchKeyPaths,
                                                                     boolean includeNewObjects)
Calls objectsWithQualifier(ec, entityName, qualifier, prefetchKeyPaths, includeNewObjects, false).

That is, passes false for includeNewObjectsInParentEditingContexts. This method exists to maintain API compatability.


objectsWithQualifier

public static com.webobjects.foundation.NSArray objectsWithQualifier(com.webobjects.eocontrol.EOEditingContext _editingContext,
                                                                     java.lang.String _entityName,
                                                                     com.webobjects.eocontrol.EOQualifier _qualifier,
                                                                     com.webobjects.foundation.NSArray _prefetchKeyPaths,
                                                                     boolean _includeNewObjects,
                                                                     boolean _includeNewObjectsInParentEditingContext)

objectsWithQualifier

public static com.webobjects.foundation.NSArray objectsWithQualifier(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                                     java.lang.String entityName,
                                                                     com.webobjects.eocontrol.EOQualifier qualifier,
                                                                     com.webobjects.foundation.NSArray prefetchKeyPaths,
                                                                     boolean includeNewObjects,
                                                                     boolean includeNewObjectsInParentEditingContext,
                                                                     boolean filterUpdatedObjects,
                                                                     boolean removeDeletedObjects)
Utility method used to fetch an array of objects given a qualifier. Also has support for filtering the newly inserted, updated, and deleted objects in the passed editing context or any parent editing contexts as well as specifying prefetching key paths. Note that only NEW objects are supported in parent editing contexts.

Parameters:
editingContext - editing context to fetch it into
entityName - name of the entity
qualifier - qualifier
prefetchKeyPaths - prefetching key paths
includeNewObjects - option to include newly inserted objects in the result set
includeNewObjectsInParentEditingContext - option to include newly inserted objects in parent editing contexts. if true, the editing context lineage is explored, any newly-inserted objects matching the qualifier are collected and faulted down through all parent editing contexts of ec.
filterUpdatedObjects - option to include updated objects that now match the qualifier or remove updated objects thats no longer match the qualifier
removeDeletedObjects - option to remove objects that have been deleted
Returns:
array of objects matching the constructed qualifier

objectsWithQualifier

public static com.webobjects.foundation.NSArray objectsWithQualifier(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                                     java.lang.String entityName,
                                                                     com.webobjects.eocontrol.EOQualifier qualifier,
                                                                     com.webobjects.foundation.NSArray prefetchKeyPaths,
                                                                     com.webobjects.foundation.NSArray sortOrderings,
                                                                     boolean usesDistinct,
                                                                     boolean isDeep,
                                                                     com.webobjects.foundation.NSDictionary hints,
                                                                     boolean includeNewObjects,
                                                                     boolean includeNewObjectsInParentEditingContext,
                                                                     boolean filterUpdatedObjects,
                                                                     boolean removeDeletedObjects)
Utility method used to fetch an array of objects given a qualifier. Also has support for filtering the newly inserted, updateed, and deleted objects in the passed editing context or any parent editing contexts as well as specifying prefetching key paths. Note that only NEW objects are supported in parent editing contexts.

Parameters:
editingContext - editing context to fetch it into
entityName - name of the entity
qualifier - qualifier
prefetchKeyPaths - prefetching key paths
sortOrderings - the sort orderings to use on the results
usesDistinct - whether or not to distinct the results
isDeep - whether or not to fetch deeply
hints - fetch hints to apply
includeNewObjects - option to include newly inserted objects in the result set
includeNewObjectsInParentEditingContext - option to include newly inserted objects in parent editing contexts. if true, the editing context lineage is explored, any newly-inserted objects matching the qualifier are collected and faulted down through all parent editing contexts of ec.
filterUpdatedObjects - option to include updated objects that now match the qualifier or remove updated objects thats no longer match the qualifier
removeDeletedObjects - option to remove objects that have been deleted
Returns:
array of objects matching the constructed qualifier

objectsWithQualifier

public static com.webobjects.foundation.NSArray objectsWithQualifier(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                                     java.lang.String entityName,
                                                                     com.webobjects.eocontrol.EOQualifier qualifier,
                                                                     com.webobjects.foundation.NSArray prefetchKeyPaths,
                                                                     com.webobjects.foundation.NSArray sortOrderings,
                                                                     int fetchLimit,
                                                                     boolean usesDistinct,
                                                                     boolean isDeep,
                                                                     com.webobjects.foundation.NSDictionary hints,
                                                                     boolean includeNewObjects,
                                                                     boolean includeNewObjectsInParentEditingContext,
                                                                     boolean filterUpdatedObjects,
                                                                     boolean removeDeletedObjects)
Utility method used to fetch an array of objects given a qualifier. Also has support for filtering the newly inserted, updated, and deleted objects in the passed editing context or any parent editing contexts as well as specifying prefetching key paths. Note that only NEW objects are supported in parent editing contexts.

Parameters:
editingContext - editing context to fetch it into
entityName - name of the entity
qualifier - qualifier
prefetchKeyPaths - prefetching key paths
sortOrderings - the sort orderings to use on the results
fetchLimit - the fetch limit to use
usesDistinct - whether or not to distinct the results
isDeep - whether or not to fetch deeply
hints - fetch hints to apply
includeNewObjects - option to include newly inserted objects in the result set
includeNewObjectsInParentEditingContext - option to include newly inserted objects in parent editing contexts. if true, the editing context lineage is explored, any newly-inserted objects matching the qualifier are collected and faulted down through all parent editing contexts of ec.
filterUpdatedObjects - option to include updated objects that now match the qualifier or remove updated objects thats no longer match the qualifier
removeDeletedObjects - option to remove objects that have been deleted
Returns:
array of objects matching the constructed qualifier

filteredObjectsWithQualifier

public static com.webobjects.foundation.NSArray filteredObjectsWithQualifier(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                                             com.webobjects.foundation.NSArray objectsToFilter,
                                                                             java.lang.String entityName,
                                                                             com.webobjects.eocontrol.EOQualifier qualifier,
                                                                             com.webobjects.foundation.NSArray sortOrderings,
                                                                             boolean usesDistinct,
                                                                             boolean isDeep,
                                                                             boolean includeNewObjects,
                                                                             boolean includeNewObjectsInParentEditingContext,
                                                                             boolean filterUpdatedObjects,
                                                                             boolean removeDeletedObjects)
Utility method used to filter an array of objects given a qualifier. Also has support for filtering the newly inserted, updated, and deleted objects in the passed editing context or any parent editing contexts as well as specifying prefetching key paths. Note that only NEW objects are supported in parent editing contexts.

Parameters:
editingContext - editing context to fetch it into
objectsToFilter - objects to filter
entityName - name of the entity
qualifier - qualifier
prefetchKeyPaths - prefetching key paths
sortOrderings - the sort orderings to use on the results
fetchLimit - the fetch limit to use
usesDistinct - whether or not to distinct the results
isDeep - whether or not to fetch deeply
hints - fetch hints to apply
includeNewObjects - option to include newly inserted objects in the result set
includeNewObjectsInParentEditingContext - option to include newly inserted objects in parent editing contexts. if true, the editing context lineage is explored, any newly-inserted objects matching the qualifier are collected and faulted down through all parent editing contexts of ec.
filterUpdatedObjects - option to include updated objects that now match the qualifier or remove updated objects thats no longer match the qualifier
removeDeletedObjects - option to remove objects that have been deleted
Returns:
array of objects matching the constructed qualifier

objectWithQualifier

public static com.webobjects.eocontrol.EOEnterpriseObject objectWithQualifier(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                                              java.lang.String entityName,
                                                                              com.webobjects.eocontrol.EOQualifier qualifier)
Returns the single object of the given type matching the qualifier.

Parameters:
editingContext - the editing context to look in
entityName - the name of the entity to look for
qualifier - the qualifier to restrict by
Returns:
the single object of the given type matching the qualifier or null if no matching object found
Throws:
com.webobjects.eoaccess.EOUtilities.MoreThanOneException - if more than one object matches the qualifier

requiredObjectWithQualifier

public static com.webobjects.eocontrol.EOEnterpriseObject requiredObjectWithQualifier(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                                                      java.lang.String entityName,
                                                                                      com.webobjects.eocontrol.EOQualifier qualifier)
Returns the single object of the given type matching the qualifier.

Parameters:
editingContext - the editing context to look in
entityName - the name of the entity to look for
qualifier - the qualifier to restrict by
Returns:
he single object of the given type matching the qualifier
Throws:
com.webobjects.eoaccess.EOObjectNotAvailableException - if no objects match the qualifier
com.webobjects.eoaccess.EOUtilities.MoreThanOneException - if more than one object matches the qualifier

insertedObjects

public static com.webobjects.foundation.NSMutableArray insertedObjects(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                                       com.webobjects.foundation.NSArray<java.lang.String> entityNames,
                                                                       com.webobjects.eocontrol.EOQualifier qualifier)
Parameters:
editingContext - the editing context to look in
entityNames - the names of the entity to look for
qualifier - the qualifier to restrict by
Returns:
the array of objects of the given type that have been inserted into the editing context and match the given qualifier. Yes, it's odd that it returns NSMutableArray -- it's an optimization specifically for objectsWithQualifier. Returns an empty array if no objects match.

updatedObjects

public static com.webobjects.foundation.NSMutableArray updatedObjects(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                                      com.webobjects.foundation.NSArray<java.lang.String> entityNames,
                                                                      com.webobjects.eocontrol.EOQualifier qualifier)
Parameters:
editingContext - the editing context to look in
entityNames - the names of the entity to look for
qualifier - the qualifier to restrict by
Returns:
the array of objects of the given type that have been updated in the editing context and match the given qualifier. Returns an empty array if no objects match.

deletedObjects

public static com.webobjects.foundation.NSMutableArray deletedObjects(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                                      com.webobjects.foundation.NSArray<java.lang.String> entityNames,
                                                                      com.webobjects.eocontrol.EOQualifier qualifier)
Parameters:
editingContext - the editing context to look in
entityNames - the names of the entity to look for
qualifier - the qualifier to restrict by
Returns:
the array of objects of the given type that have been deleted from the editing context and match the given qualifier. Returns an empty array if no objects match.

localInstancesInQualifier

public static com.webobjects.eocontrol.EOQualifier localInstancesInQualifier(com.webobjects.eocontrol.EOEditingContext ec,
                                                                             com.webobjects.eocontrol.EOQualifier q)
faults every EO in the qualifiers into the specified editingContext. This is important for in memory filtering and eo comparision

Parameters:
ec -
q -

globalIDsForObjects

public static com.webobjects.foundation.NSArray globalIDsForObjects(com.webobjects.foundation.NSArray eos)
returns a NSArray containing EOGlobalIDs from the provided eos.

Parameters:
eos - the NSArray of EOEnterpriseObjects
Returns:
a NSArray of EOGlobalIDs

objectsForGlobalIDs

public static com.webobjects.foundation.NSArray objectsForGlobalIDs(com.webobjects.eocontrol.EOEditingContext ec,
                                                                    com.webobjects.foundation.NSArray globalIDs)
Aggregate method for EOEditingContext.objectForGlobalID(). NOTE: this only returns objects that are already registered, if you need all objects from the GIDs, use faultsForGlobalIDs(EOEditingContext, NSArray).

See Also:
EOEditingContext.objectForGlobalID(EOGlobalID)

faultsForGlobalIDs

public static com.webobjects.foundation.NSArray faultsForGlobalIDs(com.webobjects.eocontrol.EOEditingContext ec,
                                                                   com.webobjects.foundation.NSArray gids)
returns a NSArray containing EOEnterpriseObjects (actually faults...) for the provided EOGlobalIDs.

Parameters:
ec - the EOEditingContext in which the EOEnterpriseObjects should be faulted
gids - the EOGlobalIDs
Returns:
a NSArray of EOEnterpriseObjects

faultsForRawRowsFromEntity

public static com.webobjects.foundation.NSArray faultsForRawRowsFromEntity(com.webobjects.eocontrol.EOEditingContext ec,
                                                                           com.webobjects.foundation.NSArray primKeys,
                                                                           java.lang.String entityName)

isNewObject

public static boolean isNewObject(com.webobjects.eocontrol.EOEnterpriseObject eo)
Determines if an enterprise object is a new object and hasn't been saved to the database yet.
Note: An object that has been deleted will have it's editing context set to null which means this method would report true for an object that has been deleted from the database.

Parameters:
eo - enterprise object to check
Returns:
true or false depending on if the object is a new object.

qualifierMatchingAnyKey

public static com.webobjects.eocontrol.EOQualifier qualifierMatchingAnyKey(com.webobjects.foundation.NSArray keys,
                                                                           com.webobjects.foundation.NSSelector selector,
                                                                           java.lang.Object value)
Creates an OR qualifier of EOKeyValueQualifiers for every keypath in the given array of keys. This is useful when trying to find a string in a set of attributes.

Parameters:
keys -
selector -
value -
Author:
ak

objectsForFaultWithSortOrderings

public static com.webobjects.foundation.NSArray objectsForFaultWithSortOrderings(com.webobjects.eocontrol.EOEditingContext ec,
                                                                                 com.webobjects.foundation.NSArray possibleFaults,
                                                                                 com.webobjects.foundation.NSArray sortOrderings)
Uses ERXEOControlUtilities.objectForFaults to turn the faults into objects, then does in memory ordering with EOSortOrdering.EOSortOrdering.sortedArrayUsingKeyOrderArray()

Parameters:
ec -
possibleFaults -
sortOrderings -
Returns:
sorted array of EOs (no faults)

objectsForFaults

public static com.webobjects.foundation.NSArray objectsForFaults(com.webobjects.eocontrol.EOEditingContext ec,
                                                                 com.webobjects.foundation.NSArray possibleFaults)
Triggers all faults in an efficient manner.

Parameters:
ec -
possibleFaults - globalIDs

rootEntityName

public static java.lang.String rootEntityName(com.webobjects.eocontrol.EOEnterpriseObject eo)
Returns the name from the root entity from the EOEnterpriseObject

Parameters:
eo - the EOEnterpriseObject from which to the the root entity
Returns:
the name from the root entity from the EOEnterpriseObject

rootEntity

public static com.webobjects.eoaccess.EOEntity rootEntity(com.webobjects.eocontrol.EOEnterpriseObject eo)
Returns the root entity from the EOEnterpriseObject

Parameters:
eo - the EOEnterpriseObject from which to the the root entity
Returns:
the root entity from the EOEnterpriseObject

stringAttributeListForEntityNamed

public static com.webobjects.foundation.NSArray stringAttributeListForEntityNamed(com.webobjects.eocontrol.EOEditingContext ec,
                                                                                  java.lang.String entityName)
Calculates all of the EOAttributes of a given entity that are mapped to String objects.

Returns:
array of all attribute names that are mapped to String objects.

trimSpaces

public static void trimSpaces(com.webobjects.eocontrol.EOEnterpriseObject object)
Trims all values from string attributes from the given EO.

Parameters:
object -

destinationEntityNameForKeyPath

public static java.lang.String destinationEntityNameForKeyPath(com.webobjects.eocontrol.EOEnterpriseObject eo,
                                                               java.lang.String keyPath)
Convenience to get the destination entity name from a key path of an object. Returns null if no destination found.

Parameters:
eo -
keyPath -

orQualifierForKeyPaths

public static com.webobjects.eocontrol.EOQualifier orQualifierForKeyPaths(com.webobjects.foundation.NSArray keyPaths,
                                                                          com.webobjects.foundation.NSSelector selector,
                                                                          java.lang.Object value)
Creates an OR qualifier with the given selector for all the given key paths. If you want LIKE matches, you need to the add "*" yourself.

Parameters:
keyPaths -
selector -
value -

orQualifierForKeyPaths

public static com.webobjects.eocontrol.EOQualifier orQualifierForKeyPaths(com.webobjects.foundation.NSArray keyPaths,
                                                                          com.webobjects.foundation.NSSelector selector,
                                                                          com.webobjects.foundation.NSArray values)
Creates an OR qualifier with the given selector for all the given key paths and all the given serach terms. If you want LIKE matches, you need to the add "*" yourself.

Parameters:
keyPaths -
selector -
values -

andQualifier

public static com.webobjects.eocontrol.EOQualifier andQualifier(com.webobjects.eocontrol.EOQualifier q1,
                                                                com.webobjects.eocontrol.EOQualifier q2)
Joins the given qualifiers with an AND. One or both arguments may be null, if both are null, null is returned.

Parameters:
q1 -
q2 -

orQualifier

public static com.webobjects.eocontrol.EOQualifier orQualifier(com.webobjects.eocontrol.EOQualifier q1,
                                                               com.webobjects.eocontrol.EOQualifier q2)
Joins the given qualifiers with an OR. One or both arguments may be null, if both are null, null is returned.

Parameters:
q1 -
q2 -

makeQualifierTrue

public static void makeQualifierTrue(com.webobjects.eocontrol.EOQualifier qualifier,
                                     java.lang.Object obj)
Given a qualifier of EOAndQualifiers and EOKVQualifiers, make then evaluate to true on the given object.

Parameters:
qualifier - the qualifier to apply to the object
obj - the object to make qualifier evaluate to true for

convertEOtoGID

public static java.lang.Object convertEOtoGID(java.lang.Object obj)
Given a dictionary, array, set, EO, etc, this will recursively turn EO's into GID's. You should lock the editingContext before calling this.

Parameters:
obj - the object to recursively turn EO's into GID's for
Returns:
the GIDful object

convertGIDtoEO

public static java.lang.Object convertGIDtoEO(com.webobjects.eocontrol.EOEditingContext editingContext,
                                              java.lang.Object obj)
Given a dictionary, array, set, EO, etc, this will recursively turn GID's into EO's. You should lock the editingContext before calling this.

Parameters:
obj - the object to recursively turn GID's into EO's for
Returns:
the EOful object

validateUniquenessOf

public static void validateUniquenessOf(java.lang.String entityName,
                                        com.webobjects.eocontrol.EOEnterpriseObject eo,
                                        com.webobjects.eocontrol.EOQualifier restrictingQualifier,
                                        java.lang.String... keys)
Validates whether the values of the specified keyPaths are unique for an Entity. Throws a ERXValidationException if there is already an EO with the same values on the given key paths. Should be combined with a constraint on the corresponding database columns.

Based on Zak Burke's idea he posted to WOCode a while ago.

Use in validateForSave like this:
       ...
       public class WikiPage extends _WikiPage {
       ...
        public void validateForSave() throws ValidationException {
                super.validateForSave();
                ERXEOControlUtilities.validateUniquenessOf(null, this, ERXQ.equals("active", true), "title", "wiki");
        }
       ...
       }
 
Combine with entries in ValidationTemplate.strings like:
 "WikiPage.title,space.UniquenessViolationNewObject" = "The page cannot be created. There is already a page named <b>@@value.title@@</b> in Wiki <b>@@value.wiki.name@@</b>.";
 "WikiPage.title,space.UniquenessViolationExistingObject" = "The page cannot be changed this way. There is already a page named <b>@@value.title@@</b> in Wiki <b>@@value.wiki.name@@</b>.";
 

Parameters:
eo - the EOEnterpriseObject to validate
keys - an arbitrary number of keyPaths to validate.
restrictingQualifier - an optional resticting qualifier to exclude certain objects from the check
entityName - the name of the entity to check. Defaults to eo.entityName(). It can be necessary to set this to the name of the parent entity when using single table inheritance.
Throws:
ERXValidationException - if an EO with the same property values already exists. If you specify more than one keyPath to validate, the 'key' property will be a comma separated string of the provided keyPaths. 'value' will be a dictionary with the supplied keyPaths as keys and the values corresponding to these keys in the supplied eo as values.
Author:
th

validateUniquenessOf

public static void validateUniquenessOf(com.webobjects.eocontrol.EOEnterpriseObject eo,
                                        com.webobjects.eocontrol.EOQualifier restrictingQualifier,
                                        java.lang.String... keys)
Convinience method which passes null for entityName.

Parameters:
eo - the EOEnterpriseObject to validate
restrictingQualifier - an optional resticting qualifier to exclude certain objects from the check
keys - an arbitrary number of keyPaths to validate.
Author:
th

validateUniquenessOf

public static void validateUniquenessOf(com.webobjects.eocontrol.EOEnterpriseObject eo,
                                        java.lang.String... keys)
Convinience method which passes null for restrictingQualifier and entityName.

Parameters:
eo - the EOEnterpriseObject to validate
keys - an arbitrary number of keyPaths to validate.
Author:
th

validateUniquenessOf

public static void validateUniquenessOf(java.lang.String entityName,
                                        com.webobjects.eocontrol.EOEnterpriseObject eo,
                                        java.lang.String... keys)
Convinience method which passes null for restrictingQualifier.

Parameters:
eo - the EOEnterpriseObject to validate
keys - an arbitrary number of keyPaths to validate.
entityName - the name of the entity to check. Defaults to eo.entityName(). It can be necessary to set this to the name of the parent entity when using single table inheritance.
Author:
th

distinctValuesForKeyPath

public static <T> com.webobjects.foundation.NSArray<T> distinctValuesForKeyPath(com.webobjects.eocontrol.EOEditingContext editingContext,
                                                                                java.lang.String entityName,
                                                                                java.lang.String keyPath,
                                                                                com.webobjects.eocontrol.EOQualifier qualifier,
                                                                                com.webobjects.foundation.NSArray<com.webobjects.eocontrol.EOSortOrdering> sortOrderings)
Returns an NSArray of distinct values available for the given entity and key path. The result can be narrowed by an optional qualifier and optionally sorted with sort orderings

Type Parameters:
T - type of values for the key path
Parameters:
editingContext - editingContext
entityName - entityName
keyPath - keyPath
qualifier - restricting qualifier (optional)
sortOrderings - sortOrderings to be applied (optional)
Returns:
array of values
Author:
th

registeredObjectCount

public static com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Integer> registeredObjectCount(com.webobjects.eocontrol.EOEditingContext ec)
Returns the count of registered objects in the EC grouped by entity name, which is useful for memory debugging. Put this in a log on session.sleep() for example.

Parameters:
ec - editing context to get count of
Returns:
dictionary of counts

changedRegisteredObjectCount

public static com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Integer> changedRegisteredObjectCount(com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Integer> currentCounts,
                                                                                                                      com.webobjects.foundation.NSDictionary<java.lang.String,java.lang.Integer> oldCounts)
Returns the changes in count registered objects in the EC grouped by entity name, which is useful for memory debugging.

Parameters:
currentCounts - current count of objects
oldCounts - previous count of objects
Returns:
dictionary of counts

schemaBasedFetchSpecification

public static com.webobjects.eocontrol.EOFetchSpecification schemaBasedFetchSpecification(com.webobjects.eocontrol.EOEditingContext ec,
                                                                                          com.webobjects.eocontrol.EOFetchSpecification fetchSpecification)
Useful for ensuring a fetch specification is safe to pass around between threads and not having to be concerned about references to EOs in the qualifier.

Parameters:
ec - a locked EOEditingContext that can be used for getting the entity
fetchSpecification -
Returns:
a clone of the fetchSpecification with the EOQualifier converted to a schema-based qualifier, or the original fetchSpec if the fetchSpec has no qualifier

schemaBasedQualifier

public static com.webobjects.eocontrol.EOQualifier schemaBasedQualifier(com.webobjects.eocontrol.EOEditingContext ec,
                                                                        java.lang.String entityName,
                                                                        com.webobjects.eocontrol.EOQualifier qualifier)
Useful for ensuring a qualifier is safe to pass around between threads and not having to be concerned about references to EOs in it. Also handy to verify that an EOQualifier can be used in a database fetch.

Parameters:
ec - a locked EOEditingContext that can be used for getting the entity
entityName - the entity being qualified
qualifier - original qualifier
Returns:
a schema based qualifier that contains no references to EOEnterpriseObjects

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.