Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to transform an ecore model into code/artifacts?
How to transform an ecore model into code/artifacts? [message #1132743] Fri, 11 October 2013 11:10 Go to next message
Jean-Baptiste Guillois is currently offline Jean-Baptiste GuilloisFriend
Messages: 33
Registered: August 2011
Member
Hi,

I have created my metamodel (using ecore mechanisms) and have used the OOTB generation features provided to now handle model instances through Java POJOs.
What i would like to do is to generate some code/artifacts that should handle JSON serialization/deserialization of these instances.

I have already succesfully tried the Acceleo tooling for generating stuff given 1) an ecore metamodel and 2) an XML serialization of some instances (created using the Sample Reflective Ecore Model Editor).
My problem is that I don't want to generate some artifacts based on the instances but on the model level, how can I do that?
What Eclipse framework would you recommend to address this kind of need?

Do you have any clues/advices regarding this point?
Many thanks for your help,

Best Regards
Re: How to transform an ecore model into code/artifacts? [message #1132761 is a reply to message #1132743] Fri, 11 October 2013 11:23 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Jean-Baptiste,

Comments below.

On 11/10/2013 1:10 PM, Jean-Baptiste Guillois wrote:
> Hi,
>
> I have created my metamodel (using ecore mechanisms) and have used the
> OOTB generation features provided to now handle model instances
> through Java POJOs.
You mean you just generated the EMF model code as normal and use it...
> What i would like to do is to generate some code/artifacts that should
> handle JSON serialization/deserialization of these instances.
I imagine such a thing could be done reflectively without any generated
code...
>
> I have already succesfully tried the Acceleo tooling for generating
> stuff given 1) an ecore metamodel and 2) an XML serialization of some
> instances (created using the Sample Reflective Ecore Model Editor). My
> problem is that I don't want to generate some artifacts based on the
> instances but on the model level, how can I do that?
Use the model... Again, expect you could use something reflective; you
could look at Texo's Jason support.
> What Eclipse framework would you recommend to address this kind of need?
>
> Do you have any clues/advices regarding this point?
> Many thanks for your help,
>
> Best Regards


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to transform an ecore model into code/artifacts? [message #1132794 is a reply to message #1132761] Fri, 11 October 2013 11:47 Go to previous messageGo to next message
Jean-Baptiste Guillois is currently offline Jean-Baptiste GuilloisFriend
Messages: 33
Registered: August 2011
Member
Hi Ed,
Thx for your email,

1) yes, I meant I generated the EMF Model code as normal
2) Your proposal on doing this reflectively is a bit unclear to me... do you mean that in my own code i should "introspect" the instance classes' and manage it this way?
If this is the case, then indeed it will address this very specific use case BUT i won't be able to *generate* code from my model. For instance:
Let's say I have defined a class "Book" with various attributes.
I would like to generate a "BookHelper" class that will be used for validation or other things...

So my question is how can i generate this BookHelper class?
What kind of framework should i use?

Thx for your help & support,

Best Regards,

-- Jean-Baptiste
Re: How to transform an ecore model into code/artifacts? [message #1132809 is a reply to message #1132794] Fri, 11 October 2013 11:59 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Jean-Baptiste,
You can check out the EMF Texo project, it supports many EMF concepts, supports JSON serialization, JSON CRUD
webservices etc. OOTB. You can also easily extend the templates to generate additional stuff. Texo does not generate the
same code as EMF, there are differences, but also advantages for the use cases for Texo (web-service/server based
environments).

Here are a bunch of wiki links:
http://wiki.eclipse.org/Texo
http://wiki.eclipse.org/Texo/JSON_REST_Web_Services
http://wiki.eclipse.org/Texo/Template_Overriding

gr. Martin

On 10/11/2013 01:47 PM, Jean-Baptiste Guillois wrote:
> Hi Ed,
> Thx for your email,
>
> 1) yes, I meant I generated the EMF Model code as normal
> 2) Your proposal on doing this reflectively is a bit unclear to me... do you mean that in my own code i should
> "introspect" the instance classes' and manage it this way?
> If this is the case, then indeed it will address this very specific use case BUT i won't be able to *generate* code from
> my model. For instance:
> Let's say I have defined a class "Book" with various attributes.
> I would like to generate a "BookHelper" class that will be used for validation or other things...
>
> So my question is how can i generate this BookHelper class?
> What kind of framework should i use?
>
> Thx for your help & support,
>
> Best Regards,
>
> -- Jean-Baptiste


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: How to transform an ecore model into code/artifacts? [message #1133006 is a reply to message #1132809] Fri, 11 October 2013 14:43 Go to previous messageGo to next message
Jean-Baptiste Guillois is currently offline Jean-Baptiste GuilloisFriend
Messages: 33
Registered: August 2011
Member
Hi Martin,
Thx for your reply.
I have installed Texo and succesfully generated my own stuff Wink, it was pretty easy following the "Quick Start" guide.

I have played a bit with the Annoted model, seems to be a cool feature Smile
Nevertheless, I am a bit stuck on how to access my own model annotations from within my xpt template file...

Should I extend Texo annotation model?
Should I browse my model ang search for annotations in the xpt template code?

Do you have any thought on this?

Thx for your help & support,

Best Regards
Re: How to transform an ecore model into code/artifacts? [message #1134472 is a reply to message #1133006] Sat, 12 October 2013 14:23 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Jean-Baptiste,
It is some work to extend the Texo annotation model. It is quite possible though, I use it for the orm/jpa generation.
But I guess the easiest is to access the annotations by going to the ecore model which is loaded in-memory, any
annotations you have specified in the model (as docs) should be reachable through the api.

For examples of xpt templates see here:
http://git.eclipse.org/c/texo/org.eclipse.emf.texo.git/tree/generator/org.eclipse.emf.texo.modelgenerator/src/org/eclipse/emf/texo/modelgenerator/templates

But if you are interested in adding your own annotations model then let me know, I would need to give some pointers, but
could be a good start of a howto on the wiki also.

gr. Martin

On 10/11/2013 04:43 PM, Jean-Baptiste Guillois wrote:
> Hi Martin,
> Thx for your reply.
> I have installed Texo and succesfully generated my own stuff ;), it was pretty easy following the "Quick Start" guide.
>
> I have played a bit with the Annoted model, seems to be a cool feature :)
> Nevertheless, I am a bit stuck on how to access my own model annotations from within my xpt template file...
> Should I extend Texo annotation model?
> Should I browse my model ang search for annotations in the xpt template code?
>
> Do you have any thought on this?
>
> Thx for your help & support,
>
> Best Regards


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Previous Topic:EMF Item Providers for interfaces.
Next Topic:[CDO] In-transaction unique ID generator?
Goto Forum:
  


Current Time: Thu Mar 28 18:38:38 GMT 2024

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

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

Back to the top