Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'proprietary/bundles/org.eclipse.upr.platform.java.cm2up/src/org/eclipse/upr/platform/java/cm2up/profileLibrary.atl')
-rw-r--r--proprietary/bundles/org.eclipse.upr.platform.java.cm2up/src/org/eclipse/upr/platform/java/cm2up/profileLibrary.atl51
1 files changed, 51 insertions, 0 deletions
diff --git a/proprietary/bundles/org.eclipse.upr.platform.java.cm2up/src/org/eclipse/upr/platform/java/cm2up/profileLibrary.atl b/proprietary/bundles/org.eclipse.upr.platform.java.cm2up/src/org/eclipse/upr/platform/java/cm2up/profileLibrary.atl
new file mode 100644
index 0000000..563101e
--- /dev/null
+++ b/proprietary/bundles/org.eclipse.upr.platform.java.cm2up/src/org/eclipse/upr/platform/java/cm2up/profileLibrary.atl
@@ -0,0 +1,51 @@
+--/*******************************************************************************
+-- * Copyright (c) 2015 Vienna University of Technology.
+-- * 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:
+-- * Alexander Bergmayr (Vienna University of Technology) - initial API and implementation
+-- * Manuel Wimmer (Vienna University of Technology) - initial API and implementation
+-- *
+-- * Initially developed in the context of ARTIST EU project www.artist-project.eu
+-- *******************************************************************************/
+
+-- @nsURI UMLMM=http://www.eclipse.org/uml2/3.0.0/UML
+
+library profileLibrary;
+
+helper context UMLMM!Element def: setTaggedValue(stereotype : OclAny, propertyName : String, newValue : OclAny ) : OclAny =
+if (not newValue.oclIsUndefined())
+ then
+ if (not thisModule.isMultiValued(newValue)) -- if single-valued
+ then
+ if (not thisModule.isComplexType(propertyName))
+ then
+ -- CASE 1: single-valued && simple
+ self.setValue(stereotype, propertyName, newValue)
+ else
+ -- CASE 2: single-valued && complex
+ self.setValue(stereotype, propertyName, thisModule.resolveTemp(newValue, 'y').getStereotypeApplications().asSequence().first())
+ endif
+ else -- if multi-valued
+ if (not thisModule.isComplexType(propertyName))
+ then
+ -- CASE 3: multi-valued && simple
+ self.setValue(stereotype, propertyName, newValue)
+ else
+ -- CASE 4: multi-valued && complex
+ self.setValue(stereotype, propertyName, newValue -> collect(c | thisModule.resolveTemp(c, 'y').getStereotypeApplications().asSequence().first()))
+ endif
+ endif
+ else OclUndefined
+endif;
+
+helper def : isMultiValued(attr : OclAny) : Boolean =
+ attr.oclIsKindOf(Collection(OclAny))
+;
+
+helper def : isComplexType(taggedValueName : String) : Boolean =
+ UMLMM!Property.allInstances() -> any(e|e.name = taggedValueName).type.oclIsTypeOf(UMLMM!Stereotype)
+;

Back to the top