Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [Xcore] How to define/constrain a class when it is referenced in two containers
[Xcore] How to define/constrain a class when it is referenced in two containers [message #1071624] Sat, 20 July 2013 17:53 Go to next message
Hugo A. Garcia is currently offline Hugo A. GarciaFriend
Messages: 258
Registered: July 2009
Senior Member
Hi

Given the wrong model below:

class Room {
Sting name
contains Box[] boxes
contains Thing[] things
}

class SmallBox {
String name
containss Thing[1] specialThing
contains Thing[] justRegularThnigs
}

class Thing {
String name
}

How does one make sure that Things are only created and stored first in
Room.things, also, SmallBox.specialThing and SmallBox.justRegularThings
are populate only from references to Room.things and not new instances
of Thing.

-H
Re: [Xcore] How to define/constrain a class when it is referenced in two containers [message #1071820 is a reply to message #1071624] Sun, 21 July 2013 08:41 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Hugo,

Comments below.

On 20/07/2013 7:53 PM, Hugo A. Garcia wrote:
> Hi
>
> Given the wrong model below:
>
> class Room {
> Sting name
> contains Box[] boxes
> contains Thing[] things
> }
>
> class SmallBox {
> String name
> containss Thing[1] specialThing
> contains Thing[] justRegularThnigs
> }
>
> class Thing {
> String name
> }
>
> How does one make sure that Things are only created and stored first
> in Room.things, also,
What do you mean by "first"?
> SmallBox.specialThing and SmallBox.justRegularThings are populate only
> from references to Room.things and not new instances of Thing.
It's a contradiction. An EObject x can be contained in at most one
container y, accessible via EObject.eContainer and must be present in
y.eGet(x.eContainmentFeature()). So if x is a Thing and y is a Room it
must be in y.getThings() and nowhere else.

Are some of these features supposed to be derived? Perhaps some type of
"directlyContains" containment reference and a derived
"directlyOrIndirectlyContains" cross reference?
>
> -H


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [Xcore] How to define/constrain a class when it is referenced in two containers [message #1071874 is a reply to message #1071820] Sun, 21 July 2013 12:33 Go to previous messageGo to next message
Hugo A. Garcia is currently offline Hugo A. GarciaFriend
Messages: 258
Registered: July 2009
Senior Member
On 2013-07-21 10:41, Ed Merks wrote:
> Hugo,
>
> Comments below.
>
> On 20/07/2013 7:53 PM, Hugo A. Garcia wrote:
>> Hi
>>
>> Given the wrong model below:
>>
>> class Room {
>> Sting name
>> contains Box[] boxes
>> contains Thing[] things
>> }
>>

CHANGED THE NAME FROM SmallBox to Box

class Box {
>> String name
>> containss Thing[1] specialThing
>> contains Thing[] justRegularThnigs
>> }
>>
>> class Thing {
>> String name
>> }
>>
>> How does one make sure that Things are only created and stored first
>> in Room.things, also,
> What do you mean by "first"?

NOTE: There is name change in the above model.

Thinking on how a user creates a model either using Xtext or a Graphiti.

First create a Room then full of hings. Now add a box to the room and
_fill_ the Box with a Box.specialThing and Box.justRegularThings from
the list of Room.things.

>> SmallBox.specialThing and SmallBox.justRegularThings are populate only
>> from references to Room.things and not new instances of Thing.
> It's a contradiction. An EObject x can be contained in at most one
> container y, accessible via EObject.eContainer and must be present in
> y.eGet(x.eContainmentFeature()). So if x is a Thing and y is a Room it
> must be in y.getThings() and nowhere else.

Exactly, that is the problem that I am facing. So either I convert the
model to a regular tree structure which might not quite express the
intent of the model OR....

>
> Are some of these features supposed to be derived? Perhaps some type of
> "directlyContains" containment reference and a derived
> "directlyOrIndirectlyContains" cross reference?
>>

Yes, something of derived feature for Box.specialThing and
Box.justRegularThings. Furthermore, in the Xtext or Graphit edtior or
even in the regular EMF editor... the available things in the room
should be visualized as a dropdown when filling the box.


>> -H
>
Re: [Xcore] How to define/constrain a class when it is referenced in two containers [message #1071879 is a reply to message #1071874] Sun, 21 July 2013 12:53 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Hugo,

Comments below.

On 21/07/2013 2:33 PM, Hugo A. Garcia wrote:
> On 2013-07-21 10:41, Ed Merks wrote:
>> Hugo,
>>
>> Comments below.
>>
>> On 20/07/2013 7:53 PM, Hugo A. Garcia wrote:
>>> Hi
>>>
>>> Given the wrong model below:
>>>
>>> class Room {
>>> Sting name
>>> contains Box[] boxes
>>> contains Thing[] things
>>> }
>>>
>
> CHANGED THE NAME FROM SmallBox to Box
>
> class Box {
>>> String name
>>> containss Thing[1] specialThing
>>> contains Thing[] justRegularThnigs
>>> }
>>>
>>> class Thing {
>>> String name
>>> }
>>>
>>> How does one make sure that Things are only created and stored first
>>> in Room.things, also,
>> What do you mean by "first"?
>
> NOTE: There is name change in the above model.
>
> Thinking on how a user creates a model either using Xtext or a Graphiti.
>
> First create a Room then full of hings. Now add a box to the room and
> _fill_ the Box with a Box.specialThing and Box.justRegularThings from
> the list of Room.things.
So those latter two relationships should be cross references...
>
>>> SmallBox.specialThing and SmallBox.justRegularThings are populate only
>>> from references to Room.things and not new instances of Thing.
>> It's a contradiction. An EObject x can be contained in at most one
>> container y, accessible via EObject.eContainer and must be present in
>> y.eGet(x.eContainmentFeature()). So if x is a Thing and y is a Room it
>> must be in y.getThings() and nowhere else.
>
> Exactly, that is the problem that I am facing. So either I convert the
> model to a regular tree structure which might not quite express the
> intent of the model OR....
In the end, it really comes down to your intent and what you want to do
with such a model.
>
>>
>> Are some of these features supposed to be derived? Perhaps some type of
>> "directlyContains" containment reference and a derived
>> "directlyOrIndirectlyContains" cross reference?
>>>
>
> Yes, something of derived feature for Box.specialThing and
> Box.justRegularThings. Furthermore, in the Xtext or Graphit edtior or
> even in the regular EMF editor... the available things in the room
> should be visualized as a dropdown when filling the box.
It's easy enough to filter the choices available for the property
descriptor in the item provider to only allow the choice of things as
you see fit.
>
>
>>> -H
>>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:Reading data stored in model objects and displaying the data
Next Topic:How to open a generated editor with an existing model
Goto Forum:
  


Current Time: Thu Apr 25 19:26:13 GMT 2024

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

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

Back to the top