Skip to main content



      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 04:53 Go to next message
Eclipse UserFriend
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 10:17 Go to previous messageGo to next message
Eclipse UserFriend
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 10:18] by Moderator

Re: [Acceleo] Error Getting Attributes with Specific Stereotypes [message #1233655 is a reply to message #1232725] Mon, 20 January 2014 02:52 Go to previous messageGo to next message
Eclipse UserFriend
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 13:37 Go to previous messageGo to next message
Eclipse UserFriend
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] Mon, 20 January 2014 23:38 Go to previous message
Eclipse UserFriend
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: Wed Jul 23 14:39:36 EDT 2025

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

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

Back to the top