Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » Java code from Ecore
Java code from Ecore [message #1066281] Mon, 01 July 2013 21:14 Go to next message
Pedro Pinto is currently offline Pedro PintoFriend
Messages: 12
Registered: April 2013
Junior Member
I would like to know how can I get java code from .ecore metamodel (in this case from atl.ecore) like it's possible, for example, with UML.

Thanks.
Re: Java code from Ecore [message #1066282 is a reply to message #1066281] Mon, 01 July 2013 21:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4154
Registered: July 2009
Senior Member
Hi

Your English is very ambiguous. Try saying what you want more clearly.

Regards

Ed Willink


On 01/07/2013 22:14, Pedro Pinto wrote:
> I would like to know how can I get java code from .ecore metamodel (in
> this case from atl.ecore) like it's possible, for example, with UML.
>
> Thanks.
Re: Java code from Ecore [message #1066301 is a reply to message #1066281] Tue, 02 July 2013 05:34 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26226
Registered: July 2009
Senior Member
Pedro,

Comments below.

On 01/07/2013 11:14 PM, Pedro Pinto wrote:
> I would like to know how can I get java code from .ecore metamodel (in
> this case from atl.ecore) like it's possible, for example, with UML.
This isn't a question that has a general answer. E.g., if I have an
Ecore model for Library or Person, and I have an instance of that, how
is that instance supposed to be mapped to Java? For UML specifically,
there is an importer that will map UML instances to Ecore instances and
from Ecore you can of course generate Java code.
>
> Thanks.
Re: Java code from Ecore [message #1066372 is a reply to message #1066301] Tue, 02 July 2013 11:32 Go to previous messageGo to next message
Pedro Pinto is currently offline Pedro PintoFriend
Messages: 12
Registered: April 2013
Junior Member
Thanks for the replies. I would like to generate Java code from Ecore instances, in concrete from ATL.ecore
Re: Java code from Ecore [message #1066376 is a reply to message #1066372] Tue, 02 July 2013 11:36 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26226
Registered: July 2009
Senior Member
http://help.eclipse.org/juno/index.jsp?topic=/org.eclipse.emf.doc/tutorials/clibmod/clibmod.html

On 02/07/2013 1:32 PM, Pedro Pinto wrote:
> Thanks for the replies. I would like to generate Java code from Ecore
> instances, in concrete from ATL.ecore
Re: Java code from Ecore [message #1066378 is a reply to message #1066372] Tue, 02 July 2013 11:44 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4154
Registered: July 2009
Senior Member
Hi

This still makes no sense to me.

ATL.ecore is a model so the ATL project already provides Java code for it.

You can of course generate your own versions.

If you want a direct Java expression of the ATL code then I think you
may have to wait a few years.

But since I don't know what you mean by Ecore instances, may be you
want something else altogether.

Regards

Ed Willink



On 02/07/2013 12:32, Pedro Pinto wrote:
> Thanks for the replies. I would like to generate Java code from Ecore
> instances, in concrete from ATL.ecore
Re: Java code from Ecore [message #1066393 is a reply to message #1066378] Tue, 02 July 2013 12:15 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 523
Registered: July 2009
Senior Member
Actually I'm not sure if the ATL metamodel is generated using EMF. It might only be used using dynamic EMF.
Re: Java code from Ecore [message #1066495 is a reply to message #1066393] Tue, 02 July 2013 20:59 Go to previous messageGo to next message
Pedro Pinto is currently offline Pedro PintoFriend
Messages: 12
Registered: April 2013
Junior Member
What I'd like is to instantiate a ecore model in java. If you say that already exists for ATL.ecore where could I find it?
Re: Java code from Ecore [message #1066546 is a reply to message #1066495] Wed, 03 July 2013 06:00 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 5574
Registered: July 2009
Senior Member
Am 02.07.2013 22:59, schrieb Pedro Pinto:
> What I'd like is to instantiate a ecore model in java. If you say that already exists for ATL.ecore where could I find
> it?
Perhaps you mean Java code like this:

EAttribute assignee = EcoreFactory.eINSTANCE.createEAttribute();
assignee.setName("assignee");
assignee.setEType(EcorePackage.eINSTANCE.getEString());
assignee.setDefaultValueLiteral(DEFAULT);
assignee.setUnsettable(true);

EClass bugzilla = EcoreFactory.eINSTANCE.createEClass();
bugzilla.setName("Bugzilla");
bugzilla.getEStructuralFeatures().add(assignee);

EPackage p = EcoreFactory.eINSTANCE.createEPackage();
p.setName("p");
p.getEClassifiers().add(bugzilla);

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: Java code from Ecore [message #1066552 is a reply to message #1066495] Wed, 03 July 2013 07:06 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26226
Registered: July 2009
Senior Member
So follow the tutorial, but use a "Ecore model" as the source of your
model in step 1.

On 02/07/2013 10:59 PM, Pedro Pinto wrote:
> What I'd like is to instantiate a ecore model in java. If you say that
> already exists for ATL.ecore where could I find it?
Re: Java code from Ecore [message #1069626 is a reply to message #1066552] Tue, 16 July 2013 09:10 Go to previous messageGo to next message
Pedro Pinto is currently offline Pedro PintoFriend
Messages: 12
Registered: April 2013
Junior Member
I followed this tutorial -> http://eclipsesource.com/blogs/tutorials/emf-tutorial/ and for the ATL example "HelloWorld" it works fine and has everything I wanted/expected. The problem is when I'm doing the same but using this time ATL.ecore. I'm receiving this errors when I try to load the ecore model:

http://img834.imageshack.us/img834/3783/z0vh.png

I can keep going besides this errors and the .genmodel file is generated, but the options for generating the java code are no longer available in this way.
Re: Java code from Ecore [message #1069638 is a reply to message #1069626] Tue, 16 July 2013 09:35 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26226
Registered: July 2009
Senior Member
Pedro,

You can ignore this error (and the ATL folks should fix it). Note the
Generator editor has tabs in the bottom, and this page showing these
errors in only one of the tabs. You can go back to the other tab to
access the GenModel.

On 16/07/2013 11:10 AM, Pedro Pinto wrote:
> I followed this tutorial ->
> http://eclipsesource.com/blogs/tutorials/emf-tutorial/ and for the
> ATL example "HelloWorld" it works fine and has everything I
> wanted/expected. The problem is when I'm doing the same but using this
> time ATL.ecore. I'm receiving this errors when I try to load the ecore
> model:
>
>
>
> I can keep going besides this errors and the .genmodel file is
> generated, but the options for generating the java code are no longer
> available in this way.
Re: Java code from Ecore [message #1069685 is a reply to message #1069638] Tue, 16 July 2013 11:46 Go to previous messageGo to next message
Pedro Pinto is currently offline Pedro PintoFriend
Messages: 12
Registered: April 2013
Junior Member
Thanks for your reply!

I know that besides this errors the model can be generated, but the problem is the option for "Generate Model Code" are no longer available because of this errors.

Here is a picture to exemplify what I'm saying:

http://img96.imageshack.us/img96/8281/6rdo.png
Re: Java code from Ecore [message #1069793 is a reply to message #1069685] Tue, 16 July 2013 15:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 26226
Registered: July 2009
Senior Member
Pedro.

Comments below.


On 16/07/2013 1:46 PM, Pedro Pinto wrote:
> Thanks for your reply!
>
> I know that besides this errors the model can be generated, but the
> problem is the option for "Generate Model Code" are no longer
> available because of this errors.
Doesn't the second 1/2 of the sentence contradict the first 1/2?
>
> Here is a picture to exemplify what I'm saying:
Why does this picture show a model with that menu option enabled?

So the *.genmodel is created? But when you open the editor you see the
error you've shown? And you've located the tabs at the bottom of the
editor that I mentioned. And you can turn to the first tab? That
context menu has disabled menu options?


>
>
>
Re: Java code from Ecore [message #1069839 is a reply to message #1069793] Tue, 16 July 2013 17:32 Go to previous message
Pedro Pinto is currently offline Pedro PintoFriend
Messages: 12
Registered: April 2013
Junior Member
You are right! Since the error was appearing when I was opening with "EMF Generator", I assume that the file couldn't be open, so I was opening with " Sample Ecore Model Editor" and obviously the generation option wasn't there.
Now I follow what you said and just change the tab and I was able to generate the code.

Thanks a lot for your help.
Previous Topic:[ECP][CDO] connect to cdo repository without branching support
Next Topic:Exception in EMF Compare 2.1.0
Goto Forum:
  


Current Time: Thu Nov 27 03:13:47 GMT 2014

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

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