PATH  WebObjects 4.0 Documentation > EOControl Reference



EOEditingContext

Inherits From:
EOObjectStore : Object (Java Client)
EOObjectStore : NSObject (Yellow Box)

Implements:
EOObserving
NSLocking (Yellow Box only)

Package:
com.apple.client.eocontrol (Java Client)
com.apple.yellow.eocontrol (Yellow Box)


Class At a Glance:


Purpose

An EOEditingContext object manages a graph of enterprise objects in an application; this object graph represents an internally consistent view of one or more external stores (most often a database).

Principal Attributes
The set of enterprise objects managed by the EOEditingContext
The EOEditingContext's parent EOObjectStore
The set of EOEditor objects messaged by the EOEditingContext
The EOEditingContext's EOMessageHandler


Commonly Used Methods
- objectsWithFetchSpecification Fetches objects from an external store.
- insertObject Registers a new object to be inserted into the parent EOObjectStore when changes are saved.
- deleteObject Registers that an object should be removed from the parent EOObjectStore when changes are saved.
- lockObject Attempts to lock an object in the external store.
- hasChanges Returns true if any of the receiver has any pending changes to the parent EOObjectStore.
- saveChanges Commits changes made in the receiver to the parent EOObjectStore.
- revert Removes everything from the undo stack, discards all insertions and deletions, and restores updated objects to their original values.
- objectForGlobalID Given a globalID, returns its associated object.
- globalIDForObject Given an object, returns its globalID.
- setDelegate Sets the receiver's delegate.
- parentObjectStore Returns the receiver's parent EOObjectStore.
- rootObjectStore Returns the receiver's root EOObjectStore.

Class Description

An EOEditingContext object represents a single "object space" or document in an application. Its primary responsibility is managing a graph of enterprise objects. This object graph is a group of related business objects that represent an internally consistent view of one or more external stores (usually a database).

All objects fetched from an external store are registered in an editing context along with a global identifier (EOGlobalID) that's used to uniquely identify each object to the external store. The editing context is responsible for watching for changes in its objects (using the EOObserving interface) and recording snapshots for object-based undo. A single enterprise object instance exists in one and only one editing context, but multiple copies of an object can exist in different editing contexts. Thus object uniquing is scoped to a particular editing context.

For more information on EOEditingContext, see the sections:

Constants

The following string constants name notifications EOEditingContext posts:

See the Notifications section for more information on the notifications.

The following string constants are the keys to the ObjectsChangedInEditingContextNotification's user info dictionary:

EditingContextFlushChangesRunLoopOrdering, is an integer that defines the order in which the editing context performs end of event processing in processRecentChanges . Messages with lower order numbers are processed before messages with higher order numbers. In an application built with the Application Kit, the constant order value schedules the editing context to perform its processing before the undo stack group is closed or window display is updated.

Interfaces Implemented

EOObserving
- objectWillChange

Method Types

Constructors
EOEditingContext
Controlling EOEditingContext's memory management strategy
Fetching objects
- objectsWithFetchSpecification
Committing or discarding changes
- saveChanges
- refaultObjects
- refetch
- revert (Yellow Box only)
- invalidateAllObjects
Registering changes
- deleteObject
- insertObject
- insertObjectWithGlobalID
- objectWillChange
- processRecentChanges
Checking changes
- deletedObjects
- insertedObjects
- updatedObjects
- hasChanges
Object registration and snapshotting
- forgetObject
- recordObject
- committedSnapshotForObject
- currentEventSnapshotForObject
- objectForGlobalID
- globalIDForObject
- registeredObjects
Locking objects
- lockObject
- lockObjectWithGlobalID
- isObjectLockedWithGlobalID
- setLocksObjectsBeforeFirstModification
- locksObjectsBeforeFirstModification
Undoing operations (Yellow Box only)
- redo (Yellow Box only)
- undo (Yellow Box only)
- setUndoManager (Yellow Box only)
- undoManager (Yellow Box only)
Deletion and Validation Behavior
- setPropagatesDeletesAtEndOfEvent
- propagatesDeletesAtEndOfEvent
- setStopsValidationAfterFirstError
- stopsValidationAfterFirstError
Returning related object stores
- parentObjectStore
- rootObjectStore
Managing editors
- editors
- addEditor
- removeEditor
Setting the delegate
- setDelegate
- delegate
Setting the message handler
- setMessageHandler
- messageHandler
Invalidating objects (Yellow Box only)
- setInvalidatesObjectsWhenFreed (Yellow Box only)
- invalidatesObjectsWhenFreed (Yellow Box only)
Interacting with the server (Java Client only)
- invokeRemoteMethod (Java Client only)
Locking (Yellow Box only)
- lock (Yellow Box only)
- unlock (Yellow Box only)
Working with raw rows (Yellow Box only)
- faultForRawRow (Yellow Box only)
Unarchiving from nib
+ defaultParentObjectStore
+ setDefaultParentObjectStore
+ setSubstitutionEditingContext
+ substitutionEditingContext
Nested EOEditingContext support
- objectsWithFetchSpecification
- objectsForSourceGlobalID
- arrayFaultWithSourceGlobalID
- faultForGlobalID
- saveChangesInEditingContext
- refaultObject
- invalidateObjectsWithGlobalIDs
- initializeObject
Archiving and unarchiving objects (Yellow Box only)
+ encodeObjectWithCoder (Yellow Box only)
+ initObjectWithCoder (Yellow Box only)
+ setUsesContextRelativeEncoding (Yellow Box only)
+ usesContextRelativeEncoding (Yellow Box only)

Constructors


EOEditingContext

public EOEditingContext ()

Creates a new EOEditingContext object with the default parent object store as its parent object store.

public EOEditingContext (EOObjectStore anObjectStore)

Creates a new EOEditingContext object with anObjectStore as its parent object store. For more discussion of parent object stores, see "Other Classes that Participate in Object Graph Management" in the class description.

See also: - parentObjectStore , + defaultParentObjectStore

Static Methods


defaultParentObjectStore

public static EOObjectStore defaultParentObjectStore ()

Returns the EOObjectStore that is the default parent object store for new editing contexts. Normally this is the EOObjectStoreCoordinator returned from the EOObjectStoreCoordinator static method defaultCoordinator .

See also: + setDefaultParentObjectStore


encodeObjectWithCoder

public static void encodeObjectWithCoder (
java.lang.Object object,
NSCoder encoder)

This method is available for Yellow Box applications only; there is no Java Client equivalent.

Invoked by an enterprise object object to ask the EOEditingContext to encode object using encoder. For more discussion of this subject, see "Using EOEditingContext to Archive Custom Objects in Web Objects Framework" in the class description.

See also: + initObjectWithCoder , + setUsesContextRelativeEncoding , + usesContextRelativeEncoding


initObjectWithCoder

public static java.lang.Object initObjectWithCoder (
java.lang.Object object,
NSCoder decoder)

This method is available for Yellow Box applications only; there is no Java Client equivalent.

Invoked by an enterprise object object to ask the EOEditingContext to initialize object from data in decoder. For more discussion of this subject, see "Using EOEditingContext to Archive Custom Objects in Web Objects Framework" in the class description.

See also: + encodeObjectWithCoder , + setUsesContextRelativeEncoding , + usesContextRelativeEncoding


setDefaultParentObjectStore

public static void setDefaultParentObjectStore (EOObjectStore store)

Sets the default parent EOObjectStore to store. You use this method before loading a nib file to change the default parent EOObjectStores of the EOEditingContexts in the nib file. The object you supply for store can be a different EOObjectStoreCoordinator or another EOEditingContext (if you're using a nested EOEditingContext). After loading a nib with an EOEditingContext substituted as the default parent EOObjectStore, you should restore the default behavior by setting the default parent EOObjectStore to null.

A default parent object store is global until it is changed again. For more discussion of this topic, see the chapter "Application Configurations" in the Enterprise Objects Framework Developer's Guide.

See also: + defaultParentObjectStore


setSubstitutionEditingContext

public static void setSubstitutionEditingContext (EOEditingContext anEditingContext)

Assigns anEditingContext as the EOEditingContext to substitute for the one specified in a nib file you're about to load. Using this method causes all of the connections in your nib file to be redirected to anEditingContext. This can be useful when you want an interface loaded from a second nib file to use an existing EOEditingContext. After loading a nib with a substitution EOEditingContext, you should restore the default behavior by setting the substitution EOEditingContext to null.

A substitution editing context is global until it is changed again. For more discussion of this topic, see the chapter "Application Configurations" in the Enterprise Objects Framework Developer's Guide.

See also: + substitutionEditingContext


setUsesContextRelativeEncoding

public static void setUsesContextRelativeEncoding (boolean flag)

This method is available for Yellow Box applications only; there is no Java Client equivalent.

Sets according to flag whether encodeObjectWithCoder uses context-relative encoding. For more discussion of this subject, see "Using EOEditingContext to Archive Custom Objects in Web Objects Framework" in the class description.

See also: + usesContextRelativeEncoding , + encodeObjectWithCoder ,


substitutionEditingContext

public static EOEditingContext substitutionEditingContext ()

Returns the substitution EOEditingContext if one has been specified. Otherwise returns null.

See also: + setSubstitutionEditingContext


usesContextRelativeEncoding

public static boolean usesContextRelativeEncoding ()

This method is available for Yellow Box applications only; there is no Java Client equivalent.

Returns true to indicate that encodeObjectWithCoder uses context relative encoding, false otherwise. For more discussion of this subject, see "Using EOEditingContext to Archive Custom Objects in Web Objects Framework" in the class description.

See also: + setUsesContextRelativeEncoding

Instance Methods


addEditor

public void addEditor (java.lang.Object editor)

Adds editor to the receiver's set of EOEditingContext.Editor. For more explanation, see the method description for editors and the EOEditingContext.Editor interface specification.

See also: - removeEditor


arrayFaultWithSourceGlobalID

public NSArray arrayFaultWithSourceGlobalID (
EOGlobalID globalID,
java.lang.String name,
EOEditingContext anEditingContext)

Overrides the implementation inherited from EOObjectStore. If the objects associated with the EOGlobalID globalID are already registered in the receiver, returns those objects. Otherwise, propagates the message down the object store hierarchy, through the parent object store, ultimately to the associated EODatabaseContext. The EODatabaseContext creates and returns a to-many fault.

When a parent EOEditingContext receives this on behalf of a child EOEditingContext and the EOGlobalID globalID identifies a newly inserted object in the parent, the parent returns a copy of its object's relationship array with the member objects translated into objects in the child EOEditingContext.

For more information on faults, see the EOObjectStore, EODatabaseContext (EOAccess), and EOFaultHandler class specifications.

See also: - faultForGlobalID


committedSnapshotForObject

public NSDictionary committedSnapshotForObject (EOEnterpriseObject object)

This method is only available in Yellow Box; there is no Java Client equivalent.

Returns a dictionary containing a snapshot of object that reflects its committed values (that is, its values as they were last committed to the database). In other words, this snapshot represents the state of the object before any modifications were made to it. The snapshot is updated to the newest object state after a save.

See also: - currentEventSnapshotForObject


currentEventSnapshotForObject

public NSDictionary currentEventSnapshotForObject (EOEnterpriseObject object)

This method is only available in Yellow Box; there is no Java Client equivalent.

Returns a dictionary containing a snapshot of object that reflects its state as it was at the beginning of the current event loop. After the end of the current event-upon invocation of processRecentChanges -this snapshot is updated to hold the modified state of the object.

See also: - committedSnapshotForObject , - processRecentChanges


delegate

public java.lang.Object delegate ()

Returns the receiver's delegate.

See also: - setDelegate


deleteObject

public void deleteObject (EOEnterpriseObject object)

Specifies that object should be removed from the receiver's parent EOObjectStore when changes are committed. At that time, the object will be removed from the uniquing tables.

See also: - deletedObjects


deletedObjects

public NSArray deletedObjects ()

Returns the objects that have been deleted from the receiver's object graph.

See also: - updatedObjects , - insertedObjects


editors

public NSArray editors ()

Returns the receiver's editors. Editors are special-purpose delegate objects that may contain uncommitted changes that need to be validated and applied to enterprise objects before the EOEditingContext saves changes. For example, EODisplayGroups (EOInterface) register themselves as editors with the EOEditingContext of their data sources so that they can save any changes in the key text field. For more information, see the EOEditingContext.Editor interface specification and the EODisplayGroup class specification.

See also: - addEditor , - removeEditor


faultForGlobalID

public EOEnterpriseObject faultForGlobalID (
EOGlobalID globalID,
EOEditingContext anEditingContext)

Overrides the implementation inherited from EOObjectStore. If the object associated with the EOGlobalID globalID is already registered in the receiver, this method returns that object. Otherwise, the method propagates the message down the object store hierarchy, through the parent object store, ultimately to the associated EODatabaseContext. The EODatabaseContext creates and returns a to-one fault.

For example, suppose you want the department object whose deptID has a particular value. The most efficient way to get it is to look it up by its globalID using faultForGlobalID .

If the department object is already registered in the EOEditingContext, faultForGlobalID returns the object (without going to the database). If not, a fault for this object is created, and the object is fetched only when you trigger the fault.

In a nested editing context configuration, when a parent EOEditingContext is sent faultForGlobalID on behalf of a child EOEditingContext and globalID identifies a newly inserted object in the parent, the parent registers a copy of the object in the child.

For more discussion of this method, see the section "Working with Objects Across Multiple EOEditingContexts" in the class description. For more information on faults, see the EOObjectStore, EODatabaseContext (EOAccess), and EOFaultHandler class specifications.

See also: - arrayFaultWithSourceGlobalID


faultForRawRow

public EOEnterpriseObject faultForRawRow (
java.lang.Object row,
java.lang.String entityName)

This method is available for Yellow Box applications only; there is no Java Client equivalent.

Returns a fault for the raw row row by invoking faultForRawRow with this as the editing context.


forgetObject

public void forgetObject (EOEnterpriseObject object)

Removes object from the uniquing tables and causes the receiver to remove itself as the object's observer. This method is invoked whenever an object being observed by an EOEditingContext is finalized. You should never invoke this method directly. The correct way to remove an object from its editing context is to remove every reference to the object by refaulting any object that references it (using refaultObjects or invalidateAllObjects ). Also note that this method does not have the effect of deleting an object-to delete an object you should either use the deleteObject method or remove the object from an owning relationship.


globalIDForObject

public EOGlobalID globalIDForObject (EOEnterpriseObject object)

Returns the EOGlobalID for object. All objects fetched from an external store are registered in an EOEditingContext along with a global identifier (EOGlobalID) that's used to uniquely identify each object to the external store. If object hasn't been registered in the EOEditingContext (that is, if no match is found), this method returns null. Objects are registered in an EOEditingContext using the insertObject method, or, when fetching, with recordObject .

See also: - objectForGlobalID


hasChanges

public boolean hasChanges ()

()

Returns true if any of the objects in the receiver's object graph have been modified-that is, if any objects have been inserted, deleted, or updated.


initializeObject

public void initializeObject (
EOEnterpriseObject object,
EOGlobalID globalID,
EOEditingContext anEditingContext)

Overrides the implementation inherited from EOObjectStore to build the properties for the object identified by globalID. When a parent EOEditingContext receives this on behalf of a child EOEditingContext (as represented by anEditingContext), and the globalID identifies an object instantiated in the parent, the parent returns properties extracted from its object and translated into the child's context. This ensures that a nested context "inherits" modified values from its parent EOEditingContext. If the receiver doesn't have object, the request is forwarded the receiver's parent EOObjectStore.


insertedObjects

public NSArray insertedObjects ()

Returns the objects that have been inserted into the receiver's object graph.

See also: - deletedObjects , - updatedObjects


insertObject

public void insertObject (EOEnterpriseObject object)

Registers (by invoking insertObjectWithGlobalID ) object to be inserted in the receiver's parent EOObjectStore the next time changes are saved. In the meantime, object is registered in the receiver with a temporary globalID.

See also: - insertedObjects , - deletedObjects , - insertObjectWithGlobalID


insertObjectWithGlobalID

public void insertObjectWithGlobalID (EOEnterpriseObject anEOEnterpriseObject, EOGlobalID anEOGlobalID)

Registers a new object identified by globalID that should be inserted in the parent EOObjectStore when changes are saved. Works by invoking recordObject , unless the receiver already contains the object. Sends object the message awakeFromInsertion . globalID must respond true to isTemporary . When the external store commits object, it re-records it with the appropriate permanent globalID.

It is an error to insert an object that's already registered in an editing context unless you are effectively undeleting the object by reinserting it.

See also: - insertObject


invalidateAllObjects

public void invalidateAllObjects ()

()

Overrides the implementation inherited from EOObjectStore to discard the values of objects cached in memory and refault them, which causes them to be refetched from the external store the next time they're accessed. This method sends the message invalidateObjectsWithGlobalIDs to the parent object store with the globalIDs of all of the objects cached in the receiver. When an EOEditingContext receives this message, it propagates the message down the object store hierarchy. EODatabaseContexts discard their snapshots for invalidated objects and broadcast an ObjectsChangedInStoreNotification. (EODatabaseContext is defined in EOAccess.)

The final effect of this method is to refault all objects currently in memory. The next time you access one of these objects, it's refetched from the database.

To flush the entire application's cache of all values fetched from an external store, use a statement such as the following:

EOEditingContext.rootObjectStore().invalidateAllObjects();

If you just want to discard uncommitted changes but you don't want to sacrifice the values cached in memory, use the EOEditingContext revert method (Yellow Box only), which reverses all changes and clears the undo stack. For more discussion of this topic, see the section "Methods for Managing the Object Graph" in the class description.

See also: - refetch , - invalidateObjectsWithGlobalIDs


invalidateObjectsWithGlobalIDs

public void invalidateObjectsWithGlobalIDs (NSArray globalIDs)

Overrides the implementation inherited from EOObjectStore to signal to the parent object store that the cached values for the objects identified by globalIDs should no longer be considered valid and that they should be refaulted. Invokes processRecentChanges before refaulting the objects. This message is propagated to any underlying object store, resulting in a refetch the next time the objects are accessed. Any related (child or peer) object stores are notified that the objects are no longer valid. All uncommitted changed to the objects are lost. For more discussion of this topic, see the section "Methods for Managing the Object Graph" in the class description.

See also: - invalidateAllObjects


invalidatesObjectsWhenFreed

public boolean invalidatesObjectsWhenFreed ()

()

This method is available for Yellow Box applications only; there is no Java Client equivalent.

Returns true to indicate that the receiver clears and "booby-traps" all of the objects registered with it when the receiver is finalized, false otherwise. The default is true . In this method, "invalidate" has a different meaning than it does in the other invalidate... methods. For more discussion of this topic, see the method description for setInvalidatesObjectsWhenFreed .


invokeRemoteMethod

public java.lang.Object invokeRemoteMethod (
EOEditingContext anEditingContext,
EOGlobalID globalID,
java.lang.String methodName,
java.lang.Object[] objects)

This method is available for Java Client applications only; there is no Yellow Box equivalent.

See also:


isObjectLockedWithGlobalID

public boolean isObjectLockedWithGlobalID (
EOGlobalID globalID,
EOEditingContext anEditingContext)

Returns true if the object identified by globalID in anEditingContext is locked, false otherwise. This method works by forwarding the message isObjectLockedWithGlobalID to its parent object store.

See also: - lockObject , - lockObjectWithGlobalID ,
- locksObjectsBeforeFirstModification


lock

public void lock ()

This method is available for Yellow Box applications only; there is no Java Client equivalent.

Locks access to the receiver to prevent other threads from accessing it. You should lock an editing context when you are accessing or modifying objects managed by the editing context. The thread-saftey provided by Enterprise Objects Framework allows one thread to be active in each EOEditingContext and one thread to be active in each EODatabaseContext (EOAccess). In other words, multiple threads can access and modify objects concurrently in different editing contexts, but only one thread can access the database at a time (to save, fetch, or fault).


Warning: This method creates an NSAutoreleasePool that is released when unlock is called. Consequently, objects that have been autoreleased within the scope of a lock /unlock pair may not be valid after the unlock .

See also: - unlock


lockObject

public void lockObject (EOEnterpriseObject anObject)

Attempts to lock anObject in the external store. This method works by invoking lockObjectWithGlobalID . Throws an exception if it can't find the globalID for anObject to pass to lockObjectWithGlobalID .

See also: - isObjectLockedWithGlobalID , - locksObjectsBeforeFirstModification


lockObjectWithGlobalID

public void lockObjectWithGlobalID (
EOGlobalID globalID,
EOEditingContext anEditingContext)

Overrides the implementation inherited from EOObjectStore to attempt to lock the object identified by globalID in anEditingContext in the external store. Throws an exception if unable to obtain the lock. This method works by forwarding the message lockObjectWithGlobalID to its parent object store.

See also: - lockObject , - isObjectLockedWithGlobalID , - locksObjectsBeforeFirstModification


locksObjectsBeforeFirstModification

public boolean locksObjectsBeforeFirstModification ()

()

Returns true if the receiver locks object in the external store (with lockObject ) the first time object is modified.

See also: - setLocksObjectsBeforeFirstModification , - isObjectLockedWithGlobalID , - lockObject , - lockObjectWithGlobalID


messageHandler

public java.lang.Object messageHandler ()

Returns the EOEditingContext's message handler. A message handler is a special-purpose delegate responsible for presenting errors to the user. Typically, an EODisplayGroup (EOInterface) registers itself as the message handler for its EOEditingContext. For more information, see the EOEditingContext.MessageHandler interface specification.

See also: - setMessageHandler


objectForGlobalID

public EOEnterpriseObject objectForGlobalID (EOGlobalID globalID)

Returns the object identified by globalID, or null if no object has been registered in the EOEditingContext with globalID.

See also: - globalIDForObject


objectsForSourceGlobalID

public NSArray objectsForSourceGlobalID (
EOGlobalID globalID,
java.lang.String name,
EOEditingContext anEditingContext)

Overrides the implementation inherited from EOObjectStore to service a to-many fault for a relationship named name. When a parent EOEditingContext receives a objectsForSourceGlobalID message on behalf of a child editing context and globalID matches an object instantiated in the parent, the parent returns a copy of its relationship array and translates its objects into the child editing context. This ensures that a child editing context "inherits" modified values from its parent. If the receiving editing context does not have the specified object or if the parent's relationship property is still a fault, the request is fowarded to its parent object store.


objectsWithFetchSpecification

public NSArray objectsWithFetchSpecification (EOFetchSpecification fetchSpecification)

public NSArray objectsWithFetchSpecification (
EOFetchSpecification fetchSpecification,
EOEditingContext anEditingContext)

Overrides the implementation inherited from EOObjectStore to fetch objects from an external store according to the criteria specified by fetchSpecification and return them in an array. If one of these objects is already present in memory, this method doesn't overwrite its values with the new values from the database. This method throws an exception if an error occurs; the error message indicates the nature of the problem.

When an EOEditingContext receives this message, it forwards the message to its root object store. Typically the root object store is an EOObjectStoreCoordinator with underlying EODatabaseContexts. In this case, the object store coordinator forwards the request to the appropriate database context based on the entity name in fetchSpecification. The database context then obtains an EODatabaseChannel and performs the fetch, registering all fetched objects in anEditingContext. (EODatabaseContext and EODatabaseChannel are defined in EOAccess.)


objectWillChange

public void objectWillChange (java.lang.Object object)

This method is automatically invoked when any of the objects registered in the receiver invokes its willChange method. This method is EOEditingContext's implementation of the EOObserving protocol.


parentObjectStore

public EOObjectStore parentObjectStore ()

Returns the EOObjectStore from which the receiver fetches and to which it saves objects.


processRecentChanges

public void processRecentChanges ()

()

Forces the receiver to process pending insertions, deletions, and updates. Normally, when objects are changed, the processing of the changes is deferred until the end of the current event. At that point, an EOEditingContext moves objects to the inserted, updated, and deleted lists, delete propagation is performed, undos are registered, and ObjectsChangedInStoreNotification and ObjectsChangedInEditingContextNotification are posted (In a Yellow Box application, this usually causes the user interface to update). You can use this method to explicitly force changes to be processed. An EOEditingContext automatically invokes this method on itself before performing certain operations such as saveChanges . This method does nothing on Java Client.


propagatesDeletesAtEndOfEvent

public boolean propagatesDeletesAtEndOfEvent ()

()

Returns true if the receiver propagates deletes at the end of the event in which a change was made, false if it propagates deletes only right before saving changes. The default is true .

See also: - setPropagatesDeletesAtEndOfEvent


recordObject

public void recordObject (
EOEnterpriseObject object,
EOGlobalID globalID)

Makes the receiver aware of an object identified by globalID existing in its parent object store. EOObjectStores (such as the access layer's EODatabaseContext) usually invoke this method for each object fetched. When it receives this message, the receiver enters the object in its uniquing table and registers itself as an observer of the object.


redo

public void redo ()

This method is available for Yellow Box applications only; there is no Java Client equivalent.

This method forwards a redo message to the receiver's NSUndoManager, asking it to reverse the latest undo operation applied to objects in the object graph.

See also: - undo


refault:

public void refault ()

This method is available for Yellow Box applications only; there is no Java Client equivalent.

This method simply invokes refaultObjects .


refaultObject

public void refaultObject (
EOEnterpriseObject anObject,
EOGlobalID globalID,
EOEditingContext anEditingContext)

Overrides the implementation inherited from EOObjectStore to refault the enterprise object object identified by globalID in anEditingContext. This method should be used with caution since refaulting an object does not remove the object snapshot from the undo stack. Objects that have been newly inserted or deleted should not be refaulted.

The main purpose of this method is to break reference cycles between enterprise objects. When you are using Java APIs to access Objective-C Enterprise Objects Framework classes, you have to take into consideration the way objects are deallocated on the Objective-C side of the Java Bridge. This means that you might still need to break reference cycles to help keep your application's memory in check. For example, suppose you have an Employee object that has a to-one relationship to its Department, and the Department object in turn has an array of Employee objects. You can use this method to break the reference cycle. Note that reference cycles are automatically broken if the EOEditingContext is finalized. For more discussion of this topic, see the section "Methods for Managing the Object Graph" in the class description.

See also: - invalidateObjectsWithGlobalIDs


refaultObjects

public void refaultObjects ()

()

Refaults all objects cached in the receiver that haven't been inserted, deleted, or updated. Invokes processRecentChanges , then invokes refaultObject for all objects that haven't been inserted, deleted, or updated. For more discussion of this topic, see the section "Methods for Managing the Object Graph" in the class description.


refetch

public void refetch ()

This method simply invokes the invalidateAllObjects method.


registeredObjects

public NSArray registeredObjects ()

Returns the enterprise objects managed by the receiver.


removeEditor

public void removeEditor (java.lang.Object anObject)

Unregisters editor from the receiver. For more discussion of EOEditors, see the editors method description and the EOEditingContext.Editor interface specification.

See also: - addEditor


revert

public void revert ()

()

This method is available for Yellow Box applications only; there is no Java Client equivalent.

Removes everything from the undo stack, discards all insertions and deletions, and restores updated objects to their last committed values. Does not refetch from the database. Note that revert doesn't automatically cause higher level display groups (WebObject's WODisplayGroups or the interface layer's EODisplayGroups) to refetch. Display groups that allow insertion and deletion of objects need to be explicitly synchronized whenever this method is invoked on their EOEditingContext.

See also: - invalidateAllObjects


rootObjectStore

public EOObjectStore rootObjectStore ()

Returns the EOObjectStore at the base of the object store hierarchy (usually an EOObjectStoreCoordinator).


saveChanges

public void saveChanges ()

public void saveChanges (java.lang.Object anObject) (Siva only)

()

Commits changes made in the receiver to its parent EOObjectStore by sending it the message saveChangesInEditingContext . If the parent is an EOObjectStoreCoordinator, it guides its EOCooperatingObjectStores, typically EODatabaseContexts, through a multi-pass save operation (see the EOObjectStoreCoordinator class specification for more information). If a database error occurs, an exception is thrown; the error message indicates the nature of the problem.


saveChangesInEditingContext

public void saveChangesInEditingContext (EOEditingContext anEditingContext)

Overrides the implementation inherited from EOObjectStore to tell the receiver's EOObjectStore to accept changes from a child EOEditingContext. This method shouldn't be invoked directly. It's invoked by a nested EOEditingContext when it's committing changes to a parent EOEditingContext. The receiving parent EOEditingContext incorporates all changes from the nested EOEditingContext into its own copies of the objects, but it doesn't immediately save those changes to the database. If the parent itself is later sent saveChanges , it propagates any changes received from the child along with any other changes to its parent EOObjectStore. Throws an exception if an error occurs; the error message indicates the nature of the problem.


setDelegate

public void setDelegate (java.lang.Object anObject)

Set the receiver's delegate to be anObject.

See also: - delegate


setInvalidatesObjectsWhenFreed

public void setInvalidatesObjectsWhenFreed (boolean flag)

This method is available for Yellow Box applications only; there is no Java Client equivalent.

Sets according to flag whether the receiver clears and "booby-traps" all of the objects registered with it when the receiver is finalized. If an editing context invalidates objects when it's finalized, it sends a clearProperties message to all of its objects, thereby breaking any reference cycles between objects that would prevent them from being finalized. This method leaves the objects in a state in which sending them any message throws an exception.

The default is true , and as a general rule, this setting must be true for enterprise objects with cyclic references to be finalized when their EOEditingContext is finalized.

Note that the word "invalidate" in this method name has a different meaning than it does in the other invalidate... methods, which discard object values and refault them.

When you are using Java APIs to access Objective-C Enterprise Objects Framework classes, you have to take into consideration the way objects are deallocated on the Objective-C side of the Java Bridge. This means that you might still need to break reference cycles to help keep your application' the objects usage in check.

See also: - invalidatesObjectsWhenFreed


setLocksObjectsBeforeFirstModification

public void setLocksObjectsBeforeFirstModification (boolean flag)

Sets according to flag whether the receiver locks object in the external store (with lockObject ) the first time object is modified. The default is false . If flag is true , an exception will be thrown raised if a lock can't be obtained when object invokes willChange . There are two reasons a lock might fail: because the row is already locked in the server, or because your snapshot is out of date. If your snapshot is out of date, you can explicitly refetch the object using an EOFetchSpecification with setRefreshesRefetchedObjects set to true . To handle the exception, you can implement the EODatabaseContext delegate method databaseContextShouldRaiseExceptionForLockFailure .

You should avoid using this method or pessimistic locking in an interactive end-user application. For example, a user might make a change in a text field and neglect to save it, thereby leaving the data locked in the server indefinitely. Consider using optimistic locking or application level explicit check-in/check-out instead.

See also: - locksObjectsBeforeFirstModification


setMessageHandler

public void setMessageHandler (java.lang.Object handler)

Set the receiver's message handler to be handler.

See also: - messageHandler


setPropagatesDeletesAtEndOfEvent

public void setPropagatesDeletesAtEndOfEvent (boolean flag)

This method is only available on Yellow Box; it has no effect in Java Client.

Sets according to flag whether the receiver propagates deletes at the end of the event in which a change was made, or only just before saving changes.

If flag is true , deleting an enterprise object triggers delete propagation at the end of the event in which the deletion occurred (this is the default behavior). If flag is false , delete propagation isn't performed until saveChanges is invoked.

You can delete enterprise objects explicitly by using the deleteObject method or implicitly by removing the enterprise object from an owning relationship. Delete propagation uses the delete rules in the EOClassDescription to determine whether objects related to the deleted object should also be deleted (for more information, see the EOClassDescription class specification and the EOEnterpriseObject interface specification). If delete propagation fails (that is, if an enterprise object refuses to be deleted-possibly due to a deny rule), all changes made during the event are rolled back.

See also: - propagatesDeletesAtEndOfEvent


setStopsValidationAfterFirstError

public void setStopsValidationAfterFirstError (boolean flag)

Sets according to flag whether the receiver stops validating after the first error is encountered, or continues for all objects (validation typically occurs during a save operation). The default is true . Setting it to false is useful if the delegate implements editingContextShouldPresentException to handle the presentation of aggregate exceptions.

See also: - stopsValidationAfterFirstError


setUndoManager

public void setUndoManager (NSUndoManager undoManager)

This method is available for Yellow Box applications only; there is no Java Client equivalent.

Sets the receiver's NSUndoManager to undoManager. You might invoke this method with null if your application doesn't need undo and you want to avoid the overhead of an undo stack. For more information on editing context's undo support, see the section "Undo and Redo."

See also: - undoManager


stopsValidationAfterFirstError

public boolean stopsValidationAfterFirstError ()

()

Returns true to indicate that the receiver should stop validating after it encounters the first error, or false to indicate that it should continue for all objects.

See also: - setStopsValidationAfterFirstError


undo

public void undo ()

This method is available for Yellow Box applications only; there is no Java Client equivalent.

This method forwards an undo message to the receiver's NSUndoManager, asking it to reverse the latest uncommitted changes applied to objects in the object graph. For more information on editing context's undo support, see the section "Undo and Redo."

See also: redo


undoManager

public NSUndoManager undoManager ()

This method is available for Yellow Box applications only; there is no Java Client equivalent.

Returns the receiver's NSUndoManager.

See also: - setUndoManager


unlock

public void unlock ()

This method is available for Yellow Box applications only; there is no Java Client equivalent.

Unlocks access to the receiver so that other threads may access it.


Warning: This method creates an NSAutoreleasePool that is released when unlock is called. Consequently, objects that have been autoreleased within the scope of a lock /unlock pair may not be valid after the unlock .

See also: - lock


updatedObjects

public NSArray updatedObjects ()

Returns the objects in the receiver's object graph that have been updated.

See also: - deletedObjects , - insertedObjects

Notification

The following notifications are declared (except where otherwise noted) and posted by EOEditingContext.


EditingContextDidSaveChangesNotification

This notification is broadcast after changes are saved to the EOEditingContext's parent EOObjectStore. The notification contains:

Notification Object The EOEditingContext
userInfo Dictionary
Key Value
updated An NSArray containing the changed objects
deleted An NSArray containing the deleted objects
inserted An NSArray containing the inserted objects


InvalidatedAllObjectsInStoreNotification

This notification is defined by EOObjectStore. When posted by an EOEditingContext, it's the result of the editing context invalidating all its objects. When an EOEditingContext receives an InvalidatedAllObjectsInStoreNotification from its parent EOObjectStore, it clears its lists of inserted, updated, and deleted objects, and resets its undo stack. The notification contains:

Notification Object The EOEditingContext
userInfo Dictionary None.

An interface layer EODisplayGroup (not a WebObjects WODisplayGroup) listens for this notification to refetch its contents. See the EOObjectStore class specification for more information on this notification.


ObjectsChangedInStoreNotification

This notification is defined by EOObjectStore. When posted by an EOEditingContext, it's the result of the editing context processing objectWillChange observer notifications in processRecentChanges , which is usually as the end of the event in which the changes occurred. See the EOObjectStore class specification for more information on ObjectsChangedInStoreNotification.

This notification contains:

Notification Object The EOEditingContext
userInfo Dictionary
Key Value
updated An NSArray of EOGlobalIDs for objects whose properties have changed. A receiving EOEditingContext typically responds by refaulting the 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. Invalidated objects are those for which the cached view should no longer be trusted. Invalidated objects should be refaulted so that they are refetched when they're next examined.


ObjectsChangedInEditingContextNotification

This notification is broadcast whenever changes are made in an EOEditingContext. It's similar to ObjectsChangedInStoreNotification, except that it contains objects rather than globalIDs. The notification contains:

Notification Object The EOEditingContext
userInfo Dictionary
Key Value
UpdatedKey An NSArray containing the changed objects
DeletedKey An NSArray containing the deleted objects
InsertedKey An NSArray containing the inserted objects
InvalidatedKey An NSArray containing invalidated objects.

Interface layer EODisplayGroups (not WebObjects WODisplayGroups) listen for this notification to redisplay their contents.





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