diff options
author | Vincent Lorenzo | 2017-02-01 15:59:31 +0000 |
---|---|---|
committer | vincent lorenzo | 2017-02-02 10:19:51 +0000 |
commit | e2911f0576dc2496838dfc9431e771065408e0a8 (patch) | |
tree | 949a8082c8d82f37f4d4d512b7cfc87037e635c7 /extraplugins | |
parent | fa565169a68abd5bce6dfdd8c9963e1321c65217 (diff) | |
download | org.eclipse.papyrus-e2911f0576dc2496838dfc9431e771065408e0a8.tar.gz org.eclipse.papyrus-e2911f0576dc2496838dfc9431e771065408e0a8.tar.xz org.eclipse.papyrus-e2911f0576dc2496838dfc9431e771065408e0a8.zip |
Bug 511486: [Importer][Rhapsody] Refactore the mapping used for association
- commit 2
- remove useless mapping method fromClasse2Associations
- remove useless mapping method toAssociationswithoutProp (bad code, checked with JUnit tests, useless)
- remove mapping toOwnedAssociationEnd and integrate its code to toAssociationswithProp mapping
Change-Id: Ia7549cca9a8b9eba0925a681e86b53e37531a147
Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
Diffstat (limited to 'extraplugins')
4 files changed, 5 insertions, 75 deletions
diff --git a/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/Rhapsody2PapyrusNotation.qvto b/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/Rhapsody2PapyrusNotation.qvto index 732c40c4f8c..4d9ae7c44e3 100644 --- a/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/Rhapsody2PapyrusNotation.qvto +++ b/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/Rhapsody2PapyrusNotation.qvto @@ -346,15 +346,7 @@ mapping umlrhapsody::CGIAssociationEnd::toPapyrusAssociation() : Connector var sourceAnchorId: String:= getAnchorId(source_mpolygon, source_mtransform,source_Port); var targetAnchorId: String:= getAnchorId(target_mpolygon, target_mtransform,target_Port); - var association:EObject:=self.m_pModelObject.resolveIn(umlrhapsody::IAssociationEnd::toAssociationswithProp, uml::Association)![EObject]; - if (association!=null) - { - result.element:=association; - } - else - { - result.element := self.m_pModelObject.resolveIn(umlrhapsody::IAssociationEnd::toAssociationswithoutProp, uml::Association)![EObject]; - }; + result.element:=self.m_pModelObject.resolveIn(umlrhapsody::IAssociationEnd::toAssociationswithProp, uml::Association)![EObject]; result.type := self.getEdgeType(); result.source:= sourceNode.resolveIn(umlrhapsody::CGIClass::toPapyrusNode, Shape)![View]; diff --git a/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/Rhapsody2PapyrusSemanticElements.qvto b/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/Rhapsody2PapyrusSemanticElements.qvto index 02776778a0b..9f3f870c614 100755 --- a/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/Rhapsody2PapyrusSemanticElements.qvto +++ b/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/Rhapsody2PapyrusSemanticElements.qvto @@ -119,7 +119,7 @@ mapping umlrhapsody::DefaultSubsystemType::iDefaultSubsystemTypeToPackage():uml: packagedElement+= iSubSystem.Classes->selectByType(IClass)->any(name="TopLevel").Attrs->selectByKind(IAttribute).oclAsType(EObject).map generalMappingToUMLElement().oclAsType(PackageableElement); //TODO probably more check are required to remove TopLevel without problems (check with MARTE...) packagedElement+= iSubSystem.Classes->selectByType(IClass)->select(curr | curr.name<>"TopLevel")->selectByKind(EObject).map generalMappingToUMLElement().oclAsType(uml::PackageableElement); - packagedElement += iSubSystem.Classes[IClass].Associations[IAssociationEnd]->select(assoEnd: IAssociationEnd |not (assoEnd.oclAsType(IAssociationEnd).inverse.oclIsUndefined()))->any(true).map toAssociationswithoutProp(); + packagedElement += iSubSystem.Types->selectByType(IType)->selectByKind(EObject).map generalMappingToUMLElement().oclAsType(uml::PackageableElement); packagedElement += iSubSystem.Actors->selectByKind(IActor)->oclAsType(EObject).map generalMappingToUMLElement().oclAsType(uml::PackageableElement); packagedElement +=iSubSystem.Declaratives[DefaultSubsystemType].oclAsSet().map iDefaultSubsystemTypeToPackage(); @@ -362,78 +362,24 @@ query umlrhapsody::IType::isUMLInstanceSpecification(): Boolean { //--------association code-------------- -mapping umlrhapsody::IAssociationEnd::toAssociationswithoutProp(): uml::Association { - var assoEnd:Set(umlrhapsody::IAssociationEnd) =inModel.rootObjects()[IProject].defaultSubsystem[ISubsystem].Classes[IClass].Associations[IAssociationEnd]->select(assoEnd: IAssociationEnd |not (assoEnd.oclAsType(IAssociationEnd).inverse.oclIsUndefined()))->asSet(); - memberEnd:=assoEnd.map toAssociationsEnd(); -} - mapping umlrhapsody::IAssociationEnd::toAssociationswithProp(): uml::Association { //please keep this order (O source and 1 target) -> if we change this property we broke the BDD of test2 var localMemberEnd:=self.map toAssociationsEnd(); memberEnd+= localMemberEnd; - var localOwnedEnd:=self.map toOwnedAssociationEnd(); + var localOwnedEnd:= object Property{ + type:= self.container().oclAsType(EObject).map generalMappingToUMLElement().oclAsType(Type); + }; ownedEnd+= localOwnedEnd; name:=localOwnedEnd.type.name + " refers to " + localMemberEnd.type.name + " as " + localMemberEnd.name; } -mapping umlrhapsody::IAssociationEnd::toOwnedAssociationEnd(): uml::Property{ - type:= self.container().oclAsType(EObject).map generalMappingToUMLElement().oclAsType(Type); - var type : uml::Class = type.oclAsType(Class); -} - mapping umlrhapsody::IAssociationEnd::toAssociationsEnd(): uml::Property when{self.oclIsTypeOf(IAssociationEnd)}{ name:=self.name.replaceAll("\"",""); type:= self.otherClass.oclAsType(EObject).map generalMappingToUMLElement().oclAsType(Type); aggregation:=AggregationKind::none; } -mapping umlrhapsody::IClass::fromClasse2Associations(): uml::Association -{ - -//TODO FIXME: default subsystem : bad code -var classes : Set(uml::Class) :=inModel.rootObjects()[IProject].defaultSubsystem[ISubsystem].Classes->selectByKind(EObject).map iClassToUMLClass()->asSet(); -var associations: Set(uml::Association); -var i : Integer=0; -classes->forEach(element) -{ -var newasso: uml::Association; - // collect the classes with AssociationEnd and create an association with both classes - if (not (element.oclAsType(IClass).Associations[IAssociationEnd]->isEmpty())) - then - { - newasso := object uml::Association - - { - var otherClass : IClass:= element.oclAsType(IClass).Associations[IAssociationEnd].otherClass->any(true).oclAsType(IClass); - memberEnd+= element.oclAsType(IClass).Associations[IAssociationEnd].map toAssociationsEnd(); - memberEnd+= otherClass.Associations[IAssociationEnd].map toAssociationsEnd(); - memberEnd->asSet(); - - }; - if (i=0){ - associations+=newasso; - i:= i+1; - }; - - if (not (associations->isEmpty())) - { - associations->forEach(asso) - { - if( not (asso.memberEnd->includesAll(newasso.memberEnd))) - associations+=newasso; - - } - }endif; - - }endif; - - - - }; - -} - /** * * This mapping convert a IPart into a uml Element diff --git a/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/SemanticInternationalization.qvto b/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/SemanticInternationalization.qvto index d8bc95415e8..3bb18871668 100755 --- a/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/SemanticInternationalization.qvto +++ b/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/SemanticInternationalization.qvto @@ -321,11 +321,6 @@ helper NamedElement::getRhaposdyLabel():String{ // rpyElement:=self.invresolveoneIn(IAssociationEnd::toAssociationsEnd)->selectByKind(IModelElement)->any(true); // }; - //mapping umlrhapsody::IClass::fromClasse2Associations(): uml::Association - if(rpyElement=null){ - rpyElement:=self.invresolveoneIn(IClass::fromClasse2Associations)->selectByKind(IModelElement)->any(true); - }; - //mapping umlrhapsody::IGeneralization::toPapyrusGeneralization(): uml::Generalization if(rpyElement=null){ rpyElement:=self.invresolveoneIn(IGeneralization::toPapyrusGeneralization)->selectByKind(IModelElement)->any(true); diff --git a/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/SysML11BlockDefinitionDiagram.qvto b/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/SysML11BlockDefinitionDiagram.qvto index 543ccc01752..781c6ee6390 100644 --- a/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/SysML11BlockDefinitionDiagram.qvto +++ b/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/SysML11BlockDefinitionDiagram.qvto @@ -667,9 +667,6 @@ mapping umlrhapsody::CGIAssociationEnd::toSysML11BDDAssociationEdge() : Connecto var association:Association:=null; if(rpySemanticElement.oclIsTypeOf(IAssociationEnd)){ association:=self.m_pModelObject.resolveoneIn(umlrhapsody::IAssociationEnd::toAssociationswithProp, uml::Association); - if (association=null){ - association := self.m_pModelObject.resolveoneIn(umlrhapsody::IAssociationEnd::toAssociationswithoutProp, uml::Association); - }; }elif(rpySemanticElement.oclIsTypeOf(IPart)){ association:=self.m_pModelObject.resolveoneIn(umlrhapsody::IPart::iPartToUMLAssociation, uml::Association).oclAsType(Association); }; |