Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » modeling probem - opposite relation(can two classes have an 'opposite' relation to same 3rd class?)
modeling probem - opposite relation [message #1017158] Sun, 10 March 2013 00:13 Go to next message
Inor Nerokstein is currently offline Inor Nerokstein
Messages: 2
Registered: March 2013
Junior Member
I want bidirectionality between the contained object and its container.
I have this model:

/** @model abstract="true" */
public interface ContainedObject {
/** @model */
public Container getContainer();
}

/** @model abstract="true" */
public interface Container extends ContainedObject { }

/* @model */
public interface Category extends Container {
/** @model containment="true" opposite="container" */
public List<Category> getCategories();
/** @model containment="true" opposite="container" */
public List<Variable> getVariables();
}

/** @model */
public interface Variable extends ContainedObject { }

For the above model i'm getting the following error message when i try to create the .genmodel:


"the opposite 'container' already has attribute 'categories' of 'Category'
as its opposite"

what's wrong with this model?
Re: modeling probem - opposite relation [message #1017568 is a reply to message #1017158] Tue, 12 March 2013 01:13 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 25744
Registered: July 2009
Senior Member
Inor,

Comments below.

On 11/03/2013 7:30 PM, Inor Nerokstein wrote:
> I want bidirectionality between the contained object and its
> container. I have this model:
>
> /** @model abstract="true" */
> public interface ContainedObject {
> /** @model */
> public Container getContainer();
> }
>
> /** @model abstract="true" */
> public interface Container extends ContainedObject { }
>
> /* @model */
> public interface Category extends Container {
> /** @model containment="true" opposite="container" */
> public List<Category> getCategories(); /** @model
> containment="true" opposite="container" */
> public List<Variable> getVariables();
There can't be one "container" feature that has both this "variables"
feature and the above "categories" feature as it's opposite. The
"container" feature can have at most one opposite (which typically will
be a feature defined in "Container" in this example).
> }
>
> /** @model */
> public interface Variable extends ContainedObject { }
>
> For the above model i'm getting the following error message when i try
> to create the .genmodel:
>
>
> "the opposite 'container' already has attribute 'categories' of
> 'Category' as its opposite"
>
> what's wrong with this model?
You could define getContainer as just an EOperation and implement it to
derive from EObject.eContainer().
Previous Topic:Maven repository available for EMF-GWT
Next Topic:[EMF Compare] Comparing unordered elements
Goto Forum:
  


Current Time: Fri Apr 18 01:48:51 EDT 2014

Powered by FUDForum. Page generated in 0.01759 seconds