Package Modeling :: Module ObjectStoreCoordinator :: Class ObjectStoreCoordinator
[show private | hide private]
[frames | no frames]

Class ObjectStoreCoordinator

ObjectStore --+
              |
             ObjectStoreCoordinator


ObjectStoreCoordinator API

Design Pattern: Chain of repsonsability

__TBD

By default only one 'ObjectStoreCoordinator' is created for an entire application ; however multiple coordinators might exist in an application (reasons will be details ine the future __TBD)

Implementation of interface 'ObjectStore'

With respect to implemented interface 'ObjectStoreInterface', the following methods make sense and are consequently overriden:

  • arrayFaultWithSourceGlobalID
  • faultForGlobalID
  • invalidateAllObjects
  • invalidateObjectsWithGlobalIDs
  • objectsForSourceGlobalID
  • objectsWithFetchSpecification
  • refaultObject
  • savesChangesInEditingContext

These methods' implementations simply forwards to the dedicated coordinator(s) the message ; determination of the coordinator(s) involved is done using either 'objectStoreForFetchSpecification', 'objectStoreForGlobalID' or 'objectStoreForObject'.

Implementation notes:

Remember that you should NOT access directly to instance variables, they are considered private (MT-safety)

Method Summary
  __init__(self)
  addCooperatingObjectStore(self, aStore)
Adds a cooperating object store
  arrayFaultWithSourceGlobalID(self, aGlobalID, aRelationshipName, anEditingContext)
See ObjectStore for details
  cooperatingObjectStores(self)
Returns a copy of the list of registered cooperatingObjectStores
  faultForGlobalID(self, aGlobalID, anEditingContext)
Forwards the message to the adequate CooperatingObjectStore, usually a DatabaseContext, and returns the result.
  faultForRawRow(self, row, entityName, anEditingContext)
Forwards the message to the adequate CooperatingObjectStore, usually a DatabaseContext, and returns the result.
  forwardUpdateForObject(self, anObject, aDictionaryOfChanges)
Called by a CooperatingObjectStore (usually a DatabaseContext) when it needs to notify that some changes were noticed that are not necessarily already noticed --this is the case, for example, when a toMany relationship, with no inverseRelationship declared in the model, has been changed.
  initializeObject(self, anObject, aGlobalID, anEditingContext)
See ObjectStore for details
  invalidateAllObjects(self)
See ObjectStore for details
  invalidateObjectsWithGlobalIDs(self, globalIDs)
See ObjectStore
  lock(self)
Acquire the lock for the ObjectStoreCoordinator.
  objectsCountWithFetchSpecification(self, aFetchSpecification, anEditingContext)
Forwards the message to the appropriate CooperatingObjectStore, usually a DatabaseContext.
  objectsForSourceGlobalID(self, aGlobalID, aRelationshipName, anEditingContext)
See ObjectStore for details
  objectStoreForEntityName(self, entityName)
Iterates on objectStores and returns the first one who answers positively to message 'ownsEntityName'
  objectStoreForFetchSpecification(self, aFetchSpecification)
Iterates on objectStores and returns the first one who answers positively to message 'handlesFetchSpecification'.
  objectStoreForGlobalID(self, aGlobalID)
Iterates on objectStores and returns the first one who answers positively to message 'ownsGlobalID'
  objectStoreForObject(self, anObject)
Iterates on objectStores and returns the first one who answers positively to message 'ownsObject'
  objectsWithFetchSpecification(self, aFetchSpecification, anEditingContext)
See ObjectStore for details
  ownsObject(self, anObject)
Tells whether the ObjectStore can handle the supplied object.
  refaultObject(self, anObject, aGlobalID, anEditingContext)
See ObjectStore for details
  removeCooperatingObjectStore(self, aStore)
Removes a cooperating object store
  rootObjectStore(self)
Returns 'self', since an 'ObjectStoreCoordinator' object is designed to be the root of an ObjectStore hierarchy.
  saveChangesInEditingContext(self, anEditingContext)
See ObjectStore for details
  unlock(self)
Releases the lock for the ObjectStoreCoordinator.
    Inherited from ObjectStore
  editingContextDidForgetObjectWithGlobalID(self, aContext, aGlobalID)
See interfaces.ObjectStore for details
  handlesObject(self, anObject)
An alias for ownsObject().
  isObjectLockedWithGlobalID(self, aGlobalID, anEditingContext)
See interfaces.ObjectStore for details
  lockObjectWithGlobalID(self, aGlobalID, anEditingContext)
See interfaces.ObjectStore for details
  savesChangesInEditingContext(self, anEditingContext)
See interfaces.ObjectStore for details

Class Variable Summary
    Inherited from ObjectStore
tuple __implements__ = (<class Modeling.interfaces.ObjectStore...

Method Details

addCooperatingObjectStore(self, aStore)

Adds a cooperating object store

Posts CooperatingObjectStoreWasAdded

See also: removeCooperatingObjectStore

arrayFaultWithSourceGlobalID(self, aGlobalID, aRelationshipName, anEditingContext)

See ObjectStore for details
Overrides:
Modeling.ObjectStore.ObjectStore.arrayFaultWithSourceGlobalID

cooperatingObjectStores(self)

Returns a copy of the list of registered cooperatingObjectStores

faultForGlobalID(self, aGlobalID, anEditingContext)

Forwards the message to the adequate CooperatingObjectStore, usually a DatabaseContext, and returns the result.
Overrides:
Modeling.ObjectStore.ObjectStore.faultForGlobalID

faultForRawRow(self, row, entityName, anEditingContext)

Forwards the message to the adequate CooperatingObjectStore, usually a DatabaseContext, and returns the result.
Overrides:
Modeling.ObjectStore.ObjectStore.faultForRawRow

forwardUpdateForObject(self, anObject, aDictionaryOfChanges)

Called by a CooperatingObjectStore (usually a DatabaseContext) when it needs to notify that some changes were noticed that are not necessarily already noticed --this is the case, for example, when a toMany relationship, with no inverseRelationship declared in the model, has been changed.

The ObjectStoreCoordinator simply locates the appropriate CooperatingObjectStore for 'anObject' then forwards the notification of changes to it.

Refer to DatabaseContext.recordUpdateForObject() and DatabaseOperation for a more complete discussion on this topic.

Paremeters:

anObject -- the object that needs to be notified of some changes.

aDictionary -- dictionary key/values corresponding to changes

See also: objectStoreForObject(),
CooperatingObjectStore.recordUpdateForObject()

initializeObject(self, anObject, aGlobalID, anEditingContext)

See ObjectStore for details
Overrides:
Modeling.ObjectStore.ObjectStore.initializeObject

invalidateAllObjects(self)

See ObjectStore for details
Overrides:
Modeling.ObjectStore.ObjectStore.invalidateAllObjects

invalidateObjectsWithGlobalIDs(self, globalIDs)

See ObjectStore
Overrides:
Modeling.ObjectStore.ObjectStore.invalidateObjectsWithGlobalIDs

lock(self)

Acquire the lock for the ObjectStoreCoordinator. Calls to 'lock()' should be balanced with the same number of 'unlock()' for the lock to be released.

You normally do not need to call this method directly.

See also: unlock()

objectsCountWithFetchSpecification(self, aFetchSpecification, anEditingContext)

Forwards the message to the appropriate CooperatingObjectStore, usually a DatabaseContext.

Returns the approximate number of objects that would be returned by objectsWithFetchSpecification() if called with the very same parameters.

About ``approximate'': the number returned is in fact the upper bound ; as the objects are not actually fetched against the database, it is not possible to determine whether some have already been deleted within anEditingContext (in which case objectsWithFetchSpecification() would not return them --see its documentation as well).

Parameters:

aFetchSpecification -- a FetchSpecification object describing the
objects to be fetched
anEditingContext -- the EditingContext in which the objects would be
fetched. This is in fact an optional argument: since no objects are fetched it is not really needed.
Overrides:
Modeling.ObjectStore.ObjectStore.objectsCountWithFetchSpecification

objectsForSourceGlobalID(self, aGlobalID, aRelationshipName, anEditingContext)

See ObjectStore for details
Overrides:
Modeling.ObjectStore.ObjectStore.objectsForSourceGlobalID

objectStoreForEntityName(self, entityName)

Iterates on objectStores and returns the first one who answers positively to message 'ownsEntityName'

Posts 'CooperatingObjectStoreNeeded' in case no store can be found at first glance, so that listeners get a chance to register an adequate 'CooperatingObjectStore' ; then the requested 'ObjectStore' is returned, or 'None' if it still cannot be found.

objectStoreForFetchSpecification(self, aFetchSpecification)

Iterates on objectStores and returns the first one who answers positively to message 'handlesFetchSpecification'.

Posts 'CooperatingObjectStoreNeeded' in case no store can be found at first glance, so that listeners get a chance to register an adequate 'CooperatingObjectStore' ; then the requested 'ObjectStore' is returned, or 'None' if it still cannot be found.

objectStoreForGlobalID(self, aGlobalID)

Iterates on objectStores and returns the first one who answers positively to message 'ownsGlobalID'

Posts 'CooperatingObjectStoreNeeded' in case no store can be found at first glance, so that listeners get a chance to register an adequate 'CooperatingObjectStore' ; then the requested 'ObjectStore' is returned, or 'None' if it still cannot be found.

objectStoreForObject(self, anObject)

Iterates on objectStores and returns the first one who answers positively to message 'ownsObject'

Posts 'CooperatingObjectStoreNeeded' in case no store can be found at first glance, so that listeners get a chance to register an adequate 'CooperatingObjectStore' ; then the requested 'ObjectStore' is returned, or 'None' if it still cannot be found.

objectsWithFetchSpecification(self, aFetchSpecification, anEditingContext)

See ObjectStore for details
Overrides:
Modeling.ObjectStore.ObjectStore.objectsWithFetchSpecification

ownsObject(self, anObject)

Tells whether the ObjectStore can handle the supplied object. ObjectStoreCoordinator determines this by searching a matching CooperatingObjectStore for that object. If such a CooperatingObjectStore is found, returns true (1), else return false (0).

Note: this method directly triggers objectStoreForObject() --refer to its doc. for more info. on its side-effect.

See also: objectStoreForObject()

Overrides:
Modeling.ObjectStore.ObjectStore.ownsObject

refaultObject(self, anObject, aGlobalID, anEditingContext)

See ObjectStore for details
Overrides:
Modeling.ObjectStore.ObjectStore.refaultObject

removeCooperatingObjectStore(self, aStore)

Removes a cooperating object store

Posts CooperatingObjectStoreWasRemoved

See also: addCooperatingObjectStore

rootObjectStore(self)

Returns 'self', since an 'ObjectStoreCoordinator' object is designed to be the root of an ObjectStore hierarchy.

See also: interface 'ObjectStore' for details

Overrides:
Modeling.ObjectStore.ObjectStore.rootObjectStore

saveChangesInEditingContext(self, anEditingContext)

See ObjectStore for details

unlock(self)

Releases the lock for the ObjectStoreCoordinator.

See also: lock()


Generated by Epydoc 2.1 on Sat Mar 4 13:36:26 2006 http://epydoc.sf.net