Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Generate Java annotations from EAnnotation's(Generate custom java annotations in generated code)
Generate Java annotations from EAnnotation's [message #1697042] Mon, 01 June 2015 07:27 Go to next message
Gordan Vosicki is currently offline Gordan VosickiFriend
Messages: 13
Registered: March 2013
Junior Member
It is of course possible to generate an ECore model from annotated Java.
But is there a standats EAnnotation which would cause a Java annotation to be generated in the generated code (like "body" to generate the source code of a method, but before the method declaration) ?

This annotation would apply to class, attribute, reference and operation.
I would need it because some of my ecore models are generated from another source and it would be an elegant way to pass additional informations to runtime (UI, DB).
It could also be useful regarding the Java validation API (JSR-303).

It would probably not be difficult, but I'm not exactly fluent with templates ...

[Updated on: Mon, 01 June 2015 11:11]

Report message to a moderator

Re: Generate Java annotations from EAnnotation's [message #1697071 is a reply to message #1697042] Mon, 01 June 2015 11:53 Go to previous messageGo to next message
Leonid Ripeynih is currently offline Leonid RipeynihFriend
Messages: 150
Registered: February 2012
Senior Member
Have a look at the Texo project, maybe...
Re: Generate Java annotations from EAnnotation's [message #1697110 is a reply to message #1697071] Mon, 01 June 2015 16:18 Go to previous messageGo to next message
Gordan Vosicki is currently offline Gordan VosickiFriend
Messages: 13
Registered: March 2013
Junior Member
Well, Texo does indeed add JPA or similar annotations in the generated code, but it does not help inserting custom annotations in the Java source code.
Re: Generate Java annotations from EAnnotation's [message #1697114 is a reply to message #1697110] Mon, 01 June 2015 16:47 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33133
Registered: July 2009
Senior Member
Gordon,

I've never looked into how one might try to support something like this...


On 01/06/2015 6:18 PM, Gordan Vosicki wrote:
> Well, Texo does indeed add JPA or similar annotations in the generated
> code, but it does not help inserting custom annotations in the Java
> source code.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Generate Java annotations from EAnnotation's [message #1697119 is a reply to message #1697110] Mon, 01 June 2015 17:26 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
With Texo you can also define manual annotations in the ecore which are transferred to the code:
https://wiki.eclipse.org/Texo/Direct_Java_Annotations

The nice thing is that import resolving/code formatting is done for these manual annotations also.

gr. Martin

On 01-06-15 18:18, Gordan Vosicki wrote:
> Well, Texo does indeed add JPA or similar annotations in the generated code, but it does not help inserting custom
> annotations in the Java source code.


--

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: Generate Java annotations from EAnnotation's [message #1697171 is a reply to message #1697119] Tue, 02 June 2015 07:25 Go to previous messageGo to next message
Gordan Vosicki is currently offline Gordan VosickiFriend
Messages: 13
Registered: March 2013
Junior Member
The same feature for Java annotations in standard EMF generation would be great ...
Actually, at some point, I need the "e" feratures (like eClass()), so Texo does not work for all cases.

Also, JPA is limited to relational databases.
Actually, a great thing would be to have direct JDO generation, actually having a JDO StateManager using the EMF introspection features, without the need for "enhancement" ... but that's another chapter !
Re: Generate Java annotations from EAnnotation's [message #1697182 is a reply to message #1697171] Tue, 02 June 2015 08:12 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
The "e" features are also there in Texo:
https://wiki.eclipse.org/Texo/Runtime_Model#Model-driven_access_to_Pojo.27s

But JDO is not there in Texo for sure.

gr. Martin

On 02-06-15 09:25, Gordan Vosicki wrote:
> The same feature for Java annotations in standard EMF generation would be great ...
> Actually, at some point, I need the "e" feratures (like eClass()), so Texo does not work for all cases.
>
> Also, JPA is limited to relational databases.
> Actually, a great thing would be to have direct JDO generation, actually having a JDO StateManager using the EMF
> introspection features, without the need for "enhancement" ... but that's another chapter !


--

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: Generate Java annotations from EAnnotation's [message #1698540 is a reply to message #1697042] Tue, 16 June 2015 10:09 Go to previous messageGo to next message
Gordan Vosicki is currently offline Gordan VosickiFriend
Messages: 13
Registered: March 2013
Junior Member
Slightly off-topic, but not really:
Wouldn't a package like "org.eclipse.emf.texo.annotations.annotationsmodel" have its place right in the EMF core as a "companion model" ?

The rationale is not to lose the annotations if the base model source is not ecore, XML, annotated Java or anything else and that base ecore model gets regenerated with slight changes ?
Re: Generate Java annotations from EAnnotation's [message #1698548 is a reply to message #1698540] Tue, 16 June 2015 11:13 Go to previous messageGo to next message
Gordan Vosicki is currently offline Gordan VosickiFriend
Messages: 13
Registered: March 2013
Junior Member
Martin, I definitely need JDO support because some use cases involve a non-SQL datastore (ex. a CAD drawing !).
After a quick look, one of the best solutions would be to add JDO generation in Texo as a variant of JPA.

The data classes could be generated already "source-enhanced" and many annotations are quite similar, as well as the O/R mapping variant for JDO.
If we decide to go this way, would you be interested in having this JDO feature incorporated in Texo, and would you be ready to eventually give a few tips/advice for project layout and organisation and maybe a few technical questions and then have these new features integrated in the Texo project ?

It's a pity that those two great products (EMF/ECore and JDO) don't yet talk together !

[Updated on: Tue, 16 June 2015 11:22]

Report message to a moderator

Re: Generate Java annotations from EAnnotation's [message #1698644 is a reply to message #1698548] Tue, 16 June 2015 22:08 Go to previous message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi Gordan,
Yes quite interesting!

For the forum/newsgroup followup/archive, we will continue the discussion directly through email on this topic.

gr. Martin

On 16-06-15 13:13, Gordan Vosicki wrote:
> Martin, I definitely need JDO support because some use cases involve a non-SQL datastore (ex. a CAD drawing !).
> After a quick look, one of the best solutions would be to add JDO generation in Texo as a variant of JPA.
>
> The data classes could be generated already "source-enhanced" and many annotations are quite similar, as well as the O/R
> mapping variant of JDO.
> If we decide to go this way, would you be interested in having this JDO feature incorporated in Texo, and would you be
> ready to eventually give a few tips/advice for project layout and organisation and maybe a few technical questions and
> then have these new features integrated in the Texo project ?
>
>


--

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:[CDO] Elements choice remains empty in properties view
Next Topic:Run CDO Hibernate server feature
Goto Forum:
  


Current Time: Tue Apr 16 14:06:51 GMT 2024

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

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

Back to the top