|
|
Sample Programs from NeXSTEP 3.3
/* RelationshipKeySetter.h created by cfeder on Tue 08-Nov-1994 */
#import <eoaccess/eoaccess.h>
@interface EOEntity (attrsNamed)
- attributesNamed:(NSArray *)names;
- createObject;
@end
// Extensions to EORelationship to handle assigning foreign keys in
// objects when they are newly assigned to point at one another.
// For instance, if an employee is set to point at a new department object
// [toEmpRelationship updateKeysForSourceObject:theEmp destinationObject:theNewDept]
// will change to dept_id property of theEmp to the dept_id of theNewDept
// and return the modified object (theEmp) so the caller can make sure that object
// is updated in the database.
//
// The following relationship types are handled:
//
// M Detail Insert rule Delete Types
// PK -> PK D->PK := M->PK delete D to-one
// FK -> PK M->FK := D->PK M->FK=NULL to-one
// PK -> FK D->FK := M->PK Delete D to-many
// Many to many create link obj Delete link to-many
//
// Decoding: The first line means, when a relationship joins from the
// primary key of the master entity to the primary key of the detail,
// handle and insertion by setting the primary key of the detail to match
// the primary key of the master.
//
@interface EORelationship (setPropsInDestObject)
- (NSArray *)sourceKeys;
- (NSDictionary *)destinationValuesFromSourceObject:sourceObject;
- (void)setJoinPropertiesInDestinationObject:destination fromSourceObject:source;
- (void)setJoinPropertiesInSourceObject:source fromDestinationObject:destination;
- (BOOL)hasJoinsOnPrimaryKeyOfSourceEntity;
- (void)updateMasterObject:master withNewDestinationObject:destination;
- linkObjectForSourceObject:master destinationObject:destination;
- updateKeysForSourceObject:source destinationObject:destination;
// Sets keys on source or destination to maintain consistency for
// the source to now map to destination for this relationship.
// Does not actually assign destination to ivar in source (just messes
// with the keys).
// Returns the modified object (source or destination). In the case of
// a many to many returns a newly created link object.
- updateKeysForDeleteOfDestinationObject:destination fromSourceObject:source;
// Sets keys on source or destination to maintain consistency for
// a delete of the destination from the source. Returns the object
// modified, or a synthesized link object that must be deleted to
// affect the delete. The caller is responsible for updating the
// source object, or deleting the destination or link in the database.
//
// This does not actually update destination to ivar in source (just messes
// with the keys).
@end
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.