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 05: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 05:13 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26054
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: Sun Sep 21 22:17:59 GMT 2014

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

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