c.getAppliedStereotypes().name doesn't work in acceleo template [message #1796681] |
Wed, 17 October 2018 14:08  |
Eclipse User |
|
|
|
Hi,
My goal is to generate a file.txt from a model annotated by MARTE profile.
For example(attached figure) the UML class is annotated with 'SwSchedulableResource' and my goal is to disply the value of its attribut numNodes in the generated file as indicated in the code:.
The file is generated but empty. (I must have a line in the file containing: nombre = 5)
Could one help me to correct my code. Really, I'm pressed and i have a deadline for today.
Thank you in advance.
[comment encoding = UTF-8 /]
[**
* The documentation of the module generate.
*/]
[module generate('http://www.eclipse.org/papyrus/MARTE/1', 'http://www.eclipse.org/uml2/5.0.0/UML')]
[**
* The documentation of the template generateElement.
* @param aModel
*/]
[template public generateElement(m : Model)]
[comment @main/]
[file (m.name.concat('.txt'), false, 'UTF-8')]
[for (c:Class|m.eContents(Class))]
[if c.getAppliedStereotypes().name->includes('SwSchedulableResource')]
[for (p : Property| c.getAppliedStereotypes().getAllAttributes())]
[if (p.name->includes('numNodes'))]
nombre = [p.getDefault()/]
[/if]
[/for]
[/if]
[/for]
[/file]
[/template]
Attachment: exple.png
(Size: 6.20KB, Downloaded 244 times)
|
|
|
|
Re: c.getAppliedStereotypes().name doesn't work in acceleo template [message #1796693 is a reply to message #1796684] |
Wed, 17 October 2018 17:18  |
Eclipse User |
|
|
|
Hi
If you provided an executable repro, it might be possible. Without that I can only recommend you read the many threads on users struggling with UML and SysML initialization. Marte is probably equally hard.
p.name->includes('numNodes') seems like a really hard way to code p.name = 'numNodes' or even ...->select(name = 'numNodes')
Regards
Ed Willink
|
|
|
Powered by
FUDForum. Page generated in 0.03728 seconds