Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Transformation of UML models with stereotypes (profiles)(How to take into account and navigate stereotypes in model transformations)
icon5.gif  Transformation of UML models with stereotypes (profiles) [message #1723849] Thu, 18 February 2016 13:31 Go to next message
Supernova S. is currently offline Supernova S.Friend
Messages: 5
Registered: January 2011
Junior Member
Hi,

How is it possible to transform a UML model which has applied stereotypes from a profile, e.g., EAST-ADL ? How can stereotypes be read and accessed in model transformation code?

Basically, I am looking for an example transformation code (in QVTo or ATL) that transforms a Papyrus UML model ( to whatever) which has stereotypes.

Can anyone provide or point me to such an example?

[Updated on: Thu, 18 February 2016 13:59]

Report message to a moderator

Re: Transformation of UML models with stereotypes (profiles) [message #1723857 is a reply to message #1723849] Thu, 18 February 2016 14:00 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 952
Registered: February 2011
Senior Member
Hi,

UML Elements have a #getStereotypeApplication method, returning instances of the required stereotypes. You can manipulate with two distinct approaches:

- Explicitly: you need to specify the profile URI in your transformation, then you can use oclAsType() to cast the stereotype application to your specific stereotype. Once this is done, you can access the stereotype properties directly
- With the generic API: using #getValue(Stereotype, Name) and #setValue(Stereotype, Name, Value)

modeltype uml "strict" uses 'http://www.eclipse.org/uml2/5.0.0/UML';
modeltype sysml "strict" uses 'http://www.eclipse.org/papyrus/0.7.0/SysML';
modeltype sysmlBlocks "strict" uses 'http://www.eclipse.org/papyrus/0.7.0/SysML/Blocks';
	
transformation StereotypesTransform(inout model : uml);

main() {
	model.objectsOfType(Class).map blockToEncapsulated();
	model.objectsOfType(Class).map blockToEncapsulatedGeneric(); 
}

mapping inout Class::blockToEncapsulated() when { /* Using the SysML API: modeltypes need to be declared for each sub-profile */
	self.getAppliedStereotype("SysML::Blocks::Block") <> null
}{
	var blockStereotype : Stereotype := self.getAppliedStereotype("SysML::Blocks::Block");
	var block : Block := self.getStereotypeApplication(blockStereotype).oclAsType(Block);
	block.isEncapsulated := true;
}

mapping inout Class::blockToEncapsulatedGeneric() when { /* Using the UML Reflexive API: you don't need the modeltypes, but you're manipulating Strings and Objects... Very error-prone */
	self.getAppliedStereotype("SysML::Blocks::Block") <> null
}{
	var blockStereotype : Stereotype := self.getAppliedStereotype("SysML::Blocks::Block");
	self.setValue(blockStereotype, "isEncapsulated", true);
	var isEncapsulated : Boolean := self.getValue(blockStereotype, "isEncapsulated").oclAsType(Boolean);
}


Camille Letavernier
Re: Transformation of UML models with stereotypes (profiles) [message #1723858 is a reply to message #1723849] Thu, 18 February 2016 14:02 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

It's not very exciting code but the following extract from

http://git.eclipse.org/c/ocl/org.eclipse.ocl.git/tree/examples/org.eclipse.ocl.examples.build/src/org/eclipse/ocl/examples/build/qvto/UML2EcoreSynthesizer.qvto

accesses the Ecore::EDataType:instanceClassName stereotype field.

mapping inout Ecore::EClassifier::installInstanceClassName(in types :
Set(UML::Type), stereotypeName : String)
{
var stereotypedTypes : Set(UML::Type) :=
types->select(getAppliedStereotype(stereotypeName) <> null)->asSet();
var stereotypedType : UML::Type := stereotypedTypes->any(true);
-- var stereotypes : Set(UML::Stereotype) :=
createType.oldTypes.oclAsType(UML::DataType).getAppliedStereotype('Ecore::EDataType')->asSet();
-- log('stereotypedType', stereotypedType);
var instanceClassName : String :=
stereotypedType.getValue(stereotypedType.getAppliedStereotype(stereotypeName),
'instanceClassName').oclAsType(String);
-- log('instanceClassName', instanceClassName);
self.instanceClassName := instanceClassName;
-- result.defaultValue := instanceClassName;
}

Regards

Ed Willink


On 18/02/2016 13:31, Supernova S. wrote:
> Hi,
>
> How is it possible to transform a UML model which has applied
> stereotypes from a profile, e.g., EAST-ADL ? How can stereotypes be
> read and accessed in model transformation code?
>
> Basically, I am looking for an example transformation code (in QVTo or
> ATL) that transforms a Papyrus UML model which has stereotypes.
>
> Can anyone provide or point me to such an example?
>
>
Re: Transformation of UML models with stereotypes (profiles) [message #1723998 is a reply to message #1723858] Fri, 19 February 2016 15:26 Go to previous message
Supernova S. is currently offline Supernova S.Friend
Messages: 5
Registered: January 2011
Junior Member
Thank you all!
Previous Topic:SVG presentation in diagrams
Next Topic:Trace and Refine dependencies missed from SysML Requirements Diagram
Goto Forum:
  


Current Time: Thu Apr 18 06:12:58 GMT 2024

Powered by FUDForum. Page generated in 0.02113 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top