net.wotonomy.control
Class AbstractObjectStore

java.lang.Object
  extended by net.wotonomy.control.EOObjectStore
      extended by net.wotonomy.control.AbstractObjectStore

public abstract class AbstractObjectStore
extends EOObjectStore

An abstract implementation of object store that implements common functionality. Subclasses must implement data object creation, initialization, and refault logic, as well as logic to commit an editing context.


Field Summary
 
Fields inherited from class net.wotonomy.control.EOObjectStore
DeletedKey, InsertedKey, InvalidatedAllObjectsInStoreNotification, InvalidatedKey, ObjectsChangedInStoreNotification, UpdatedKey
 
Constructor Summary
AbstractObjectStore()
          Constructs a new instance of this object store.
 
Method Summary
 net.wotonomy.foundation.NSArray arrayFaultWithSourceGlobalID(EOGlobalID aGlobalID, java.lang.String aRelationship, EOEditingContext aContext)
          This implementation returns an appropriately configured array fault.
protected abstract  java.util.Collection changedKeysForObject(java.lang.Object anObject)
          Returns the keys that have changed on the specified object.
protected  java.lang.Object createInstanceWithEditingContext(EOGlobalID aGlobalID, EOEditingContext aContext)
          Creates a new instance of an object that corresponds to the specified global id and is registered in the specified context.
protected abstract  java.lang.Object deleteObject(EOGlobalID aGlobalID)
          Returns the data for the row corresponding to the specified id.
protected abstract  java.lang.String entityForGlobalIDOrObject(EOGlobalID aGlobalID, java.lang.Object anObject)
          Returns the entity that corresponds to the specified global id and/or object.
 java.lang.Object faultForGlobalID(EOGlobalID aGlobalID, EOEditingContext aContext)
          This implementation returns the actual object for the specified id.
 java.lang.Object faultForRawRow(java.util.Map aDictionary, java.lang.String anEntityName, EOEditingContext aContext)
          Returns a fault representing an object of the specified entity type with values from the specified dictionary.
protected  java.util.Map getUpdateMap(EOEditingContext aContext, java.lang.Object anObject)
          This method returns a map containing just the keys that are modified for a given object, converting any to-one or to-many relationships to id references.
protected abstract  EOGlobalID globalIDForData(java.util.Map aDataMap)
          Extracts the global id for the fetched data or snapshot.
 void initializeObject(java.lang.Object anObject, EOGlobalID aGlobalID, EOEditingContext aContext)
          Given a newly instantiated object, this method initializes its properties to values appropriate for the specified id.
protected abstract  java.util.Map insertObject(EOGlobalID aGlobalID, java.util.Map aDataMap)
          Returns the data for the row corresponding to the specified id.
protected  void invalidateAllCache()
          Dumps all snapshots.
 void invalidateAllObjects()
          Remove all values from all objects in memory, turning them into faults, and posts a notification that all objects have been invalidated.
protected  void invalidateObject(EOGlobalID aGlobalID)
          Dumps the snapshot corresponding to the specified id.
 void invalidateObjectsWithGlobalIDs(java.util.List aList)
          Removes values with the specified ids from memory, turning them into faults, and posts a notification that those objects have been invalidated.
 boolean isObjectLockedWithGlobalID(EOGlobalID aGlobalID, EOEditingContext aContext)
          Returns false because locking is not currently permitted.
 void lockObjectWithGlobalID(EOGlobalID aGlobalID, EOEditingContext aContext)
          Does nothing because locking is not currently permitted.
 net.wotonomy.foundation.NSArray objectsForSourceGlobalID(EOGlobalID aGlobalID, java.lang.String aRelationship, EOEditingContext aContext)
          Returns a List of objects associated with the object with the specified id for the specified property relationship.
 net.wotonomy.foundation.NSArray objectsWithFetchSpecification(EOFetchSpecification aFetchSpec, EOEditingContext aContext)
          Returns a List of objects the meet the criteria of the supplied specification.
protected  java.lang.Object processInsert(EOEditingContext aContext, java.lang.Object object)
           
protected  java.util.Map readFromCache(EOGlobalID aGlobalID, java.util.Collection keys)
          Reads the local data snapshot for the specified id.
protected abstract  java.util.Map readObject(EOGlobalID aGlobalID, java.util.Collection keys)
          Returns the data for the row corresponding to the specified id containing at least the specified keys.
 void refaultObject(java.lang.Object anObject, EOGlobalID aGlobalID, EOEditingContext aContext)
          Removes all values from the specified object, converting it into a fault for the specified id.
 void saveChangesInEditingContext(EOEditingContext aContext)
          Writes all changes in the specified editing context to the respository.
protected abstract  java.lang.Comparable timestampForData(java.util.Map aDataMap)
          Returns a comparable object (typically a Date or Long) for the given data map or snapshot.
protected abstract  java.lang.Object updateObject(EOGlobalID aGlobalID, java.util.Map aDataMap)
          Returns the data for the row corresponding to the specified id.
 
Methods inherited from class net.wotonomy.control.EOObjectStore
editingContextDidForgetObjectWithGlobalID
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractObjectStore

public AbstractObjectStore()
Constructs a new instance of this object store.

Method Detail

arrayFaultWithSourceGlobalID

public net.wotonomy.foundation.NSArray arrayFaultWithSourceGlobalID(EOGlobalID aGlobalID,
                                                                    java.lang.String aRelationship,
                                                                    EOEditingContext aContext)
This implementation returns an appropriately configured array fault.

Specified by:
arrayFaultWithSourceGlobalID in class EOObjectStore

faultForGlobalID

public java.lang.Object faultForGlobalID(EOGlobalID aGlobalID,
                                         EOEditingContext aContext)
This implementation returns the actual object for the specified id.

Specified by:
faultForGlobalID in class EOObjectStore

faultForRawRow

public java.lang.Object faultForRawRow(java.util.Map aDictionary,
                                       java.lang.String anEntityName,
                                       EOEditingContext aContext)
Returns a fault representing an object of the specified entity type with values from the specified dictionary. The fault should belong to the specified editing context. NOTE: Faults are not supported yet.

Specified by:
faultForRawRow in class EOObjectStore

initializeObject

public void initializeObject(java.lang.Object anObject,
                             EOGlobalID aGlobalID,
                             EOEditingContext aContext)
Given a newly instantiated object, this method initializes its properties to values appropriate for the specified id. The object should belong to the specified editing context. This method is called to populate faults.

Specified by:
initializeObject in class EOObjectStore

readFromCache

protected java.util.Map readFromCache(EOGlobalID aGlobalID,
                                      java.util.Collection keys)
Reads the local data snapshot for the specified id. If no snapshot exists, a new snapshot is created. If the specified keys are not in the snapshot, new data is fetched into the snapshot. If null is specified, all known keys are returned. Will not return null. Result will have values for those keys and only those keys requested. Missing keys indicate an error occurred.


timestampForData

protected abstract java.lang.Comparable timestampForData(java.util.Map aDataMap)
Returns a comparable object (typically a Date or Long) for the given data map or snapshot. This is used to determine whether a local snapshot should be dumped in favor of fetched data from the server. Returns null if no timestamp can be determined, in which case the fetched data will assumed to be more recent than any local snapshot.


globalIDForData

protected abstract EOGlobalID globalIDForData(java.util.Map aDataMap)
Extracts the global id for the fetched data or snapshot. Some entities have multi-attribute keys that would be assembled into a single instance of EOGlobalID.


entityForGlobalIDOrObject

protected abstract java.lang.String entityForGlobalIDOrObject(EOGlobalID aGlobalID,
                                                              java.lang.Object anObject)
Returns the entity that corresponds to the specified global id and/or object. Either may be null, but both will not be null. //FIXME: This is less than elegant.


changedKeysForObject

protected abstract java.util.Collection changedKeysForObject(java.lang.Object anObject)
Returns the keys that have changed on the specified object. If null, all keys are presumed changed, including relationships.


readObject

protected abstract java.util.Map readObject(EOGlobalID aGlobalID,
                                            java.util.Collection keys)
Returns the data for the row corresponding to the specified id containing at least the specified keys. Implementations are allowed to return more data than requested, and callers are advised to take advantage of the returned data.


insertObject

protected abstract java.util.Map insertObject(EOGlobalID aGlobalID,
                                              java.util.Map aDataMap)
Returns the data for the row corresponding to the specified id. //TODO: Need a better return value? How to return invalidated list?


updateObject

protected abstract java.lang.Object updateObject(EOGlobalID aGlobalID,
                                                 java.util.Map aDataMap)
Returns the data for the row corresponding to the specified id. //TODO: Need a better return value? How to return invalidated list?


deleteObject

protected abstract java.lang.Object deleteObject(EOGlobalID aGlobalID)
Returns the data for the row corresponding to the specified id. //TODO: Need a better return value? How to return invalidated list?


createInstanceWithEditingContext

protected java.lang.Object createInstanceWithEditingContext(EOGlobalID aGlobalID,
                                                            EOEditingContext aContext)
Creates a new instance of an object that corresponds to the specified global id and is registered in the specified context. This implementation extracts the entity type from getEntityForGlobaID and construct a new instance from the class description that corresponds to the entity type. Override to change this behavior.


invalidateObject

protected void invalidateObject(EOGlobalID aGlobalID)
Dumps the snapshot corresponding to the specified id.


invalidateAllCache

protected void invalidateAllCache()
Dumps all snapshots.


invalidateAllObjects

public void invalidateAllObjects()
Remove all values from all objects in memory, turning them into faults, and posts a notification that all objects have been invalidated.

Specified by:
invalidateAllObjects in class EOObjectStore

invalidateObjectsWithGlobalIDs

public void invalidateObjectsWithGlobalIDs(java.util.List aList)
Removes values with the specified ids from memory, turning them into faults, and posts a notification that those objects have been invalidated.

Specified by:
invalidateObjectsWithGlobalIDs in class EOObjectStore

isObjectLockedWithGlobalID

public boolean isObjectLockedWithGlobalID(EOGlobalID aGlobalID,
                                          EOEditingContext aContext)
Returns false because locking is not currently permitted.

Specified by:
isObjectLockedWithGlobalID in class EOObjectStore

lockObjectWithGlobalID

public void lockObjectWithGlobalID(EOGlobalID aGlobalID,
                                   EOEditingContext aContext)
Does nothing because locking is not currently permitted.

Specified by:
lockObjectWithGlobalID in class EOObjectStore

objectsForSourceGlobalID

public net.wotonomy.foundation.NSArray objectsForSourceGlobalID(EOGlobalID aGlobalID,
                                                                java.lang.String aRelationship,
                                                                EOEditingContext aContext)
Returns a List of objects associated with the object with the specified id for the specified property relationship. This method may not return an array fault because array faults call this method to fetch on demand. All objects must be registered the specified editing context. The specified relationship key must produce a result of type Collection for the source object or an exception is thrown.

Specified by:
objectsForSourceGlobalID in class EOObjectStore

objectsWithFetchSpecification

public net.wotonomy.foundation.NSArray objectsWithFetchSpecification(EOFetchSpecification aFetchSpec,
                                                                     EOEditingContext aContext)
Returns a List of objects the meet the criteria of the supplied specification. Faults are not allowed in the array. Each object is registered with the specified editing context. If any object is already fetched in the specified context, it is not refetched and that object should be used in the array.

Specified by:
objectsWithFetchSpecification in class EOObjectStore

refaultObject

public void refaultObject(java.lang.Object anObject,
                          EOGlobalID aGlobalID,
                          EOEditingContext aContext)
Removes all values from the specified object, converting it into a fault for the specified id. New or deleted objects should not be refaulted.

Specified by:
refaultObject in class EOObjectStore

saveChangesInEditingContext

public void saveChangesInEditingContext(EOEditingContext aContext)
Writes all changes in the specified editing context to the respository.

Specified by:
saveChangesInEditingContext in class EOObjectStore

processInsert

protected java.lang.Object processInsert(EOEditingContext aContext,
                                         java.lang.Object object)

getUpdateMap

protected java.util.Map getUpdateMap(EOEditingContext aContext,
                                     java.lang.Object anObject)
This method returns a map containing just the keys that are modified for a given object, converting any to-one or to-many relationships to id references.



Copyright © 2006 null. All Rights Reserved.