Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Doesn't transform classes that are inside packages
icon8.gif  [Acceleo] Doesn't transform classes that are inside packages [message #1034285] Fri, 05 April 2013 08:43 Go to next message
Javier García is currently offline Javier GarcíaFriend
Messages: 129
Registered: April 2013
Senior Member
Hi everyone,
I'm facing a problem with Acceleo 3, I'll try to explain in detail.
I generate a UML file from Java code using MoDisco, then with Papyrus I set a profile on that model, then I transform it with ATL to another UML model and finally I transform it to Java code again using Acceleo.

The classes are inside a package, which is inside another package, which is inside a model, which is inside another model.
Now the problem is that none of these classes are getting generated, so I tried taking the classes out of the package and the generation works perfectly, so I think it's not a problem with the template or the .mtl file and it's not either a problem with the classes, it seems like Acceleo has a problem accessing the classes inside these packages, does anyone know how could I fix this?

The idea is to use this on many different models, so I can' be editing all models to take the classes out of their packages.

Thanks in advance,
greetings
Javier
Re: [Acceleo] Doesn't transform classes that are inside packages [message #1036319 is a reply to message #1034285] Mon, 08 April 2013 08:21 Go to previous messageGo to next message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

Acceleo can generate code from UML classes nested inside packages. What is the code that you are using in your template to navigate inside of model? Something like this would work:

[module myModule('http://www.eclipse.org/uml2/4.0.0/UML')]

[template public aTemplate(aModel: Model)]
[comment @main/]
[aModel.eAllContents(Class).generateFile()/]
[/template]

[template private generateFile(aClass: Class)]
[file (aClass.name + '.java', false, 'UTF-8)]
[aClass.name/]
[/file]
[/template]


".eAllContents(Type)" is here used to navigate recursively on all the children of my model object to select all the children with the type "Class".

If you are looking for an UML to Java generator, I have realized one for UML2 v3.x.x and UML2 v4.x.x, it is open source and available on Github (branch R1_0_maintenance for UML2 v3 (UML to Java 1.0.x) and branch master for UML2 v4 (UML to Java 2.0.x)). This generator comes with its dedicated launch configuration to specify the options of the generation and it also generates Eclipse project for each UML components located in your model. The version 2.0.0 will be released in a couple of days for the new release of UML Designer.

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau
Google+: +stephane.begaudeau
Blog: http://stephanebegaudeau.tumblr.com | Eclipse Java Development Tools Tips and Tricks

[Updated on: Mon, 08 April 2013 08:23]

Report message to a moderator

Re: [Acceleo] Doesn't transform classes that are inside packages [message #1037260 is a reply to message #1036319] Tue, 09 April 2013 10:52 Go to previous message
Javier García is currently offline Javier GarcíaFriend
Messages: 129
Registered: April 2013
Senior Member
Hi Stephane,
thanks a lot, I must have been doing something wrong on the template because I started using a newly created one and it all seemed to work properly.
Also thanks for the link to your project, it might actually prove very useful to me, thanks!
Previous Topic:[Acceleo] Cannot find the Acceleo perspective after installation
Next Topic:[Acceleo] Generate Eclipse Project
Goto Forum:
  


Current Time: Wed Apr 24 17:23:27 GMT 2024

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

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

Back to the top