Package Modeling :: Package interfaces :: Module Relationship :: Class RelationshipInterface
[show private | hide private]
[frames | no frames]

Class RelationshipInterface

Base --+
       |
      RelationshipInterface


Responsible for class descriptions
class Relationship(Persistent, XMLCapability):

Describes a relationship

Implementation notes:
- join semantic is not used for the moment being, and defaults to INNER_JOIN

Features added to the EOF standard API:
- cardinality of the relationship


[Tableau suivant  verifier avec le Modeler]::

                     SimpleRel.   FlattenedRel.
  definition   get       y:None        Y         
               set       N             Y         
  deleteRule   get       Y             Y         
               set       Y             Y         
  displayLabel get       Y             Y         
               set       Y             Y         
  entity       get       Y             Y         
               set       Y             Y         
  isClassProp. get       Y             Y         
               set       Y             Y         
  joins        get       Y             y:()      
               set       Y             N         
  joinSemantic get       Y             N         
               set       Y             N         
  name         get       Y             Y         
               set       Y             Y         
  mult.Lower   get       Y             Y?        
               set       Y             Y?        
  mult.Upper   get       Y             Y?        
               set       Y             Y?        
  propagatesPK get       Y             y:false   
               set       Y             N         
  ownsDestinat.get       Y             ?         
               set       Y             ?         
funcs.:
  componentRelationship  y:()          Y
  destinationAttributes  Y             y?
  destinationEntity      Y             Y                 
  inverseRelationship    Y             Y
  isCompound             Y             N? (see isSimple) 
  isFlattened            Y             Y  
  isMandatory            Y             Y? (see 'Y?' for multiplicities)
  isSimple               Y             N? (see isCompound)
  isToOne                Y             Y? (|see
  isToMany               Y             Y? (|   'Y?' for multiplicities)

Method Summary
  __init__(self, aName)
Initializes a relationship.
  __eq__(self, aRelationship)
Tests whether both relationship are equal
  addJoin(self, aJoin)
Adds a join to the relationship
  checkRelationshipValidity(self)
Checks the relationship validity.
  componentRelationships(self)
Returns the sequence of (non flattened) relationships involved in the flattened relationship, or 'None' if the receiver is not flattened See also: definition
  definition(self)
Returns the definition (keypath) for the flattened relationship, or 'None' if the relationship is not flattened See also: componentRelationships
  deleteRule(self)
Returns the delete rule applicable to this relationship.
  destinationAttributes(self)
Simply returns the list of joins' destination attributes
  destinationEntity(self)
Returns the destination entity, or 'None' if the relationship has no joins yet
  destinationEntityName(self)
Return the destination entity, or None
  displayLabel(self)
Returns the display label for the relationship
  entity(self)
Return the relationship's source entity
  getXMLDOM(self, doc, parentNode, encoding)
Returns the (DOM) DocumentObject for the receiver.
  initWithXMLDOMNode(self, aNode, encoding)
Initializes a relationship with the supplied xml.dom.node.
  inverseRelationship(self)
Returns the inverse relationship in the destination entity, or None if it does not exist.
  isClassProperty(self)
Indicates whether the attribute belongs to the class properties/fields
  isCompound(self)
Simply indicates whether the relationship has one or more joins Returns true iff relationship has one join, false otherwise.
  isFlattened(self)
Returns true (integer '1') if the receiver is flattened, false ('0') otherwise See also: definition, componentRelationships
  isMandatory(self)
Indicates whether the relationship requires at least a destination entity to be bound.
  isSimple(self)
Indicates whether the relation holds one join.
  isToMany(self)
Indicates whether the relationship has a maximum cardinality > 1.
  isToOne(self)
Indicates whether the relationship has a maximim cardinality = 1.
  joins(self)
Return the whole set of joins registered in this relationship
  multiplicityLowerBound(self)
Returns the lower bound of the relationship's multiplicity
  multiplicityUpperBound(self)
Returns the upper bound of the relationship's multiplicity.
  name(self)
Returns the relationship's name
  ownsDestination(self)
Returns true if the relationship owns the destinationEntity.
  propagatesPrimaryKey(self)
Returns true if the relationship propagates PK value, false otherwise _TBD should be explained
  removeJoin(self, aJoin)
Removes the supplied join from the relation's join.
  setDefinition(self)
Sets the definition for the receiver, making it a flattened relationship
  setDeleteRule(self, rule)
Sets the delete rule.
  setDisplayLabel(self, aLabel)
Sets the display label (string) for the relationship
  setEntity(self, anEntity)
Sets the source entity
  setIsClassProperty(self, aBool)
Tells the receiver whether it belongs to the class properties/fields
  setIsMandatory(self, aBool)
Tells the relationship whether it is mandatory.
  setMultiplicity(self, lowerBound, upperBound)
Sets the lower and upper bounds for the relationship's multiplicity.
  setMultiplicityLowerBound(self, lowerBound)
Sets the lower bound of the relationship's multiplicity Parameter lowerBound must be an positive integer.
  setMultiplicityUpperBound(self, upperBound)
Sets the upper bound of the relationship's multiplicity.
  setName(self, aName)
Sets the relationship's name
  setOwnsDestination(self, boolean)
Tells the receiver whether it owns its destination objects.
  setPropagatesPrimaryKey(self, aBool)
Tells the relationship whether it propagates PK value _TBD should be explained
  sourceAttributes(self)
Simply returns the list of joins' source attributes
  sourceEntity(self)
Return the relationship's source entity
  validateRelationship(self)
Validates the relationship against general model consistency: - relationship should have a source and a destination entity -
  validateValue(self, value, object)
Checks whether the supplied value is valid, i.e.
  xmlAttributesDict(self)
.

Method Details

__init__(self, aName='')
(Constructor)

Initializes a relationship. A name must be provided.

Default value is a non-flattened, to-one relationship with no joins, deleteRule: Nullify, joinSemantic: INNER_JOIN,

__eq__(self, aRelationship)
(Equality operator)

Tests whether both relationship are equal

addJoin(self, aJoin)

Adds a join to the relationship

Raises ValueError if aJoin's source attribute does not belong to receiver's entity, if either aJoin's source or destination attribute is already registered in an other relationship's join, or if aJoin's destination entity does not equal to 'self.destinationEntity()' (if this one is not 'None').

checkRelationshipValidity(self)

Checks the relationship validity. This includes the following tests: - cardinality > 0 - len(joins) > 0 - name - source and destinationEntity are not None - joins' sources are identical (idem for destinations) Raises the relation is invalid.

componentRelationships(self)

Returns the sequence of (non flattened) relationships involved in the flattened relationship, or 'None' if the receiver is not flattened See also: definition

definition(self)

Returns the definition (keypath) for the flattened relationship, or 'None' if the relationship is not flattened See also: componentRelationships

deleteRule(self)

Returns the delete rule applicable to this relationship. Possible values are module's integer constants DELETE_CASCADE, DELETE_NULLIFY and DELETE_DENY

destinationAttributes(self)

Simply returns the list of joins' destination attributes

destinationEntity(self)

Returns the destination entity, or 'None' if the relationship has no joins yet

destinationEntityName(self)

Return the destination entity, or None

displayLabel(self)

Returns the display label for the relationship

entity(self)

Return the relationship's source entity

getXMLDOM(self, doc=None, parentNode=None, encoding='iso-8859-1')

Returns the (DOM) DocumentObject for the receiver.

Parameters 'doc' and 'parentDoc' should be both omitted or supplied. If they are omitted, a new DocumentObject is created. If they are supplied, elements are added to the parentNode.

Returns: the (possibly new) DocumentObject.

initWithXMLDOMNode(self, aNode, encoding='iso-8859-1')

Initializes a relationship with the supplied xml.dom.node. Also take care of initializing joins

inverseRelationship(self)

Returns the inverse relationship in the destination entity, or None if it does not exist. The notion of inverse relationship is very precise: an inverse relationship has the same number of joins, and there is a bijective relation defined by 'Join.isReciprocicalTo' between both sets of joins.

isClassProperty(self)

Indicates whether the attribute belongs to the class properties/fields

isCompound(self)

Simply indicates whether the relationship has one or more joins Returns true iff relationship has one join, false otherwise. Raises if relationship has no joins.

isFlattened(self)

Returns true (integer '1') if the receiver is flattened, false ('0') otherwise See also: definition, componentRelationships

isMandatory(self)

Indicates whether the relationship requires at least a destination entity to be bound. This is a computed attribute, equivalent to: 'self.multiplicityLowerBound()>0'.

isSimple(self)

Indicates whether the relation holds one join. Note that this method return also 'true' when the relationship is invalid (i.e. it holds no joins)

isToMany(self)

Indicates whether the relationship has a maximum cardinality > 1. This is the contrary of method isToOne.

isToOne(self)

Indicates whether the relationship has a maximim cardinality = 1. This is the contrary of method isToMany.

joins(self)

Return the whole set of joins registered in this relationship

multiplicityLowerBound(self)

Returns the lower bound of the relationship's multiplicity

multiplicityUpperBound(self)

Returns the upper bound of the relationship's multiplicity. Returned value is a strictly positive integer, or -1 if there is no upper bound.

name(self)

Returns the relationship's name

ownsDestination(self)

Returns true if the relationship owns the destinationEntity. See also: setOwnsDestination() When a relationship owns its destination, the related entity object cannot exist without the source object. Thus, as a side-effect, this sets the delete rule to 'cascade'.

propagatesPrimaryKey(self)

Returns true if the relationship propagates PK value, false otherwise _TBD should be explained

removeJoin(self, aJoin)

Removes the supplied join from the relation's join. Parameter 'aJoin' must be a 'Join' instance. Raises 'ValueError' if 'aJoin' cannot be found.

setDefinition(self)

Sets the definition for the receiver, making it a flattened relationship

setDeleteRule(self, rule)

Sets the delete rule. Accepted values are module's constants: DELETE_NULLIFY, DELETE_CASCADE and DELETE_DENY

setDisplayLabel(self, aLabel)

Sets the display label (string) for the relationship

setEntity(self, anEntity)

Sets the source entity

setIsClassProperty(self, aBool)

Tells the receiver whether it belongs to the class properties/fields

setIsMandatory(self, aBool)

Tells the relationship whether it is mandatory. This method has the following side-effects: if set to 'true' and the multiplicity lower bound was '0' (zero) it is set to '1' (one) ; if set to 'false', the multiplicity lower bound is set to 'zero'.

setMultiplicity(self, lowerBound, upperBound)

Sets the lower and upper bounds for the relationship's multiplicity. See also: setMultiplicityLowerBound, setMultiplicityUpperBound.

setMultiplicityLowerBound(self, lowerBound)

Sets the lower bound of the relationship's multiplicity Parameter lowerBound must be an positive integer.

setMultiplicityUpperBound(self, upperBound)

Sets the upper bound of the relationship's multiplicity. Parameter 'upperBound' must be a strictly positive integer, or -1 for a non constrained to-many relationship.

setName(self, aName)

Sets the relationship's name

setOwnsDestination(self, boolean)

Tells the receiver whether it owns its destination objects.

When a relationship owns its destination, the related object(s) cannot exist without the source object. Thus, as a side-effect, this sets the delete rule to 'cascade' when it is set to true.

setPropagatesPrimaryKey(self, aBool)

Tells the relationship whether it propagates PK value _TBD should be explained

sourceAttributes(self)

Simply returns the list of joins' source attributes

sourceEntity(self)

Return the relationship's source entity

validateRelationship(self)

Validates the relationship against general model consistency: - relationship should have a source and a destination entity -

Unimplemented

validateValue(self, value, object=None)

Checks whether the supplied value is valid, i.e. the following tests are made:

  1. value cannot be void ('not value' equals to 1) if the relationship is mandatory
  2. Value has a method 'entityName' (i.e. it is 'model-powered'), or if it is a tuple each item has a persistentID
  3. 'value' matches the multiplicity bounds
  4. Value's entity is the relationship's destination entity (same for 'value' 's items if 'value' is a tuple)

Parameter 'value' is required, and 'object' is optional --it is only used to make the error message clearer in case of failure.

Silently returns if it suceeds.

In case of failure, it raises 'Modeling.Validation.Exception' ; in this case, exception's value ('sys.exc_info[1]') consists in a set of lines, describing line per line the different tests which failed.

xmlAttributesDict(self)

.

Generated by Epydoc 2.1 on Sat Mar 4 13:36:21 2006 http://epydoc.sf.net