Previous Table of Contents Next


4.5.4 OCL Representation of Relationships Constraints


4.5.4.1 Association

   Operations

   The operation allConnections results in the set of all AssociationEnds of the Association.

   allConnections : Set(AssociationEnd);allConnections = self.feature.oclIsKindOf(AssociationEnd)

   Constraints

   [C-5-1] An Association must have at least 2 AssociationEnds. context Association inv:

   self.allConnections->size > 1

   [C-5-2] The AssociationEnds must have a unique name within the association.context Association inv:self.allConnections->forAll( r1, r2 | r1.name = r2.name implies r1 = r2)

   [C-5-3] At most one AssociationEnd may be an aggregation or composition. context Association inv:

   self.allConnections->select(aggregation <> #ak_none)->size <= 1

   [C-5-4] If an Association has three or more AssociationEnds, then no AssociationEnd may be an aggregation or composition.

   context Association inv:

   self.allConnections->size >=3 implies self.allConnections->forall(aggregation = #ak_none)

   [C-5-5] The connected Classifiers of the AssociationEnds should be included in the Namespace of the Association, or be Classifiers with public visibility in other Namespaces to which the Association has access.

   context Association inv:

   self.allConnections->forAll(r | self.namespace.allContents->includes (r.type) ) or self.allConnections->forAll(r | self.namespace.allContents->excludes (r.type))

   implies

   self.namespace.clientDependency->exists (d | d.supplier.oclAsType(Namespace).ownedElement->select (e | e.elementOwnership.visibility = #ak_public)->includes (r.type) or

    d.supplier.oclAsType(Classifier).allParents. oclAsType(Namespace).ownedElement->select (e | e.elementOwnership.visibility = #ak_public)->includes (r.type) or

    d.supplier.oclAsType(Package).allImportedElements->select (e | e.elementImport.visibility = #ak_public) ->includes (r.type) ) )

4.5.4.2 AssociationEnd

   Constraints

   [C-5-6] An AssociationEnd must have an owning Association. context AssociationEnd inv:

   self.owner.oclIsKindOf(Association)

   [C-5-7] The Classifier of an AssociationEnd cannot be an Interface or a DataType if the association is navigable away from that end.

   context AssociationEnd inv:

   (self.type.oclIsKindOf (Interface) or self.type.oclIsKindOf (DataType)) implies self.owner->select (ae | ae <self)->forAll(ae | ae.isNavigable = #false)

   [C-5-8] An instance may not belong by composition to more than one composite Instance.context AssociationEnd inv:self.aggregation = #ak_composite implies self.multiplicity.max <= 1

   [C-5-9] An AssociationEnd with composite or shared aggregation semantics must

   be owned by an Association.

   context AssociationEnd inv:

   self.aggregation = #ak_composite or self.aggregation = #ak_shared implies self.owner.oclIsKindOf(Association)