Documentation Archive Developer
Search
PATH  WebObjects 4.0 Documentation > EOControl Reference



EOObjectStore

Inherits From:
NSObject

Conforms To: NSObject (NSObject)

Declared in: EOControl/EOObjectStore.h

EOObjectStore is the abstract class that defines the API for an "intelligent" repository of objects, the control layer's object storage abstraction. An object store is responsible for constructing and registering objects, servicing object faults, and saving changes made to objects. For more information on the object storage abstraction, see "Object Storage Abstraction" in the introduction to the EOControl Framework.

EOEditingContext is the principal EOObjectStore subclass and is used for managing objects in memory-in fact, the primary purpose of the EOObjectStore class is to define an API for servicing editing contexts, not to define a completely general API. Other subclasses of EOObjectStore are:

A subclass of EOObjectStore must implement all of its methods. The default implementations simply raise exceptions.

Initializing objects
- initializeObject:withGlobalID:editingContext:
Getting objects
- objectsWithFetchSpecification:editingContext:
- objectsForSourceGlobalID:relationshipName:editingContext:
Getting faults
- faultForGlobalID:editingContext:
- arrayFaultWithSourceGlobalID:relationshipName:editingContext:
- refaultObject:withGlobalID:editingContext:
- faultForRawRow:entityNamed:editingContext:
Locking objects
- lockObjectWithGlobalID:editingContext:
- isObjectLockedWithGlobalID:editingContext:
Saving changes to objects
- saveChangesInEditingContext:
Invalidating objects
- invalidateAllObjects
- invalidateObjectsWithGlobalIDs:


arrayFaultWithSourceGlobalID:relationshipName:editingContext:

- (NSArray *)arrayFaultWithSourceGlobalID: (EOGlobalID *)globalID
relationshipName: (NSString *)relationshipName
editingContext: (EOEditingContext *)anEditingContext

Implemented by subclasses to return the destination objects for a to-many relationship, whether as real instances or as faults (EOFault objects). globalID identifies the source object for the relationship (which doesn't necessarily exist in memory yet), and relationshipName is the name of the relationship. The object identified by globalID and the destination objects for the relationship all belong to anEditingContext.

If you implement this method to return a fault, you must define an EOFaultHandler subclass that stores globalID and relationshipName, using them to fetch the objects in a later objectsForSourceGlobalID:relationshipName:editingContext: message and that turns the fault into an array containing those objects. See the EOFaultHandler and EOFault class specifications for more information on faults.

See the EOEditingContext and EODatabaseContext (EOAccess) class specifications for more information on how this method works in concrete subclasses.

See also: - faultForGlobalID:editingContext:


faultForGlobalID:editingContext:

- (id)faultForGlobalID: (EOGlobalID *)globalID
editingContext: (EOEditingContext *)anEditingContext

If the receiver is anEditingContext and the object associated with globalID is already registered in anEditingContext, this method returns that object. Otherwise it creates a to-one fault, registers it in anEditingContext, and returns the fault. This method is always directed first at anEditingContext, which forwards the message to its parent object store if needed to create a fault.

If you implement this method to return a fault (an EOFault object), you must define an EOFaultHandler subclass that stores globalID, uses it to fetch the object and turn the EOFault into that object, and initializes the object with EOObjectStore's initializeObject:withGlobalID:editingContext: . See the EOFaultHandler and EOFault class specifications for more information on faults.

See the EOEditingContext and EODatabaseContext (EOAccess) class specifications for more information on how this method works in concrete subclasses.

See also: - arrayFaultWithSourceGlobalID:relationshipName:editingContext: , - recordObject: globalID: (EOEditingContext)


faultForRawRow:entityNamed:editingContext:

- (id)faultForRawRow: (id)row
entityNamed: (NSString *)entityName
editingContext: (EOEditingContext *)anEditingContext

Returns a fault for the enterprise object corresponding to row, which is a dictionary of values containing at least the primary key of the corresponding enterprise object. This is especially useful if you have fetched raw rows and now want a unique enterprise object.


initializeObject:withGlobalID:editingContext:

- (void)initializeObject: (id)anObject
withGlobalID: (EOGlobalID *)globalID
editingContext: (EOEditingContext *)anEditingContext

Implemented by subclasses to set anObject's properties, as obtained for globalID. This method is typically invoked after anObject has been created using EOClassDescription's createInstanceWithEditingContext:globalID:zone: or using NSObject's initWithEditingContext:classDescription:globalID: . This method is also invoked after a fault has been fired.

See also: - initWithEditingContext:classDescription:globalID: (NSObject Additions), - awakeFromInsertionInEditingContext: (NSObject Additions), - awakeFromFetchInEditingContext: (NSObject Additions)


invalidateAllObjects

- (void)invalidateAllObjects

Discards the values of all objects held by the receiver and turns them into faults (EOFault objects). This causes all locks to be dropped and any transaction to be rolled back. The next time any object is accessed, its data is fetched anew. Any child object stores are also notified that the objects are no longer valid. See the EOEditingContext class specification for more information on how this method works in concrete subclasses.

This method should also post an EOInvalidatedAllObjectsInStoreNotification.

See also: - invalidateObjectsWithGlobalIDs: , - refaultObject:withGlobalID:editingContext:


invalidateObjectsWithGlobalIDs:

- (void)invalidateObjectsWithGlobalIDs: (NSArray *)globalIDs

Signals that the objects identified by the EOGlobalIDs in globalIDs should no longer be considered valid and that they should be turned into faults (EOFault objects). This causes data for each object to be refetched the next time it's accessed. Any child object stores are also notified that the objects are no longer valid.

See also: - invalidateAllObjects , - refaultObject:withGlobalID:editingContext:


isObjectLockedWithGlobalID:editingContext:

- (BOOL)isObjectLockedWithGlobalID: (EOGlobalID *)globalID
editingContext: (EOEditingContext *)anEditingContext

Returns YES if the object identified by globalID is locked, NO if it isn't. See the EODatabaseContext (EOAccess) class specification for more information on how this method works in concrete subclasses.


lockObjectWithGlobalID:editingContext:

- (void)lockObjectWithGlobalID: (EOGlobalID *)globalID
editingContext: (EOEditingContext *)anEditingContext

Locks the object identified by globalID. See the EODatabaseContext (EOAccess) class specification for more information on how this method works in concrete subclasses.


objectsForSourceGlobalID:relationshipName:editingContext:

- (NSArray *)objectsForSourceGlobalID: (EOGlobalID *)globalID
relationshipName: (NSString *)relationshipName
editingContext: (EOEditingContext *)anEditingContext

Returns the destination objects for a to-many relationship. This method is used by an array fault previously constructed using arrayFaultWithSourceGlobalID:relationshipName:editingContext: . globalID identifies the source object for the relationship (which doesn't necessarily exist in memory yet), and relationshipName is the name of the relationship. The object identified by globalID and the destination objects for the relationship all belong to anEditingContext.

See the EOEditingContext and EODatabaseContext (EOAccess) class specifications for more information on how this method works in concrete subclasses.


objectsWithFetchSpecification:editingContext:

- (NSArray *)objectsWithFetchSpecification: (EOFetchSpecification *)aFetchSpecification
editingContext: (EOEditingContext *)anEditingContext

Fetches objects from an external store according to the criteria specified by fetchSpecification and returns them in an array for inclusion in anEditingContext. If one of these objects is already present in memory, this method doesn't overwrite its values with the new values from the database. Raises an exception if an error occurs.

See the EOEditingContext and EODatabaseContext (EOAccess) class specifications for more information on how this method works in concrete subclasses.


refaultObject:withGlobalID:editingContext:

- (void)refaultObject: (id)anObject
withGlobalID: (EOGlobalID *)globalID
editingContext: (EOEditingContext *)anEditingContext

Turns anObject into a fault (an EOFault), identified by globalID in anEditingContext. Objects that have been inserted but not saved, or that have been deleted, shouldn't be refaulted. When using the Yellow Box, use this method with caution since refaulting an object doesn't remove the object snapshot from the undo stack.


saveChangesInEditingContext:

- (void)saveChangesInEditingContext: (EOEditingContext *)anEditingContext

Saves any changes in anEditingContext to the receiver's repository. Sends insertedObjects , deletedObjects , and updatedObjects messages to anEditingContext and applies the changes to the receiver's data repository as appropriate. For example, EODatabaseContext (EOAccess) implements this method to send operations to an EOAdaptor (EOAccess) for making the changes in a database.

Notification


EOInvalidatedAllObjectsInStoreNotification

Posted whenever an EOObjectStore receives an invalidateAllObjects message. The notification contains:

Notification Object The EOObjectStore that received the invalidateAllObjects message.
Userinfo None


EOObjectsChangedInStoreNotification

Posted whenever an EOObjectStore observes changes to its objects. The notification contains:

Notification Object The EOObjectStore that observed the change.
Userinfo
Key Value
updated An NSArray of EOGlobalIDs for objects whose properties have changed. A receiving EOEditingContext typically responds by refaulting its corresponding objects.
inserted An NSArray of EOGlobalIDs for objects that have been inserted into the EOObjectStore.
deleted An NSArray of EOGlobalIDs for objects that have been deleted from the EOObjectStore.
invalidated An NSArray of EOGlobalIDs for objects that have been turned into faults.





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