Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Generate text on Annotation
Generate text on Annotation [message #1843921] Tue, 24 August 2021 14:00 Go to next message
Pascal PONSARD is currently offline Pascal PONSARDFriend
Messages: 3
Registered: August 2021
Junior Member
Hi,

i want to generate text on a Eclass witch contains attributes, some attributes have Annotation.
Acceleo 2 template was that :

<%script type="ecore.EClass" name="scTrier"%>
<%if (eAttributes[eAnnotations[source=="fce"].details[key=="trier"]]){%>
<%for (eAttributes[eAnnotations[source=="fce"].details[key=="trier"]].sep(",")){%><%name%><%}%>
<%}%>

This template "scTrier" Acceleo 2 returns
att1,att2
where att1 have a Annotation 'fce 'with a key 'trier'.
and nothing if any attribute of a Eclass contains this Annotation and this key.

How can i do the same thing on acceleo 3 ?

Thanks
Re: Generate text on Annotation [message #1843942 is a reply to message #1843921] Wed, 25 August 2021 09:01 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7505
Registered: July 2009
Senior Member
Hi

This forum is not a free coding service.

Once you have studied https://wiki.eclipse.org/Acceleo/Migration_From_Acceleo_2 feel free to post your best endeavor and n outline of what problems you face. Then we can help you.

Regards

Ed Willink
Re: Generate text on Annotation [message #1844074 is a reply to message #1843942] Tue, 31 August 2021 08:58 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1900
Registered: July 2009
Senior Member
Hello Pascal,

As Ed mentionned, the wiki lists a few of the rules to keep in mind when migrating an Acceleo 2 project towards Acceleo 3.

In this case though, the acceleo 2 constructs for filtering are not intuitive and have to be translated to a proper filtering, I suggest using a query for that. Something like the following should give you the result you're expecting:

[template public scTrier(class : EClass)]
[for (attribute : EAttribute | class.eAttributes->select(att : EAttribute | att.hasAnnotation())) separator (',')][name/][/for]
[/template]

[query public hasAnnotation(att : EAttribute) : EBoolean =
att.eAnnotations->select(ann : EAnnotation | ann.source = 'fce' and ann.details->select(entry : EStringToStringMapEntry | entry.key = 'trier')->size() > 0)->size() > 0
/]
[/query]


Regards,

Laurent Goubet
Obeo
Re: Generate text on Annotation [message #1844088 is a reply to message #1844074] Tue, 31 August 2021 21:31 Go to previous messageGo to next message
Pascal PONSARD is currently offline Pascal PONSARDFriend
Messages: 3
Registered: August 2021
Junior Member
Thanks
When i copy your code, i have this error (syntax) : model content not valid ; behind [/query]



Re: Generate text on Annotation [message #1844089 is a reply to message #1844088] Tue, 31 August 2021 21:52 Go to previous message
Pascal PONSARD is currently offline Pascal PONSARDFriend
Messages: 3
Registered: August 2021
Junior Member
It works well.

Thanks
Previous Topic:Share a (E)MTL file using a JAR dependency
Next Topic:Acceleo: Custom Exception handler for IO exceptions
Goto Forum:
  


Current Time: Mon Aug 15 04:26:24 GMT 2022

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

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

Back to the top