dynamically add features to model object [message #629731] |
Wed, 29 September 2010 07:57  |
Eclipse User |
|
|
|
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
|
|
|
Re: dynamically add features to model object [message #629820 is a reply to message #629731] |
Wed, 29 September 2010 12:03   |
Eclipse User |
|
|
|
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
|
|
|
|
|
Re: dynamically add features to model object [message #630652 is a reply to message #629820] |
Mon, 04 October 2010 09:45  |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.04306 seconds