-- $Id$ -- Helpers for the MergeModel transformation library MergeHelpers; ------------------------------- General helpers ----------------------------------- helper context UML!ModelElement def : qName() : String = if self.namespace.oclIsTypeOf(UML!Package) then self.namespace.qName() + '.' + self.name else self.name endif; ------------------------------- Model ----------------------------------- helper context UML!Model def : notInSourceModel() : Boolean = false; helper context UML!Model def : fromSourceModel() : UML!Model = UML!Model.allInstancesFrom('IN')->asSequence()->first(); ------------------------------- Classifier ------------------------------ helper context UML!Classifier def : notInSourceModel() : Boolean = UML!Classifier.allInstancesFrom('IN')->select(e|e.qName()=self.qName())->isEmpty(); helper context UML!Classifier def : fromSourceModel() : UML!Classifier = UML!Classifier.allInstancesFrom('IN')->select(e|e.qName()=self.qName())->first(); ------------------------------- Package --------------------------------- helper context UML!Package def : notInSourceModel() : Boolean = UML!Package.allInstancesFrom('IN')->select(e|e.qName()=self.qName())->isEmpty(); helper context UML!Package def : fromSourceModel() : UML!Package = UML!Package.allInstancesFrom('IN')->select(e|e.qName()=self.qName())->first(); ------------------------------- TagDefinition --------------------------- helper context UML!TagDefinition def : notInSourceModel() : Boolean = UML!TagDefinition.allInstancesFrom('IN')->select(e|e.qName()=self.qName())->isEmpty(); helper context UML!TagDefinition def : fromSourceModel() : UML!TagDefinition = UML!TagDefinition.allInstancesFrom('IN')->select(e|e.qName()=self.qName())->first(); ------------------------------- Stereotype ------------------------------ helper context UML!Stereotype def : notInSourceModel() : Boolean = UML!Stereotype.allInstancesFrom('IN')->select(e|e.qName()=self.qName())->isEmpty(); helper context UML!Stereotype def : fromSourceModel() : UML!Stereotype = UML!Stereotype.allInstancesFrom('IN')->select(e|e.qName()=self.qName())->first(); ------------------------------- Association ----------------------------- helper context UML!Association def : notInSourceModel() : Boolean = not self.connection->forAll(c|c.inSourceModel()); helper context UML!AssociationEnd def : inSourceModel() : Boolean = if self.isNavigable then not UML!AssociationEnd.allInstancesFrom('IN')->select(e|e.isNavigable)->select(e| e.name=self.name and e.participant.qName()=self.participant.qName())->isEmpty() else if self.otherEnd().isNavigable then self.otherEnd().inSourceModel() else true endif endif; helper context UML!AssociationEnd def : otherEnd() : UML!AssociationEnd = self.association.connection->select(x|x<>self)->first(); ------------------------------- AssociationEnd -------------------------- helper context UML!AssociationEnd def : notInSourceModel() : Boolean = thisModule.newElements->includes(self.association); ------------------------------- TaggedValue ----------------------------- helper context UML!TaggedValue def : notInSourceModel() : Boolean = if thisModule.newElements->includes(self.modelElement) then true else self.modelElement.notInSourceModel() endif; ------------------------------- StructuralFeature ----------------------- helper context UML!StructuralFeature def : notInSourceModel() : Boolean = if thisModule.newElements->includes(self.owner) then true else self.owner.fromSourceModel().feature->select(f| f.name=self.name and f.oclIsKindOf(UML!StructuralFeature))->isEmpty() endif; ------------------------------- Operation ------------------------------- helper context UML!Operation def : notInSourceModel() : Boolean = if thisModule.newElements->includes(self.owner) then true else self.owner.fromSourceModel().feature->select(f| f.name=self.name and f.oclIsKindOf(UML!Operation))->select(o| o.hasSameParametersAs(self))->isEmpty() endif; helper context UML!BehavioralFeature def : hasSameParametersAs(f : UML!BehavioralFeature) : Boolean = f.parameter->select(p|not self.hasSameParameter(p))->isEmpty(); helper context UML!BehavioralFeature def : hasSameParameter(p : UML!Parameter) : Boolean = not self.parameter->select(sp|sp.kind=p.kind and sp.type.qName()=p.type.qName())->isEmpty(); ------------------------------- Method ---------------------------------- helper context UML!Method def : notInSourceModel() : Boolean = if thisModule.newElements->includes(self.owner) then true else self.specification.notInSourceModel() endif; ------------------------------- Dependency ------------------------------ helper context UML!Dependency def : notInSourceModel() : Boolean = UML!Dependency.allInstancesFrom('IN')->select(d| d.supplier->forAll(s1|self.supplier->forAll(s2|s1.qName()=s2.qName())) and d.client->forAll(c1|self.client->forAll(c2|c1.qName()=c2.qName())))->isEmpty(); ------------------------------- Generalization -------------------------- helper context UML!Generalization def : notInSourceModel() : Boolean = UML!Generalization.allInstancesFrom('IN')->select(g| g.parent.qName()=self.parent.qName() and g.child.qName()=self.child.qName())->isEmpty(); ------------------------------- Parameter ------------------------------- helper context UML!Parameter def : notInSourceModel() : Boolean = if self.behavioralFeature.oclIsUndefined() then false else self.behavioralFeature.notInSourceModel() endif;