Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] how to input multiple models URGENT!!(Question about how to give multiple models (conforming to Ecore) as input of a .mtl)
[Acceleo] how to input multiple models URGENT!! [message #769582] Thu, 22 December 2011 11:16 Go to next message
federico ciccozzi is currently offline federico ciccozziFriend
Messages: 1
Registered: December 2011
Junior Member
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 #769599 is a reply to message #769582] Thu, 22 December 2011 11:54 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,

You should have a look at the getArguments() method of the Java launcher. You can load your second model thanks to "ModelUtils.load(...)" and return the root package of your 2nd model. Acceleo will thenhave your first model and your second model and it will try to launch the main template for all EPackage in the first model with the "argument". So if you want something like [template ....(e : SomeStuff, p : EPackage)] you just have to pass the root EPackage of your second model in the argument. You could also create a "supermodel" that has references to both of your models.

Regards,

Stephane Begaudeau, Obeo

--
Twitter: @sbegaudeau & @acceleo
Google+: stephane.begaudeau & acceleo
Blog: http://stephanebegaudeau.tumblr.com
Acceleo Documentation: http://docs.obeonetwork.com/acceleo
Re: [Acceleo] how to input multiple models URGENT!! [message #808155 is a reply to message #769599] Mon, 27 February 2012 13:15 Go to previous messageGo to next message
fabrizio di Giuseppe is currently offline fabrizio di GiuseppeFriend
Messages: 1
Registered: February 2012
Junior Member
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 10:01 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,

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
Re: [Acceleo] how to input multiple models URGENT!! [message #899734 is a reply to message #808937] Thu, 02 August 2012 07:09 Go to previous message
AxA AxA is currently offline AxA AxAFriend
Messages: 5
Registered: July 2012
Junior Member
Hi Stephane,

I'm also trying to load 2 models, I read your first answer but I didn't fully understand:
Quote:

You should have a look at the getArguments() method of the Java launcher. You can load your second model thanks to "ModelUtils.load(...)" and return the root package of your 2nd model. Acceleo will thenhave your first model and your second model and it will try to launch the main template for all EPackage in the first model with the "argument". So if you want something like [template ....(e : SomeStuff, p : EPackage)] you just have to pass the root EPackage of your second model in the argument. You could also create a "supermodel" that has references to both of your models.


I have loaded a first .bpel model and now I'd like to load and use another .wsdl model.
I understand I should modify the generator constructor, could you maybe provide an example?

This is how my generator constructor looks like right now:
public Bpel2java(URI modelURI, File targetFolder,
            List<? extends Object> arguments) throws IOException {
        initialize(modelURI, targetFolder, arguments);
        
    }


Thanks Wink
Previous Topic:[Acceleo] Internal Error ArrayIndexOutOfBoundsException
Next Topic:[acceleo] Question on OCL cache and standalone + thread
Goto Forum:
  


Current Time: Fri Apr 19 03:12:08 GMT 2024

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

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

Back to the top