Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » generate "wrapper" classes from annotated java
generate "wrapper" classes from annotated java [message #630217] Fri, 01 October 2010 08:12 Go to next message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 13
Registered: October 2010
Junior Member
Hi,

Is it possible to generate ecore model that contains only "wrapper" classes from annotated java interfaces?

E.g.,

public interface PurchaseOrder {
...
}



should result in the folowing ecore class

<eClassifiers xsi:type="ecore:EClass" name="PurchaseOrder" instanceClassName="mypackage.xyz.PurchaseOrder" abstract="true" interface="true"/>

I can specify

@model interface="true" abstract="true"

but is it also possible to specify the instanceClassName ?

Regards,
Stanislav





Re: generate "wrapper" classes from annotated java [message #630302 is a reply to message #630217] Fri, 01 October 2010 13:41 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Stanislav,

Comments below.


Stanislav wrote:
> Hi,
>
> Is it possible to generate ecore model that contains only "wrapper"
> classes from annotated java interfaces?
Yes.
>
> E.g.,
> public interface PurchaseOrder {
> ..
> }
>
>
> should result in the folowing ecore class
>
> <eClassifiers xsi:type="ecore:EClass" name="PurchaseOrder"
> instanceClassName="mypackage.xyz.PurchaseOrder" abstract="true"
> interface="true"/>
>
> I can specify
> @model interface="true" abstract="true"
You don't want the interface to be generated by the model though.
> but is it also possible to specify the instanceClassName ?
Once it's generated, that information is included in the generated model
but I gather you don't want that, though not sure why.

You'll have to include annotations directly in the XyzPackage to define
just wrapper EClasses:

* @model instanceClass="mypackage.xyz.PurchaseOrder"
>
> Regards,
> Stanislav
>
>
>
>
>
>
Re: generate "wrapper" classes from annotated java [message #630382 is a reply to message #630302] Fri, 01 October 2010 19:28 Go to previous messageGo to next message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 13
Registered: October 2010
Junior Member
Hi Ed and thanks for your quick response.

I tried your suggestion but it did not work for me. Apparently I'm doing something wrong. Let me explain what I did.

1. I have a bunch of interfaces that I would like to wrap in EMF classes, e.g.,

package mypackage;
public interface Person {}


package mypackage;
public interface Man extends Person {}


2. I followed your suggestion, created a class MyPackage.java and put some annotations in it

package mypackage;
/**
* @model kind="package"
* @model instanceClass="mypackage.Person"
* @model instanceClass="mypackage.Man
*/
public class InterfacesPackage {}


3. I created a genmodel and imported the annotated java classes.

4. What I got was an ecore model that only contains one packege mypackage.

What is the right way to annotate MyPackage? In addition, do I need to annotate the interfaces as well, e.g.


package mypackage;
/**
* @model interface="true" abstract="true"
*/
public interface Person {}



Your help is very much appreciated.

Cheers,
Stanislav

[Updated on: Fri, 01 October 2010 19:54]

Report message to a moderator

Re: generate "wrapper" classes from annotated java [message #630437 is a reply to message #630382] Sat, 02 October 2010 13:26 Go to previous messageGo to next message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 13
Registered: October 2010
Junior Member
Ok, I think I figured it out.

package mypackage;

/**
* @model kind="package"
*/
public interface MyPackagePackage {

/**
* @model instanceClass="mypackage.Person"
*/
public EClass getPerson();

/**
* @model instanceClass="mypackage.Man" superTypes="mypackage.Person"
*/
public EClass getMan();
}


Now I get an ecore model with wrapper EMF classes. Unfortunately, it seems that the Java importer does not use the annotation superTypes="mypackage.Person". That is, the attribute of ESuper Types of the class Man is not set to Person. Is this a bug of a feature ?

Cheers,
Stanislav

Re: generate "wrapper" classes from annotated java [message #630446 is a reply to message #630437] Sat, 02 October 2010 15:54 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30551
Registered: July 2009
Senior Member
Stanislav,

That annotation isn't supported, but would be nice thing to have. You
might want to open an enhancement request.

Cheers,
Ed


Stanislav wrote:
> Ok, I think I figured it out.
>
> package mypackage;
>
> /**
> * @model kind="package"
> */
> public interface MyPackagePackage {
>
> /**
> * @model instanceClass="mypackage.Person"
> */
> public EClass getPerson();
>
> /**
> * @model instanceClass="mypackage.Man" superTypes="mypackage.Person"
> */
> public EClass getMan();
> }
>
> Now I get an ecore model with wrapper EMF classes. Unfortunately, it
> seems that the Java importer does not use the annotation
> superTypes="mypackage.Person". That is, the attribute of ESuper Types
> of the class Man is not set to Person. Is this a bug of a feature ?
>
> Cheers,
> Stanislav
>
>
Re: generate "wrapper" classes from annotated java [message #630475 is a reply to message #630446] Sun, 03 October 2010 06:10 Go to previous message
Missing name Missing name is currently offline Missing name Missing nameFriend
Messages: 13
Registered: October 2010
Junior Member
Thanks Ed,

I'll open an enhancement request.

Cheers,
Stanislav
Previous Topic:[CDO] Is there any example for offline mode ?
Next Topic:What is the best practice to keep the generated and handmade code in separate files ?
Goto Forum:
  


Current Time: Sat Oct 19 10:47:10 GMT 2019

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

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

Back to the top