Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] trying to use eGet
[Acceleo] trying to use eGet [message #809037] Tue, 28 February 2012 12:20 Go to next message
Nicolas SEILLER is currently offline Nicolas SEILLERFriend
Messages: 10
Registered: May 2011
Junior Member
Hello,

I am experiencing trouble while trying to use acceleo's "eGet" query.

I am trying to generate text from an element of my model. For the sake of code reuse, I created a template which generates text from the name of a feature of the model element. In this template I call acceleo's "eGet" in which I pass on the name of the property I want to get. Here is the code sample:

[template public generateProperty(element : Element, propertyName : String, featureName : String) post (trim())]

[propertyName.toUpper()/]=[element.eGet(featureName)/]

[/template]

My problem arises for a particular feature of Element. The text output for this particular feature is empty. I defined this feature unchangeable, volatile, transient and derived in my ecore model. I guess the transient, unchangeable and derived property do not influence the result. But I do guess that volatile features do not work properly with acceleo's "eGet". Is my guess correct ? If so would there be any workaround ?

Regards,
--
Nicolas

[Updated on: Tue, 28 February 2012 12:21]

Report message to a moderator

Re: [Acceleo] trying to use eGet [message #809053 is a reply to message #809037] Tue, 28 February 2012 12:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4151
Registered: July 2009
Senior Member
Hi

Modeling tools understand models; they are therefore better than Java,
so there is no need for eGet.

Just do element.featureName

Regards

Ed Willink

On 28/02/2012 12:20, Nicolas SEILLER wrote:
> Hello,
>
> I am trying to generate text from an element of my model. For the sake
> of code reuse, I created a template which generates text from the name
> of a feature of the model element. In this template I call acceleo's
> "eGet" in which I pass on the name of the property I want to get. Here
> is the code sample:
>
> [template public generateProperty(element : Element, propertyName :
> String, featureName : String) post (trim())]
>
> [propertyName.toUpper()/]=[element.eGet(featureName)/]
>
> [/template]
>
> My problem arises for a particular feature of Element. The text output
> for this particular feature is empty. I defined this feature
> unchangeable, volatile, transient and derived in my ecore model. I
> guess the transient, unchangeable and derived property do not
> influence the result. But I do guess that volatile features do not
> work properly with acceleo's "eGet". Is my guess correct ? If so would
> there be any workaround ?
>
> Regards,
> --
> Nicolas
Re: [Acceleo] trying to use eGet [message #809059 is a reply to message #809053] Tue, 28 February 2012 12:49 Go to previous messageGo to next message
Nicolas SEILLER is currently offline Nicolas SEILLERFriend
Messages: 10
Registered: May 2011
Junior Member
Hello Edward,

thank you very much for your reply but using element.featureName as you suggest wouldn't work because featureName is a string containing the name of a feature. It is not the feature itself. Let's say 'element' contains two features, one called f1 and one called f2. 'featureName' would then be a string containing 'f1' or 'f2', without the application being aware of it. Then the call to my template would look like something like this:

[generateProperty('FEATURE1', 'f1')/]
[generateProperty('FEATURE2', 'f2')/]

As I said, I am not using Java, the eGet I use is pure Acceleo language.

I hope things are clearer now.

Regards,
--
Nicolas

[Updated on: Tue, 28 February 2012 12:52]

Report message to a moderator

Re: [Acceleo] trying to use eGet [message #809073 is a reply to message #809059] Tue, 28 February 2012 13:01 Go to previous message
Nicolas SEILLER is currently offline Nicolas SEILLERFriend
Messages: 10
Registered: May 2011
Junior Member
And I just realize that it might not come from "eGet", even element.f2 doesn't seem to be working (if we set up that f2 is the volatile feature).
Previous Topic:[Acceleo ]ECORE Loop over References
Next Topic:[MWE,JET] no auto complete in either?
Goto Forum:
  


Current Time: Mon Nov 24 09:33:01 GMT 2014

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

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