| /***************************************************************************** |
| * Copyright (c) 2017 CEA LIST and others. |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * Nicolas FAUVERGUE (CEA LIST) nicolas.fauvergue@cea.fr - Initial API and implementation |
| *****************************************************************************/ |
| |
| import org.eclipse.papyrus.uml.m2m.qvto.common.blackboxes.ecore.EcoreHelper; |
| import org.eclipse.papyrus.interoperability.sysml14.sysml.blackboxes.sysml.SysMLBlackboxHelper; |
| import org.eclipse.papyrus.interoperability.sysml14.sysml.SysMLUtils; |
| |
| modeltype UML "strict" uses 'http://www.eclipse.org/uml2/5.0.0/UML'; |
| modeltype ecore "strict" uses 'http://www.eclipse.org/emf/2002/Ecore'; |
| modeltype SysML11 "strict" uses 'http://www.eclipse.org/papyrus/0.7.0/SysML'; |
| modeltype SysML14 "strict" uses 'http://www.eclipse.org/papyrus/sysml/1.4/SysML'; |
| modeltype UMLPrimitivesTypes "strict" uses 'http://www.eclipse.org/uml2/5.0.0/Types'; |
| modeltype UMLProfileStandard "strict" uses 'http://www.eclipse.org/uml2/5.0.0/UML/Profile/Standard'; |
| |
| |
| transformation SysMLSemantic(in inS14Profile : SysML14, in primitiveTypes : UMLPrimitivesTypes, in sysMLStandardLibrary : SysML14, in umlProfileStandard : UMLProfileStandard, inout inOutModel : UML); |
| |
| // Declare needed constants |
| property sysML11USRI:String = 'http://www.eclipse.org/papyrus/0.7.0/SysML'; |
| property standardProfileName:String = "StandardProfile"; |
| property librariesName:String = "Libraries"; |
| property unitName:String = "Unit"; |
| property createStereotypeName:String = "Create"; |
| property viewOperationName:String = "View"; |
| |
| property s14Profile:UML::Profile = inS14Profile.rootObjects()![UML::Profile]; |
| |
| // Those two properties need to save the packages replaced by classes for 'View's |
| // This is needed to search the class replacing a package for the 'Conform' generalization classifier |
| property packagesToDestroy:Sequence(UML::Package); |
| property replacedPackagesByClasses:Sequence(UML::Class); |
| |
| main() { |
| var model:UML::Model := inOutModel.rootObjects()[uml::Model]->any(true); |
| |
| model.eAnnotations += model.createEAnnotationForVersioning(); |
| |
| // Apply SysML 1.4 profile with all sub profiles |
| inS14Profile.objectsOfType(UML::Profile)->forEach(profile) { |
| model.applyProfile(profile); |
| }; |
| |
| // Import UML Profile standard |
| var profileStandard:UML::Profile := umlProfileStandard.objectsOfType(UML::Profile)->any(curr | curr.name=standardProfileName); |
| model.applyProfile(profileStandard); |
| |
| // The view must be done before the conform -> change Package to Class needed for conform |
| inOutModel.objects()[SysML11::modelelements::View].map toSysML14ModelelementsView(model); |
| |
| // Make the transformation of all elements to SysML elements |
| inOutModel.objects()[ecore::EObject].map toSysML14Elements(model); |
| |
| // unapply and remove all sysml 1.1 profiles application |
| inOutModel.objectsOfType(ProfileApplication).map removeSysML11Profile(model); |
| |
| // Import uml basic primitives Types by default |
| primitiveTypes.objectsOfType(UML::Model)->forEach(package){ |
| var packageImport := object UML::PackageImport{ |
| importedPackage := package; |
| }; |
| model.packageImport+=packageImport; |
| }; |
| |
| // Import SysML librairies package by default |
| var librairies:UML::Package := sysMLStandardLibrary.objectsOfType(UML::Package)->any(curr | curr.name=librariesName); |
| var librairiesPackageImport := object UML::PackageImport{ |
| importedPackage := librairies; |
| }; |
| model.packageImport+=librairiesPackageImport; |
| |
| // Destroy the needed packages (replaced by class for 'View') |
| packagesToDestroy->forEach(package){ |
| package.destroy(); |
| }; |
| } |
| |
| // Mapping for View is different because it must be called before the others, because the Package must be replaced by a class and must be referenced by other objects |
| mapping SysML11::modelelements::View::toSysML14ModelelementsView(model:UML::Model) : SysML14::modelelements::View { |
| var oldViewPoint:SysML11::modelelements::View := self.oclAsType(SysML11::modelelements::View); |
| // See C.5 in SysML 1.4 Norm for View transition from 1.1 to 1.4 |
| var oldBasePackage:UML::Package := oldViewPoint.base_Package; |
| var newBaseClass:UML::Class := object UML::Class{ |
| eAnnotations += oldBasePackage.eAnnotations; |
| ownedComment += oldBasePackage.ownedComment; |
| name := oldBasePackage.name; |
| nameExpression := oldBasePackage.nameExpression; |
| visibility := oldBasePackage.visibility; |
| ownedRule += oldBasePackage.ownedRule; |
| elementImport += oldBasePackage.elementImport; |
| packageImport += oldBasePackage.packageImport; |
| owningTemplateParameter := oldBasePackage.owningTemplateParameter; |
| templateParameter := oldBasePackage.templateParameter; |
| templateBinding += oldBasePackage.templateBinding; |
| }; |
| |
| var packageOwner:UML::Package := oldBasePackage.owner.oclAsType(UML::Package); |
| if(not packageOwner.oclIsUndefined()){ |
| packageOwner.packagedElement += newBaseClass; |
| base_Class := newBaseClass; |
| packagesToDestroy += oldBasePackage; |
| replacedPackagesByClasses += newBaseClass; |
| }else{ |
| log("Problem when set the created class owner for 'View'."); |
| }; |
| addToResourceContent(model.oclAsType(ecore::EObject), result.oclAsType(ecore::EObject)); |
| } |
| |
| mapping ecore::EObject::toSysML14Elements(model:UML::Model) : ecore::EObject disjuncts |
| ecore::EObject::toSysML14ActivitiesContinuous, |
| ecore::EObject::toSysML14ActivitiesControlOperator, |
| ecore::EObject::toSysML14ActivitiesDiscrete, |
| ecore::EObject::toSysML14ActivitiesNoBuffer, |
| ecore::EObject::toSysML14ActivitiesOptional, |
| ecore::EObject::toSysML14ActivitiesOverwrite, |
| ecore::EObject::toSysML14ActivitiesProbability, |
| ecore::EObject::toSysML14ActivitiesRate, |
| ecore::EObject::toSysML14AllocationsAllocate, |
| ecore::EObject::toSysML14AllocationsAllocateActivityPartition, |
| ecore::EObject::toSysML14BlocksBindingConnector, |
| ecore::EObject::toSysML14BlocksBlock, |
| ecore::EObject::toSysML14BlocksConnectorProperty, |
| ecore::EObject::toSysML14BlocksDistributedProperty, |
| ecore::EObject::toSysML14BlocksNestedConnectorEnd, |
| ecore::EObject::toSysML14BlocksParticipantProperty, |
| ecore::EObject::toSysML14BlocksPropertySpecificType, |
| ecore::EObject::toSysML14BlocksValueType, |
| ecore::EObject::toSysML14ConstraintsConstaintBlock, |
| ecore::EObject::toSysML14ModelelementsProblem, |
| ecore::EObject::toSysML14ModelelementsConform, |
| ecore::EObject::toSysML14ModelelementsRationale, |
| ecore::EObject::toSysML14ModelelementsViewPoint, |
| ecore::EObject::toSysML14PortandflowsFlowPort, |
| ecore::EObject::toSysML14PortandflowsFlowProperty, |
| ecore::EObject::toSysML14PortandflowsFlowSpecification, |
| ecore::EObject::toSysML14PortandflowsItemFlow, |
| ecore::EObject::toSysML14RequirementsCopy, |
| ecore::EObject::toSysML14RequirementsDeriveReqt, |
| ecore::EObject::toSysML14RequirementsRequirement, |
| ecore::EObject::toSysML14RequirementsSatisfy, |
| ecore::EObject::toSysML14RequirementsTestCase, |
| ecore::EObject::toSysML14RequirementsVerify |
| {} |
| |
| // Activities |
| mapping ecore::EObject::toSysML14ActivitiesContinuous(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::activities::Continuous)} { |
| init { |
| var newContinuous:SysML14::activities::Continuous := object SysML14::activities::Continuous{ |
| var oldContinuous:SysML11::activities::Continuous := self.oclAsType(SysML11::activities::Continuous); |
| base_Parameter := oldContinuous.base_Parameter; |
| base_ActivityEdge := oldContinuous.base_ActivityEdge; |
| rate := oldContinuous.rate; |
| }; |
| result := newContinuous.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14ActivitiesControlOperator(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::activities::ControlOperator)} { |
| init { |
| var newControlOperator:SysML14::activities::ControlOperator := object SysML14::activities::ControlOperator{ |
| var oldControlOperator:SysML11::activities::ControlOperator := self.oclAsType(SysML11::activities::ControlOperator); |
| base_Operation := oldControlOperator.base_Operation; |
| base_Behavior := oldControlOperator.base_Behavior; |
| }; |
| result := newControlOperator.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14ActivitiesDiscrete(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::activities::Discrete)} { |
| init { |
| var newDiscrete:SysML14::activities::Discrete := object SysML14::activities::Discrete{ |
| var oldDiscrete:SysML11::activities::Discrete := self.oclAsType(SysML11::activities::Discrete); |
| base_Parameter := oldDiscrete.base_Parameter; |
| base_ActivityEdge := oldDiscrete.base_ActivityEdge; |
| rate := oldDiscrete.rate; |
| }; |
| result := newDiscrete.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14ActivitiesNoBuffer(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::activities::NoBuffer)} { |
| init { |
| var newNoBuffer:SysML14::activities::NoBuffer := object SysML14::activities::NoBuffer{ |
| var oldNoBuffer:SysML11::activities::NoBuffer := self.oclAsType(SysML11::activities::NoBuffer); |
| base_ObjectNode := oldNoBuffer.base_ObjectNode; |
| }; |
| result := newNoBuffer.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14ActivitiesOptional(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::activities::Optional)} { |
| init { |
| var newOptional:SysML14::activities::Optional := object SysML14::activities::Optional{ |
| var oldOptional:SysML11::activities::Optional := self.oclAsType(SysML11::activities::Optional); |
| base_Parameter := oldOptional.base_Parameter; |
| }; |
| result := newOptional.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14ActivitiesOverwrite(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::activities::Overwrite)} { |
| init { |
| var newOverwrite:SysML14::activities::Overwrite := object SysML14::activities::Overwrite{ |
| var oldOverwrite:SysML11::activities::Overwrite := self.oclAsType(SysML11::activities::Overwrite); |
| base_ObjectNode := oldOverwrite.base_ObjectNode; |
| }; |
| result := newOverwrite.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14ActivitiesProbability(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::activities::Probability)} { |
| init { |
| var newProbability:SysML14::activities::Probability := object SysML14::activities::Probability{ |
| var oldProbability:SysML11::activities::Probability := self.oclAsType(SysML11::activities::Probability); |
| base_ActivityEdge := oldProbability.base_ActivityEdge; |
| base_ParameterSet := oldProbability.base_ParameterSet; |
| probability := oldProbability.probability; |
| }; |
| result := newProbability.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14ActivitiesRate(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::activities::Rate)} { |
| init { |
| var newRate:SysML14::activities::Rate := object SysML14::activities::Rate{ |
| var oldRate:SysML11::activities::Rate := self.oclAsType(SysML11::activities::Rate); |
| base_Parameter := oldRate.base_Parameter; |
| base_ActivityEdge := oldRate.base_ActivityEdge; |
| rate := oldRate.rate; |
| }; |
| result := newRate.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| |
| // Allocations |
| mapping ecore::EObject::toSysML14AllocationsAllocate(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::allocations::Allocate)} { |
| init { |
| var newAllocate:SysML14::allocations::Allocate := object SysML14::allocations::Allocate{ |
| var oldAllocate:SysML11::allocations::Allocate := self.oclAsType(SysML11::allocations::Allocate); |
| base_DirectedRelationship := oldAllocate.base_Abstraction; |
| base_Abstraction := oldAllocate.base_Abstraction; |
| }; |
| result := newAllocate.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14AllocationsAllocateActivityPartition(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::allocations::AllocateActivityPartition)} { |
| init { |
| var newAllocateActivityPartition:SysML14::allocations::AllocateActivityPartition := object SysML14::allocations::AllocateActivityPartition{ |
| var oldAllocateActivityPartition:SysML11::allocations::AllocateActivityPartition := self.oclAsType(SysML11::allocations::AllocateActivityPartition); |
| base_ActivityPartition := oldAllocateActivityPartition.base_ActivityPartition; |
| }; |
| result := newAllocateActivityPartition.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| // Blocks |
| mapping ecore::EObject::toSysML14BlocksBindingConnector(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::blocks::BindingConnector)} { |
| init { |
| var newBindingConnector:SysML14::blocks::BindingConnector := object SysML14::blocks::BindingConnector{ |
| var oldBindingConnector:SysML11::blocks::BindingConnector := self.oclAsType(SysML11::blocks::BindingConnector); |
| base_Connector := oldBindingConnector.base_Connector; |
| }; |
| result := newBindingConnector.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14BlocksBlock(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::blocks::Block)} { |
| init { |
| var newBlock:SysML14::blocks::Block := object SysML14::blocks::Block{ |
| var oldBlock:SysML11::blocks::Block := self.oclAsType(SysML11::blocks::Block); |
| base_Class := oldBlock.base_Class; |
| isEncapsulated := oldBlock.isEncapsulated; |
| }; |
| result := newBlock.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14BlocksConnectorProperty(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::blocks::ConnectorProperty)} { |
| init { |
| var newConnectorProperty:SysML14::blocks::ConnectorProperty := object SysML14::blocks::ConnectorProperty{ |
| var oldConnectorProperty:SysML11::blocks::ConnectorProperty := self.oclAsType(SysML11::blocks::ConnectorProperty); |
| base_Property := oldConnectorProperty.base_Property; |
| connector := oldConnectorProperty.connector; |
| }; |
| result := newConnectorProperty.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14BlocksDistributedProperty(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::blocks::DistributedProperty)} { |
| init { |
| var newDistributedProperty:SysML14::blocks::DistributedProperty := object SysML14::blocks::DistributedProperty{ |
| var oldDistributedProperty:SysML11::blocks::DistributedProperty := self.oclAsType(SysML11::blocks::DistributedProperty); |
| base_Property := oldDistributedProperty.base_Property; |
| }; |
| result := newDistributedProperty.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14BlocksNestedConnectorEnd(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::blocks::NestedConnectorEnd)} { |
| init { |
| var newNestedConnectorEnd:SysML14::blocks::NestedConnectorEnd := object SysML14::blocks::NestedConnectorEnd{ |
| var oldNestedConnectorEnd:SysML11::blocks::NestedConnectorEnd := self.oclAsType(SysML11::blocks::NestedConnectorEnd); |
| base_ConnectorEnd := oldNestedConnectorEnd.base_ConnectorEnd; |
| propertyPath := oldNestedConnectorEnd.propertyPath; |
| }; |
| result := newNestedConnectorEnd.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14BlocksParticipantProperty(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::blocks::ParticipantProperty)} { |
| init { |
| var newParticipantProperty:SysML14::blocks::ParticipantProperty := object SysML14::blocks::ParticipantProperty{ |
| var oldParticipantProperty:SysML11::blocks::ParticipantProperty := self.oclAsType(SysML11::blocks::ParticipantProperty); |
| base_Property := oldParticipantProperty.base_Property; |
| _end := oldParticipantProperty._end; |
| }; |
| result := newParticipantProperty.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14BlocksPropertySpecificType(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::blocks::PropertySpecificType)} { |
| init { |
| var newPropertySpecificType:SysML14::blocks::PropertySpecificType := object SysML14::blocks::PropertySpecificType{ |
| var oldPropertySpecificType:SysML11::blocks::PropertySpecificType := self.oclAsType(SysML11::blocks::PropertySpecificType); |
| base_Classifier := oldPropertySpecificType.base_Classifier; |
| }; |
| result := newPropertySpecificType.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14BlocksValueType(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::blocks::ValueType)} { |
| init { |
| var newValueType:SysML14::blocks::ValueType := object SysML14::blocks::ValueType{ |
| var oldValueType:SysML11::blocks::ValueType := self.oclAsType(SysML11::blocks::ValueType); |
| base_DataType := oldValueType.base_DataType; |
| if(not oldValueType.dimension.oclIsUndefined() and not oldValueType.dimension.base_InstanceSpecification.oclIsUndefined()){ |
| quantityKind := oldValueType.dimension.base_InstanceSpecification; |
| }; |
| // See C.6 of the SysML1.4 Norm for the transition from 1.4 to 1.4 |
| if(not oldValueType.unit.oclIsUndefined() and not oldValueType.unit.base_InstanceSpecification.oclIsUndefined()){ |
| unit := oldValueType.unit.base_InstanceSpecification; |
| // Search the Unit class from the standard library to set the classifier for the instance specification |
| var unit:UML::Class := sysMLStandardLibrary.objectsOfType(UML::Class)->any(curr | curr.name=unitName); |
| oldValueType.unit.base_InstanceSpecification.classifier += unit; |
| }; |
| }; |
| result := newValueType.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| |
| // Constraints |
| mapping ecore::EObject::toSysML14ConstraintsConstaintBlock(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::constraints::ConstraintBlock)} { |
| init { |
| var newConstraintBlock:SysML14::constraintblocks::ConstraintBlock := object SysML14::constraintblocks::ConstraintBlock{ |
| var oldConstraintBlock:SysML11::constraints::ConstraintBlock := self.oclAsType(SysML11::constraints::ConstraintBlock); |
| base_Class := oldConstraintBlock.base_Class; |
| isEncapsulated := oldConstraintBlock.isEncapsulated; |
| }; |
| result := newConstraintBlock.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| |
| // Model Elements |
| mapping ecore::EObject::toSysML14ModelelementsProblem(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::modelelements::Problem)} { |
| init { |
| var newProblem:SysML14::modelelements::Problem := object SysML14::modelelements::Problem{ |
| var oldProblem:SysML11::modelelements::Problem := self.oclAsType(SysML11::modelelements::Problem); |
| base_Comment := oldProblem.base_Comment; |
| }; |
| result := newProblem.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14ModelelementsConform(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::modelelements::Conform)} { |
| init { |
| var newConform:SysML14::modelelements::Conform := object SysML14::modelelements::Conform{ |
| var oldConform:SysML11::modelelements::Conform := self.oclAsType(SysML11::modelelements::Conform); |
| // See C.5 SysML 1.4 norm for the conform transition from 1.1 to 1.4 |
| var oldDependency:UML::Dependency := oldConform.base_Dependency; |
| var newGeneralization:UML::Generalization := object UML::Generalization{ |
| eAnnotations += oldDependency.eAnnotations; |
| ownedComment += oldDependency.ownedComment; |
| general := oldDependency.supplier->selectByKind(UML::Classifier)->any(true); |
| }; |
| // Get the source to set the generalization as its child |
| var ownerClassifier:UML::Element := oldDependency.client->any(true); |
| if(not ownerClassifier.oclIsUndefined() and ownerClassifier.oclIsKindOf(UML::Package)){ |
| // This allows to search the class replacing the package when the 'View' transformation is done |
| ownerClassifier := getClassifier(ownerClassifier.oclAsType(UML::Package), packagesToDestroy, replacedPackagesByClasses); |
| }; |
| |
| if(not ownerClassifier.oclIsUndefined() and ownerClassifier.oclIsKindOf(UML::Classifier)){ |
| ownerClassifier.oclAsType(UML::Classifier).generalization += newGeneralization; |
| base_Generalization := newGeneralization; |
| oldDependency.destroy(); |
| }else{ |
| log("Problem when set the created generalization owner for 'Conform'."); |
| }; |
| }; |
| result := newConform.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14ModelelementsRationale(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::modelelements::Rationale)} { |
| init { |
| var newRationale:SysML14::modelelements::Rationale := object SysML14::modelelements::Rationale{ |
| var oldRationale:SysML11::modelelements::Rationale := self.oclAsType(SysML11::modelelements::Rationale); |
| base_Comment := oldRationale.base_Comment; |
| }; |
| result := newRationale.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14ModelelementsViewPoint(inout model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::modelelements::ViewPoint)} { |
| init { |
| var newViewPoint:SysML14::modelelements::Viewpoint := object SysML14::modelelements::Viewpoint{ |
| var oldViewPoint:SysML11::modelelements::ViewPoint := self.oclAsType(SysML11::modelelements::ViewPoint); |
| base_Class := oldViewPoint.base_Class; |
| purpose := oldViewPoint.purpose; |
| language += oldViewPoint.languages; |
| |
| // Manage the concerns |
| if(oldViewPoint.concerns->size() > 0){ |
| oldViewPoint.concerns->forEach(concern){ |
| // Create a comment in the class and affect the concerns to the body of the comment |
| var createdComment:UML::Comment := object UML::Comment{ |
| body := concern; |
| }; |
| oldViewPoint.base_Class.ownedComment += createdComment; |
| concernList += createdComment; |
| }; |
| }; |
| |
| // See 7.3.2.8 Constraints: The ownedOperation must include at least one operation named 'View' stereotyped by 'create' |
| // Search the 'Create' stereotype from Standard Profile |
| var create:UML::Stereotype := umlProfileStandard.objectsOfType(UML::Stereotype)->any(curr | curr.name=createStereotypeName); |
| var createdOperation:UML::Operation := object UML::Operation{ |
| name := viewOperationName; |
| }; |
| oldViewPoint.base_Class.ownedOperation += createdOperation; |
| if(not create.oclIsUndefined()){ |
| var createdStereotypeApplication:ecore::EObject := createdOperation.applyStereotype(create); |
| addToResourceContent(model.oclAsType(ecore::EObject), createdStereotypeApplication); |
| }; |
| |
| // See C.5 in SysML 1.4 Norm for ViewPoint transition from 1.1 to 1.4 |
| var createdStakeHolders:Set(SysML14::modelelements::Stakeholder); |
| oldViewPoint.stakeHolders->forEach(stakeHolder){ |
| var createdClassifier:UML::Classifier := object UML::Class{ |
| name := stakeHolder; |
| }; |
| oldViewPoint.base_Class.nestedClassifier += createdClassifier; |
| var createdStackHolder:SysML14::modelelements::Stakeholder := object SysML14::modelelements::Stakeholder{ |
| base_Classifier := createdClassifier; |
| }; |
| addToResourceContent(model.oclAsType(ecore::EObject), createdStackHolder.oclAsType(ecore::EObject)); |
| createdStakeHolders += createdStackHolder; |
| }; |
| stakeholder := createdStakeHolders; |
| |
| // See C.5 in SysML 1.4 Norm for ViewPoint transition from 1.1 to 1.4 |
| // Manage the methods |
| if(oldViewPoint.methods->size() > 0){ |
| var concatMethodsString:String; |
| oldViewPoint.methods->forEach(method){ |
| if(concatMethodsString.length() = 0){ |
| concatMethodsString := method; |
| }else{ |
| concatMethodsString := concatMethodsString + '\n' + method; |
| }; |
| }; |
| |
| var createdComment:UML::Comment := object UML::Comment{ |
| body := concatMethodsString; |
| }; |
| createdOperation.ownedComment += createdComment; |
| }; |
| }; |
| result := newViewPoint.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| |
| // Port and flows |
| mapping ecore::EObject::toSysML14PortandflowsFlowPort(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::portandflows::FlowPort)} { |
| init { |
| var newFlowPort:SysML14::deprecatedelements::FlowPort := object SysML14::deprecatedelements::FlowPort{ |
| var oldFlowPort:SysML11::portandflows::FlowPort := self.oclAsType(SysML11::portandflows::FlowPort); |
| base_Port := oldFlowPort.base_Port; |
| direction := getDirection(oldFlowPort.direction); |
| }; |
| result := newFlowPort.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14PortandflowsFlowProperty(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::portandflows::FlowProperty)} { |
| init { |
| var newFlowProperty:SysML14::portsandflows::FlowProperty := object SysML14::portsandflows::FlowProperty{ |
| var oldFlowProperty:SysML11::portandflows::FlowProperty := self.oclAsType(SysML11::portandflows::FlowProperty); |
| base_Property := oldFlowProperty.base_Property; |
| direction := getDirection(oldFlowProperty.direction); |
| }; |
| result := newFlowProperty.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14PortandflowsFlowSpecification(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::portandflows::FlowSpecification)} { |
| init { |
| var newFlowSpecification:SysML14::deprecatedelements::FlowSpecification := object SysML14::deprecatedelements::FlowSpecification{ |
| var oldFlowSpecification:SysML11::portandflows::FlowSpecification := self.oclAsType(SysML11::portandflows::FlowSpecification); |
| base_Interface := oldFlowSpecification.base_Interface; |
| }; |
| result := newFlowSpecification.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14PortandflowsItemFlow(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::portandflows::ItemFlow)} { |
| init { |
| var newItemFlow:SysML14::portsandflows::ItemFlow := object SysML14::portsandflows::ItemFlow{ |
| var oldItemFlow:SysML11::portandflows::ItemFlow := self.oclAsType(SysML11::portandflows::ItemFlow); |
| base_InformationFlow := oldItemFlow.base_InformationFlow; |
| itemProperty := oldItemFlow.itemProperty; |
| }; |
| result := newItemFlow.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| |
| // Requirements |
| mapping ecore::EObject::toSysML14RequirementsCopy(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::requirements::Copy)} { |
| init { |
| var newCopy:SysML14::requirements::Copy := object SysML14::requirements::Copy{ |
| var oldCopy:SysML11::requirements::Copy := self.oclAsType(SysML11::requirements::Copy); |
| base_DirectedRelationship := oldCopy.base_Abstraction; |
| base_Abstraction := oldCopy.base_Abstraction; |
| }; |
| result := newCopy.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14RequirementsDeriveReqt(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::requirements::DeriveReqt)} { |
| init { |
| var newDeriveReqT:SysML14::requirements::DeriveReqt := object SysML14::requirements::DeriveReqt{ |
| var oldDeriveReqT:SysML11::requirements::DeriveReqt := self.oclAsType(SysML11::requirements::DeriveReqt); |
| base_DirectedRelationship := oldDeriveReqT.base_Abstraction; |
| base_Abstraction := oldDeriveReqT.base_Abstraction; |
| }; |
| result := newDeriveReqT.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14RequirementsRequirement(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::requirements::Requirement)} { |
| init { |
| var newRequirement:SysML14::requirements::Requirement := object SysML14::requirements::Requirement{ |
| var oldRequirement:SysML11::requirements::Requirement := self.oclAsType(SysML11::requirements::Requirement); |
| base_Class := oldRequirement.base_Class; |
| id := oldRequirement.id; |
| text := oldRequirement.text; |
| }; |
| result := newRequirement.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14RequirementsSatisfy(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::requirements::Satisfy)} { |
| init { |
| var newSatisfy:SysML14::requirements::Satisfy := object SysML14::requirements::Satisfy{ |
| var oldSatisfy:SysML11::requirements::Satisfy := self.oclAsType(SysML11::requirements::Satisfy); |
| base_Abstraction := oldSatisfy.base_Abstraction; |
| base_DirectedRelationship := oldSatisfy.base_Abstraction; |
| }; |
| result := newSatisfy.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14RequirementsTestCase(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::requirements::TestCase)} { |
| init { |
| var newTestCase:SysML14::requirements::TestCase := object SysML14::requirements::TestCase{ |
| var oldTestCase:SysML11::requirements::TestCase := self.oclAsType(SysML11::requirements::TestCase); |
| base_Behavior := oldTestCase.base_Behavior; |
| base_Operation := oldTestCase.base_Operation; |
| }; |
| result := newTestCase.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| mapping ecore::EObject::toSysML14RequirementsVerify(model:UML::Model) : ecore::EObject when {self.oclIsTypeOf(SysML11::requirements::Verify)} { |
| init { |
| var newVerify:SysML14::requirements::Verify := object SysML14::requirements::Verify{ |
| var oldVerify:SysML11::requirements::Verify := self.oclAsType(SysML11::requirements::Verify); |
| base_Abstraction := oldVerify.base_Abstraction; |
| base_DirectedRelationship := oldVerify.base_Abstraction; |
| }; |
| result := newVerify.oclAsType(ecore::EObject); |
| } |
| addToResourceContent(model.oclAsType(ecore::EObject), result); |
| } |
| |
| |
| // Utility to remove all SysML 1.1 Profiles |
| mapping ProfileApplication::removeSysML11Profile(model:UML::Model) when { self.appliedProfile.URI.startsWith(sysML11USRI);}{ |
| model.unapplyProfile(self.appliedProfile); |
| } |