Project Wonder 2.0

er.extensions
Class EOEnterpriseObjectClazz

java.lang.Object
  extended byer.extensions.EOEnterpriseObjectClazz
Direct Known Subclasses:
ERXCustomObject.ERXCustomObjectClazz, ERXGenericRecord.ERXGenericRecordClazz

public class EOEnterpriseObjectClazz
extends Object

Adds class-level inheritance to EOF.
Use subclasses of EOEnterpriseObjectClazz as inner classes in your EO subclasses to work around the missing class object inheritance of java. They must be named XXX.XXXClazz to work.
Every subclass of this class will get their own "ClazzObject" instance, so it's OK to store things which might be different in superclasses. That is, the "User"'s implementation can override the "Person"'s and because Person.clazz() will get it's own instance, it will do only "Person" things.
The methods from EOUtilities are mirrored here so you don't have to import EOAccess in your subclasses, which is not legal for client-side classes. The implementation for a client-side class could then be easily switched to use the server-side EOUtilites implementation.


Field Summary
static ERXLogger log
          logging support
 
Constructor Summary
EOEnterpriseObjectClazz()
          Default public constructor
 
Method Summary
 NSArray allObjects(EOEditingContext ec)
          Gets all of the objects for the clazz's entity.
static EOEnterpriseObjectClazz clazzForEntityNamed(String entityName)
          Method used to get a clazz object for a given entity name.
 EOEnterpriseObject createAndInsertObject(EOEditingContext ec)
          Creates and inserts an object of the type of the clazz into the given editing context.
 EOEntity entity()
          Gets the entity corresponding to the entity name of the clazz.
 EOEntity entity(EOEditingContext ec)
          Gets the entity corresponding to the entity name of the clazz.
 String entityName()
          Gets the entity name of the clazz.
protected  String entityNameFromRawRow(EOEditingContext ec, NSDictionary dict)
          Utility method to get the entity name from a raw row dictionary, taking subclasses and restricting qualifiers into account.
 NSArray faultsFromRawRows(EOEditingContext ec, NSArray nsarray)
          Constructs an array of faults for a given array of primary keys in a given editing context for the clazz's entity.
 NSArray faultsMatchingQualifier(EOEditingContext ec, EOQualifier eoqualifier)
          Fetches an array of faults matching a given qualifier.
 NSArray faultsMatchingQualifier(EOEditingContext ec, EOQualifier eoqualifier, NSArray sortOrderings)
          Fetches an array of faults matching a given qualifier and sorted by an array of sort orderings.
 NSArray faultsMatchingValues(EOEditingContext ec, NSDictionary nsdictionary, NSArray sortOrderings)
          Fetches an array of faults for a given set of criteria.
 EOFetchSpecification fetchSpecificationNamed(EOEditingContext ec, String name)
          Gets a fetch specification for a given name.
 EOFetchSpecification fetchSpecificationNamed(String name)
          Gets a fetch specification for a given name.
 NSArray newPrimaryKeys(EOEditingContext ec, int i)
          Generates an array of primary key values for the clazz's entity.
protected static EOAttribute objectCountAttribute()
          Creates and caches an eo attribute that can be used to return the number of objects that a given fetch specification will return.
protected static EOAttribute objectCountUniqueAttribute(EOAttribute foo)
           
 Number objectCountWithFetchSpecificationAndBindings(EOEditingContext ec, String fetchSpecName, NSDictionary bindings)
          Find the number of objects matching the given fetch specification and bindings for the clazz's entity name.
 Number objectCountWithQualifier(EOEditingContext ec, EOQualifier qualifier)
          Returns the number of objects matching the given qualifier for the clazz's entity name.
 EOEnterpriseObject objectFromRawRow(EOEditingContext ec, NSDictionary dict)
          Creates an enterprise object from a raw row for the clazz's entity in the given editing context.
 NSArray objectsWithFetchSpecificationAndBindings(EOEditingContext ec, String name, NSDictionary bindings)
          Fetchs an array of objects for a given fetch specification and an array of bindings.
 NSArray objectsWithQualifierFormat(EOEditingContext ec, String qualifier, NSArray args)
          Fetches all of the objects matching the given qualifer format corresponding to the clazz's entity using the given editing context.
 EOEnterpriseObject objectWithPrimaryKeyValue(EOEditingContext ec, Object pk)
          Fetches the enterprise object for the specified primary key value and corresponding to the clazz's entity name.
 EOFetchSpecification primaryKeyFetchSpecificationForEntity(EOEditingContext ec, EOQualifier eoqualifier, NSArray sortOrderings, NSArray additionalKeys)
          Constructs a fetch specification that will only fetch the primary keys for a given qualifier.
 NSArray primaryKeysMatchingQualifier(EOEditingContext ec, EOQualifier eoqualifier, NSArray sortOrderings)
          Fetches an array of primary keys matching a given qualifier and sorted with a given array of sort orderings.
 NSArray primaryKeysMatchingValues(EOEditingContext ec, NSDictionary nsdictionary, NSArray sortOrderings)
          Fetches an array of primary keys matching the values in a given dictionary.
static void resetClazzCache()
          Resets the clazz cache.
 void setEntityName(String name)
          Sets the entity name of the clazz.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

public static final ERXLogger log
logging support

Constructor Detail

EOEnterpriseObjectClazz

public EOEnterpriseObjectClazz()
Default public constructor

Method Detail

objectCountAttribute

protected static EOAttribute objectCountAttribute()
Creates and caches an eo attribute that can be used to return the number of objects that a given fetch specification will return.

Returns:
eo count attribute

objectCountUniqueAttribute

protected static EOAttribute objectCountUniqueAttribute(EOAttribute foo)
Parameters:
foo -

resetClazzCache

public static void resetClazzCache()
Resets the clazz cache.


clazzForEntityNamed

public static EOEnterpriseObjectClazz clazzForEntityNamed(String entityName)
Method used to get a clazz object for a given entity name. This method will cache the generated clazz object so that for a given entity name only one clazz object will be created.

Parameters:
entityName - name of the entity to get the Clazz object for
Returns:
clazz object for the given entity

createAndInsertObject

public EOEnterpriseObject createAndInsertObject(EOEditingContext ec)
Creates and inserts an object of the type of the clazz into the given editing context.

Parameters:
ec - an editing context
Returns:
newly created and inserted object

newPrimaryKeys

public NSArray newPrimaryKeys(EOEditingContext ec,
                              int i)
Generates an array of primary key values for the clazz's entity. Uses the database context for the entity's model and the given editingcontext.

Parameters:
ec - am editing context
i - number of primary keys to generate
Returns:
array of new primary keys

allObjects

public NSArray allObjects(EOEditingContext ec)
Gets all of the objects for the clazz's entity. Just a cover method for the EOUtilities method objectsForEntityNamed.

Parameters:
ec - editingcontext to fetch the objects into
Returns:
array of all the objects for a given entity name.

objectFromRawRow

public EOEnterpriseObject objectFromRawRow(EOEditingContext ec,
                                           NSDictionary dict)
Creates an enterprise object from a raw row for the clazz's entity in the given editing context.

Parameters:
ec - editing context to create the eo in
dict - raw row dictionary
Returns:
enterprise object for the raw row

entityNameFromRawRow

protected String entityNameFromRawRow(EOEditingContext ec,
                                      NSDictionary dict)
Utility method to get the entity name from a raw row dictionary, taking subclasses and restricting qualifiers into account.

Parameters:
ec - an editing context
dict - raw row dictionary
Returns:
entity name, if any

objectWithPrimaryKeyValue

public EOEnterpriseObject objectWithPrimaryKeyValue(EOEditingContext ec,
                                                    Object pk)
Fetches the enterprise object for the specified primary key value and corresponding to the clazz's entity name.

Parameters:
ec - editing context to fetch into
pk - primary key value. Compound primary keys are given as NSDictionaries.
Returns:
enterprise object for the specified primary key value.

objectsWithQualifierFormat

public NSArray objectsWithQualifierFormat(EOEditingContext ec,
                                          String qualifier,
                                          NSArray args)
Fetches all of the objects matching the given qualifer format corresponding to the clazz's entity using the given editing context.

Parameters:
ec - editing context
qualifier - qualifier string
args - qualifier format arguments
Returns:
array of objects corresponding to the passed in parameters.

objectsWithFetchSpecificationAndBindings

public NSArray objectsWithFetchSpecificationAndBindings(EOEditingContext ec,
                                                        String name,
                                                        NSDictionary bindings)
Fetchs an array of objects for a given fetch specification and an array of bindings. The fetch specifiation is resolved off of the entity corresponding to the current clazz.

Parameters:
ec - editing content to fetch into
name - fetch specification name
bindings - used to resolve binding keys within the fetch specification
Returns:
array of objects fetched using the given fetch specification

setEntityName

public void setEntityName(String name)
Sets the entity name of the clazz.

Parameters:
name - of the entity

entityName

public String entityName()
Gets the entity name of the clazz.

Returns:
entity name of the clazz.

entity

public EOEntity entity()
Gets the entity corresponding to the entity name of the clazz.

Returns:
entity for the clazz

entity

public EOEntity entity(EOEditingContext ec)
Gets the entity corresponding to the entity name of the clazz.

Parameters:
ec - an editing context
Returns:
entity for the clazz

fetchSpecificationNamed

public EOFetchSpecification fetchSpecificationNamed(String name)
Gets a fetch specification for a given name.

Parameters:
name - of the fetch specification
Returns:
fetch specification for the given name and the clazz's entity name

fetchSpecificationNamed

public EOFetchSpecification fetchSpecificationNamed(EOEditingContext ec,
                                                    String name)
Gets a fetch specification for a given name.

Parameters:
ec - editing context to use for finding the model group
name - of the fetch specification
Returns:
fetch specification for the given name and the clazz's entity name

objectCountWithQualifier

public Number objectCountWithQualifier(EOEditingContext ec,
                                       EOQualifier qualifier)
Returns the number of objects matching the given qualifier for the clazz's 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
qualifier - to find the matching objects
Returns:
number of matching objects

objectCountWithFetchSpecificationAndBindings

public Number objectCountWithFetchSpecificationAndBindings(EOEditingContext ec,
                                                           String fetchSpecName,
                                                           NSDictionary bindings)
Find the number of objects matching the given fetch specification and bindings for the clazz's entity name. Implementation wise the sql generated will only return the count of the query, not all of the rows matching the qualification.

Parameters:
ec - ec used to perform the count in
fetchSpecName - name of the fetch specification
bindings - dictionary of bindings for the fetch specification
Returns:
number of objects matching the given fetch specification and bindings

primaryKeyFetchSpecificationForEntity

public EOFetchSpecification primaryKeyFetchSpecificationForEntity(EOEditingContext ec,
                                                                  EOQualifier eoqualifier,
                                                                  NSArray sortOrderings,
                                                                  NSArray additionalKeys)
Constructs a fetch specification that will only fetch the primary keys for a given qualifier.

Parameters:
ec - editing context, not used
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 NSArray primaryKeysMatchingQualifier(EOEditingContext ec,
                                            EOQualifier eoqualifier,
                                            NSArray 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
eoqualifier - to restrict matching primary keys
sortOrderings - array of sort orders to sort result set
Returns:
array of primary keys matching a given qualifier

primaryKeysMatchingValues

public NSArray primaryKeysMatchingValues(EOEditingContext ec,
                                         NSDictionary nsdictionary,
                                         NSArray sortOrderings)
Fetches an array of primary keys matching the values in a given dictionary.

Parameters:
ec - editing context to fetch into
nsdictionary - dictionary of key value pairs to match against.
sortOrderings - array of sort orders to sort the result set by.
Returns:
array of primary keys matching the given criteria.

faultsFromRawRows

public NSArray faultsFromRawRows(EOEditingContext ec,
                                 NSArray nsarray)
Constructs an array of faults for a given array of primary keys in a given editing context for the clazz's entity.

Parameters:
ec - editing context to construct the faults in
nsarray - array of primary key dictionaries
Returns:
array of faults for an array of primary key dictionaries.

faultsMatchingQualifier

public NSArray faultsMatchingQualifier(EOEditingContext ec,
                                       EOQualifier eoqualifier)
Fetches an array of faults matching a given qualifier.

Parameters:
ec - editing context to use to fetch into
eoqualifier - qualifier to match against
Returns:
array of faults that match the given qualifier

faultsMatchingQualifier

public NSArray faultsMatchingQualifier(EOEditingContext ec,
                                       EOQualifier eoqualifier,
                                       NSArray sortOrderings)
Fetches an array of faults matching a given qualifier and sorted by an array of sort orderings.

Parameters:
ec - editing context to use to fetch into
eoqualifier - qualifier to match against
sortOrderings - array of sort orderings to order the faults
Returns:
array of faults that match the given qualifier

faultsMatchingValues

public NSArray faultsMatchingValues(EOEditingContext ec,
                                    NSDictionary nsdictionary,
                                    NSArray sortOrderings)
Fetches an array of faults for a given set of criteria.

Parameters:
ec - editing context to use to fetch into
nsdictionary - key value criteria to match against
sortOrderings - array of sort orderings to order the faults
Returns:
array of faults that match the given criteria

Last updated: Do, Dez 9, 2004 • 12:46 PM CET

Copyright © 2002 – 2004 Project Wonder.