PATH  WebObjects 4.0 Documentation > EOAccess Reference



EOModelGroup

Inherits From:
NSObject

Inherits From:
com.apple.yellow.eoaccess


Class Description

An EOModelGroup represents an aggregation of related models (see the EOModel class specification for more information on 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 shouldn't appear in any two of the models. All cross-model information is represented in the models by entity name only. Binding the entity name to an actual entity is done at run-time within the EOModelGroup.

In the majority of applications, the automatic creation of the default model group is sufficient. However, your code can override this automatic creation; see "Setting Up A Model Group Programmatically."


EOModelGroup Delegates

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-while the instance delegate can implement the methods defined in the EOModelGroup.Delegate interface. For more information on EOModelGroup class delegate and instance delegate methods, see the EOModelGroup.ClassDelegate and EOModelGroup.Delegate interface specifications, respectively.


Method Types

Constructors
EOModelGroup
Accessing the group
addModel
addModelWithPath
modelNamed
modelNames
models
modelWithPath
removeModel
Accessing model groups
defaultGroup
setDefaultGroup
globalModelGroup
modelGroupForObjectStoreCoordinator
setModelGroup
Searching a group
entityNamed
entityForObject
fetchSpecificationNamed
storedProcedureNamed
Loading all of a group's objects
loadAllModelObjects
Assigning a delegate
classDelegate
delegate
setClassDelegate
setDelegate

Constructors


EOModelGroup

public EOModelGroup()

Creates a new EOModelGroup that contains no models.



classDelegate

public static java.lang.Object classDelegate()

Returns the EOModelGroup's class delegate. This delegate optionally implements the defaultModelGroup method (see the EOModelGroup.ClassDelegate interface specification for more information).

See also: setClassDelegate


defaultGroup

public static EOModelGroup defaultGroup()

Returns the default EOModelGroup. Unless you've either specified a default model group with setDefaultGroup or implemented the defaultModelGroup class delegate method to return a non-null value, this method is equivalent to globalModelGroup.

See also: classDelegate


globalModelGroup

public static EOModelGroup globalModelGroup()

Returns an EOModelGroup composed of all models in the resource directory of the main bundle, as well as those in all the bundles and frameworks loaded into the application.

See also: defaultGroup


modelGroupForObjectStoreCoordinator

public static EOModelGroup modelGroupForObjectStoreCoordinator(com.apple.yellow.eocontrol.EOObjectStoreCoordinator anObjectStoreCoordinator)

Returns the EOModelGroup used by anObjectStoreCoordinator.

See also: setModelGroup


setClassDelegate

public static void setClassDelegate(java.lang.Object anObject)

Assigns anObject as the EOModelGroup's class delegate. The class delegate is optional; it allows you to determine the default model group (see the EOModelGroup.ClassDelegate interface specification for more information).

See also: classDelegate, defaultModelGroup


setDefaultGroup

public static void setDefaultGroup(EOModelGroup group)

Sets the default model group to group. If you've implemented the defaultModelGroup class delegate method to return a non-null value, the delegate's return value overrides group as the default model group.

See also: defaultGroup,setClassDelegate


setModelGroup

public static void setModelGroup(EOModelGroup group, com.apple.yellow.eocontrol.EOObjectStoreCoordinator anObjectStoreCoordinator)

Assigns group to anObjectStoreCoordinator. By default, an EOObjectStoreCoordinator uses the defaultGroup. You might want to assign a different 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 different models have the same name.

See also: modelGroupForObjectStoreCoordinator


Instance Methods


addModel

public void addModel(EOModel model)

Adds a model to the receiver, sets the model's model group to the receiver, and posts ModelAddedNotification. Throws an exception if the receiver already contains an EOModel with the same name as the specified model.

See also: models, removeModel


addModelWithPath

public EOModel addModelWithPath(java.lang.String path)

Creates an EOModel object with the contents of the file identified by path, and adds the newly created model to the receiver. Adds the new model to the receiver with addModel. Throws an exception if for any reason it cannot create the model from the file specified by path.


delegate

public java.lang.Object delegate()

Returns the receiver's delegate, which is different from the EOModelGroup's class delegate. Each EOModelGroup object can have it's own delegate in addition to the delegate that's assigned to the EOModelGroup class. See the EOModelGroup.Delegate interface specification for more information.

See also: setDelegate, classDelegate


entityForObject

public EOEntity entityForObject(java.lang.Object object)

Returns the EOEntity associated with object from any of the models in the receiver that handle object, or null if none of the entities in the receiver handles object.

See also: entityForObject (EOModel)


entityNamed

public EOEntity entityNamed(java.lang.String entityName)

Searches each of the EOModels in the receiver for the entity specified by entityName, and returns the entity if found. Returns null if it is unable to find the specified entity.

See also: entityNamed (EOModel)


fetchSpecificationNamed

public com.apple.yellow.eocontrol.EOFetchSpecification fetchSpecificationNamed(java.lang.String fetchSpecName,
java.lang.String entityName)

Returns the named fetch specification from the entity specified by entityName in the receiving model group.


loadAllModelObjects

public void loadAllModelObjects()

Sends loadAllModelObjects to 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.

See also: loadAllModelObjects (EOModel)


modelNamed

public EOModel modelNamed(java.lang.String modelName)

Returns the EOModel named modelName if it's part of the receiver, or null if the receiver doesn't contain an EOModel with the specified name.

See also: modelNames, models


modelNames

public 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. The order of the model names in the array isn't defined.

See also: modelNamed, models


models

public NSArray models()

Returns an array containing the receiver's EOModels, or an empty array if the receiver contains no EOModels. The order of the models in the array isn't defined.

See also: modelNamed, modelNames, models


modelWithPath

public EOModel modelWithPath(java.lang.String path)

If the receiver contains an EOModel whose path (as determined by sending path to the EOModel object) is equal to path, that EOModel is returned. Otherwise, returns null. String's equals method is used to compare the paths, and each path is standardized before comparison.

See also: modelNamed:, path (EOModel)


removeModel

public void removeModel(EOModel aModel)

Removes aModel from the receiver, and unbinds any connections to aModel from other EOModels in the receiver. Posts ModelInvalidatedNotification to the default notification center after removing aModel from the receiver.

See also: addModel, models


setDelegate

public void setDelegate(java.lang.Object anObject)

Sets the receiver's delegate to anObject. See the EOModelGroup.Delegate interface specification for more information.

See also: delegate


storedProcedureNamed

public EOStoredProcedure storedProcedureNamed(java.lang.String aName)

Returns the stored procedure in the receiving model group having the given name.


Notifications

EOModelGroup declares and posts the following notifications.


ModelAddedNotification

Posted by an EOModelGroup when an EOModel is added to the group. This notification is sent, for instance, inside Interface Builder when the user has saved changes to a model in EOModeler and the objects in Interface Builder must be brought back in sync. The old model is flushed and receivers of the notification (like data sources) can invoke modelNamed to re-fetch their models.

Notification Object The newly added model.
Userinfo None


ModelInvalidatedNotification

Posted by an EOModelGroup when an EOModel is removed from the group. This notification is sent, for instance, inside Interface Builder when the user has saved changes to a model in EOModeler and the objects in Interface Builder must be brought back in sync. The old model is flushed and receivers of the notification (like data sources) can invoke modelNamed to re-fetch their models.

Notification Object The invalidated model.
Userinfo None





Copyright © 1998, Apple Computer, Inc. All rights reserved.