Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How can I add eOpposite relationship to an existing attribute?
How can I add eOpposite relationship to an existing attribute? [message #415589] Thu, 20 December 2007 22:51 Go to next message
Eclipse UserFriend
Originally posted by: fchen.castortech.com

I want to extend an ecore metamodel. And add some eOpposite relationships
to the eStructuralFeatures which have already defined in the base ecore
model.

For example, I have this EXTENDED_MODEL.ecore which extends
BASE_MODEL.ecore.
in the BASE_MODEL.ecore,
I defined
<eClassifiers xsi:type="ecore:EClass" name="Element" abstract="true">
<eStructuralFeatures xsi:type="ecore:EReference" name="attribute"
ordered="false"
upperBound="-1" eType="#//Attribute" containment="true"/>
</eClassifiers>

now I want to add eOpposite relationship to this "attribute" in
EXTENDED_MODEL.ecore.
Is it possible to allow me to do that in .ecore model, if possible, how
can I achieve it?

Thanks in advance.
Re: How can I add eOpposite relationship to an existing attribute? [message #415590 is a reply to message #415589] Thu, 20 December 2007 23:02 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Dereck,

An eOpposite relationship introduces an intimate two way dependency
between the EClasses on either side so you can't add one for an existing
base model without modifying that model directly. Both models will then
have mutual initialization dependencies on each other so can't be
generated with separate GenModels.


Dereck wrote:
> I want to extend an ecore metamodel. And add some eOpposite
> relationships to the eStructuralFeatures which have already defined in
> the base ecore model.
>
> For example, I have this EXTENDED_MODEL.ecore which extends
> BASE_MODEL.ecore.
> in the BASE_MODEL.ecore,
> I defined
> <eClassifiers xsi:type="ecore:EClass" name="Element" abstract="true">
> <eStructuralFeatures xsi:type="ecore:EReference" name="attribute"
> ordered="false"
> upperBound="-1" eType="#//Attribute" containment="true"/>
> </eClassifiers>
>
> now I want to add eOpposite relationship to this "attribute" in
> EXTENDED_MODEL.ecore.
> Is it possible to allow me to do that in .ecore model, if possible,
> how can I achieve it?
>
> Thanks in advance.
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How can I add eOpposite relationship to an existing attribute? [message #415653 is a reply to message #415590] Mon, 24 December 2007 22:42 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: fchen.castortech.com

Thanks Ed,

It seams that it is impossible to use the “extend” approach to fix the
problem.

In my situation, the BASE_MODEL.ecore is a standard metamodel from the
third party. We modify it to meet some special needs for our company.
Every time, when the new version of the BASE_MODEL.ecore is released, we
have to go over the annoying process again to add those special features
and relationships into it. I was thinking ALTAS, but it is apparently for
model transformation, not for metamodel.

Is there any tool or plugin available to meet this need? Do you have any
suggestion for this?

Thanks again

Dereck
Re: How can I add eOpposite relationship to an existing attribute? [message #415657 is a reply to message #415653] Wed, 26 December 2007 11:31 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Dereck,

Adding a bidirectional reference definitely requires actual
modifications to the models containing each of the two EReferences.
Since Ecore is just a model as well as being a metamodel, I think ATL
should still be applicable. I could also imagine "scripting" such
changes as a small Java utility that reads the model, looks for classes
by name, and makes changes that way...


Dereck wrote:
> Thanks Ed,
> It seams that it is impossible to use the �extend� approach to fix the
> problem.
>
> In my situation, the BASE_MODEL.ecore is a standard metamodel from the
> third party. We modify it to meet some special needs for our company.
> Every time, when the new version of the BASE_MODEL.ecore is released,
> we have to go over the annoying process again to add those special
> features and relationships into it. I was thinking ALTAS, but it is
> apparently for model transformation, not for metamodel.
>
> Is there any tool or plugin available to meet this need? Do you have
> any suggestion for this?
>
> Thanks again
>
> Dereck
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:about the hierarchy of emf
Next Topic:Two editors sharing the model and or edit plugins
Goto Forum:
  


Current Time: Fri Apr 26 05:24:53 GMT 2024

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

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

Back to the top