|
WebObjects 5.2.3 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.webobjects.eoaccess.EOModelGroup
An EOModelGroup represents an aggregation of related models. When a model in the group needs to resolve a relationship to an entity in another model, it looks for that model in its group. Model groups allow applications to load entities and their properties only as they're needed, by distributing them among separate EOModels.
The default model group contains all models for an application, as well as any frameworks the application references. It is automatically created on demand. The entity name space among all of these models is global; consequently, the same entity name should not appear in any two of models in the group. All cross-model information is represented in the models by entity name only. Binding the entity name to an actual entity is done at runtime within the EOModelGroup.
In the majority of applications, the automatically created default model group is sufficient. If different model grouping semantics are needed, programmers can create their own model group instance, add whatever models they like, and then replace the default model group with their custom model group.
The following code demonstrates programmatic creation of a model group.
java.net.URL modelURL;//Assume this exists EOModelGroup group =new EOModelGroup(); group.addModelWithPathURL(modelURL); EOModelGroup.setDefaultGroup(group);
Each model lives within a group and can form connections to other models in its group. EOModeler puts models with identical names in separate groups to allow you to load two models with the same name at the same time.
A model can find a related model by name using the statement
this.modelGroup().modelNamed(name);
.
A data source can locate a model using the statement:
EOModelGroup.defaultGroup().modelNamed(name);
.
Your EOModelGroup object should have a delegate which can influence how it
finds and loads models. In addition to the delegates you assign to
EOModelGroup instances, the EOModelGroup class itself can have a delegate.
The class delegate implements a single method,
defaultModelGroup
. The instance delegate can implement the
methods defined in the EOModelGroup.Delegate
interface.
Note that the following delegate methods are set on EOModelGroup, rather than EOEntity, to provide a single point in the code where you can alter the database-to-objects mapping.
classForObjectWithGlobalID
failedToLookupClassNamed
relationshipForRow
subEntityForEntity
EOModelGroup.ClassDelegate.defaultModelGroup()
,
EOModelGroup.Delegate.classForObjectWithGlobalID(EOEntity entity, EOGlobalID gid)
,
EOModelGroup.Delegate.subEntityForEntity(EOEntity entity, NSDictionary dic)
,
EOModelGroup.ClassDelegate
,
EOModelGroup
,
EOModel
Nested Class Summary | |
static interface |
EOModelGroup.ClassDelegate
This interface defines a delegate to the EOModelGroup class to allow modification of the creation of the default model group. |
static interface |
EOModelGroup.Delegate
This interface defines a delegate to EOModelGroup to allow instances to modify how the model group finds and loads models. |
Field Summary | |
static String |
ModelAddedNotification
Posted by an EOModelGroup when an EOModel is added to the group. |
static String |
ModelInvalidatedNotification
Posted by an EOModelGroup when an EOModel is removed from the group. |
Constructor Summary | |
EOModelGroup()
Creates and returns a new EOModelGroup. |
Method Summary | |
void |
addModel(EOModel model)
Adds model to the receiving model group, sets the
receiving model group as model 's model group, and posts a
ModelAddedNotification . |
EOModel |
addModelWithPath(String path)
Deprecated. use addModelWithPathURL instead |
EOModel |
addModelWithPathURL(URL url)
Creates and returns a new EOModel object from the contents of the model archive identified by url ; may return null . |
static Object |
classDelegate()
Returns EOModelGroup's class delegate. |
static EOModelGroup |
defaultGroup()
Returns the default EOModelGroup, which is the same as the global EOModelGroup unless you have either explicitly set a default model group with setDefaultGroup or implemented
the class delegate method defaultModelGroup to return a
non-null value. |
Object |
delegate()
Returns the receiver's instance delegate, which is different than the EOModelGroup class delegate. |
NSArray |
entitiesWithSharedObjects()
Returns an array of entities that have objects to load into a shared editing context. |
EOEntity |
entityForObject(EOEnterpriseObject object)
Returns the EOEntity associated with object from any of the
models in the receiver that handle object , or
null if none of the models in the receiver handle
object . |
EOEntity |
entityNamed(String name)
Searches each of the EOModels in the receiver for the entity specified by name , and returns the entity, if found, or
null if unable to find the specified entity. |
EOFetchSpecification |
fetchSpecificationNamed(String fetchSpecName,
String entityName)
Returns the fetch specification identifed by fetchSpecName
from the entity specified by entityName in the receiving
model group. |
static EOModelGroup |
globalModelGroup()
Returns an EOModelGroup composed of all models in the resource directory of the application, as well as those in all frameworks loaded into the application. |
void |
loadAllModelObjects()
Invokes loadAllModelObjects on each of the receiver's
EOModels, thereby loading any EOEntities, EOAttributes, EORelationships,
and EOStoredProcedures that haven't yet been loaded from each of the
EOModels in the receiver. |
static EOModelGroup |
modelGroupForObjectStoreCoordinator(EOObjectStoreCoordinator objectCoord)
Returns the EOModelGroup used by the EOObjectStoreCoordinator objectCoord . |
EOModel |
modelNamed(String name)
Returns the EOModel identifed by name if it is part of the
receiving model group, or null if the receiver doesn't
contain an EOModel with the specified name. |
NSArray |
modelNames()
Returns an array containing the names of all of the EOModels in the receiver, or an empty array if the receiver contains no EOModels. |
NSArray |
models()
Returns an array containing the receiver's EOModels, or an empty array if the receiver contains no EOModels. |
EOModel |
modelWithPath(String path)
Deprecated. use modelWithPathURL instead |
EOModel |
modelWithPathURL(URL url)
Returns the EOModel whose URL is identical to url or
null if the receiver does not contain an EOModel with the
specified URL. |
void |
removeModel(EOModel model)
Removes model from the receiving model group and unbinds any
references to model from other EOModels in the group. |
static void |
setClassDelegate(Object delegate)
Assigns delegate as EOModelGroup's class delegate. |
static void |
setDefaultGroup(EOModelGroup group)
Sets the default model group to group . |
void |
setDelegate(Object delegate)
Sets the receiver's instance delegate to delegate . |
static void |
setModelGroupForObjectStoreCoordinator(EOObjectStoreCoordinator objectCoord,
EOModelGroup group)
Assigns group as the working model group for the
EOObjectStoreCoordinator objectCoord . |
EOStoredProcedure |
storedProcedureNamed(String name)
Searches each of the EOModels in the receiver for the stored procedure specified by name , and returns the stored procedure, if
found, or null if unable to find the specified stored
procedure. |
String |
toString()
Returns a string representation of the model group. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final String ModelAddedNotification
modelNamed
to re-fetch their
models.
Notification Object | The newly added model. |
Userinfo | None |
modelNamed(String modelName)
public static final String ModelInvalidatedNotification
modelNamed
to re-fetch their
models.
Notification Object | The invalidated model. |
Userinfo | None |
modelNamed(String modelName)
Constructor Detail |
public EOModelGroup()
Method Detail |
public void addModel(EOModel model)
model
to the receiving model group, sets the
receiving model group as model
's model group, and posts a
ModelAddedNotification
. Throws an exception if the
receiver already contains an EOModel with the same name as
model
, of if there is a name conflict between entities
in model
and entities in any of the model group's other
models.
model
- A model to add to the receiver.
IllegalStateException
- if there is a name conflict between
model
and the receiver's current models, or
between entities in model
and entities in the
receiver's current models.ModelAddedNotification
public EOModel addModelWithPath(String path)
path
- The path to an EOModel archive.
path
,
or null
.public EOModel addModelWithPathURL(URL url)
url
; may return null
. If
a model can be created from path
, adds the newly created
model to the receiver.
url
- The URL to an EOModel archive.
url
,
or null
.public static Object classDelegate()
setClassDelegate(Object anObject)
,
EOModelGroup.ClassDelegate
public static EOModelGroup defaultGroup()
setDefaultGroup
or implemented
the class delegate method defaultModelGroup
to return a
non-null
value.
Note: In WebObjects applications, the WOApplication instance
assigns the WOApplication class as the EOModelGroup's class delegate.
Its implementation of defaultModelGroup
can return a
different default model group than the one returned by this method.
classDelegate()
,
setDefaultGroup(EOModelGroup group)
,
EOModelGroup.ClassDelegate.defaultModelGroup()
,
globalModelGroup()
public Object delegate()
EOModelGroup.ClassDelegate
,
classDelegate()
,
setClassDelegate(Object anObject)
,
EOModelGroup.Delegate
public NSArray entitiesWithSharedObjects()
EOEditingContext
public EOEntity entityForObject(EOEnterpriseObject object)
object
from any of the
models in the receiver that handle object
, or
null
if none of the models in the receiver handle
object
.
object
- An object for which to search in the receiver's models.
object
, or
null
.EOModel.entityForObject(EOEnterpriseObject object)
public EOEntity entityNamed(String name)
name
, and returns the entity, if found, or
null
if unable to find the specified entity.
name
- The name of an entity for which to search in the
receiver's models.
name
, or
null
.EOModel.entityNamed(String name)
public EOFetchSpecification fetchSpecificationNamed(String fetchSpecName, String entityName)
fetchSpecName
from the entity specified by entityName
in the receiving
model group.
fetchSpecName
- The name of a fetch specification for which to
search in the entity named entityName
.entityName
- The name of an EOEntity to search for a fetch
specification named fetchSpecName
.
public static EOModelGroup globalModelGroup()
defaultGroup()
public void loadAllModelObjects()
loadAllModelObjects
on each of the receiver's
EOModels, thereby loading any EOEntities, EOAttributes, EORelationships,
and EOStoredProcedures that haven't yet been loaded from each of the
EOModels in the receiver.
EOModel.loadAllModelObjects()
public static EOModelGroup modelGroupForObjectStoreCoordinator(EOObjectStoreCoordinator objectCoord)
objectCoord
.
objectCoord
- A EOObjectStoreCoordinator.
objectCoord
.setModelGroupForObjectStoreCoordinator(
EOObjectStoreCoordinator objectCoord, EOModelGroup group)
public EOModel modelNamed(String name)
name
if it is part of the
receiving model group, or null
if the receiver doesn't
contain an EOModel with the specified name.
name
- The name of an EOModel for which to search in the receiver.
name
, or
null
.setModelGroupForObjectStoreCoordinator(
EOObjectStoreCoordinator objectCoord, EOModelGroup group)
public NSArray modelNames()
public EOModel modelWithPath(String path)
path
- The path to an EOModel archive.
path
, or
null
.modelWithPathURL(java.net.URL URL)
public EOModel modelWithPathURL(URL url)
url
or
null
if the receiver does not contain an EOModel with the
specified URL.
url
- The URL to an EOModel archive.
url
, or
null
.EOModel.pathURL()
public NSArray models()
public void removeModel(EOModel model)
model
from the receiving model group and unbinds any
references to model
from other EOModels in the group.
Posts a ModelInvalidatedNotification
to the default
notification center after removing model
.
model
- An EOModel to remove from the receiver.ModelInvalidatedNotification
,
models()
public static void setClassDelegate(Object delegate)
delegate
as EOModelGroup's class delegate.
The class delegate is optional; it allows modification of the creation of
the default model group.
delegate
- The object to set as EOModelGroup's class
delegate.classDelegate()
,
EOModelGroup.ClassDelegate
public static void setDefaultGroup(EOModelGroup group)
group
. If you have
implemented the defaultModelGroup
class delegate method to
return a non-null
value, the delegate's return value
overrides the value set by this method.
group
- A model group to set as the receiver's default model
group.EOModelGroup.ClassDelegate.defaultModelGroup()
,
defaultGroup()
,
setClassDelegate(Object anObject)
public void setDelegate(Object delegate)
delegate
. The
EOModelGroup class may also have a class delegate set, which is
independent of the instance delegate.
delegate
- The object to set as the receiver's instance delegate.delegate()
,
classDelegate()
,
EOModelGroup.Delegate
,
EOModelGroup.ClassDelegate
public static void setModelGroupForObjectStoreCoordinator(EOObjectStoreCoordinator objectCoord, EOModelGroup group)
group
as the working model group for the
EOObjectStoreCoordinator objectCoord
. By default,
an EOObjectStoreCoordinator uses the default model group. You might
want to assign a different model group to an EOObjectStoreCoordinator
if you need to scope models to particular coordinators, if different
models have the same name, or if different entities in some models have
the same name.
objectCoord
- An object store coordinator.group
- The model group to be used by
objectCoord
.defaultGroup()
,
modelGroupForObjectStoreCoordinator(
EOObjectStoreCoordinator objectCoord)
public EOStoredProcedure storedProcedureNamed(String name)
name
, and returns the stored procedure, if
found, or null
if unable to find the specified stored
procedure.
name
- The name of a stored procedure for which to search in the
receiver's models.
name
, or
null
.public String toString()
|
Last updated Thu Oct 21 15:04:16 PDT 2004. | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |