Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Artifact fileName(How access an artifact's fileName value)
Artifact fileName [message #1767125] Sat, 01 July 2017 14:41 Go to next message
Geoffry Roberts is currently offline Geoffry RobertsFriend
Messages: 52
Registered: July 2016
Member
All,

I am processing a UML deployment diagram where one of the nodes contains and artifact. The artifact has a value set as its fileName.

How may I access the fileName? I doesn't show up in the content assist.

Here's my template:
[template public generate(n : Node)]
[file ('deploy.sh', false)]
    [for (ne : NamedElement | ownedMember)]
       [ne.toString()/] 
    [/for]
[/file]
[/template]


Here's the output:
org.eclipse.uml2.uml.internal.impl.ArtifactImpl@c7a977f (name: TripleReceive, visibility: public) (isLeaf: false, isAbstract: false, isFinalSpecialization: false) (fileName: gov.nist.hla:gov.nist.hla.Triple.TripleReceive:0.0.1) 

Re: Artifact fileName [message #1767165 is a reply to message #1767125] Sun, 02 July 2017 20:20 Go to previous messageGo to next message
Tomasz  abczy?ski is currently offline Tomasz abczy?skiFriend
Messages: 11
Registered: May 2015
Junior Member
1) You have the same file name in file tag with false as the second parameter - the same file will be generated for each node overwriting the previous one.

2) fileName attribute belongs to the Artifact not to any NamedElement. If you want to iterate over the artefacts only you could do something like it:

[template public generate(n : Node)]
[file (n.name.concat('deploy.sh'), false)]
    [for (ne : Artifact | n.ownedMember->filter(Artifact))]
       [ne.fileName/] 
    [/for]
[/file]
[/template]


T.B.


Tomasz Babczyński
Re: Artifact fileName [message #1767201 is a reply to message #1767165] Mon, 03 July 2017 14:07 Go to previous messageGo to next message
Geoffry Roberts is currently offline Geoffry RobertsFriend
Messages: 52
Registered: July 2016
Member
Thanks Tomasz,

I have been looking for a comprehensive set of documentation for this template language. What I have so far is sketchy and down right terse. Does any such documentation exist?

Thanks again
Re: Artifact fileName [message #1767210 is a reply to message #1767201] Mon, 03 July 2017 14:58 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You've already asked about documentation and been answered. Acceleo is far from lacking in documentation. You are welcome to improve it.

In particular:

The file block contains three parameters:

An expression returning a string for the name of the file
A boolean indicating if existing files should be overwritten or if the newly generated content should be appended at the end of the existing file
The encoding of the file


seems to address your problems with file rather well.

M2T languages are particularly easy to debug. I suggest you learn to add debug comments to your output so that you can debug the difference between your expectation and actuality.

Regards

Ed Willink
Re: Artifact fileName [message #1767252 is a reply to message #1767210] Tue, 04 July 2017 08:21 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hi Geoffry,

For the record, the excerpt of documentation Ed pasted here comes from the documentation integrated in Eclipse (Help > Help Contents) and an also be found online.

Laurent Goubet
Obeo
Previous Topic:Nothing is being generated
Next Topic:[Acceleo] Getting object's textual reference
Goto Forum:
  


Current Time: Thu Apr 25 07:08:57 GMT 2024

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

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

Back to the top