home *** CD-ROM | disk | FTP | other *** search
- // EORelationship.h
- // Copyright (c) 1994, NeXT Software, Inc. All rights reserved.
-
- #import <EOControl/EOControl.h>
- #import <EOAccess/EOJoin.h>
- #import <EOAccess/EOPropertyListEncoding.h>
-
- @class EOEntity;
- @class EOAttribute;
- @class EOExpressionArray;
-
- // An EORelationship describes an association between two entities. The two
- // entities can be in the same model or two different models as long as they
- // are in the same model group. The assocation can be to-one or to-many, and
- // is directional: no inverse is implied, however an inverse relationship may
- // exist. A relationship maintains an array of joins identifying
- // attributes from the related entities. See EOJoin.h for more information.
-
- typedef enum {
- EOInnerJoin = 0, EOFullOuterJoin,
- EOLeftOuterJoin, EORightOuterJoin
- } EOJoinSemantic;
- // EOJoinSemantic specifies the manner in which a join should be made.
- // An inner join (also known as an equijoin) produces results only for
- // destinations of the join relationship that have non-null values. A
- // full outer join produces results for all source records, regardless of
- // the values of the relationships. A left outer join preserves rows in
- // the left (source) table (keeps them even if there's no corresponding
- // row in the right table), while a right outer join preserves rows in the
- // right (destination) table. Not all join semantics are supported by all
- // database servers.
-
-
- @interface EORelationship:NSObject <EOPropertyListEncoding>
- {
- NSString *_name;
- EOEntity *_entity;
- EOEntity *_destination;
- EOQualifier *_qualifier;
- EOExpressionArray *_definitionArray;
- NSMutableArray *_joins;
- NSMutableDictionary *_sourceNames;
- NSMutableDictionary *_destinationNames;
- NSDictionary *_userInfo;
- EOExpressionArray *_expressionArray;
- NSDictionary *_sourceToDestinationKeyMap;
- unsigned int _batchCount;
- EOJoinSemantic _joinSemantic;
-
- struct {
- unsigned int isToMany:1;
- unsigned int useBatchFaulting:1;
- unsigned int deleteRule:2;
- unsigned int isMandatory:1;
- unsigned int ownsDestination:1;
- unsigned int propagatesPrimaryKey:1;
- unsigned int extraRefCount:25;
- } _flags;
- id _sourceRowToForeignKeyMapping;
- EORelationship *_inverseRelationship;
- EORelationship *_hiddenInverseRelationship;
- }
-
- - (NSString *)name;
- // Returns the internal name of the relationship.
-
- - (EOEntity *)entity;
- // Returns the source entity of the relationship.
-
- - (EOEntity *)destinationEntity;
- // Returns the destination entity of the relationship
-
- - (NSString *)definition;
- // A path containing relationships that defines a flattened relationship.
- // This may be something like "toAuthor.toPublisher".
-
- - (BOOL)isFlattened;
- // Returns YES if the relationship has a definition; that is, if the
- // relationship traverses more than two entities.
-
- - (BOOL)isToMany;
- // Returns YES if this is a to-many relationship, NO if it's a
- // to-one relationship.
-
- - (BOOL)isCompound;
- // Returns YES if this joins more than one pair of attributes, NO if it
- // joins only one.
-
- - (NSArray *)sourceAttributes;
- // Returns the source attributes of the relationship.
-
- - (NSArray *)destinationAttributes;
- // Returns the destination attributes of the relationship.
-
- - (NSArray *)joins;
- // Returns all joins used by relationship.
-
- - (EOJoinSemantic)joinSemantic;
- // Returns the semantic used to create sql expressions for this relationship.
-
- - (NSArray *)componentRelationships;
- // Returns an array of base relationships making up a flattened
- // relationship. Returns nil if the relationship is not flattened.
-
- - (NSDictionary *)userInfo;
- // Returns a dictionary of user data. Your application can use this data
- // for whatever it needs.
-
- - (BOOL)referencesProperty:(id)property;
- // Returns YES if property is in the relationship's data path or is a join
- // attribute of the relationship, NO otherwise.
-
- - (EODeleteRule)deleteRule;
- // Returns rule describing the action to take when object is being deleted.
-
- - (BOOL)isMandatory;
- // Return value indicating if the target of the relationship can be nil.
-
- - (BOOL)propagatesPrimaryKey;
- // Returns yes if objects should propagate their primary key to related objects
- // through this relationship. Only propagates the value if the corresponding
- // keys don't have a value in the destination object.
-
- - (EORelationship *)inverseRelationship;
- // Searches destinationEntity for a user-created, back-pointing relationship
- // joining on the same keys. Returns nil if none found.
-
- - (EORelationship *)anyInverseRelationship;
- // Searches the destination for a user-created, back-pointing relationship
- // joining on the same keys. If none is found, is looks for a "hidden" inverse
- // relationship that was manufactured by EOF. If none is found, EOF creates
- // a "hidden" inverse relationship and returns that. These hidden relationships
- // are used internally by the framework.
-
- - (unsigned int)numberOfToManyFaultsToBatchFetch;
- // Returns the number of toMany faults that are fired at one time.
-
- - (BOOL)ownsDestination;
- // returns YES if the relationship should insert or delete the target object when
- // added or removed
-
- - (EOQualifier *)qualifierWithSourceRow:(NSDictionary *)sourceRow;
- // Returns the qualifier needed to fetch the destination
- // of the receiving relationship.
-
- @end
-
-
- @interface EORelationship(EORelationshipEditing)
-
-
- - (NSException *)validateName:(NSString *)name;
- // Returns nil if name is a valid relationship name
-
- - (void)setName:(NSString *)name;
- // Sets the relationship's name. This method raises if the name is
- // not a valid name or if the relationship's entity already has a
- // property with this name.
-
- - (void)setDefinition:(NSString *)definition;
- // Sets the definition of the relationship. This method will release
- // any joins and source/destination attributes that may be associated
- // with the relationship. This method will not function correctly if
- // the relationship's entity has not been set.
-
- - (void)setEntity:(EOEntity *)entity;
- // Sets the entity of the relationship. If the relationship is currently
- // owned by a different entity, this method will remove the relationship
- // from that entity. This method does not add the attribute to the new
- // entity. EOEntity's addRelationship: method invokes this method.
-
- - (void)setToMany:(BOOL)yn;
- // Sets whether the relationship is one-to-many or one-to-one.
-
- - (void)setPropagatesPrimaryKey:(BOOL)yn;
- // Sets whether the object propagates its primary key to its destination
- // object.
-
- - (void)setOwnsDestination:(BOOL)yn;
- // Sets whether the relationship should insert or delete the target object when
- // added or removed.
-
- - (void)addJoin:(EOJoin *)join;
- // Adds a source/destination attribute pair to the relationship. This could raise
- // if the join is invalid.
-
- - (void)removeJoin:(EOJoin *)join;
- // Deletes a source/destination attribute pair from the relationship.
-
- - (void)setJoinSemantic:(EOJoinSemantic)joinSemantic;
- // Sets the semantic used to create sql expressions for this relationship.
-
- - (void)setUserInfo:(NSDictionary *)dictionary;
- // Sets the dictionary of auxiliary data, which your application can use
- // for whatever it needs.
-
- - (void)beautifyName;
- // Make the name conform to the Next naming style
- // NAME -> name, FIRST_NAME -> firstName
-
- - (void)setNumberOfToManyFaultsToBatchFetch:(unsigned int)size;
- // Sets the number of toMany faults that are fired at one time.
-
- - (void)setDeleteRule:(EODeleteRule)deleteRule;
- // Set rule describing the action to take when object is being deleted.
-
- - (void)setIsMandatory:(BOOL)isMandatory;
- // Set value indicating if the target of the relationship can be nil.
-
- @end
-
-