[Acceleo] how to input multiple models URGENT!! [message #769582] |
Thu, 22 December 2011 06:16  |
Eclipse User |
|
|
|
Hi All,
I have this problem.
I'm writing higher-order transformations for merging models.
In order to generate the transformation I need to give two Ecore models as input for my .mtl in Acceleo.
Is it possible, and in that case how, to input two models in Acceleo?
I tried with:
[template public generateClass(root : EPackage, root2 : EPackage)]
but then in the run configuration I can only input one model.
I would very much appreciate some helpful comments since I'm quite in a hurry.
Thanks in advance,
Federico
|
|
|
|
Re: [Acceleo] how to input multiple models URGENT!! [message #808155 is a reply to message #769599] |
Mon, 27 February 2012 08:15   |
Eclipse User |
|
|
|
hi
I'm fabrizio
I have a problem
I did not understand how load multiple models into Acceleo file.mtl
help me please
I have a NodeSpecification.xmi model conforming to Node.ecore metamodel
how load the model into Acceleo?
how to use the command ModelUtils.Load (....)?
example:
file.mtl
[comment encoding = UTF-8 /]
[module iniFile('it.univaq.wsn.sa','it.univaq.wsn.node')]
[query public load(rec : String) : NodeSpecification = invoke('it.univaq.wsn.acceleo.common.LoadModels', 'gen(java.lang.String)', Sequence{'rec'}) /]
[template public iniGen(a : NodeSpecification)]
[comment @main /]
[file ('sample.txt', false, 'Cp1252')]
[let var : NodeSpecification = load('ciao')]
[var/]
[for (app : Node | var.nodes)]
[name/]
[/for]
[/let]
[/file]
[/template]
LoadModels.java
public class LoadModels {
public static EObject gen(String args) throws IOException, ParserConfigurationException, SAXException {
ResourceSet rs = new ResourceSetImpl();
rs.getEObject(URI.createFileURI("C:/Documents and Settings/Brizio/workspace/it.univaq.wsn.examples/nodes/NodeSpecification.xmi"), true);
EObject model = ModelUtils.load(new java.io.File("C:/Documents and Settings/Brizio/workspace/it.univaq.wsn.examples/nodes/NodeSpecification.xmi"),rs);
System.out.println(model);
}
}
|
|
|
Re: [Acceleo] how to input multiple models URGENT!! [message #808937 is a reply to message #808155] |
Tue, 28 February 2012 05:01   |
Eclipse User |
|
|
|
Hi,
If you want to generate something, remove this query (you do not load the model this way) and try something like this:
[comment encoding = UTF-8 /]
[module iniFile('it.univaq.wsn.sa','it.univaq.wsn.node')]
[template public iniGen(a : NodeSpecification)]
[comment @main /]
[file ('sample.txt', false, 'Cp1252')]
[let var : NodeSpecification = load('ciao')]
[var/]
[for (app : Node | var.nodes)]
[name/]
[/for]
[/let]
[/file]
[/template]
Then, right click on your module and select Run as -> Acceleo application. In the launch configuration, choose your model and the output folder and then click on Run. If you want to see the launch of an Acceleo generator (and loading of the input model) in video, have a look here in the second video starting at 12min48s, you will see it.
Regards,
Stephane Begaudeau, Obeo
--
Twitter: @sbegaudeau & @acceleo
Google+: stephane.begaudeau & acceleo
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
|
|
|
|
Powered by
FUDForum. Page generated in 0.25464 seconds