Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » How to determine stereotype of class in EGL?(How to determine applied stereotype of class in EGL code template?)
How to determine stereotype of class in EGL? [message #1775813] Mon, 06 November 2017 18:01 Go to next message
Kaan Koseler is currently offline Kaan KoselerFriend
Messages: 2
Registered: November 2017
Junior Member
Hello,

I apologize if this is a newbie question. I am trying to access the stereotype of a class in an EGL template. I already created a UML profile with several defined stereotypes and created a model with them. Now in the EGL template, I want to determine which stereotype has been applied to the classes.

One stereotype I defined is called an "ObservedVariable" and I would like to gather all "ObservedVariable" classes from my model into a variable.
For example, this is what I have in my template:

[% 
var observedVars = Class.all.hasAppliedStereotypes("ObservedVariable"); 
%]


I then receive the following error (where "Strikes" has the "ObservedVariable" stereotype applied):
Method 'hasAppliedStereotypes' not found for: Sequence {Class [name=Strikes, qualifiedName=RootElement::Strikes, visibility=public, isLeaf=false, isAbstract=false, isFinalSpecialization=false, isActive=false, ]

Can anyone provide any guidance?
Thank you very much
Re: How to determine stereotype of class in EGL? [message #1775956 is a reply to message #1775813] Wed, 08 November 2017 15:12 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1520
Registered: July 2009
Location: York, UK
Senior Member

Hi Kaan,

You may want to have a look at the thread below which contains a few examples of querying profiled UML models with Epsilon:

https://www.eclipse.org/forums/index.php/t/1072732/

Cheers,
Dimitris
Re: How to determine stereotype of class in EGL? [message #1775962 is a reply to message #1775956] Wed, 08 November 2017 15:35 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1520
Registered: July 2009
Location: York, UK
Senior Member

Hi again,

The transformation below also demonstrates querying a profiled UML model:

http://git.eclipse.org/c/epsilon/org.eclipse.epsilon.git/tree/examples/org.eclipse.epsilon.examples.uml2simulink/uml2simulink.etl

Cheers,
Dimitris
Re: How to determine stereotype of class in EGL? [message #1776284 is a reply to message #1775962] Wed, 15 November 2017 02:11 Go to previous messageGo to next message
Kaan Koseler is currently offline Kaan KoselerFriend
Messages: 2
Registered: November 2017
Junior Member
Hello Dimitris,

Thank you kindly for your reply and the informative links. After reading through them I managed to figure it out :)
This is somewhat off topic from my original question but it's a minor enough question:
when placing an EString data type within an EGL template, is there any way to remove the brackets that surround the EString in the generated code?
For example I have the following code:

[%=c.stereotypeApplications.trainValues%]


where trainValues is an EString with value: { 0, 1, 2, 3, 4}
In the generated code, the result shows up as: [{0, 1, 2, 3, 4}]

Is there any way to remove these brackets and just leave the original string?
Thank you again, I greatly appreciate your help.
Re: How to determine stereotype of class in EGL? [message #1776312 is a reply to message #1776284] Wed, 15 November 2017 09:12 Go to previous message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 1520
Registered: July 2009
Location: York, UK
Senior Member

Hi Kaan,

EGL doesn't automatically add square brackets so my guess is that c.stereotypeApplications.trainValues is not returning what you expect it to. Printing the result of c.stereotypeApplications.trainValues.getClass() should help.

Cheers,
Dimitris
Previous Topic:[Epsilon - EOL]
Next Topic:Connecting SQL Server 2012 to Java Eclipse
Goto Forum:
  


Current Time: Tue Apr 24 10:28:16 GMT 2018

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

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