Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » ECore diagram reference creation
ECore diagram reference creation [message #717630] Sun, 21 August 2011 19:57 Go to next message
janpojer is currently offline janpojerFriend
Messages: 40
Registered: July 2011
Member
Hi,

My goal is to be able to create an editor, where I can create an instance of Item and as its child create another Item as an instance of the same very same class (ie. Father - Son relation: both Son and Father are instances of the same class - Man and i need to connect them using, lets say, hasSon relation). So in the ecore model i need to create a reference to the same class. But whenever i do create such refenrece in the ecore diagram and set the container property to true (so i can model it using emf editor), then after reloading the .genmodel it throws the following error:
A containment reference of a type with a container feature xxx that requires instances to be contained elsewhere cannot be populated.


Any idea how to workout this "self reference" relation?

Thanks in advance

Jan

[Updated on: Sun, 21 August 2011 19:58]

Report message to a moderator

Re: ECore diagram reference creation [message #717635 is a reply to message #717630] Sun, 21 August 2011 20:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The container property is derived. Try setting the containment property
instead.

Regards

Ed Willink

On 21/08/2011 20:57, janpojer wrote:
> Hi,
>
> My goal is to be able to create an editor, where I can create an
> instance of Item and as its child create another Item as an instance
> of the same very same class (ie. Father - Son relation: both Son and
> Father are instances of the same class - Man and i need to connect
> them using, lets say, hasSon relation). So in the ecore model i need
> to create a reference to the same class. But whenever i do create such
> refenrece in the ecore diagram and set the container property to true
> (so i can model it using emf editor), then after reloading the
> .genmodel it throws the following error:
> A containment reference of a type with a container feature xxx that
> requires instances to be contained elsewhere cannot be populated.
>
> Any idea how to workout this "self reference" relation?
>
> Thanks in advance
Re: ECore diagram reference creation [message #717636 is a reply to message #717635] Sun, 21 August 2011 20:53 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Comments below.

On 21/08/2011 1:39 PM, Ed Willink wrote:
> Hi
>
> The container property is derived. Try setting the containment
> property instead.
That's probably what he meant.
>
> Regards
>
> Ed Willink
>
> On 21/08/2011 20:57, janpojer wrote:
>> Hi,
>>
>> My goal is to be able to create an editor, where I can create an
>> instance of Item and as its child create another Item as an instance
>> of the same very same class (ie. Father - Son relation: both Son and
>> Father are instances of the same class - Man and i need to connect
>> them using, lets say, hasSon relation). So in the ecore model i need
>> to create a reference to the same class. But whenever i do create
>> such refenrece in the ecore diagram and set the container property to
>> true (so i can model it using emf editor), then after reloading the
>> .genmodel it throws the following error:
>> A containment reference of a type with a container feature xxx that
>> requires instances to be contained elsewhere cannot be populated.
Keep in mind that if you have two containment references of the same
type X and both of them have an opposite (a container reference) X.c1
and X.c2 and both of those you make be required (lower bound 1) you'll
end up with a model where it's not possible for object of type X to be
valid. That's because an object can be in at most one containment
reference, so only of its container features c1 or c2 (never c1 and c2)
can ever be populated at any one time Hence c1 and c2 need to both be
optional.
>>
>> Any idea how to workout this "self reference" relation?
>>
>> Thanks in advance
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: ECore diagram reference creation [message #717640 is a reply to message #717636] Sun, 21 August 2011 21:25 Go to previous messageGo to next message
janpojer is currently offline janpojerFriend
Messages: 40
Registered: July 2011
Member
Yes I ment containment... thanks

What I dont understand is that i can create 0-* reference to other entity but i cannot for some reason create reference 0-* to the same class to signal that instance can include references to other instance of the same kind...

So what approach would u recommend when I need to create an editor tool where u can create items with subitems of the same kind?
Re: ECore diagram reference creation [message #717644 is a reply to message #717640] Sun, 21 August 2011 22:21 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Comments below.

On 21/08/2011 2:25 PM, janpojer wrote:
> Yes I ment containment... thanks
>
> What I dont understand is that i can create 0-* reference to other
> entity but i cannot for some reason create reference 0-* to the same
> class to signal that instance can include references to other instance
> of the same kind...
I think you're misinterpretting things. You're trying create a model
where instances will always be invalid. I believe you have a container
reference with lower bound 1. If you have that, you should expect a
diagnostic if you try to create any other containment reference for that
entity.
>
> So what approach would u recommend when I need to create an editor
> tool where u can create items with subitems of the same kiI think nd?
Look for container references on that object and set the lower bound to
be 0.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: ECore diagram reference creation [message #717926 is a reply to message #717644] Mon, 22 August 2011 18:24 Go to previous messageGo to next message
janpojer is currently offline janpojerFriend
Messages: 40
Registered: July 2011
Member
Hi,

I am not sure if we are on the same page still.

I have uploaded an image of my model. Setting the containment property to true renders the error i have previously mentioned. But how else can I make such reference?

(The lower bound doesnt matter, it gives me the same error on either 1-* or 0-*)
J
  • Attachment: model.PNG
    (Size: 21.19KB, Downloaded 171 times)

[Updated on: Mon, 22 August 2011 18:39]

Report message to a moderator

Re: ECore diagram reference creation [message #717945 is a reply to message #717926] Mon, 22 August 2011 19:23 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

An image is better than nothing, but it is barely 1% of the model. If we
cannot see or animate the problem we have to be telepathic to suggest
solutions.

I suggest you provide an example that clearly demonstrates exactly what
'does not work' and what you would like it to be doing.

Regards

Ed Willink

On 22/08/2011 19:24, janpojer wrote:
> Hi,
>
> I am not sure if we are on the same page still.
>
> I have uploaded an image of my model. Setting the containment property to true renders the error i have previously mentioned. But how else can I make such reference?
>
> J
Re: ECore diagram reference creation [message #717958 is a reply to message #717945] Mon, 22 August 2011 20:07 Go to previous messageGo to next message
janpojer is currently offline janpojerFriend
Messages: 40
Registered: July 2011
Member
Ok, I will try to explain more in depth.

Using the ecore file I am trying to define necessary means to create an editor for my so called Domain Knowledge. Simply put it is a collection of functions where each functions can have some incoming and outgoing ports. But also it can hold another function. This should signal inheritance relation. So to sum it up I would like to be able to create a child item Function within Function.

To demonstrate in on real data, lets say i wanna fill my domain knowledge with Bluetooth sensor with one incoming and one outgoing port, my editor would look as follows:

DK
 |- Sensor: Bluetooth Sensor 1
    |- IncomingPort: Port 1
    |- OutgoingPort: Port 2


But also, I want to be able to have the ability to add advance Bluetooth sensor that would have one more port but would share the other ports (inherit it). So i want my diagram to look like as follows:

DK
 |- Sensor: Bluetooth Sensor 1
    |- IncomingPort: Port 1
    |- OutgoingPort: Port 2
    |- Sensor: Advanced Bluetooth Sensor
       |- IncomingPort: Port 3


What I am struggling with is to be able to create a reference in my ecore model that points at the same type... (To have the Sensor type hold 0 to many other instances of Sensor type) I can create the reference, but once I set the containment property of the reference to true (to make it appear in create child menu) I get on reloading .genmodel the error mentioned on top...

Does it make more sence now?

[Updated on: Mon, 22 August 2011 20:10]

Report message to a moderator

Re: ECore diagram reference creation [message #718009 is a reply to message #717926] Tue, 23 August 2011 01:40 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
Might it be the case that Feature.dk is a container reference (the
opposite of DomainKnowledge.functions)? This would imply that for a
Feature to be valid, it must be contained by a DomainKnowledge
instance. So if a Feature is contained by another Feature via
Feature.f, then dk will be null and that Feature will be invalid,
right? That's not a good thing is it?


On 22/08/2011 11:24 AM, janpojer wrote:
> Hi,
>
> I am not sure if we are on the same page still.
>
> I have uploaded an image of my model. Setting the containment property to true renders the error i have previously mentioned. But how else can I make such reference?
>
> J


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: ECore diagram reference creation [message #718010 is a reply to message #717958] Tue, 23 August 2011 01:43 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33141
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
I think this example completely misses the issue which is related to
a non-optional container references.  Please reread carefully what
I've said already and think hard about what I said about a Feature
containing a Feature when it <big>must </big>be contained by a
DomainKnowledge because your model requires it.<br>
<br>
<br>
On 22/08/2011 1:07 PM, janpojer wrote:
<blockquote cite="mid:j2ucad$rlo$1@news.eclipse.org" type="cite">Ok,
I will try to explain more in depth.
<br>
<br>
Using the ecore file I am trying to define necessary means to
create an editor for my so called Domain Knowledge. Simply put it
is a collection of functions where each functions can have some
incoming and outgoing ports. But also it can hold another
function. This should signal inheritance relation. So to sum it up
I would like to be able to create a child item Function within
Function. <br>
To demonstrate in on real data, lets say i wanna fill my domain
knowledge with Bluetooth sensor with one incoming and one outgoing
port, my editor would look as follows:
<br>
<br>
DK
<br>
|- Sensor: Bluetooth Sensor 1
<br>
   |- IncomingPort: Port 1
<br>
   |- OutgoingPort: Port 2
<br>
<br>
But also, I want to be able to have the ability to add advance
Bluetooth sensor that would have one more port but would share the
other ports (inherit it). So i want my diagram to look like as
follows:
<br>
<br>
DK
<br>
|- Sensor: Bluetooth Sensor 1
<br>
   |- IncomingPort: Port 1
<br>
   |- OutgoingPort: Port 2
<br>
   |- Sensor: Advanced Bluetooth Sensor
<br>
      |- IncomingPort: Port 3
<br>
<br>
What I am struggling with is to be able to create a reference in
my ecore model that points at the same type... (To have the Sensor
type hold 0 to many other instances of Sensor type)
<br>
<br>
Does it make more sence now?
<br>
</blockquote>
</body>
</html>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: ECore diagram reference creation [message #718060 is a reply to message #718010] Tue, 23 August 2011 06:50 Go to previous message
janpojer is currently offline janpojerFriend
Messages: 40
Registered: July 2011
Member
Ha! Yes I got what you mean. Of course, the lower bound must be 0 for dk.

Thanks a lot for help!

J
Previous Topic:[EMF.core] EcoreUtils.resolve() do not return the actual instance
Next Topic:Should not be able to save when editor has errors
Goto Forum:
  


Current Time: Fri Apr 26 05:43:21 GMT 2024

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

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

Back to the top