Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] Generating code from multiple metamodels
[Acceleo] Generating code from multiple metamodels [message #522695] Tue, 23 March 2010 16:00 Go to next message
Tobias R is currently offline Tobias RFriend
Messages: 6
Registered: March 2010
Junior Member
Dear all,

I would like to generate code from two models that have different metamodels. Is is possible with Acceleo?

As far as I know, it is not possible to append multiple metamodels to the [model ... /] tag. How can I bypass the problem?

If Acceleo does not allow code generation from multiple metamodels, is there a way to do it with XPAND?

I have only little experience with M2T technologies and am thankful for any help.

Thanks a lot!

Tobias

Re: [Acceleo] Generating code from multiple metamodels [message #522697 is a reply to message #522695] Tue, 23 March 2010 16:13 Go to previous messageGo to next message
Darius Jockel is currently offline Darius JockelFriend
Messages: 63
Registered: July 2009
Member
Hello Tobias,

Tobias R wrote on Tue, 23 March 2010 17:00

... is there a way to do it with XPAND?


Yes, it is possible to import and process multiple different metamodells with Xpand. Xpand also allows a transparent access of the properties of the models. Xpand is independent of any metamodell(-framework) and can process any kind of formal modells.
Adapter for the most common metamodels, like UML, EMF, JavaBeans, XML Schema, are shipped with Xpand.

Regards
Darius

Re: [Acceleo] Generating code from multiple metamodels [message #522856 is a reply to message #522695] Wed, 24 March 2010 08:47 Go to previous messageGo to next message
Stephane Bouchet is currently offline Stephane BouchetFriend
Messages: 280
Registered: July 2009
Senior Member
Hi Tobias,

What acceleo version dou you use ?

With Acceleo 0.9.0, it is possible to do this :
[module myModule('http://www.eclipse.org/emf/eef/components/1.0.0',
'http://www.eclipse.org/emf/2002/Ecore')/]

But with Acceleo version 2.X you cannot have multiple metamodels inside
the same template. the workaround is to split the template.

Tobias R a écrit :
> Dear all,
>
> I would like to generate code from two models that have different
> metamodels. Is is possible with Acceleo?
>
> As far as I know, it is not possible to append multiple metamodels to
> the [model ... /] tag. How can I bypass the problem?
>
> If Acceleo does not allow code generation from multiple metamodels, is
> there a way to do it with XPAND?
>
> I have only little experience with M2T technologies and am thankful for
> any help.
>
> Thanks a lot!
>
> Tobias
>


--
Cheers,

Stéphane Bouchet, OBEO
Re: [Acceleo] Generating code from multiple metamodels [message #523384 is a reply to message #522856] Fri, 26 March 2010 09:25 Go to previous messageGo to next message
Tobias R is currently offline Tobias RFriend
Messages: 6
Registered: March 2010
Junior Member
Hello Stéphane,

I use Eclipse Helios M6 along with Acceleo v 3.0.

Having extended the module declaration to work with multiple metamodels, the Acceleo Lunch configuration dialogue allows me only to specify a single model. How can I load my other models?

Thanks very much for your help!

Tobias
Re: [Acceleo] Generating code from multiple metamodels [message #523406 is a reply to message #523384] Fri, 26 March 2010 09:56 Go to previous messageGo to next message
Stephane Bouchet is currently offline Stephane BouchetFriend
Messages: 280
Registered: July 2009
Senior Member
hi Tobias,

You cannot select multiples models with launch config, but you can have
a model that references your others models. ( for example like genmodel
reference .ecore model )

Tobias R a écrit :
> Hello Stéphane,
>
> I use Eclipse Helios M6 along with Acceleo v 3.0.
> Having extended the module declaration to work with multiple metamodels,
> the Acceleo Lunch configuration dialogue allows me only to specify a
> single model. How can I load my other models?
> Thanks very much for your help!
>
> Tobias


--
Cheers,

Stéphane Bouchet, OBEO
Re: [Acceleo] Generating code from multiple metamodels [message #523426 is a reply to message #523406] Fri, 26 March 2010 08:00 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1895
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090902050401050508090105
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Tobias,

As Stéphane mentionned, the Acceleo UI (thus the launch config) doesn't
allow users to generate on multiple models at once. You can either
create multiple launch configs (one for each of the models for which you
wish to generate), generate an "Acceleo UI plugin" that will
automatically generate all that's need for a right-click action on your
models to generate your code (you'll need to launch a new runtime
configuration with this plugin or install both this plugin and your
generators in your Eclipse to see this action) or create your own code
that will make use of the Acceleo API to launch generation on multiple
models with one click.

Laurent Goubet
Obeo

Stéphane Bouchet wrote:
> hi Tobias,
>
> You cannot select multiples models with launch config, but you can have
> a model that references your others models. ( for example like genmodel
> reference .ecore model )
>
> Tobias R a écrit :
>> Hello Stéphane,
>>
>> I use Eclipse Helios M6 along with Acceleo v 3.0.
>> Having extended the module declaration to work with multiple
>> metamodels, the Acceleo Lunch configuration dialogue allows me only to
>> specify a single model. How can I load my other models?
>> Thanks very much for your help!
>>
>> Tobias
>
>


--------------090902050401050508090105
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=
--------------090902050401050508090105--
Re: [Acceleo] Generating code from multiple metamodels [message #523429 is a reply to message #523426] Fri, 26 March 2010 13:20 Go to previous messageGo to next message
Tobias R is currently offline Tobias RFriend
Messages: 6
Registered: March 2010
Junior Member
First thanks a lot for your information. However, I believe my question is somehow ambiguous --- at least if I regard the posting from Laurent Goubet. So, I don't know if we speak about the same thing.

Let's try to state my problem again Smile

I have two models that conform to two different EMF metamodels. To generate a single source code file, both models are required. In other words, the contents of the two models are supposed to result in a single Java class by using Acceleo.

To summarise: I don't need to generate multiple models at once, however, I need to generate a Java file from two given models!

Is is possible to solve this problem by using a Genmodel?

Thanks a lot!

Tobias
Re: [Acceleo] Generating code from multiple metamodels [message #523579 is a reply to message #523429] Fri, 26 March 2010 22:27 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1895
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------090809040906010608050901
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

Tobias,

Indeed, that wasn't what I understood from your last post :).

If your two models are both required for the generation of a single
file, I believe one of the two references the other? The example of
Stéphane with the genmodel referencing the ecore is a good one : if your
model A has references towards model B, you can simply launch the
generation on A : references to B will be transparently resolved (much
like opening A in the EMF editor transparently loads B when needed if a
reference to it is visited). For example, a "GenPackage" element from
the genmodel has a reference "ecorePackage" that points to an "EPackage"
element from an ecore model.

However, if your two models are totally unrelated (A has no reference
whatsoever to B, B has no reference whatsoever to A), then the use case
cannot be handled through Acceleo (in fact, I fail to see how both could
be required for a single module if they don't share any reference to one
another).

I don't know if this helps, yet if not, I'll have to know a little more
about what you're trying to accomplish, the metamodels and models you
use and why loading both is mandatory.

Laurent Goubet
Obeo

Tobias R wrote:
> First thanks a lot for your information. However, I believe my question
> is somehow ambiguous --- at least if I regard the posting from Laurent
> Goubet. So, I don't know if we speak about the same thing.
>
> Let's try to state my problem again :)
>
> I have two models that conform to two different EMF metamodels. To
> generate a single source code file, both models are required. In other
> words, the contents of the two models are supposed to result in a single
> Java class by using Acceleo.
> To summarise: I don't need to generate multiple models at once, however,
> I need to generate a Java file from two given models!
>
> Is is possible to solve this problem by using a Genmodel?
>
> Thanks a lot!
>
> Tobias


--------------090809040906010608050901
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=
--------------090809040906010608050901--
Re: [Acceleo] Generating code from multiple metamodels [message #523755 is a reply to message #523579] Mon, 29 March 2010 08:23 Go to previous messageGo to next message
Tobias R is currently offline Tobias RFriend
Messages: 6
Registered: March 2010
Junior Member
Thanks a lot for your quick replies.

My question has been solved now. Unfortunately, my problem is not solvable with Acceleo. My two metamodels are totally unrelated. A workaround is to use a M2M along with ATL which supports my requirements.

But one question remains: Will Acceleo support generation of single source files from multiple models in future? This would be a very helpful feature because domains and their models are often divided into submodels in practice. And therefore I believe there is demand for such a feature.

Keep up the good work, Obeo Team! I like Acceleo. It is simple to use and well documented. That's why I decided to use it and not OAW.

Cheers,

Tobias
Re: [Acceleo] Generating code from multiple metamodels [message #524264 is a reply to message #523755] Wed, 31 March 2010 06:26 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1895
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080806070005060305070604
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Tobias,

Acceleo does support generation of files from multiple models ... but
not through its GUI. It is a matter of calling the API with the accurate
arguments (in your case, arguments coming from multiple resources). I
don't think this option will be added to the UI though ; experienced
users can call the API directly, but for all others it would clutter the
UI and make things unclear.

Laurent Goubet
Obeo

Tobias R wrote:
> Thanks a lot for your quick replies.
>
> My question has been solved now. Unfortunately, my problem is not
> solvable with Acceleo. My two metamodels are totally unrelated. A
> workaround is to use a M2M along with ATL which supports my requirements.
> But one question remains: Will Acceleo support generation of single
> source files from multiple models in future? This would be a very
> helpful feature because domains and their models are often divided into
> submodels in practice. And therefore I believe there is demand for such
> a feature.
> Keep up the good work, Obeo Team! I like Acceleo. It is simple to use
> and well documented. That's why I decided to use it and not OAW.
>
> Cheers,
>
> Tobias


--------------080806070005060305070604
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=
--------------080806070005060305070604--
Re: [Acceleo] Generating code from multiple metamodels [message #1690800 is a reply to message #524264] Tue, 31 March 2015 11:44 Go to previous messageGo to next message
Christoforos Zolotas is currently offline Christoforos ZolotasFriend
Messages: 8
Registered: March 2015
Junior Member
Hello,

I have the same issue as the original opener. Pretty much Laurent Goubet clearly answered the question and offered 2 viable options:

a) either to directly use the Acceleo API to load the 2nd model

b) create a reference to the 2nd model from the other one.

Could you please provide me with some resources/links that document:

1) the acceleo API that allows to load the 2nd model

2) demonstrate how to create such a reference between the models? (this would be preferred in my case)

Thanks in advance,
Christoforos
Re: [Acceleo] Generating code from multiple metamodels [message #1691266 is a reply to message #1690800] Sat, 04 April 2015 09:08 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7265
Registered: July 2009
Senior Member
HI

On 31/03/2015 14:41, Christoforos Zolotas wrote:
> Hello,
> I have the same issue as the original opener. Pretty much Laurent
> Goubet clearly answered the question and offered 2 viable options:
> a) either to directly use the Acceleo API to load the 2nd model

Step through your code and emulate the way that the first model is loaded.
>
> b) create a reference to the 2nd model from the other one.
>
Use "Load Resource...." in the Sample Ecore Model Editor.

Regards

Ed Willink
Re: [Acceleo] Generating code from multiple metamodels [message #1691344 is a reply to message #1691266] Mon, 06 April 2015 10:46 Go to previous messageGo to next message
Christoforos Zolotas is currently offline Christoforos ZolotasFriend
Messages: 8
Registered: March 2015
Junior Member
Hello Ed and thank you for your reply,

Before I type anything else let me ask you, should I open a new thread to continue this conversation? I initially asked for more details here as my question is identical to the opener's one.

As of the 1st module loading emulation:

I guess by stepping in my code you mean stepping and editing the "Generate.java" that is automatically generated when I build a new Acceleo project? If yes, let me write down a concrete example, since to me this "emulating" step is not clear at all:

Assume that I have 2 meta-models, MMA and MMB and have already populated two respective models MA (conforming to MMA) and MB (conforming to MMB). And the way I wish my @main template to look is something like this:

[comment encoding = UTF-8 /]
[module generate('file:/...full path to/MMA.ecore', 'file:/...full path to /MMB.ecore')]

[template public generateElement(anMMAElement : MMAElement, anMMBElement : MMBElement)]
[comment @main/]
[file (.....)]
.....
 [anMMAElement.name/]  <-- Access MA model

....
   [anMMBElement.name/]   <-- Access MB model
[/file]
[/template]


I guess that I have to edit the main function in the generate.java file like this? (with a preceding arrow are the added lines):

   public static void main(String[] args) {
        try {
            if (args.length < 2) {
                System.out.println("Arguments not valid : {model, folder}.");
            } else {
                URI modelURI = URI.createFileURI(args[0]);
                File folder = new File(args[1]);
 -->           URI modelMBURI = URI.createFileURI("full path to/modelMB.xmi");[/b]                
                List<String> arguments = new ArrayList<String>();
 -->           arguments.add("anMMBElement : MMB");
               
                Generate generator = new Generate(modelURI, folder, arguments);
-->           Generate modelMBGenerator = new Generate(modelMBURI, folder, arguments);
                
                for (int i = 2; i < args.length; i++) {
                    generator.addPropertiesFile(args[i]);
                }
                
                generator.doGenerate(new BasicMonitor());
-->           modelMBGenerator.doGenerate(new BasicMonitor());
            }


(I do get an Argument types mismatch for module element generateElement exception at the line "generator.doGenerate(new BasicMonitor()); )

Thanks for your feedback,
Christoforos.

[Updated on: Mon, 06 April 2015 10:47]

Report message to a moderator

Re: [Acceleo] Generating code from multiple metamodels [message #1692387 is a reply to message #1691344] Wed, 15 April 2015 12:37 Go to previous messageGo to next message
lucky star is currently offline lucky starFriend
Messages: 44
Registered: April 2015
Member
Hi,
i have a similar kind of issue but i am generating source files(output files) using xpand. In my case i am trying to load two models by loading them in generator.mwe file, but while generating the source files second model output data is replacing the first model output and now the source file is having only one model output. But i want to print both the results in a single output file.Please help me in this by sharing your suggestions or links or examples.

Thank you in advance.
Re: [Acceleo] Generating code from multiple metamodels [message #1693636 is a reply to message #1691344] Mon, 27 April 2015 07:45 Go to previous message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

The list of arguments should just be the list of the objects that you want as arguments. Your template has the following signature:

[template public generateElement(anMMAElement : MMAElement, anMMBElement : MMBElement)]


Then the arguments list should be something like this:

List<MMBElement> arguments = new ArrayList<>();
arguments.add(yourMMBElement);


and not

List<String> arguments = new ArrayList<String>();
arguments.add("anMMBElement : MMB");


And on top of that, do not use the path of the ecore model in the declaration of your module, you should use the NsURI of your EPackages in those ecore model.

[module generate('file:/...full path to/MMA.ecore', 'file:/...full path to /MMB.ecore')]


Regards,

Stephane Bégaudeau, Obeo
Previous Topic:Where to find resources on JET...
Next Topic:XTend + artop combined sdk
Goto Forum:
  


Current Time: Tue Sep 21 12:15:29 GMT 2021

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

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

Back to the top