Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Error Getting Attributes with Specific Stereotypes
[Acceleo] Error Getting Attributes with Specific Stereotypes [message #1232597] Fri, 17 January 2014 09:53 Go to next message
Maya Retno is currently offline Maya RetnoFriend
Messages: 3
Registered: January 2014
Junior Member
Dear all,
Supposed I have a class Account in UML Class Diagram with 4 attributes: Integer fee, <<aParam>> Integer amount, <<aParam>> Integer balance, Integer id.

I would like to get the class name and its attributes with stereotypes <<aParam>>.

Here is my Acceleo transformation code:
class [aClass.name/] ([for (att: Property | aClass.getAllAttributes()) separator (',')]
[for (s: Stereotype | att.getAppliedStereotypes()) ? (s.name='aParam')]
[att.type.name/] [att.name/] [/for][/for]);


I hope the output is:
class Account (Integer amount, Integer balance);

but the current output is:
class Account (,,Integer amount,,Integer balance);

Based on the current output, at first it seems that all attributes was retrieved. Then when there is a condition that only attributes with stereotypes 'aParam' that should be retrieved, the attributes without stereotypes 'aParam' is deleted. Therefore, there is still space in the output with empty string (indicated by the comma separator).

Any idea how to solve this problem?

Regards,
Maya
Re: [Acceleo] Error Getting Attributes with Specific Stereotypes [message #1232725 is a reply to message #1232597] Fri, 17 January 2014 15:17 Go to previous messageGo to next message
Sebastien Roy is currently offline Sebastien RoyFriend
Messages: 51
Registered: November 2009
Member
Hello,

This behaviour occurs because the attribute loop occurs even if the stereotype is not applied on the attribute.
You should filter in the first loop only attributes that hold the stereotype :

class [aClass.name/] ([for (att: Property | aClass.getAllAttributes()->select(getAppliedStereotypes()->contains(s: Stereotype |s.name='aParam'))) separator (',')]
[att.type.name/] [att.name/] [/for]);


I didn't test that piece of code but it should be close to what you actually need.

Regards

[Updated on: Fri, 17 January 2014 15:18]

Report message to a moderator

Re: [Acceleo] Error Getting Attributes with Specific Stereotypes [message #1233655 is a reply to message #1232725] Mon, 20 January 2014 07:52 Go to previous messageGo to next message
Maya Retno is currently offline Maya RetnoFriend
Messages: 3
Registered: January 2014
Junior Member
Thanks for the response.
Yap, the solution above is close to my need,
but when I tried the code, there was syntax error like this:
Incomplete iterator expression: (temp1.""()->contains(s:""| s."".""('aParam'))).

I attempted to solve the error, but I couldn't get an appropriate result.

anyone can help me to solve the problem?

Regards,
Maya
Re: [Acceleo] Error Getting Attributes with Specific Stereotypes [message #1233883 is a reply to message #1233655] Mon, 20 January 2014 18:37 Go to previous messageGo to next message
Sebastien Roy is currently offline Sebastien RoyFriend
Messages: 51
Registered: November 2009
Member
Hello,

There was actally a mistake in my (not tested) code.
This one should be better :

class [aClass.name/] ([for (att: Property | aClass.getAllAttributes()->select(getAppliedStereotypes()->exists(s: Stereotype |s.name='aParam'))) separator (',')]
[att.type.name/] [att.name/] [/for]);
Re: [Acceleo] Error Getting Attributes with Specific Stereotypes [message #1234037 is a reply to message #1233883] Tue, 21 January 2014 04:38 Go to previous message
Maya Retno is currently offline Maya RetnoFriend
Messages: 3
Registered: January 2014
Junior Member
Thanks for your help,
the output is correct now.

Regards,
Maya
Previous Topic:having empty line
Next Topic:[Acceleo] Testing an acceleo project, which depends on another acceleo project
Goto Forum:
  


Current Time: Mon Nov 24 22:54:10 GMT 2014

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

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