Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Main
[Acceleo] Main [message #538202] Sun, 06 June 2010 11:09 Go to next message
Daniel  is currently offline Daniel Friend
Messages: 44
Registered: June 2010
Member
Hi, I have some problems understanding how the mt2mtl creates the main entry point:

I had a module with a chain that called 4 templates, class, enum, interface and core.

When doing the mt2mtl it generates this file:

[module main('http://www.eclipse.org/uml2/2.1.0/UML')/]

[import org::acceleo::module::pim::uml21::gen::java::class /]
[import org::acceleo::module::pim::uml21::gen::java::enum /]
[import org::acceleo::module::pim::uml21::gen::java::interface /]
[import org::acceleo::module::pim::uml21::gen::java::validator::core /]

[template public main(c : Class)]
[comment @main /]

[comment Call the file block in 'class' /]
[ classJava() /]

[comment Call the file block in 'enum' /]
[ enumJava() /]

[comment Call the file block in 'interface' /]
[ interfaceJava() /]

[comment Call the file block in 'core' /]
[ validator() /]

[/template]

It gaves me errors when trying to call enumJava, interfaceJava and validator. I think this is because of the:

[template public main(c : Class)]

The problem is that core operates a UML model, enum operates Enumerations, interface operates Interfaces and class (the only one without errors) operates classes.

When doing the mt2mtl I choose generate for metamodel:

http://www.eclipse.org/uml2/2.1.0/UML

And for type:

Class

I tried generating for type "Model" and then all fails except for validator which is applied correctly to model.

How could I fix this? I mean, how can I tell Acceleo to apply class to classes, enum to enumerations, interface to interfaces and validator to model?

Should I generate different main points? Or should I call it on model and search for the classes and enumerations and interfaces present on the model?

Thank you very much!
Re: [Acceleo] Main [message #538299 is a reply to message #538202] Mon, 07 June 2010 08:36 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1638
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------040408070105080600070809
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Daniel,

The main file we generate is but a stub : as you found out Acceleo 3
operates quite differently from Acceleo 2. I'd say the best way of doing
what you wish to is to call your template on Model and iterate to find
the other arguments :

[template public main(m : Model)]
[comment @main /]

[comment Call the file block in 'class' /]
[ m.packagedElements()->filter(Class).classJava() /]

[comment Call the file block in 'enum' /]
[ m.packagedElements()->filter(Enum).enumJava() /]

[comment Call the file block in 'interface' /]
[ m.packagedElements()->filter(Interface).interfaceJava() /]

[comment Call the file block in 'core' /]
[ validator() /]
[/template]

Laurent Goubet
Obeo

Daniel wrote:
> Hi, I have some problems understanding how the mt2mtl creates the main
> entry point:
>
> I had a module with a chain that called 4 templates, class, enum,
> interface and core.
>
> When doing the mt2mtl it generates this file:
>
> [module main('http://www.eclipse.org/uml2/2.1.0/UML')/]
>
> [import org::acceleo::module::pim::uml21::gen::java::class /]
> [import org::acceleo::module::pim::uml21::gen::java::enum /]
> [import org::acceleo::module::pim::uml21::gen::java::interface /]
> [import org::acceleo::module::pim::uml21::gen::java::validator::core /]
>
> [template public main(c : Class)]
> [comment @main /]
>
> [comment Call the file block in 'class' /]
> [ classJava() /]
>
> [comment Call the file block in 'enum' /]
> [ enumJava() /]
>
> [comment Call the file block in 'interface' /]
> [ interfaceJava() /]
>
> [comment Call the file block in 'core' /]
> [ validator() /]
>
> [/template]
>
> It gaves me errors when trying to call enumJava, interfaceJava and
> validator. I think this is because of the:
>
> [template public main(c : Class)]
>
> The problem is that core operates a UML model, enum operates
> Enumerations, interface operates Interfaces and class (the only one
> without errors) operates classes.
>
> When doing the mt2mtl I choose generate for metamodel:
>
> http://www.eclipse.org/uml2/2.1.0/UML
>
> And for type:
>
> Class
>
> I tried generating for type "Model" and then all fails except for
> validator which is applied correctly to model.
>
> How could I fix this? I mean, how can I tell Acceleo to apply class to
> classes, enum to enumerations, interface to interfaces and validator to
> model?
>
> Should I generate different main points? Or should I call it on model
> and search for the classes and enumerations and interfaces present on
> the model?
>
> Thank you very much!
>


--------------040408070105080600070809
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------040408070105080600070809--
Re: [Acceleo] Main [message #538742 is a reply to message #538299] Tue, 08 June 2010 14:18 Go to previous messageGo to next message
Daniel  is currently offline Daniel Friend
Messages: 44
Registered: June 2010
Member
Hi, in the end I used::

[template public main(m : Model)]
[comment @main /]

[comment Call the file block in 'class' /]
[m.packagedElement->filter(Class).classJava() /]

[comment Call the file block in 'enum' /]
[ m.packagedElement->filter(Enumeration).enumJava() /]

[comment Call the file block in 'interface' /]
[ m.packagedElement->filter(Interface).interfaceJava() /]

[comment Call the file block in 'core' /]
[ validator() /]

[/template]

Because I couldnt find the method packagedElements().

Only one more question, do I have to change the Main.java now that I am applying the main method on a model instead of a class?

Thank you very much again!
Re: [Acceleo] Main [message #538780 is a reply to message #538742] Tue, 08 June 2010 15:29 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1638
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090003070903000901030409
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi,

Comments inlined below.

Laurent Goubet
Obeo

Daniel wrote:
> Hi, in the end I used::
>
> [template public main(m : Model)]
> [comment @main /]
>
> [comment Call the file block in 'class' /]
> [m.packagedElement->filter(Class).classJava() /]
>
> [comment Call the file block in 'enum' /]
> [ m.packagedElement->filter(Enumeration).enumJava() /]
>
> [comment Call the file block in 'interface' /]
> [ m.packagedElement->filter(Interface).interfaceJava() /]
>
> [comment Call the file block in 'core' /]
> [ validator() /]
>
> [/template]
>
> Because I couldnt find the method packagedElements().

I wrote my answer directly from thunderbird, so I didn't have syntax
verification :p. Your version is correct.

>
> Only one more question, do I have to change the Main.java now that I am
> applying the main method on a model instead of a class?

It should have been re-generated as soon as you saved the main.mtl ; you
don't have to manually change it.

>
> Thank you very much again!


--------------090003070903000901030409
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------090003070903000901030409--
Re: [Acceleo] Main [message #538854 is a reply to message #538780] Tue, 08 June 2010 19:33 Go to previous message
Daniel  is currently offline Daniel Friend
Messages: 44
Registered: June 2010
Member
Perfect! Thank you very much
Previous Topic:[Acceleo] For one Colaboration, no name attribute in the owned Interaction
Next Topic:[Acceleo] Launching java services from a .mtl file
Goto Forum:
  


Current Time: Wed Nov 26 23:39:19 GMT 2014

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

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