home *** CD-ROM | disk | FTP | other *** search
- // EODatabaseOperations.h
- // Copyright (c) 1995, NeXT Software, Inc. All rights reserved.
-
- //
- // This file contains the declarations for two classes: EODatabaseOperation
- // and EOAdaptorOperation.
- //
- // EOAdaptorOperations are objects that represent a specific action that needs
- // to be taken in the database. An adaptorOperation will specify that an insert,
- // delete, or update operation needs to be applied to a particular row in a
- // particular table.
- //
- // EODatabaseOperations are used internally by the EODatabaseContext when
- // determining what changes have been made to the object graph and eventually
- // which adaptorOperations need to be sent to the adaptor.
- //
-
- #import <EOControl/EOControl.h>
-
- @class EOEntity;
- @class EOStoredProcedure;
-
-
- // Represents the different adaptor operations that may be requested by the
- // EODatabaseContext.
- typedef enum {
- EOAdaptorLockOperator,
- EOAdaptorInsertOperator,
- EOAdaptorUpdateOperator,
- EOAdaptorDeleteOperator,
- EOAdaptorStoredProcedureOperator
- } EOAdaptorOperator;
-
- @interface EOAdaptorOperation:NSObject
- {
- EOAdaptorOperator _adaptorOperator;
- EOEntity *_entity;
- EOQualifier *_qualifier;
- NSDictionary *_changedValues;
- NSArray *_attributes;
- EOStoredProcedure *_storedProcedure;
- NSException *_exception; // raised while trying to perform this operation during batch mode
- }
-
- -initWithEntity:(EOEntity *)entity;
- // Designated initializer.
-
- - (EOAdaptorOperator)adaptorOperator;
- - (void)setAdaptorOperator:(EOAdaptorOperator)adaptorOperator;
- // Returns/Sets the adaptorOperator
-
- - (EOEntity *)entity;
- // Return the entity that this adaptorOperation will be applied to.
-
- - (EOQualifier *)qualifier;
- - (void)setQualifier:(EOQualifier *)qualifier;
- // Returns/Sets the qualifier that identifies the row in the table
- // that this adaptorOperation wil be applied to.
-
- - (NSMutableDictionary *)changedValues;
- - (void)setChangedValues:(NSDictionary *)changedValues;
- // Returns/Sets the dictionary containing any values that need to be
- // updated, inserted, or compared for locking purposes.
-
- - (NSArray *)attributes;
- - (void)setAttributes:(NSArray *)attributes;
- // Returns/Sets the array of attributes used for performing fetches to
- // lock a given row.
-
- - (EOStoredProcedure *)storedProcedure;
- - (void)setStoredProcedure:(EOStoredProcedure *)storedProcedure;
- // Returns/Sets the stored procedure
-
- - (NSException *)exception;
- - (void)setException:(NSException *)exception;
- // Returns/Sets an exception for this adaptorOperation. If a database error
- // occurs while trying to process this adaptorOperation an exception will be
- // created and stored in the adaptorOperation.
-
- - (NSComparisonResult)compareAdaptorOperation:(EOAdaptorOperation *)adaptorOp;
- // This is the default compare method used to order the adaptor operations
- // before invoking perform adaptor operations. This method returns the adaptorOps
- // ordered by entityName(alphabetical) and then by operation(lock, insert, update,
- // and delete.
- @end
-
- // The different operations that may need to be performed on objects in the database.
- typedef enum {
- EODatabaseNothingOperator,
- EODatabaseInsertOperator,
- EODatabaseUpdateOperator,
- EODatabaseDeleteOperator
- } EODatabaseOperator;
-
- @interface EODatabaseOperation:NSObject
- {
- EODatabaseOperator _databaseOperator;
- NSMutableDictionary *_newRow;
- NSDictionary *_dbSnapshot;
- EOGlobalID *_globalID;
- EOEntity *_entity;
- NSMutableArray *_adaptorOps;
- id _object;
- }
-
- -initWithGlobalID:(EOGlobalID *)globalID object:(id)object entity:(EOEntity *)entity;
- // Designated initializer
-
- - (NSDictionary *)dbSnapshot;
- - (void)setDBSnapshot:(NSDictionary *)dbSnapshot;
- // Returns/Sets the dbSnapshot. The snapshot contains the values that were
- // last known to be in the database.
-
- - (NSMutableDictionary *)newRow;
- - (void)setNewRow:(NSMutableDictionary *)newRow;
- // Returns/Sets the newRow. The newRow contains the values contained in the object
- // and related objects.
-
- - (EOGlobalID *)globalID;
- // returns the globalID that corresponds to the object represented by the database
- // operation.
-
- - (id)object;
- // Returns the object that corresponds to this databaseOperation.
-
- - (EOEntity *)entity;
- // Returns the entity that corresponds to the object in this databaseOperation.
-
- - (EODatabaseOperator)databaseOperator;
- - (void)setDatabaseOperator:(EODatabaseOperator)dbOp;
- // Returns/Sets the databaseOperator.
-
- - (NSDictionary *)rowDiffs;
- // Returns a dictionary that contains any values that are in the newRow that are
- // different than those in the dbSnapshot.
-
- - (NSDictionary *)rowDiffsForAttributes:(NSArray *)attributes;
- // Returns a dictionary that contains any values indicated by attributes that
- // are in the newRow that are different than those in the dbSnapshot.
-
- - (NSDictionary *)primaryKeyDiffs;
- // Returns a dictionary that contains any primary key values in newRow that are
- // different from those in the dbSnapshot. Returns nil for any dbOp that does
- // not have a databaseOperator == EODatabaseUpdateOperator.
-
- - (NSArray *)adaptorOperations;
- // Returns the array of adaptorOperations that corresponds to this databaseOperation.
-
- - (void)addAdaptorOperation:(EOAdaptorOperation *)adaptorOperation;
- - (void)removeAdaptorOperation:(EOAdaptorOperation *)adaptorOperation;
- // Adds/Removes an adaptorOperation to this databaseOperation.
-
- @end
-
-