|
|
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 |
Hugo A. Garcia 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 |
Ed Merks 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/
|
|
|
Powered by
FUDForum. Page generated in 0.03189 seconds