C# Class Habanero.BO.ClassDefinition.RelationshipDef

Defines the relationship between the ownming Business Object (IBusinessObject and the related Business Object. This class collaborates with the RelKeyDef, the ClassDef to provide a definition Relationship. This class along with the RelKeyDef and RelPropDef provides an implementation of the Foreign Key Mapping pattern (Fowler (236) - 'Patterns of Enterprise Application Architecture' - 'Maps an association between objects to a foreign Key Reference between tables.') The RelationshipDef should not be used by the Application developer since it is usually constructed based on the mapping in the ClassDef.xml file. The RelationshipDef (Relationship Definition) is used bay a ClassDef to define a particular relationship. Each relationship has a relationship name e.g. A relationship betwee a person and a department may manager, employee etc. The related Class e.g. A Department definition would contain a relationship definition to a Person Class. (to allow for the person class to be in a different assemply the assembly name is also stored. The list of properties the define the Foreign key mapping of relationship between these two classes is stored using the RelKeyDef. The Relationship also stores additional information such as DeleteParentAction and order critieria. The DeleteParentAction defines any constraints that the relationship should provide in the case of the parent (relationship owner e.g. Depertment in our example) being deleted. E.g. If the department (parent) is being deleted you may want to delete all related object or prevent delete if there are any related objects. In cases where there are many related objects e.g. A Department can have many Employees the relationship may be required to load in a specifically order e.g. by employee number. The order criteria is used for this.
Inheritance: IRelationshipDef
Datei anzeigen Open project: Chillisoft/habanero Class Usage Examples

Private Properties

Property Type Description
RelationshipDef System

Public Methods

Method Description
CheckCanAddChild ( IBusinessObject bo ) : void

Can the child business object be added to this relationship. Typically a persisted child business object cannot be added to a compositional relationship. A new (i.e. unpersisted) child object can however be.

CheckCanRemoveChild ( IBusinessObject bo ) : void

Checks to see whether a business object can be removed from the relationship. Typically a business object cannot be removed from the relationship if the relationship is composition.

CreateRelationship ( IBusinessObject owningBo, IBOPropCol lBOPropCol ) : IRelationship

Create and return a new Relationship based on the relationship definition.

Protected Methods

Method Description
RelatedClassDefLoaded ( ) : bool

Returns true if the related class def has been loaded already.

RelationshipDef ( string relationshipName, Type relatedObjectClassType, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction ) : System

Constructor to create a new relationship definition

RelationshipDef ( string relationshipName, string relatedObjectAssemblyName, string relatedObjectClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction, InsertParentAction insertParentAction, RelationshipType relationshipType ) : System

Constructor to create a new relationship definition

Private Methods

Method Description
RelationshipDef ( string relationshipName, Type relatedObjectClassType, string relatedObjectAssemblyName, string relatedObjectClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction, InsertParentAction insertParentAction, RelationshipType relationshipType ) : System

Method Details

CheckCanAddChild() public method

Can the child business object be added to this relationship. Typically a persisted child business object cannot be added to a compositional relationship. A new (i.e. unpersisted) child object can however be.
public CheckCanAddChild ( IBusinessObject bo ) : void
bo IBusinessObject
return void

CheckCanRemoveChild() public method

Checks to see whether a business object can be removed from the relationship. Typically a business object cannot be removed from the relationship if the relationship is composition.
public CheckCanRemoveChild ( IBusinessObject bo ) : void
bo IBusinessObject The business object being removed
return void

CreateRelationship() public abstract method

Create and return a new Relationship based on the relationship definition.
public abstract CreateRelationship ( IBusinessObject owningBo, IBOPropCol lBOPropCol ) : IRelationship
owningBo IBusinessObject The business object that owns /// this relationship e.g. The department
lBOPropCol IBOPropCol The collection of properties of the Business object
return IRelationship

RelatedClassDefLoaded() protected method

Returns true if the related class def has been loaded already.
protected RelatedClassDefLoaded ( ) : bool
return bool

RelationshipDef() protected method

Constructor to create a new relationship definition
protected RelationshipDef ( string relationshipName, Type relatedObjectClassType, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction ) : System
relationshipName string A name for the relationship
relatedObjectClassType Type The class type of the related object
relKeyDef IRelKeyDef The related key definition
keepReferenceToRelatedObject bool Whether to keep a /// reference to the related object. Could be false for memory- /// intensive applications.
deleteParentAction DeleteParentAction The required action when the parent is deleted e.g. Dereference related, delete related, prevent delete
return System

RelationshipDef() protected method

Constructor to create a new relationship definition
protected RelationshipDef ( string relationshipName, string relatedObjectAssemblyName, string relatedObjectClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction, InsertParentAction insertParentAction, RelationshipType relationshipType ) : System
relationshipName string A name for the relationship
relatedObjectAssemblyName string The assembly that the related object is in
relatedObjectClassName string The class type of the related object
relKeyDef IRelKeyDef The related key definition
keepReferenceToRelatedObject bool Whether to keep a /// reference to the related object. Could be false for memory- /// intensive applications.
deleteParentAction DeleteParentAction The required action when the parent is deleted e.g. Dereference related, delete related, prevent delete
insertParentAction InsertParentAction
relationshipType RelationshipType
return System