Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [ACCELEO] new metamodel(add new metamodel and use it)
[ACCELEO] new metamodel [message #668790] Sat, 07 May 2011 14:09 Go to next message
radwane  is currently offline radwane Friend
Messages: 27
Registered: April 2011
Junior Member
hi
this is my file generator.mtl

[comment encoding = UTF-8 /]
[module generate('http://www.eclipse.org/uml2/3.0.0/UML')/]
[template public generate(aClass : Class)]
[file (aClass.name.concat('.java'), false)]
public class [aClass.name.toUpperFirst()/] {
[for (p: Property | aClass.attribute) separator('\n')]
private [p.type.name/] [p.name/];
[/for]

[for (p: Property | aClass.attribute) separator('\n')]
public [p.type.name/] get[p.name.toUpperFirst()/]() {
return this.[p.name/];
}
[/for]

[for (o: Operation | aClass.ownedOperation) separator('\n')]
public [o.type.name/] [o.name/]() {
// TODO should be implemented
}
[/for]
}
[/file]
[/template]


its ok if i choise input file .uml
but if i want to use my model .xmi i must change this ligne
[module generate('http://www.eclipse.org/uml2/3.0.0/UML')/]
but i dont know what i must write ?
Re: [ACCELEO] new metamodel [message #669399 is a reply to message #668790] Tue, 10 May 2011 08:17 Go to previous message
Stephane Begaudeau is currently offline Stephane BegaudeauFriend
Messages: 458
Registered: April 2010
Location: Nantes (France)
Senior Member

Hi,

If you have a file with the "xmi" extension, I assume that you have created a dynamic instance of an element of a metamodel that you have created. If this is the case, then you need to define your Acceleo module on your own concepts not on UML.

You can see how it is done in this screenshot:
https://lh5.googleusercontent.com/_R0aPxLxg16E/TaWiybT6r0I/AAAAAAAAAPQ/3PVq38MefA4/s600/DynamicMetamodelDependencies.png

In this example, my Acceleo module is defined on myecore and myecore1 which are the URIs of my two metamodels. If you click on the root package of your metamodel in your ".ecore" file you can see its uri. Since you are using a dynamic metamodel, the URI will not appear in the wizard for the creation of a new module, you will have to edit the module after its creation.

The metamodel(s) used in the Acceleo module:
[module mymodule('myMetamodel1', 'myMetamodel2')]

it must be the same metamodel for your model (as I have explained it to leila already).

Since you and leila don't seem to understand this simple principle that I have already explained to you. Here is a nice screenshot explaining the same thing:

https://lh3.googleusercontent.com/_R0aPxLxg16E/TcjzTPYCuHI/AAAAAAAAARw/UbTH4KyRgio/s600/MetamodelDynamique.png

You see the difference with your situation ? You can't define a generator that will manipulate potatoes and carrots and give it a model about flying pigs and then expect a result!

Stephane Begaudeau, Obeo
--
Twitter: @sbegaudeau
Acceleo wiki: http://wiki.eclipse.org/Acceleo
Blogs: http://stephanebegaudeau.tumblr.com & http://sbegaudeau.tumblr.com
Previous Topic:an executable file
Next Topic:[ACCELEO] Overwriting existing files?
Goto Forum:
  


Current Time: Sat Nov 09 01:44:50 GMT 2024

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

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

Back to the top