Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Customising the source codes generated from a model by EMF
Customising the source codes generated from a model by EMF [message #427289] Wed, 11 February 2009 09:10 Go to next message
Yeu Wen Mak is currently offline Yeu Wen MakFriend
Messages: 14
Registered: July 2009
Location: Melbourne, Australia
Junior Member

Hi all,

If I would like to modify the Java Interfaces that are generated from an
EMF model, ie the outputs as a result of right-clicking the root model
object in xxx.genmodel, what is the recommended way to achieve that?

If I import an industry standard XSDs like those defined in Universal
Business Language (UBL) from OASIS to obtain an EMF Model, what is the
best way for me to generate Java Interfaces from the model? For eg, a
Purchase Order in XSD format will result in PurchaseOrderValue,
PurchaseOrderKey, PurchaseOrderException POJOs and a CRUD service such as
PurchaseOrderValue getPurchaseOrderByKey(PurchaseOrderKey) throws
PurchaseOrderException. Create a UML2 profile on a UML2 Model?

To be more specific, the EMF tutorials show an example of how
LibraryPackage.java is generated from Library EMF model. Can I customise
the generation engine to generate LibrarySessionBean.java for use in an
EJB3.0 container instead?

Thank you.

Yeu Wen
Re: Customising the source codes generated from a model by EMF [message #427296 is a reply to message #427289] Wed, 11 February 2009 13:05 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------020101030002050003010600
Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Yeu Wen,

Comments below.


Yeu Wen Mak wrote:
> Hi all,
>
> If I would like to modify the Java Interfaces that are generated from
> an EMF model, ie the outputs as a result of right-clicking the root
> model object in xxx.genmodel, what is the recommended way to achieve
> that?
Have a look at
http://wiki.eclipse.org/index.php/EMF/FAQ#What_are_Dynamic_T emplates.3F?
> If I import an industry standard XSDs like those defined in Universal
> Business Language (UBL) from OASIS to obtain an EMF Model, what is the
> best way for me to generate Java Interfaces from the model?
The normal way: Tutorial: Generating an EMF Model using XML Schema
< http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/tutorials/xlibmod/xlibmod.html>

> For eg, a Purchase Order in XSD format will result in
> PurchaseOrderValue, PurchaseOrderKey, PurchaseOrderException POJOs and
> a CRUD service such as PurchaseOrderValue
> getPurchaseOrderByKey(PurchaseOrderKey) throws PurchaseOrderException.
> Create a UML2 profile on a UML2 Model?
Probably it's generally better to keep the service separate from the
data model.
>
> To be more specific, the EMF tutorials show an example of how
> LibraryPackage.java is generated from Library EMF model. Can I
> customise the generation engine to generate LibrarySessionBean.java
> for use in an EJB3.0 container instead?
The org.eclipse.emf.examples.generator.validator example shows how to
specialize the generator to produce additional artifacts as opposed to
changing how existing files are generated, which is done with dynamic
templates.
>
> Thank you.
>
> Yeu Wen
>
>

--------------020101030002050003010600
Content-Type: text/html; charset=ISO-8859-15
Content-Transfer-Encoding: 8bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-15"
http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Yeu Wen,<br>
<br>
Comments below.<br>
<br>
<br>
Yeu Wen Mak wrote:
<blockquote
cite="mid:75f9ae6891dc6fb6a7b30ae416edb68d$1@www.eclipse.org"
type="cite">Hi all,
<br>
<br>
If I would like to modify the Java Interfaces that are generated from
an EMF model, ie the outputs as a result of right-clicking the root
model object in xxx.genmodel, what is the recommended way to achieve
that? <br>
</blockquote>
Have a look at <a
href=" http://wiki.eclipse.org/index.php/EMF/FAQ#What_are_Dynamic_T emplates.3F"> http://wiki.eclipse.org/index.php/EMF/FAQ#What_are_Dynamic_T emplates.3F</a>?
<blockquote
cite="mid:75f9ae6891dc6fb6a7b30ae416edb68d$1@www.eclipse.org"
type="cite">If I import an industry standard XSDs like those defined
in Universal Business Language (UBL) from OASIS to obtain an EMF Model,
what is the best way for me to generate Java Interfaces from the model?
<br>
</blockquote>
The normal way: <a
href=" http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/tutorials/xlibmod/xlibmod.html">Tutorial:
Generating an EMF Model using XML Schema</a>
<blockquote
cite="mid:75f9ae6891dc6fb6a7b30ae416edb68d$1@www.eclipse.org"
type="cite"> For eg, a Purchase Order in XSD format will result in
PurchaseOrderValue, PurchaseOrderKey, PurchaseOrderException POJOs and
a CRUD service such as PurchaseOrderValue
getPurchaseOrderByKey(PurchaseOrderKey) throws PurchaseOrderException.
Create a UML2 profile on a UML2 Model?
<br>
</blockquote>
Probably it's generally better to keep the service separate from the
data model.<br>
<blockquote
cite="mid:75f9ae6891dc6fb6a7b30ae416edb68d$1@www.eclipse.org"
type="cite"><br>
To be more specific, the EMF tutorials show an example of how
LibraryPackage.java is generated from Library EMF model.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Customising the source codes generated from a model by EMF [message #427311 is a reply to message #427296] Thu, 12 February 2009 04:03 Go to previous messageGo to next message
Yeu Wen Mak is currently offline Yeu Wen MakFriend
Messages: 14
Registered: July 2009
Location: Melbourne, Australia
Junior Member

Hi Ed,

Thank you for the hints. Unfortunately, I am unable to find
org.eclipse.emf.examples.generator.validator example in my plugins folder.
I am using EMF 2.4.1 now.

Can you provide more details of the above example as I really want to
generate additional java interfaces from the EMF model created from the
original input XSDs?

Thank you.

yeuwen
Re: Customising the source codes generated from a model by EMF [message #427313 is a reply to message #427296] Thu, 12 February 2009 07:20 Go to previous messageGo to next message
Yeu Wen Mak is currently offline Yeu Wen MakFriend
Messages: 14
Registered: July 2009
Location: Melbourne, Australia
Junior Member

Also, you mentioned about keeping data separate from services below. Can
you elaborate please?

I plan to have both of them generated from the same EMF model.

The other approach I am contemplating is to import the XSDs into UML2
graphical editor, apply transformation into a service and a data models
(for eg each datatype from the XSD will result in 4 CRUD service
interfaces and 1 ValueObject interface (all platform-neutral), then apply
a profile to generate EJB interfaces for the service interfaces and a POJO
for the ValueObject interface. Is this approach with the current maturity
level of EMF and UML2 tools?

Thanks.

Ed Merks wrote:

> Yeu Wen,

> Comments below.


> Yeu Wen Mak wrote:
>> Hi all,
>>
>> If I would like to modify the Java Interfaces that are generated from
>> an EMF model, ie the outputs as a result of right-clicking the root
>> model object in xxx.genmodel, what is the recommended way to achieve
>> that?
> Have a look at
> http://wiki.eclipse.org/index.php/EMF/FAQ#What_are_Dynamic_T emplates.3F?
>> If I import an industry standard XSDs like those defined in Universal
>> Business Language (UBL) from OASIS to obtain an EMF Model, what is the
>> best way for me to generate Java Interfaces from the model?
> The normal way: Tutorial: Generating an EMF Model using XML Schema
>
< http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/tutorials/xlibmod/xlibmod.html>

>> For eg, a Purchase Order in XSD format will result in
>> PurchaseOrderValue, PurchaseOrderKey, PurchaseOrderException POJOs and
>> a CRUD service such as PurchaseOrderValue
>> getPurchaseOrderByKey(PurchaseOrderKey) throws PurchaseOrderException.
>> Create a UML2 profile on a UML2 Model?
> Probably it's generally better to keep the service separate from the
> data model.
>>
>> To be more specific, the EMF tutorials show an example of how
>> LibraryPackage.java is generated from Library EMF model. Can I
>> customise the generation engine to generate LibrarySessionBean.java
>> for use in an EJB3.0 container instead?
> The org.eclipse.emf.examples.generator.validator example shows how to
> specialize the generator to produce additional artifacts as opposed to
> changing how existing files are generated, which is done with dynamic
> templates.
>>
>> Thank you.
>>
>> Yeu Wen
>>
>>
Re: Customising the source codes generated from a model by EMF [message #427320 is a reply to message #427311] Thu, 12 February 2009 11:16 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Yeu,

It's an example so it's not installed in the running IDE. You can
create it in your workspace with File->New->Example...->Eclipse Modeling
Framework->Generator Extension Example.


Yeu Wen Mak wrote:
> Hi Ed,
>
> Thank you for the hints. Unfortunately, I am unable to find
> org.eclipse.emf.examples.generator.validator example in my plugins
> folder. I am using EMF 2.4.1 now.
>
> Can you provide more details of the above example as I really want to
> generate additional java interfaces from the EMF model created from
> the original input XSDs?
>
> Thank you.
>
> yeuwen
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Customising the source codes generated from a model by EMF [message #427321 is a reply to message #427313] Thu, 12 February 2009 11:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Yeu Wen,

Comments below.

Yeu Wen Mak wrote:
> Also, you mentioned about keeping data separate from services below.
> Can you elaborate please?
Given that I haven't a clue what you're doing it's hard to elaborate
much. I just imagine that the basic generated model ought to be just a
data model and that services that use it are in a separate class...
>
> I plan to have both of them generated from the same EMF model.
>
> The other approach I am contemplating is to import the XSDs into UML2
> graphical editor, apply transformation into a service and a data
> models (for eg each datatype from the XSD will result in 4 CRUD
> service interfaces and 1 ValueObject interface (all platform-neutral),
> then apply a profile to generate EJB interfaces for the service
> interfaces and a POJO for the ValueObject interface. Is this approach
> with the current maturity level of EMF and UML2 tools?
You can do pretty much anything you can imagine, but given that EMF
already supports XSD->Ecore and there is an Ecore graphical edit (Ecore
Tools) I don't see any need for UML. Also, given that EMF already
fully support CRUD for instances conforming to an XSD, it's not entirely
clear what else you mean by CRUD. Of course I know very little about
what EJBs need...
>
> Thanks.
>
> Ed Merks wrote:
>
>> Yeu Wen,
>
>> Comments below.
>
>
>> Yeu Wen Mak wrote:
>>> Hi all,
>>>
>>> If I would like to modify the Java Interfaces that are generated
>>> from an EMF model, ie the outputs as a result of right-clicking the
>>> root model object in xxx.genmodel, what is the recommended way to
>>> achieve that?
>> Have a look at
>> http://wiki.eclipse.org/index.php/EMF/FAQ#What_are_Dynamic_T emplates.3F?
>>> If I import an industry standard XSDs like those defined in
>>> Universal Business Language (UBL) from OASIS to obtain an EMF Model,
>>> what is the best way for me to generate Java Interfaces from the model?
>> The normal way: Tutorial: Generating an EMF Model using XML Schema
> < http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/tutorials/xlibmod/xlibmod.html>
>
>>> For eg, a Purchase Order in XSD format will result in
>>> PurchaseOrderValue, PurchaseOrderKey, PurchaseOrderException POJOs
>>> and a CRUD service such as PurchaseOrderValue
>>> getPurchaseOrderByKey(PurchaseOrderKey) throws
>>> PurchaseOrderException. Create a UML2 profile on a UML2 Model?
>> Probably it's generally better to keep the service separate from the
>> data model.
>>>
>>> To be more specific, the EMF tutorials show an example of how
>>> LibraryPackage.java is generated from Library EMF model. Can I
>>> customise the generation engine to generate LibrarySessionBean.java
>>> for use in an EJB3.0 container instead?
>> The org.eclipse.emf.examples.generator.validator example shows how to
>> specialize the generator to produce additional artifacts as opposed
>> to changing how existing files are generated, which is done with
>> dynamic templates.
>>>
>>> Thank you.
>>>
>>> Yeu Wen
>>>
>>>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Customising the source codes generated from a model by EMF [message #427347 is a reply to message #427321] Fri, 13 February 2009 02:30 Go to previous messageGo to next message
Yeu Wen Mak is currently offline Yeu Wen MakFriend
Messages: 14
Registered: July 2009
Location: Melbourne, Australia
Junior Member

When I was referring to applying a profile below, I mean the UML2
profiling mechanism to extend UML metamodel, for eg a <<EJBSession>>
stereotype applied to an interface modeling element (or classifier) would
generate an EJB Java interface in the last step of the approach I have
outlined below.

Is that possible to do using Ecore graphical editor tools?

Ed Merks wrote:
> Yeu Wen,

> Comments below.

> Yeu Wen Mak wrote:
>> Also, you mentioned about keeping data separate from services below.
>> Can you elaborate please?
> Given that I haven't a clue what you're doing it's hard to elaborate
> much. I just imagine that the basic generated model ought to be just a
> data model and that services that use it are in a separate class...
>>
>> I plan to have both of them generated from the same EMF model.
>>
>> The other approach I am contemplating is to import the XSDs into UML2
>> graphical editor, apply transformation into a service and a data
>> models (for eg each datatype from the XSD will result in 4 CRUD
>> service interfaces and 1 ValueObject interface (all platform-neutral),
>> then apply a profile to generate EJB interfaces for the service
>> interfaces and a POJO for the ValueObject interface. Is this approach
>> with the current maturity level of EMF and UML2 tools?
> You can do pretty much anything you can imagine, but given that EMF
> already supports XSD->Ecore and there is an Ecore graphical edit (Ecore
> Tools) I don't see any need for UML. Also, given that EMF already
> fully support CRUD for instances conforming to an XSD, it's not entirely
> clear what else you mean by CRUD. Of course I know very little about
> what EJBs need...
>>
>> Thanks.
>>
>> Ed Merks wrote:
>>
>>> Yeu Wen,
>>
>>> Comments below.
>>
>>
>>> Yeu Wen Mak wrote:
>>>> Hi all,
>>>>
>>>> If I would like to modify the Java Interfaces that are generated
>>>> from an EMF model, ie the outputs as a result of right-clicking the
>>>> root model object in xxx.genmodel, what is the recommended way to
>>>> achieve that?
>>> Have a look at
>>> http://wiki.eclipse.org/index.php/EMF/FAQ#What_are_Dynamic_T emplates.3F?
>>>> If I import an industry standard XSDs like those defined in
>>>> Universal Business Language (UBL) from OASIS to obtain an EMF Model,
>>>> what is the best way for me to generate Java Interfaces from the model?
>>> The normal way: Tutorial: Generating an EMF Model using XML Schema
>>
< http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/tutorials/xlibmod/xlibmod.html>
>>
>>>> For eg, a Purchase Order in XSD format will result in
>>>> PurchaseOrderValue, PurchaseOrderKey, PurchaseOrderException POJOs
>>>> and a CRUD service such as PurchaseOrderValue
>>>> getPurchaseOrderByKey(PurchaseOrderKey) throws
>>>> PurchaseOrderException. Create a UML2 profile on a UML2 Model?
>>> Probably it's generally better to keep the service separate from the
>>> data model.
>>>>
>>>> To be more specific, the EMF tutorials show an example of how
>>>> LibraryPackage.java is generated from Library EMF model. Can I
>>>> customise the generation engine to generate LibrarySessionBean.java
>>>> for use in an EJB3.0 container instead?
>>> The org.eclipse.emf.examples.generator.validator example shows how to
>>> specialize the generator to produce additional artifacts as opposed
>>> to changing how existing files are generated, which is done with
>>> dynamic templates.
>>>>
>>>> Thank you.
>>>>
>>>> Yeu Wen
>>>>
>>>>
>>
Re: Customising the source codes generated from a model by EMF [message #427349 is a reply to message #427320] Fri, 13 February 2009 09:21 Go to previous messageGo to next message
Yeu Wen Mak is currently offline Yeu Wen MakFriend
Messages: 14
Registered: July 2009
Location: Melbourne, Australia
Junior Member

After reading the example source, I am still not sure what makes the 2
additional templates - ModelDescription.txtjet and Validator.javajet -
picked up by the EMF to generate ModelDescription.java and Validator.java.

Also, I am not sure what to do with the class files in
org.eclipse.emf.examples.generator.validator package. Sorry I am quite
new to the platform.

Ed Merks wrote:

> Yeu,

> It's an example so it's not installed in the running IDE. You can
> create it in your workspace with File->New->Example...->Eclipse Modeling
> Framework->Generator Extension Example.


> Yeu Wen Mak wrote:
>> Hi Ed,
>>
>> Thank you for the hints. Unfortunately, I am unable to find
>> org.eclipse.emf.examples.generator.validator example in my plugins
>> folder. I am using EMF 2.4.1 now.
>>
>> Can you provide more details of the above example as I really want to
>> generate additional java interfaces from the EMF model created from
>> the original input XSDs?
>>
>> Thank you.
>>
>> yeuwen
>>
Re: Customising the source codes generated from a model by EMF [message #427353 is a reply to message #427349] Fri, 13 February 2009 14:41 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Yeu Wen,

The plugin.xml contains registrations glue it all together.
Unfortunately I don't have time to give step by step instructions for
everything that's in the code base...

The generated artifacts themselves are just an interesting example
rather than something totally useful.


Yeu Wen Mak wrote:
> After reading the example source, I am still not sure what makes the 2
> additional templates - ModelDescription.txtjet and Validator.javajet -
> picked up by the EMF to generate ModelDescription.java and
> Validator.java.
>
> Also, I am not sure what to do with the class files in
> org.eclipse.emf.examples.generator.validator package. Sorry I am
> quite new to the platform.
>
> Ed Merks wrote:
>
>> Yeu,
>
>> It's an example so it's not installed in the running IDE. You can
>> create it in your workspace with File->New->Example...->Eclipse
>> Modeling Framework->Generator Extension Example.
>
>
>> Yeu Wen Mak wrote:
>>> Hi Ed,
>>>
>>> Thank you for the hints. Unfortunately, I am unable to find
>>> org.eclipse.emf.examples.generator.validator example in my plugins
>>> folder. I am using EMF 2.4.1 now.
>>>
>>> Can you provide more details of the above example as I really want
>>> to generate additional java interfaces from the EMF model created
>>> from the original input XSDs?
>>>
>>> Thank you.
>>>
>>> yeuwen
>>>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Customising the source codes generated from a model by EMF [message #427354 is a reply to message #427347] Fri, 13 February 2009 14:42 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Yeu Wen,

EMF only supports EAnnotations but the could be used for similar purposes.


Yeu Wen Mak wrote:
> When I was referring to applying a profile below, I mean the UML2
> profiling mechanism to extend UML metamodel, for eg a <<EJBSession>>
> stereotype applied to an interface modeling element (or classifier)
> would generate an EJB Java interface in the last step of the approach
> I have outlined below.
>
> Is that possible to do using Ecore graphical editor tools?
>
> Ed Merks wrote:
>> Yeu Wen,
>
>> Comments below.
>
>> Yeu Wen Mak wrote:
>>> Also, you mentioned about keeping data separate from services
>>> below. Can you elaborate please?
>> Given that I haven't a clue what you're doing it's hard to elaborate
>> much. I just imagine that the basic generated model ought to be just
>> a data model and that services that use it are in a separate class...
>>>
>>> I plan to have both of them generated from the same EMF model.
>>>
>>> The other approach I am contemplating is to import the XSDs into
>>> UML2 graphical editor, apply transformation into a service and a
>>> data models (for eg each datatype from the XSD will result in 4 CRUD
>>> service interfaces and 1 ValueObject interface (all
>>> platform-neutral), then apply a profile to generate EJB interfaces
>>> for the service interfaces and a POJO for the ValueObject
>>> interface. Is this approach with the current maturity level of EMF
>>> and UML2 tools?
>> You can do pretty much anything you can imagine, but given that EMF
>> already supports XSD->Ecore and there is an Ecore graphical edit
>> (Ecore Tools) I don't see any need for UML. Also, given that EMF
>> already fully support CRUD for instances conforming to an XSD, it's
>> not entirely clear what else you mean by CRUD. Of course I know
>> very little about what EJBs need...
>>>
>>> Thanks.
>>>
>>> Ed Merks wrote:
>>>
>>>> Yeu Wen,
>>>
>>>> Comments below.
>>>
>>>
>>>> Yeu Wen Mak wrote:
>>>>> Hi all,
>>>>>
>>>>> If I would like to modify the Java Interfaces that are generated
>>>>> from an EMF model, ie the outputs as a result of right-clicking
>>>>> the root model object in xxx.genmodel, what is the recommended way
>>>>> to achieve that?
>>>> Have a look at
>>>> http://wiki.eclipse.org/index.php/EMF/FAQ#What_are_Dynamic_T emplates.3F?
>>>>
>>>>> If I import an industry standard XSDs like those defined in
>>>>> Universal Business Language (UBL) from OASIS to obtain an EMF
>>>>> Model, what is the best way for me to generate Java Interfaces
>>>>> from the model?
>>>> The normal way: Tutorial: Generating an EMF Model using XML Schema
>>>
> < http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclips e.emf.doc/tutorials/xlibmod/xlibmod.html>
>
>>>
>>>>> For eg, a Purchase Order in XSD format will result in
>>>>> PurchaseOrderValue, PurchaseOrderKey, PurchaseOrderException POJOs
>>>>> and a CRUD service such as PurchaseOrderValue
>>>>> getPurchaseOrderByKey(PurchaseOrderKey) throws
>>>>> PurchaseOrderException. Create a UML2 profile on a UML2 Model?
>>>> Probably it's generally better to keep the service separate from
>>>> the data model.
>>>>>
>>>>> To be more specific, the EMF tutorials show an example of how
>>>>> LibraryPackage.java is generated from Library EMF model. Can I
>>>>> customise the generation engine to generate
>>>>> LibrarySessionBean.java for use in an EJB3.0 container instead?
>>>> The org.eclipse.emf.examples.generator.validator example shows how
>>>> to specialize the generator to produce additional artifacts as
>>>> opposed to changing how existing files are generated, which is done
>>>> with dynamic templates.
>>>>>
>>>>> Thank you.
>>>>>
>>>>> Yeu Wen
>>>>>
>>>>>
>>>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Copying GMF diagram and model
Next Topic:XMI serialization of data type to external file and CDO
Goto Forum:
  


Current Time: Fri Apr 26 21:14:22 GMT 2024

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

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

Back to the top