[Acceleo] trying to use eGet [message #809037] |
Tue, 28 February 2012 12:20 |
Nicolas SEILLER 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 |
Ed Willink Messages: 7670 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 |
Nicolas SEILLER 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
|
|
|
|
Powered by
FUDForum. Page generated in 0.03822 seconds