| /***************************************************************************** |
| * Copyright (c) 2016 CEA LIST. |
| * |
| * 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: |
| * Vincent Lorenzo (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation |
| *****************************************************************************/ |
| |
| import RpyUtils; |
| import org.eclipse.papyrus.interoperability.rpy.blackboxes.ConstantsBlackboxes; |
| |
| modeltype umlrpy "strict" uses 'http://www.eclipse.org/Papyrus/UMLRpy/1.0.0'; |
| modeltype sysml11 "strict" uses 'http://www.eclipse.org/papyrus/0.7.0/SysML'; |
| modeltype ecore "strict" uses 'http://www.eclipse.org/emf/2002/Ecore'; |
| |
| |
| /** |
| * |
| * This file provides useful method to manage SysML Rpy Model |
| */ |
| library SysMLRpyUtils; |
| |
| |
| /** |
| * Return true if the IDiagram is a SysML Parametric Diagram |
| */ |
| query rpymetamodel::IDiagram::isSysMLParametricDiagram():Boolean{ |
| return self.isRpyClassChart() and self.isStereotypedWith("Parametric Diagram"); |
| } |
| |
| /** |
| * Return true if the IDiagram represents a SysML Block Definition Diagram |
| */ |
| query rpymetamodel::IDiagram::isSysMLBlockDefinitionDiagram():Boolean{ |
| return self.isRpyClassChart() and self.isStereotypedWith("Block Definition Diagram"); |
| } |
| |
| /** |
| * Return true if the IDiagram represents a SysML Internal Block Diagram |
| */ |
| query rpymetamodel::IDiagram::isSysMLInternalBlockDiagram():Boolean{ |
| return self.oclIsTypeOf(rpymetamodel::IStructureDiagram) and self.isRpyClassChart() and self.isStereotypedWith("Internal Block Diagram"); |
| } |
| |
| |
| /** |
| * Return true if the IType is stereotyped with the SysML Rpy flowSpecification |
| */ |
| query umlrpy::IClass::isSysMLFlowSpecification(): Boolean{ |
| return self.isStereotypedWith("flowSpecification"); |
| } |
| |
| //TODO :duplciated code for IType and IClass |
| /** |
| * Return true if the IType is stereotyped with the SysML Rpy flowSpecification |
| */ |
| query umlrpy::IType::isSysMLFlowSpecification(): Boolean{ |
| return self.isStereotypedWith("flowSpecification"); |
| } |
| |
| /** |
| * Return true if the IType is stereotyped with the SysML Rpy ValueType |
| */ |
| query umlrpy::IType::isSysMLValueType():Boolean { |
| return self.isStereotypedWith("ValueType"); |
| } |
| |
| /** |
| * Return true if the IType is stereotyped with the SysML Rpy ConstraintProperty |
| */ |
| query umlrpy::IPart::isSysMLConstraintProperty():Boolean { |
| return self.isStereotypedWith("ConstraintProperty"); |
| } |
| |
| /** |
| * Return true if the IType is stereotyped with the SysML Rpy ConstraintBlock |
| * |
| */ |
| query umlrpy::IClass::isSysMLConstraintBlock(): Boolean{ |
| return self.isStereotypedWith("ConstraintBlock"); |
| } |
| |
| /** |
| * Return true if the IType is stereotyped with the SysML Rpy Dimension |
| */ |
| query umlrpy::IType::isSysMLDimension(): Boolean { |
| return self.isStereotypedWith("Dimension"); |
| } |
| |
| /** |
| *Return true if the IType is stereotyped with the SysML Rpy Unit |
| */ |
| query umlrpy::IType::isSysMLUnit(): Boolean { |
| return self.isStereotypedWith("Unit"); |
| } |
| |
| /** |
| * Return true if the IType is stereotyped with the SysML Rpy DataType (this stereotype doesn't exist in SysML implementation used by Papyrus') |
| */ |
| query umlrpy::IType::isRpyDataType(): Boolean { |
| return self.isStereotypedWith("DataType"); |
| } |
| |
| |
| |
| /** |
| * Return true if the IStereotype comes from the SysML Rpy profile (or must be mapped in a SysML Profile in Papyrus) |
| * |
| */ |
| query IStereotype::isARpySysMLStereotype():Boolean{ |
| var ret:Boolean:=false; |
| var fileName:String:=self.oclAsType(EModelElement).getFileName(); |
| ret:=fileName="$OMROOT\\\\Profiles\\\\SysML\\\\SysMLProfile_rpy\\\\SysML.sbs"; //TODO : move me in const file |
| if(not ret){ |
| ret:=fileName="PredefinedTypes.sbs" and self.name.equalsIgnoreCase("flowPort"); //TODO : move me in const file |
| }; |
| if(not ret){ |
| ret:=self.name.equalsIgnoreCase("block");//TODO sure of this case ? |
| }; |
| return ret; |
| } |
| |
| /** |
| * @param set: a set of EObject |
| * return true if one of this EObject is a Rpy SysML Stereotype |
| */ |
| helper isContainingSysMLRpyStereotypeReference(set:Set(EObject)):Boolean{ |
| var ret:Boolean:=false; |
| set->selectByType(IStereotype)->forEach(current){ |
| if(current.isARpySysMLStereotype()){ |
| ret:=true; |
| break; |
| } |
| }; |
| return ret; |
| } |
| |