Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Lorenzo2017-01-24 10:20:04 -0500
committervincent lorenzo2017-01-24 11:47:17 -0500
commit98273f637af98256817506a61136afd330784b83 (patch)
tree7b32f6b64873e53d8d39886c7a2ab6c0df91d4af
parent8f242fb8f157e50f25f03de822996cc903a411cd (diff)
downloadorg.eclipse.papyrus-98273f637af98256817506a61136afd330784b83.tar.gz
org.eclipse.papyrus-98273f637af98256817506a61136afd330784b83.tar.xz
org.eclipse.papyrus-98273f637af98256817506a61136afd330784b83.zip
Bug 510960: [Importer][Rhapsody] Unit for value type stereotype is not always defined
Change-Id: Ic54a3f057ba683c704f92617ba4885a314339e16 Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
-rw-r--r--extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/SysML11Profile.qvto577
1 files changed, 287 insertions, 290 deletions
diff --git a/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/SysML11Profile.qvto b/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/SysML11Profile.qvto
index 7ac86c53026..2eab4fe4c17 100644
--- a/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/SysML11Profile.qvto
+++ b/extraplugins/migration/rhapsody/org.eclipse.papyrus.migration.rhapsody/transform/SysML11Profile.qvto
@@ -29,6 +29,7 @@ modeltype UMLPrimitivesTypes "strict" uses 'http://www.eclipse.org/uml2/5.0.0/Ty
*
* WARNING : ISysMLPort is a part of Rhapsody metamodel and doesn't come from the SysML Rhapsody Profile
*
+*
*/
transformation SysML11Profile(in inModel:umlrhapsody, out outModel:uml, in Sysml11Profile:sysml11, in primitives:UMLPrimitivesTypes)
extends Rhapsody2PapyrusSemanticElements(in inModel:umlrhapsody, out outModel:uml, in primitives:UMLPrimitivesTypes)
@@ -46,385 +47,381 @@ extends Rhapsody2PapyrusSemanticElements(in inModel:umlrhapsody, out outModel:um
sysml11Profiles->forEach(profile) {
model.applyProfile(profile);
};
-
- //transform the Rhapsody SysML applied sterotype to Papyrus SysML applied sterotype
- //inModel.rootObjects()[IProject].defaultSubsystem[ISubsystem].map toSysML11PapyrusProfile();
+
+ //apply SysML 1.1 stereotype when it is applied in Rhapsody Model
+ inModel.objects()->select(rpy | not rpy.oclIsKindOf( GraphElementsType))->selectByKind(EObject).map applyRequiredSysML11Stereotype();
+
+ //apply NestedConnectorEnd stereotype
+ outModel.objects()->selectByKind(uml::ConnectorEnd).map applySysML11ConnectorEndStereotype();
- inModel.rootObjects()[IProject].Subsystems.map toSysML11PapyrusProfile();
log("End SysML Profiles and Stereotypes Application");
};
};
}
/**
+* This mapping create the NestedConnectorEnd stereotype when required for the given object
*
-* This method cross all contents and applied SysML stereotypes when required
*/
-mapping DefaultSubsystemType::toSysML11PapyrusProfile() when{self.oclIsTypeOf(ISubsystem)}{
- var allContents:=getAllUMLSemanticElementAsList(self.oclAsType(EObject))->asSequence();
-
- //1. we apply all required SysML
- allContents->forEach(current){
- current.oclAsType(EObject).map applyRequiredStereotypes();
- };
-
- //2. we do additional stuff : when some property of stereotypes must be set, referencing others stereotypes applications!
- allContents->selectByType(IType)->forEach(iType){
- iType.manageUnitStereotype();
- };
-
- allContents->selectByType(IType)->forEach(iType){
- iType.manageValueTypeStereotype();
- };
-
- //3. we apply stereotype NestedConnectorEnd when required
- var allConnectorEnd:Sequence(uml::ConnectorEnd):=getAllConnectorEnds(outModel.rootObjects()->selectByKind(Package)->any(true).oclAsType(Element));
- allConnectorEnd->forEach(connectorEnd){
- var path:Sequence(uml::Property)=getNestedConnectorEndPropertyPath(connectorEnd);
- if(path->size()>0){
- var stereotype:uml::Stereotype:=getSysML11Stereotype("NestedConnectorEnd");
- connectorEnd.applyStereotype(stereotype);
- var appliedStereotype:uml::Stereotype:=connectorEnd.getAppliedStereotype(stereotype.getQualifiedName());
- connectorEnd.setValue(appliedStereotype, "propertyPath", path);
- };
- };
+mapping uml::ConnectorEnd::applySysML11ConnectorEndStereotype() : sysml11::blocks::NestedConnectorEnd when {getNestedConnectorEndPropertyPath(self)->size()>0}{
+ base_ConnectorEnd:=self;
+ propertyPath:=getNestedConnectorEndPropertyPath(self);
}
+
/**
*
-* This mapping allows to apply required stereotypes on the managed elements
+* Return true if the Rhapsody SysML Profile is applied on the Rhapsody model
*/
-mapping EObject::applyRequiredStereotypes() disjuncts
- EObject::iClassApplyStereotypes,
- EObject::iPartApplyStereotypes,
- EObject::iSysMLPortApplyStereotype,
- EObject::iAttributeApplyStereotype,
- EObject::iTypeApplyStereotypes,
- EObject::iInformationFlowApplyStereotypes
+query isRhapsodySysMLProfileApplied():Boolean {
+ var ret:Boolean = false;
+ var isProfiledModel:Boolean:=inModel.objectsOfType(IStereotype)->size()>0;
+ if (isProfiledModel) {
+ inModel.objectsOfType(IStereotype)->forEach(stereotype){
+ if(stereotype.isARhapsodySysMLStereotype()){
+ ret:= true;
+ break;
+ }
+ }
+ };
+ return ret;
+}
+
+
+//--------------------------Here we are working on the Rhapsody Stereotypes--------------
+
+/**
+* This method manage the stereotype application from Rhapsody to Papyrus for a set of Rhapsody element
+*
+* TODO : edit the Rhapsody metamodel to get a common ancestor to manipulate easily the stereotyped element in Rhapsody
+*/
+mapping ecore::EObject::applyRequiredSysML11Stereotype() disjuncts
+ ecore::EObject::applyStereotypeFromIClass,
+ ecore::EObject::applyStereotypeFromIType_To_InstanceSpecification,
+ ecore::EObject::applyStereotypeFromIType_To_DataType,
+ ecore::EObject::applyStereotypeFromIType_To_Class,
+ ecore::EObject::applyStereotypeFromIType_To_Type,
+ ecore::EObject::applyStereotypeFromISysMLPort,
+ ecore::EObject::applyStereotypeFromIPart,
+ ecore::EObject::applyStereotypeFromIAttribute,
+ ecore::EObject::applyStereotypeFromIInformationFlow
{}
/**
-* Apply required stereotype on UML element created from Rhapsody IClass
+* This method cross the stereotypes applied on the IClass and call the method to apply them on the equivalent uml element
*/
-mapping EObject::iClassApplyStereotypes() when {self.oclIsTypeOf(IClass) and not self.oclAsType(IClass).Stereotypes->isEmpty()}{
- var localIClass:IClass:=self.oclAsType(IClass);
- //1. we reapply all stereotypes applied on the rhapsody IClass
- var stereotypes:Set(IUnit):=localIClass.Stereotypes;
- stereotypes->forEach(stereotype){
- if (stereotype.oclIsTypeOf(IStereotype)){
- // map it to the papyrus sysml11 profile
- var papySysML11Ste:uml::Stereotype := stereotype[IStereotype].map toPapyrusSysML11Stereotype()->any(true);
- var umlElement:uml::Element:=localIClass.resolveIn(IClass::toUMLElement, uml::Element)![uml::Element];
- if(umlElement<>null and not(papySysML11Ste.oclIsUndefined()) and umlElement.isStereotypeApplicable(papySysML11Ste)){
- umlElement.applyStereotype(papySysML11Ste);
- };
+mapping ecore::EObject::applyStereotypeFromIClass() when {self.oclIsTypeOf(IClass) /*and not self.oclAsType(IClass).Stereotypes->isEmpty()*/}{ //test on stereotype must be done in the method, because we always need to do some thing for IClass
+ var rpyElement:IClass:=self.oclAsType(IClass);
+ //we look for the created uml element
+ var umlElement:Element:=rpyElement.resolveoneIn(IClass::toUMLElement, uml::Element);
+ if(umlElement<>null){
+ rpyElement.Stereotypes->selectByType(umlrhapsody::IStereotype)->forEach(current){
+ umlElement.map applySysML11Stereotype(rpyElement.oclAsType(EObject), getSysML11StereotypeName(current.name));
}
- };
-
- //2. required ?
- var nestedClassesForPart:Sequence(IClass):=localIClass.Associations[IPart]->select(current | current.implicitClass<>null).implicitClass.oclAsSet();
+ };
+
+ //apply Block and PropertySpecificType on some class
+ var nestedClassesForPart:Sequence(IClass):=rpyElement.Associations[IPart]->select(current | current.implicitClass<>null).implicitClass.oclAsSet();
nestedClassesForPart->forEach(current){
- current.resolveone().oclAsType(uml::Element).applyStereotype(getSysML11Stereotype("Block"));
- current.resolveone().oclAsType(uml::Element).applyStereotype(getSysML11Stereotype("PropertySpecificType"));
+ var umlClass:uml::Class:=current.resolveone().oclAsType(uml::Class);
+ umlClass.map applySysML11Stereotype(current.oclAsType(EObject), "Block");
+ umlClass.map applySysML11Stereotype(current.oclAsType(EObject), "PropertySpecificType");
};
}
/**
-* Apply required stereotype on UML element created from Rhapsody IPart
+* This method cross the stereotypes applied on the IType and call the method to apply them on the equivalent uml element
*/
-mapping EObject::iPartApplyStereotypes() when {self.oclIsTypeOf(IPart) and not self.oclAsType(IPart).Stereotypes->isEmpty()}{
- var localIPart:IPart:=self.oclAsType(IPart);
- var umlElement:Element:=localIPart.resolveoneIn(umlrhapsody::IPart::iPartToUMLElement);
- localIPart.Stereotypes[IStereotype]->forEach(iStereotype){
- applySysMLStereotype(iStereotype,umlElement);
- }
+mapping ecore::EObject::applyStereotypeFromIType_To_InstanceSpecification() when {self.oclIsTypeOf(IType) and not self.oclAsType(IType).Stereotypes->isEmpty() and self.oclAsType(IType).resolveoneIn(IType::toUMLInstanceSpecification, InstanceSpecification)<>null}{
+ var rpyElement:IType:=self.oclAsType(IType);
+ //we look for the created uml element
+ var umlElement:Element:=rpyElement.resolveoneIn(IType::toUMLInstanceSpecification, InstanceSpecification);
+ if(umlElement<>null){
+ rpyElement.Stereotypes->selectByType(umlrhapsody::IStereotype)->forEach(current){
+ umlElement.map applySysML11Stereotype(rpyElement.oclAsType(EObject), getSysML11StereotypeName(current.name));
+ }
+ }
}
/**
-*
-* Apply after several checks the SysML 1.1 stereotype to the UML element. We check:
-*<ul>
-*<li>rpyStereotype<>null </li>
-*<li>umlElement<>null </li>
-*<li>SysML 1.1 Stereotype<>null</li>
-*<li>umlElement.isStereotypeApplicable()(</li>
-*</ul>
+* This method cross the stereotypes applied on the IType and call the method to apply them on the equivalent uml element
*/
-//TODO : use me in all location
-query applySysMLStereotype(rpyStereotype:IStereotype, umlElement:Element):EObject{
+mapping ecore::EObject::applyStereotypeFromIType_To_DataType() when {self.oclIsTypeOf(IType) and not self.oclAsType(IType).Stereotypes->isEmpty() and self.oclAsType(IType).resolveoneIn(IType::toUMLDatatype, DataType)<>null}{
+ var rpyElement:IType:=self.oclAsType(IType);
+ //we look for the created uml element
+ var umlElement:Element:=rpyElement.resolveoneIn(IType::toUMLDatatype, DataType);
if(umlElement<>null){
- var umlStereotype:Stereotype:=rpyStereotype.map toPapyrusSysML11Stereotype();
- if(umlStereotype<>null){
- if(umlElement.isStereotypeApplicable(umlStereotype)){
- return umlElement.applyStereotype(umlStereotype);
- }
- };
- };
- return null;
-};
+ rpyElement.Stereotypes->selectByType(umlrhapsody::IStereotype)->forEach(current){
+ umlElement.map applySysML11Stereotype(rpyElement.oclAsType(EObject), getSysML11StereotypeName(current.name));
+ }
+ }
+}
+//TODO umlDataType and umlClass are probably useless now, waiting for JUnit tests to remove them from this method
/**
-* Apply required stereotype on UML element created from Rhapsody ISysMLPort
+* This method cross the stereotypes applied on the IType and call the method to apply them on the equivalent uml element
*/
-mapping EObject::iSysMLPortApplyStereotype() when {self.oclIsTypeOf(ISysMLPort) and not self.oclAsType(ISysMLPort).Stereotypes->isEmpty()}{
- var res:uml::Element:=self.resolveoneIn(umlrhapsody::IRelation::iRelationToUMLElement);
- if(res<>null){
- var isysmlPort:umlrhapsody::ISysMLPort:=self.oclAsType(ISysMLPort);
- isysmlPort.Stereotypes->forEach(istereotype){
- isysmlPort.map applyIStereotypeToUMLElement(res, istereotype.oclAsType(IStereotype));
- }
- }
+mapping ecore::EObject::applyStereotypeFromIType_To_Class() when {self.oclIsTypeOf(IType) and not self.oclAsType(IType).Stereotypes->isEmpty() and self.oclAsType(IType).resolveoneIn(IType::iTypeToUMLClass, Class)<>null}{
+ var rpyElement:IType:=self.oclAsType(IType);
+ //we look for the created uml element
+ var umlElement:Element:=rpyElement.resolveoneIn(IType::iTypeToUMLClass, Class);
+ if(umlElement<>null){
+ rpyElement.Stereotypes->selectByType(umlrhapsody::IStereotype)->forEach(current){
+ umlElement.map applySysML11Stereotype(rpyElement.oclAsType(EObject), getSysML11StereotypeName(current.name));
+ };
+
+ //in all case, we apply block on the class
+ umlElement.map applySysML11Stereotype(rpyElement.oclAsType(EObject), getSysML11StereotypeName("Block"));
+ }
}
/**
-* Apply required stereotype on UML element created from Rhapsody IAttribute
+* This method cross the stereotypes applied on the IType and call the method to apply them on the equivalent uml element
*/
-mapping EObject::iAttributeApplyStereotype() when {self.oclIsTypeOf(IAttribute) and not self.oclAsType(IAttribute).Stereotypes->isEmpty()}{
- var tmpAttribute:IAttribute:=self.oclAsType(IAttribute);
- tmpAttribute.Stereotypes->forEach(stereotype){
- if (stereotype.oclIsTypeOf(IStereotype)){
- var papySysML11Ste:uml::Stereotype := stereotype[IStereotype].map toPapyrusSysML11Stereotype()->any(true);
- var umlElement:uml::Element:=tmpAttribute.resolveIn(IVariable::iVariableToUMLElement, uml::Property)![uml::Property];
- if(not(papySysML11Ste.oclIsUndefined()) and umlElement.isStereotypeApplicable(papySysML11Ste)){
- umlElement.applyStereotype(papySysML11Ste);
- };
-
- if(stereotype.oclAsType(IStereotype).name="flowProperty"){
- //it seems that the value of the property for a stereotype are not owned by the stereotype application in Rhapsody, but in a tag
- var allValueSpec:=tmpAttribute.Tags->select(t | t.name="direction")->select( t2 | t2.typeOf.oclAsType(IType).name.toLower()="flowdirection")->any(true).ValueSpecifications;
- var directionValue:String:=allValueSpec->select(v | v.oclIsKindOf(ILiteralSpecification))->any(true).oclAsType(ILiteralSpecification).value;
- if(directionValue.oclIsUndefined()){
- //it seems there are 2 ways to define it!
- allValueSpec:=tmpAttribute.Tags->select(t | t.name="direction")->select( t2 | t2.typeOf.oclAsType(IType).name="RhpString")->any(true).ValueSpecifications;
- directionValue:=allValueSpec->select(v | v.oclIsKindOf(ILiteralSpecification))->any(true).oclAsType(ILiteralSpecification).value;
- };
- //SysML : we set the value direction!
- umlElement.setValue(umlElement.getAppliedStereotype(papySysML11Ste.getQualifiedName()), "direction", getSysML11FlowDirection(directionValue));
- }
- }
- }
+mapping ecore::EObject::applyStereotypeFromIType_To_Type() when {self.oclIsTypeOf(IType) and not self.oclAsType(IType).Stereotypes->isEmpty() and self.oclAsType(IType).resolveoneIn(IType::iTypeToUMLElement, Type)<>null}{
+ var rpyElement:IType:=self.oclAsType(IType);
+ //we look for the created uml element
+ var umlElement:Element:=rpyElement.resolveoneIn(IType::iTypeToUMLElement, Type);
+ if(umlElement<>null){
+ rpyElement.Stereotypes->selectByType(umlrhapsody::IStereotype)->forEach(current){
+ umlElement.map applySysML11Stereotype(rpyElement.oclAsType(EObject), getSysML11StereotypeName(current.name));
+ }
+ }
}
/**
-* Apply required stereotype on UML element created from Rhapsody IType
+* This method cross the stereotypes applied on the ISysMLPort and call the method to apply them on the equivalent uml element
*/
-mapping EObject::iTypeApplyStereotypes() when {self.oclIsTypeOf(IType) and not self.oclAsType(IType).Stereotypes->isEmpty()}{
- var localIType:IType:=self.oclAsType(IType);
-
-
- //there are several ways to map IType!!!
- var umlInstanceSpec:uml::InstanceSpecification:=localIType.resolveIn(IType::toUMLInstanceSpecification, InstanceSpecification)![InstanceSpecification];
- var umlDatatType:uml::DataType:=localIType.resolveIn(IType::toUMLDatatype, DataType)![DataType];
- var umlClass:uml::Class:=localIType.resolveIn(IType::iTypeToUMLClass, Class)![Class];
-
- //TODO umlDataType and umlClass are probably useless now, waiting for JUnit tests to remove them from this method
- var umlType:uml::Type:=localIType.resolveIn(IType::iTypeToUMLElement, Type)![Type];
- localIType.Stereotypes[IStereotype]->select(currentSte | currentSte.name<>"DataType")->forEach(stereotype){//datatype stereotype doesn't exists in SysML 1.1
- var papySysML11Ste:uml::Stereotype := stereotype[IStereotype].map toPapyrusSysML11Stereotype()->any(true);
- if(papySysML11Ste<>null){
- if(umlInstanceSpec<>null and umlInstanceSpec.isStereotypeApplicable(papySysML11Ste)){
- umlInstanceSpec.applyStereotype(papySysML11Ste);
- }elif(umlDatatType<>null and umlDatatType.isStereotypeApplicable(papySysML11Ste)){
- umlDatatType.applyStereotype(papySysML11Ste);
- }elif(umlClass<>null and umlClass.isStereotypeApplicable(papySysML11Ste)){
- umlClass.applyStereotype(papySysML11Ste);
- }elif(umlType<>null and umlType.isStereotypeApplicable(papySysML11Ste)){
- umlType.applyStereotype(papySysML11Ste);
- };
- };
- };
- //in all cases, if the IType has been map on a Class, we apply the Block stereotype
- if(umlClass<>null){
- var blockSte = getSysML11Stereotype("Block");
- if(umlClass.isStereotypeApplicable(blockSte)){
- umlClass.applyStereotype(blockSte);
- }
+mapping ecore::EObject::applyStereotypeFromISysMLPort() when {self.oclIsTypeOf(ISysMLPort) and not self.oclAsType(ISysMLPort).Stereotypes->isEmpty()}{
+ var rpyElement:ISysMLPort:=self.oclAsType(ISysMLPort);
+ //we look for the created uml element
+ var umlElement:Element:=rpyElement.resolveoneIn(umlrhapsody::IRelation::iRelationToUMLElement);
+ if(umlElement<>null){
+ rpyElement.Stereotypes->selectByType(umlrhapsody::IStereotype)->forEach(current){
+ umlElement.map applySysML11Stereotype(rpyElement.oclAsType(EObject), getSysML11StereotypeName(current.name));
+ }
}
-
}
/**
-* Helper used to set fields of SysML Unit stereotype
+* This method cross the stereotypes applied on the IPart and call the method to apply them on the equivalent uml element
*/
-helper umlrhapsody::IType::manageUnitStereotype(){
- //if the Rhapsody stereotype is Unit, we set the field dimension
- var rpyUnit:IStereotype:=self.Stereotypes->selectByKind(IStereotype)->select(ste | ste.name="Unit")->any(true);
- var umlInstanceSpec:uml::InstanceSpecification:=self.resolveIn(IType::toUMLInstanceSpecification, InstanceSpecification)![InstanceSpecification];
- if(umlInstanceSpec<>null){
- var tt=self.Tags->select(t | t.name="dimension")->any(true);
- if(tt<>null){
- var iinstancespec:umlrhapsody::IInstanceValue=tt.oclAsType(umlrhapsody::ITag).ValueSpecifications -> select(curr | curr.oclIsKindOf(umlrhapsody::IInstanceValue))->any(true).oclAsType(IInstanceValue);
- if(iinstancespec<>null){
- var val = iinstancespec.value;
- var res:uml::InstanceSpecification = val.resolveoneIn(IType::toUMLInstanceSpecification);
- var dimensionAppliedSte:uml::Stereotype=res.getAppliedStereotype("SysML::Blocks::Dimension");
- var dimensionSteAppl:ecore::EObject=res.getStereotypeApplication(dimensionAppliedSte);
-
- var unitAppliedSte:uml::Stereotype=umlInstanceSpec.getAppliedStereotype("SysML::Blocks::Unit");
- umlInstanceSpec.setValue(unitAppliedSte,"dimension",dimensionSteAppl);
- }
- };
- };
+mapping ecore::EObject::applyStereotypeFromIPart() when {self.oclIsTypeOf(IPart) and not self.oclAsType(IPart).Stereotypes->isEmpty()}{
+ var rpyElement:IPart:=self.oclAsType(IPart);
+ //we look for the created uml element
+ var umlElement:Element:=rpyElement.resolveoneIn(umlrhapsody::IPart::iPartToUMLElement);
+ if(umlElement<>null){
+ rpyElement.Stereotypes->selectByType(umlrhapsody::IStereotype)->forEach(current){
+ umlElement.map applySysML11Stereotype(rpyElement.oclAsType(EObject), getSysML11StereotypeName(current.name));
+ }
+ }
}
-
/**
-* Helper used to set fields of SysML ValueType stereotype
+* This method cross the stereotypes applied on the IAttribute and call the method to apply them on the equivalent uml element
*/
-helper umlrhapsody::IType::manageValueTypeStereotype(){
-//if the Rhapsody stereotype is Unit, we set the field dimension and unit //TODO : update this comment with the good stereotype name
- var rpyValueType:IStereotype:=self.Stereotypes->selectByKind(IStereotype)->select(ste | ste.name="ValueType")->any(true);
- if(rpyValueType<>null){
- var type:uml::Type:=self.resolveIn(IType::iTypeToUMLElement, Type)![Type];
- if(type<>null){
- var tt=self.Tags->select(t | t.name="dimension")->any(true);
- var iinstancespec:umlrhapsody::IInstanceValue=tt.oclAsType(umlrhapsody::ITag).ValueSpecifications -> select(curr | curr.oclIsKindOf(umlrhapsody::IInstanceValue))->any(true).oclAsType(IInstanceValue);
- var val = iinstancespec.value;
-
- var res:uml::InstanceSpecification = val.resolveoneIn(IType::toUMLInstanceSpecification);
- if(res<>null){
-
- var dimensionAppliedSte:uml::Stereotype=res.getAppliedStereotype("SysML::Blocks::Dimension");
- if(dimensionAppliedSte<>null){
- var dimensionSteAppl:ecore::EObject=res.getStereotypeApplication(dimensionAppliedSte);
-
- var valueTypeAppliedSte:uml::Stereotype=type.getAppliedStereotype("SysML::Blocks::ValueType");
- if(valueTypeAppliedSte<>null){
- type.setValue(valueTypeAppliedSte,"dimension",dimensionSteAppl);
-
- var tt2=self.Tags->select(t | t.name="unit")->any(true);
- var iinstancespec2:umlrhapsody::IInstanceValue=tt2.oclAsType(umlrhapsody::ITag).ValueSpecifications -> select(curr | curr.oclIsKindOf(umlrhapsody::IInstanceValue))->any(true).oclAsType(IInstanceValue);
- var val2 = iinstancespec2.value;
-
- var res2:uml::InstanceSpecification = val2.resolveoneIn(IType::toUMLInstanceSpecification);
- if(res2<>null){
- var dimensionAppliedSte2:uml::Stereotype=res2.getAppliedStereotype("SysML::Blocks::Unit");
- var dimensionSteAppl2:ecore::EObject=res2.getStereotypeApplication(dimensionAppliedSte2);
- if(dimensionAppliedSte2<>null and dimensionSteAppl2<>null){
- type.setValue(valueTypeAppliedSte,"unit",dimensionSteAppl2);
- }
- }
- }
- }
- }
- }
- };
+mapping ecore::EObject::applyStereotypeFromIAttribute() when {self.oclIsTypeOf(IAttribute) and not self.oclAsType(IAttribute).Stereotypes->isEmpty()}{
+ var rpyElement:IAttribute:=self.oclAsType(IAttribute);
+ //we look for the created uml element
+ var umlElement:Element:=rpyElement.resolveoneIn(IVariable::iVariableToUMLElement, uml::Property);
+ if(umlElement<>null){
+ rpyElement.Stereotypes->selectByType(umlrhapsody::IStereotype)->forEach(current){
+ umlElement.map applySysML11Stereotype(rpyElement.oclAsType(EObject), getSysML11StereotypeName(current.name));
+ }
+ }
}
/**
-* Apply required stereotype on UML element created from Rhapsody IType
+* This method cross the stereotypes applied on the IInformationFlow and call the method to apply them on the equivalent uml element
*/
-mapping EObject::iInformationFlowApplyStereotypes() when {self.oclIsTypeOf(IInformationFlow) and not self.oclAsType(IInformationFlow).Stereotypes->isEmpty()}{
- var localIInformationFlow:IInformationFlow:=self.oclAsType(IInformationFlow);
- localIInformationFlow.Stereotypes[IStereotype]->forEach(iStereotype){
- localIInformationFlow.resolveoneIn(umlrhapsody::IInformationFlow::iInformationFlowToUMLElement).applyStereotype(getSysML11Stereotype(iStereotype.name));
- }
+mapping ecore::EObject::applyStereotypeFromIInformationFlow() when {self.oclIsTypeOf(IInformationFlow) and not self.oclAsType(IInformationFlow).Stereotypes->isEmpty()}{
+ var rpyElement:IInformationFlow:=self.oclAsType(IInformationFlow);
+ //we look for the created uml element
+ var umlElement:Element:=rpyElement.resolveoneIn(umlrhapsody::IInformationFlow::iInformationFlowToUMLElement);
+ if(umlElement<>null){
+ rpyElement.Stereotypes->selectByType(umlrhapsody::IStereotype)->forEach(current){
+ umlElement.map applySysML11Stereotype(rpyElement.oclAsType(EObject), getSysML11StereotypeName(current.name));
+ }
+ }
}
+
+//--------------------------Here we are working on the UML Stereotypes-------------------
/**
-*
-* This mapping is used to apply a Rhapsody IStereotype applied on a IRelation as a uml Stereotype on a Element
-*
-* Mapping is used to be able to make disjuncts!
-*
+* Common method to apply a UML stereotype from the rhapsody element and from its name to a UML Element
*/
-mapping umlrhapsody::IRelation::applyIStereotypeToUMLElement(element:uml::Element, istereotype:umlrhapsody::IStereotype):ecore::EObject disjuncts
- umlrhapsody::IRelation::applySysML11FlowPortToUMLElement
+mapping uml::Element::applySysML11Stereotype(rpyElement:EObject, umlSteName:String):EObject disjuncts
+ uml::DataType::applySysML11ValueType,
+ uml::InstanceSpecification::applySysML11Dimension,
+ uml::InstanceSpecification::applySysML11Unit,
+ uml::Class::applySysML11Block,
+ uml::Property::applySysML11FlowProperty,
+ uml::Port::applySysML11FlowPort,
+
+ //default mapping method
+ uml::Element::applySysML11Stereotype_DefaultMapping
{}
/**
-* Map a irelation onto a stereotype application
-* Mapping is used instead of query to be able to call disjunct
-*
+* Default mapping to apply Sysml11 stereotype
+*
*/
-mapping umlrhapsody::IRelation::applySysML11FlowPortToUMLElement(element:uml::Element, istereotype:umlrhapsody::IStereotype):ecore::EObject when {element.oclIsKindOf(uml::Port) and istereotype<>null and istereotype.isARhapsodySysMLStereotype() and istereotype.name="flowPort" and self.oclIsKindOf(umlrhapsody::ISysMLPort) and getSysML11Stereotype(istereotype.name)<>null}{
+mapping uml::Element::applySysML11Stereotype_DefaultMapping(rpyElement:EObject, umlSteName:String):EObject when {getSysML11Stereotype(umlSteName)<>null}{
init {
- var steToApply:Stereotype:=istereotype.map toPapyrusSysML11Stereotype(); //<> null already checked in the when condition
- result:=element.applyStereotype(steToApply);
- var realAppliedStereotype:Stereotype:=element.getAppliedStereotype(steToApply.getQualifiedName());
- element.setValue(realAppliedStereotype, "direction", getSysML11FlowDirection(self.oclAsType(ISysMLPort).direction));
- element.setValue(realAppliedStereotype, "isConjugated", self.oclAsType(ISysMLPort).isConjugated());
+ var stereotypeToApply:Stereotype:=getSysML11Stereotype(umlSteName);
+ self.applyStereotype(stereotypeToApply);
+ result:=self.getAppliedStereotype(stereotypeToApply.getQualifiedName()).oclAsType(EObject);
}
}
/**
*
-* This method convert the rhaspody flow direction into the SysML FlowDirection
-*/
-query getSysML11FlowDirection(rpyDirection:String) : String{
- var direction: String :="inout";
- direction:= switch {
- case (rpyDirection="In") "in";
- case (rpyDirection="Out") "out";
- case (rpyDirection="InOut") "inout";
- case (rpyDirection="Bidirectional") "inout";
- };
- return direction;
+* This method apply the stereotype SysML FlowPort
+*/
+mapping uml::Port::applySysML11FlowPort(rpyElement:EObject, stereotypeName:String):EObject when{rpyElement.oclIsKindOf(ISysMLPort) and stereotypeName="FlowPort"}{
+ init{
+ var stereotypeApplication:sysml11::portandflows::FlowPort:= object sysml11::portandflows::FlowPort{
+ base_Port:=self;
+ direction:=getSysML11FlowDirection(rpyElement.oclAsType(ISysMLPort).direction);
+ isConjugated:=rpyElement.oclAsType(ISysMLPort).isConjugated();
+ };
+ result:=stereotypeApplication.oclAsType(EObject);
+ }
}
-
/**
-* Map a Rhapsody SysML Stereotype on a (Papyrus) SysML Stereotype when this one exists
-*
+*
+* This method apply the stereotype SysML FlowPort
*/
-mapping IStereotype::toPapyrusSysML11Stereotype() : uml::Stereotype when {self.name<>null and self.isARhapsodySysMLStereotype() and getSysML11Stereotype(self.name)<>null}{
+mapping uml::Property::applySysML11FlowProperty(rpyElement:EObject, stereotypeName:String):EObject when{rpyElement.oclIsKindOf(IAttribute) and stereotypeName="FlowProperty"}{
init{
- result := getSysML11Stereotype(self.name);
+ var stereotypeApplication:sysml11::portandflows::FlowProperty:= object sysml11::portandflows::FlowProperty{
+ base_Property:=self;
+
+ //we have model with 2 kind of declaration for the same thing...
+ //the first way!
+ var dir:String:=rpyElement.oclAsType(IAttribute).Tags->select(t | (t.name="direction" and t.typeOf.oclAsType(IType).name="FlowDirection"))
+ ->any(true).ValueSpecifications->any(true).oclAsType(ILiteralSpecification).value;
+
+ //the 2nd way when required
+ if(dir=null){
+ dir:=rpyElement.oclAsType(IAttribute).Tags->select(t | (t.name="direction" and t.typeOf.oclAsType(IType).name="RhpString")) //probably due to an error in the model
+ ->any(true).ValueSpecifications->any(true).oclAsType(ILiteralSpecification).value;
+ };
+ direction:=getSysML11FlowDirection(dir);
+ };
+ result:=stereotypeApplication.oclAsType(EObject);
}
}
/**
-*
-* Return the SysML 1.1 Stereotype for the given string or null if not found
+* This method apply the stereotype Block
*/
-query getSysML11Stereotype(s:String ) :uml::Stereotype { //TODO : replace all calls to me by the mapping!
- var stereotype: uml::Stereotype = null;
- stereotype:= switch {
- case (s="flowSpecification") Sysml11Profile.objectsOfType(Stereotype)![name = "FlowSpecification"];
- case (s="flowProperty") Sysml11Profile.objectsOfType(Stereotype)![name = "FlowProperty"];
- case (s="flowPort") Sysml11Profile.objectsOfType(Stereotype)![name = "FlowPort"];
-
- //all case where the Rhapsody SysML Stereotype name is the same than the Papyrus SysML Name
- case (true) Sysml11Profile.objectsOfType(Stereotype)![name = s];
-
- };
- return stereotype;
+mapping uml::Class::applySysML11Block(rpyElement:EObject, stereotypeName:String):EObject when{stereotypeName="Block"}{
+ init{
+ var stereotypeApplication:sysml11::blocks::Block:= object sysml11::blocks::Block{
+ base_Class:=self;
+ };
+ result:=stereotypeApplication.oclAsType(EObject);
+ }
}
+/**
+* This method apply the stereotype Dimension
+*/
+mapping uml::InstanceSpecification::applySysML11Dimension(rpyElement:EObject, umlSteName:String):EObject when {umlSteName="Dimension"}{
+ init{
+ var stereotypeApplication:sysml11::blocks::Dimension:= object sysml11::blocks::Dimension{
+ base_InstanceSpecification:=self;
+ };
+ result:=stereotypeApplication.oclAsType(EObject);
+ }
+}
/**
-*
-* Return true if the Rhapsody SysML Profile is applied on the Rhapsody model
+* This method apply the stereotype Unit
*/
-query isRhapsodySysMLProfileApplied():Boolean {
- var ret:Boolean = false;
- var isProfiledModel:Boolean:=inModel.objectsOfType(IStereotype)->size()>0;
- if (isProfiledModel) {
- inModel.objectsOfType(IStereotype)->forEach(stereotype){
- if(stereotype.isARhapsodySysMLStereotype()){
- ret:= true;
- break;
+mapping uml::InstanceSpecification::applySysML11Unit(rpyElement:EObject, umlSteName:String):EObject when {umlSteName="Unit" and rpyElement.oclIsKindOf(IType)}{
+ init{
+ var stereotypeApplication:sysml11::blocks::Unit:= object sysml11::blocks::Unit{
+ base_InstanceSpecification:=self;
+
+ //manage the dimension field
+ var tt:umlrhapsody::ITag=rpyElement.oclAsType(IType).Tags->select(t | t.name="dimension")->any(true);
+ var iinstancespec:umlrhapsody::IInstanceValue=tt.ValueSpecifications->selectByKind(umlrhapsody::IInstanceValue)->any(true);
+ if(iinstancespec<>null){
+ var val = iinstancespec.value;
+ var res:uml::InstanceSpecification = val.resolveoneIn(IType::toUMLInstanceSpecification);
+ dimension:=res.map applySysML11Stereotype(val.oclAsType(EObject),"Dimension").oclAsType(sysml11::blocks::Dimension);
}
- }
- };
- return ret;
+ };
+ result:=stereotypeApplication.oclAsType(EObject);
+ }
+}
+
+mapping uml::DataType::applySysML11ValueType(rpyElement:EObject, umlSteName:String):EObject when {umlSteName="ValueType" and rpyElement.oclIsKindOf(IType)}{
+ init{
+ var stereotypeApplication:sysml11::blocks::ValueType:= object sysml11::blocks::ValueType{
+ base_DataType:=self;
+
+ //manage the dimension field
+ var dimensionTag:umlrhapsody::ITag=rpyElement.oclAsType(IType).Tags->select(t | t.name="dimension")->any(true);
+ var dimensionInstanceIInstancespec:umlrhapsody::IInstanceValue=dimensionTag.ValueSpecifications -> selectByKind(umlrhapsody::IInstanceValue)->any(true);
+ if(dimensionInstanceIInstancespec<>null){
+ var val = dimensionInstanceIInstancespec.value;
+ var res:uml::InstanceSpecification = val.resolveoneIn(IType::toUMLInstanceSpecification);
+ dimension:=res.map applySysML11Stereotype(val.oclAsType(EObject),"Dimension").oclAsType(sysml11::blocks::Dimension);
+ };
+
+ //manage the unit field
+ var unitTag:umlrhapsody::ITag=rpyElement.oclAsType(IType).Tags->select(t | t.name="unit")->any(true);
+ var unitInstanceIInstancespec:umlrhapsody::IInstanceValue=unitTag.ValueSpecifications -> selectByKind(umlrhapsody::IInstanceValue)->any(true);
+ if(unitInstanceIInstancespec<>null){
+ var val = unitInstanceIInstancespec.value;
+ var res:uml::InstanceSpecification = val.resolveoneIn(IType::toUMLInstanceSpecification);
+ unit:=res.map applySysML11Stereotype(val.oclAsType(EObject),"Unit").oclAsType(sysml11::blocks::Unit);
+ };
+ };
+ result:=stereotypeApplication.oclAsType(EObject);
+ }
}
+
/**
-* Return true if the IStereotype comes from the SysML Rhapsody profile (or must be mapped in a SysML Profile in Papyrus)
*
+* Return the SysML 1.1 Stereotype for the given string or null if not found
*/
-query umlrhapsody::IStereotype::isARhapsodySysMLStereotype():Boolean{
- var ret:Boolean:=false;
- var profileresource:EResource:=self[EObject].eResource()![EResource];
- if(profileresource<>null){
- ret:=profileresource.toString().endsWith("SysML.umlrhapsody'")
- };
- if(not ret){
- var steName:String:=self.name;
- ret:=profileresource.toString().endsWith("PredefinedTypes.umlrhapsody'") and steName.equalsIgnoreCase("flowPort");
- };
- return ret;
+query getSysML11Stereotype(rpyStereotypeName:String ) :uml::Stereotype {
+ return Sysml11Profile.objectsOfType(Stereotype)![name=getSysML11StereotypeName(rpyStereotypeName)];
}
+/**
+* Return the SysML 1.1 name corresponding to the Rhapsody SysML Name
+*/
+query getSysML11StereotypeName(rpyStereotypeName:String): String{
+ var sysml11SteName:=switch{
+ case (rpyStereotypeName="flowSpecification") "FlowSpecification";
+ case (rpyStereotypeName="flowProperty") "FlowProperty";
+ case (rpyStereotypeName="flowPort") "FlowPort";
+
+ //all case where the Rhapsody SysML Stereotype name is the same than the Papyrus SysML Name
+ case (true) rpyStereotypeName;
+ };
+ return sysml11SteName
+}
+/**
+*
+* This method convert the rhaspody flow direction into the SysML FlowDirection
+*/
+query getSysML11FlowDirection(rpyDirection:String) : sysml11::portandflows::FlowDirection{
+ var direction: sysml11::portandflows::FlowDirection;
+ direction:= switch {
+ case (rpyDirection="In") sysml11::portandflows::FlowDirection::_in;
+ case (rpyDirection="Out") sysml11::portandflows::FlowDirection::_out;
+ case (rpyDirection="InOut") sysml11::portandflows::FlowDirection::_inout;
+ case (rpyDirection="Bidirectional") sysml11::portandflows::FlowDirection::_inout;
+ case (true) sysml11::portandflows::FlowDirection::_inout;
+ };
+ return direction;
+}

Back to the top