Skip to main content



      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 10:41 Go to next message
Eclipse UserFriend
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 16:20 Go to previous messageGo to next message
Eclipse UserFriend
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.
Re: Artifact fileName [message #1767201 is a reply to message #1767165] Mon, 03 July 2017 10:07 Go to previous messageGo to next message
Eclipse UserFriend
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 10:58 Go to previous messageGo to next message
Eclipse UserFriend
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 04:21 Go to previous message
Eclipse UserFriend
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: Wed May 21 05:12:54 EDT 2025

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

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

Back to the top