Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Modeling (top-level project) » dynamically add features to model object
dynamically add features to model object [message #629731] Wed, 29 September 2010 11:57 Go to next message
Flavio Donze is currently offline Flavio DonzeFriend
Messages: 211
Registered: July 2009
Location: Switzerland
Senior Member
Hello

I'm using EMF and Teneo to persist my model objects.

I'm facing a problem and was wondering if anybody has done something similar.
I have to dynamically add features to an existing model object.

eClass.getEStructuralFeatures().add(feature)

causes eGet and eSet to fail.

I tried to dynamically create a new model object that extends my current one as described in the EMF Book "14.3. Dynamic EMF".
The problem here is that eClass().getName() then is not equal to the name I have in my original eClass. If I use the same name, teneo complains that the table already exists, which totally makes sense.

Anybody has a idea, reference or hint on how I should accomplish this? Maybe it is really easy and I'm on the wrong path...
Thanks
Flavio


Prozessmanagement und Qualitätsmanagement Software QMS/IMS
https://www.scodi.ch
Re: dynamically add features to model object [message #629820 is a reply to message #629731] Wed, 29 September 2010 16:03 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Flavio,

Comments below. Please use the EMF newsgroup/forum (eclipse.tools.emf)
for questions like this.


Flavio Donzé wrote:
> Hello
>
> I'm using EMF and Teneo to persist my model objects.
>
> I'm facing a problem and was wondering if anybody has done something
> similar.
> I have to dynamically add features to an existing model object.
>
> eClass.getEStructuralFeatures().add(feature)
>
> causes eGet and eSet to fail.
Yes, you can't do that.
>
> I tried to dynamically create a new model object that extends my
> current one as described in the EMF Book "14.3. Dynamic EMF".
> The problem here is that eClass().getName() then is not equal to the
> name I have in my original eClass.
I suppose you could make the names the same, but I doubt that would
eliminate all issues...
> If I use the same name, teneo complains that the table already exists,
> which totally makes sense.
Yep.
> Anybody has a idea, reference or hint on how I should accomplish this?
You should not expect to be able to dynamically change models just as
you shouldn't expect to be able to dynamically change how many rows are
in a table.
> Maybe it is really easy and I'm on the wrong path...
I think taking a step back and asking what exactly are the dynamic needs
would be good. Many models have some type of extensibility feature,
e.g., annotations in XML Schema, Java, and Ecore. I.e., they allow
instances to be decorated, but they don't allow the model itself to be
changed or extended.
> Thanks
> Flavio


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: dynamically add features to model object [message #629978 is a reply to message #629731] Thu, 30 September 2010 08:04 Go to previous messageGo to next message
Gregoire Dupe is currently offline Gregoire DupeFriend
Messages: 75
Registered: September 2009
Location: France
Member
Hi,

You can have a look to the MoDisco facet tool (http://wiki.eclipse.org/MoDisco/Components/FacetManager). It allows to dynamically extend meta-models. Currently, the additional features are only derived.

Hoping that it help you.

Regards,
Grégoire Dupé

Re: dynamically add features to model object [message #630647 is a reply to message #629978] Mon, 04 October 2010 13:32 Go to previous messageGo to next message
Flavio Donze is currently offline Flavio DonzeFriend
Messages: 211
Registered: July 2009
Location: Switzerland
Senior Member
Hi Grégoire Dupé

Thanks for the link, I took a look at the project, for my case I see a problem working with teneo. As far as I see it, MoDisco will not add the new features to the database tables.

A very interesting project though!

greets
Flavio


Prozessmanagement und Qualitätsmanagement Software QMS/IMS
https://www.scodi.ch
Re: dynamically add features to model object [message #630652 is a reply to message #629820] Mon, 04 October 2010 13:45 Go to previous message
Flavio Donze is currently offline Flavio DonzeFriend
Messages: 211
Registered: July 2009
Location: Switzerland
Senior Member
Hi Ed

Thanks for your comments.
I will have to find some way to accomplish this, probably with a lot of refactoring of our framework.

In our framework we provide a basic model which needs to be expendable for each customer (e.g. new fields for a Person object).
I don't want to generate code since that will be overridden through the p2 update mechanism on the next update.
So I was thinking to provide additional features through customer plug-ins using extension points. So after the update the model is extended and the database updated.

So I thought maybe EMF provides a standard way of doing this.
I'll do some thinking and "hacking", if I find a nice solution, I'll post it.

greets
Flavio


Prozessmanagement und Qualitätsmanagement Software QMS/IMS
https://www.scodi.ch
Previous Topic:Is there a smart way to adjust/use the EMF code generator for instances of my ecore model?
Next Topic:[CDO]Are derived features supported ?
Goto Forum:
  


Current Time: Fri Apr 19 10:01:00 GMT 2024

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

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

Back to the top