Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF] Base Ecore and extending one.(extending an ecore or importing one (with referencing EClasses))
[EMF] Base Ecore and extending one. [message #889449] Tue, 19 June 2012 08:43 Go to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 452
Registered: July 2009
Senior Member
Hello,

i wrote a framework which is based on an EMF ecore generated model.
to make this framework reuseable i want to put my ecore into the package,
so it can be extended for any later use.

what do i need to do to get this working?

is it enough to get the ecore and add stuff anyone wants to use? i doubt so, because if anyone edits the package names my framework will no longer accept the classes as their input (as they are hardcoded as parameters)

so my thought was creating a second .ecore which 'simply' imports/extends the ecore defined by me.

i created:
framework.ecore
framework.ecorediag
framework.genmodel
(i also generated an framework.xsd and an frameworkXMI.xsd)

i did not find a way to import an xsd or ecore in the ecore editor.
so i am not able to reference to the EClasses defined in my framework.ecore

myModel.ecore extends framework.ecore
(which generates the defined framework and its packages/factory etc and the myModel packages/factory (or one factory for both)

iff this problem is described in the book it seems i'm searching for the wrong words/places so simply point me to the page and name.

thanks in advance
lumo

[Updated on: Tue, 19 June 2012 08:44]

Report message to a moderator

Re: [EMF] Base Ecore and extending one. [message #889487 is a reply to message #889449] Tue, 19 June 2012 09:24 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6494
Registered: July 2009
Senior Member
Am 19.06.12 10:43, schrieb Ludwig Moser:
> Hello,
>
> i wrote a framework which is based on an EMF ecore generated model.
> to make this framework reuseable i want to put my ecore into the package,
> so it can be extended for any later use.
>
> what do i need to do to get this working?
>

Nothing special, export all your packages from framework-bundle

> is it enough to get the ecore and add stuff anyone wants to use? i doubt
> so, because if anyone edits the package names my framework will no
> longer accept the classes as their input (as they are hardcoded as
> parameters)

Someone can't edit your package names, all one can is to derive from
your base class so this sentence is not making sense to me but maybe I
got something wrong.

>
> so my thought was creating a second .ecore which 'simply'
> imports/extends the ecore defined by me.
>

Yes that's the way it works.

> i created:
> framework.ecore
> framework.ecorediag
> framework.genmodel
> (i also generated an framework.xsd and an frameworkXMI.xsd)
>
> i did not find a way to import an xsd or ecore in the ecore editor.
> so i am not able to reference to the EClasses defined in my framework.ecore
>
> myModel.ecore extends framework.ecore
> (which generates the defined framework and its packages/factory etc and
> the myModel packages/factory (or one factory for both)
>

make sure the myModel.genmodel references the framework.genmodel so that
the base classes are not regenerated.

We are using such a setup in our Teneo/EMF based project where we have a
base.ecore and multiple custom.ecores and at runtime we load them
through OSGi-Services, generate the hbm.xml and bootstrap teneo.

Tom
Re: [EMF] Base Ecore and extending one. [message #889504 is a reply to message #889487] Tue, 19 June 2012 09:53 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 452
Registered: July 2009
Senior Member
>Nothing special, export all your packages from framework-bundle
thats the point, how do i 'export' the package (from the framework.ecore)?

>Someone can't edit your package names, all one can is to derive from
>your base class so this sentence is not making sense to me but maybe I
>got something wrong.
someone can edit my package name iff i provide the framework.ecore, then open it and edit the content to extend it; its not editable if i extend it Wink

>make sure the myModel.genmodel references the framework.genmodel so that
>the base classes are not regenerated.
thanks for the hint, thats what i guessed.

probably i am searching on the wrong place.

i open up my framework.ecore in the 'Sample Ecore Model Editor'
in the editor: rightclick on framework.ecore nor package name brings up an export menuepoint.

in the package explorer rightclick on the framework.ecore brings up an export menue point but this one seems the wrong one.

so next try was creating an .genmodel file
in the 'EMF Generator' View clicking on the Framework, the option export shows up, and i can export an XML or xmi.XML, which i both created.

but how do i import the stuff now to the new extending.ecore?


EDIT: - or did you mean this:
do you mean exporting the package (generated classes) from the bundle?
actually thats not what i want to do. i would like to extend the ecore, not the generated files, if possible.

so if possible have one framework.ecore, and another one wich extends this file (then generate the whole model)

other option is to generate the framework.ecore;
use the generated files and generate a new ecore from it (import)
then add the Eclasses i want/need
/EDIT
Re: [EMF] Base Ecore and extending one. [message #889528 is a reply to message #889504] Tue, 19 June 2012 10:15 Go to previous messageGo to next message
Thomas Schindl is currently offline Thomas SchindlFriend
Messages: 6494
Registered: July 2009
Senior Member
Am 19.06.12 11:53, schrieb Ludwig Moser:
>> Nothing special, export all your packages from framework-bundle
> thats the point, how do i 'export' the package (from the framework.ecore)?
>

You are exporting them in your MANIFEST.MF then others can reference
your java classes.

>> Someone can't edit your package names, all one can is to derive from
>> your base class so this sentence is not making sense to me but maybe I
>> got something wrong.
> someone can edit my package name iff i provide the framework.ecore, then
> open it and edit the content to extend it; its not editable if i extend
> it ;)

That's not a good idea, you provided a fixed API and allow people
subclass (extend, derive other) - that's no different than it is in Java.

>
>> make sure the myModel.genmodel references the framework.genmodel so that
>> the base classes are not regenerated.
> thanks for the hint, thats what i guessed.
>
> probably i am searching on the wrong place.
>
> i open up my framework.ecore in the 'Sample Ecore Model Editor'
> in the editor: rightclick on framework.ecore nor package name brings up
> an export menuepoint.
>

Exporting is done on the bundle / java level. ecore-packages are public
because they are registered in the registry using the plugin.xml

> in the package explorer rightclick on the framework.ecore brings up an
> export menue point but this one seems the wrong one.
>
> so next try was creating an .genmodel file
> in the 'EMF Generator' View clicking on the Framework, the option export
> shows up, and i can export an XML or xmi.XML, which i both created.
>
> but how do i import the stuff now to the new extending.ecore?
>

bring up the context menu on the root-node of extending.ecore and select
load resource.

>
> EDIT: - or did you mean this:
> do you mean exporting the package (generated classes) from the bundle?
> actually thats not what i want to do. i would like to extend the ecore,
> not the generated files, if possible.
>

Why? This means people having nothing to programm against beside but yes
you are not required to generate java classes anyone then has to use the
reflective API

> so if possible have one framework.ecore, and another one wich extends
> this file (then generate the whole model)
>

So you want anyone to use the reflective EMF-API?

> other option is to generate the framework.ecore;
> use the generated files and generate a new ecore from it (import)
> then add the Eclasses i want/need
> /EDIT
Re: [EMF] Base Ecore and extending one. [message #889539 is a reply to message #889528] Tue, 19 June 2012 10:31 Go to previous messageGo to next message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 452
Registered: July 2009
Senior Member
somehow you are not getting my point.
i do know how to export packages from bundles.
no, i do not want to work with reflective emf api.

i also do know that i can generate the java files from the framework.ecore and use them as datatype in another ecore.

in java you create an class as base class, then extend it from any other class you have.
my question is if this is also possible with ecore.
so i define an base ecore and someone else extends this ecore (so the extended ecore reads includes the xml/definitions from the base ecore)

THEN when the extended ecore is finished the code gets generated (which will ALWAYS include the same classes from the base.ecore AND the new classes added by someone)

i hope this makes my point clear now.

so when i open up the extended ecore i can see a full model (including the details of the base ecore)
Re: [EMF] Base Ecore and extending one. [message #889637 is a reply to message #889539] Tue, 19 June 2012 12:33 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30352
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Ludwig,<br>
<br>
Comments below.<br>
<div class="moz-cite-prefix">On 19/06/2012 6:31 AM, Ludwig Moser
wrote:<br>
</div>
<blockquote cite="mid:jrpkdo$tsa$1@xxxxxxxxe.org" type="cite">somehow
you are not getting my point.
<br>
i do know how to export packages from bundles.
<br>
</blockquote>
Java packages are exported using the MANIFEST.MF editor.  EPackages
aren't exported.  They're registered in the model's plugin.xml and
the resources in the models folder are part of the binary bundle
available at runtime.<br>
<blockquote cite="mid:jrpkdo$tsa$1@xxxxxxxxe.org" type="cite">no,
i do not want to work with reflective emf api.
<br>
<br>
i also do know that i can generate the java files from the
framework.ecore and use them as datatype in another ecore.
<br>
</blockquote>
As Tom already mentioned, you can use Load Resource... to load other
*.ecore resource and once you do that, you'll be able to use them in
that model.<br>
<blockquote cite="mid:jrpkdo$tsa$1@xxxxxxxxe.org" type="cite">
<br>
in java you create an class as base class, then extend it from any
other class you have.
<br>
</blockquote>
Yes, you can define a new EClass that extends other EClasses.<br>
<blockquote cite="mid:jrpkdo$tsa$1@xxxxxxxxe.org" type="cite">my
question is if this is also possible with ecore.
<br>
</blockquote>
Yes.<br>
<blockquote cite="mid:jrpkdo$tsa$1@xxxxxxxxe.org" type="cite">so
i define an base ecore and someone else extends this ecore (so the
extended ecore reads includes the xml/definitions from the base
ecore)
<br>
</blockquote>
Yes, that's possible.  You might find this useful<a
href="http://ed-merks.blogspot.com/2008/01/creating-children-you-didnt-know.html"><br>
</a>
<blockquote><a
href="http://ed-merks.blogspot.com/2008/01/creating-children-you-didnt-know.html">http://ed-merks.blogspot.com/2008/01/creating-children-you-didnt-know.html</a><br>
</blockquote>
<blockquote cite="mid:jrpkdo$tsa$1@xxxxxxxxe.org" type="cite">
<br>
THEN when the extended ecore is finished the code gets generated
(which will ALWAYS include the same classes from the base.ecore
AND the new classes added by someone)
<br>
</blockquote>
Pay attention to the instructions for how to reuse another GenModel
on the last page of the wizard.<br>
<blockquote><a
href="http://help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.emf.doc/tutorials/slibmod/slibmod.html">Tutorial:
Generating an Extended EMF Model</a></blockquote>
<blockquote cite="mid:jrpkdo$tsa$1@xxxxxxxxe.org" type="cite">
<br>
i hope this makes my point clear now.
<br>
<br>
so when i open up the extended ecore i can see a full model
(including the details of the base ecore)
<br>
</blockquote>
<br>
<br>
</body>
</html>
Re: [EMF] Base Ecore and extending one. [message #889661 is a reply to message #889637] Tue, 19 June 2012 12:59 Go to previous message
Ludwig Moser is currently offline Ludwig MoserFriend
Messages: 452
Registered: July 2009
Senior Member
thanks a lot ed,
that's what i was searching for!
Previous Topic:[CDO] NPE on commit
Next Topic:How can I set multiple root to treeviewer using emf adapterfactoryContentProvider
Goto Forum:
  


Current Time: Mon Aug 19 11:46:21 GMT 2019

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

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

Back to the top