home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / EODEV.Z / EODatabaseOperation.h < prev    next >
Encoding:
Text File  |  1996-09-09  |  5.4 KB  |  155 lines

  1. // EODatabaseOperations.h
  2. // Copyright (c) 1995, NeXT Software, Inc. All rights reserved.
  3.  
  4. //
  5. // This file contains the declarations for two classes: EODatabaseOperation
  6. // and EOAdaptorOperation.
  7. //
  8. // EOAdaptorOperations are objects that represent a specific action that needs
  9. // to be taken in the database. An adaptorOperation will specify that an insert,
  10. // delete, or update operation needs to be applied to a particular row in a
  11. // particular table.
  12. //
  13. // EODatabaseOperations are used internally by the EODatabaseContext when
  14. // determining what changes have been made to the object graph and eventually
  15. // which adaptorOperations need to be sent to the adaptor.
  16. //
  17.  
  18. #import <EOControl/EOControl.h>
  19.  
  20. @class EOEntity;
  21. @class EOStoredProcedure;
  22.  
  23.  
  24. // Represents the different adaptor operations that may be requested by the
  25. // EODatabaseContext.
  26. typedef enum {
  27.     EOAdaptorLockOperator,
  28.     EOAdaptorInsertOperator,
  29.     EOAdaptorUpdateOperator,
  30.     EOAdaptorDeleteOperator,
  31.     EOAdaptorStoredProcedureOperator
  32. } EOAdaptorOperator;
  33.  
  34. @interface EOAdaptorOperation:NSObject
  35. {
  36.     EOAdaptorOperator _adaptorOperator;
  37.     EOEntity *_entity;
  38.     EOQualifier *_qualifier;
  39.     NSDictionary *_changedValues;
  40.     NSArray *_attributes;
  41.     EOStoredProcedure *_storedProcedure;
  42.     NSException *_exception; // raised while trying to perform this operation during batch mode
  43. }
  44.  
  45. -initWithEntity:(EOEntity *)entity;
  46.     // Designated initializer.
  47.  
  48. - (EOAdaptorOperator)adaptorOperator;
  49. - (void)setAdaptorOperator:(EOAdaptorOperator)adaptorOperator;
  50.     // Returns/Sets the adaptorOperator    
  51.  
  52. - (EOEntity *)entity;
  53.     // Return the entity that this adaptorOperation will be applied to.
  54.  
  55. - (EOQualifier *)qualifier;
  56. - (void)setQualifier:(EOQualifier *)qualifier;
  57.     // Returns/Sets the qualifier that identifies the row in the table
  58.     // that this adaptorOperation wil be applied to.
  59.  
  60. - (NSMutableDictionary *)changedValues;
  61. - (void)setChangedValues:(NSDictionary *)changedValues;
  62.     // Returns/Sets the dictionary containing any values that need to be
  63.     // updated, inserted, or compared for locking purposes.
  64.  
  65. - (NSArray *)attributes;
  66. - (void)setAttributes:(NSArray *)attributes;
  67.     // Returns/Sets the array of attributes used for performing fetches to
  68.     // lock a given row.
  69.  
  70. - (EOStoredProcedure *)storedProcedure;
  71. - (void)setStoredProcedure:(EOStoredProcedure *)storedProcedure;
  72.     // Returns/Sets the stored procedure
  73.  
  74. - (NSException *)exception;
  75. - (void)setException:(NSException *)exception;
  76.     // Returns/Sets an exception for this adaptorOperation. If a database error
  77.     // occurs while trying to process this adaptorOperation an exception will be
  78.     // created and stored in the adaptorOperation.
  79.  
  80. - (NSComparisonResult)compareAdaptorOperation:(EOAdaptorOperation *)adaptorOp;
  81.     // This is the default compare method used to order the adaptor operations
  82.     // before invoking perform adaptor operations. This method returns the adaptorOps
  83.     // ordered by entityName(alphabetical) and then by operation(lock, insert, update,
  84.     // and delete.
  85. @end
  86.  
  87. // The different operations that may need to be performed on objects in the database.
  88. typedef enum {
  89.     EODatabaseNothingOperator,
  90.     EODatabaseInsertOperator,
  91.     EODatabaseUpdateOperator,
  92.     EODatabaseDeleteOperator
  93. } EODatabaseOperator;
  94.  
  95. @interface EODatabaseOperation:NSObject
  96. {
  97.     EODatabaseOperator _databaseOperator;
  98.     NSMutableDictionary *_newRow;
  99.     NSDictionary *_dbSnapshot;
  100.     EOGlobalID *_globalID;
  101.     EOEntity *_entity;
  102.     NSMutableArray *_adaptorOps;
  103.     id _object;
  104. }
  105.  
  106. -initWithGlobalID:(EOGlobalID *)globalID object:(id)object entity:(EOEntity *)entity;
  107.     // Designated initializer
  108.  
  109. - (NSDictionary *)dbSnapshot;
  110. - (void)setDBSnapshot:(NSDictionary *)dbSnapshot;
  111.     // Returns/Sets the dbSnapshot. The snapshot contains the values that were
  112.     // last known to be in the database.
  113.  
  114. - (NSMutableDictionary *)newRow;
  115. - (void)setNewRow:(NSMutableDictionary *)newRow;
  116.     // Returns/Sets the newRow. The newRow contains the values contained in the object
  117.     // and related objects.
  118.  
  119. - (EOGlobalID *)globalID;
  120.     // returns the globalID that corresponds to the object represented by the database
  121.     // operation.
  122.  
  123. - (id)object;
  124.     // Returns the object that corresponds to this databaseOperation.
  125.  
  126. - (EOEntity *)entity;
  127.     // Returns the entity that corresponds to the object in this databaseOperation.
  128.  
  129. - (EODatabaseOperator)databaseOperator;
  130. - (void)setDatabaseOperator:(EODatabaseOperator)dbOp;
  131.     // Returns/Sets the databaseOperator.
  132.  
  133. - (NSDictionary *)rowDiffs;
  134.     // Returns a dictionary that contains any values that are in the newRow that are
  135.     // different than those in the dbSnapshot.
  136.  
  137. - (NSDictionary *)rowDiffsForAttributes:(NSArray *)attributes;
  138.     // Returns a dictionary that contains any values indicated by attributes that
  139.     // are in the newRow that are different than those in the dbSnapshot.
  140.  
  141. - (NSDictionary *)primaryKeyDiffs;
  142.     // Returns a dictionary that contains any primary key values in newRow that are
  143.     // different from those in the dbSnapshot. Returns nil for any dbOp that does
  144.     // not have a databaseOperator == EODatabaseUpdateOperator.
  145.  
  146. - (NSArray *)adaptorOperations;
  147.     // Returns the array of adaptorOperations that corresponds to this databaseOperation.
  148.  
  149. - (void)addAdaptorOperation:(EOAdaptorOperation *)adaptorOperation;
  150. - (void)removeAdaptorOperation:(EOAdaptorOperation *)adaptorOperation;
  151.     // Adds/Removes an adaptorOperation to this databaseOperation.
  152.  
  153. @end
  154.  
  155.