blob: 563101e8616b2bb663c2c4abc2af6d1e3d88a5bd [file] [log] [blame]
--/*******************************************************************************
-- * 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)
;