Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [EMF] Inheritance across two ecore-files
[EMF] Inheritance across two ecore-files [message #740162] |
Tue, 18 October 2011 08:17 |
Dominik J Messages: 6 Registered: July 2011 |
Junior Member |
|
|
Hello,
I have a problem, using the inheritance across two different ecore-files.
I will give a short example to have a better understanding of my issue.
My first ecore file is called A.ecore. It has several eClasses. The root class is A, which has a containment towards B, B has a containment towards C.
The second model I have is called B.ecore. B has as a root class D, which has a containment to E and E has a containment to F. E has as attribute value for eSupertypes B from the A.ecore. (B.ecore is quite similar to A.ecore, only with other names)
I would now expect that I can assign below class A in the instance of A.ecore(My.a) not only B, but also E, because E inherits from B. But in fact I cannot do this.
Has anyone an idea, what mistake I made?
In the wizard for creating B.genmodel, I made a reference of A.genmodel.
I tried to open My.a with the Sample Ecore Editor and go to "load Resource" and load B.ecore into it. The idea was, that the knowledge of B.ecore is first available, after the resource was added.
(This project is just an example, I have a bigger project where I need this inheritance. So I considered to solve this issue on a small example project)
|
|
|
Re: [EMF] Inheritance across two ecore-files [message #740179 is a reply to message #740162] |
Tue, 18 October 2011 08:31 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Dominik,<br>
<br>
Comments below.<br>
<br>
On 18/10/2011 10:17 AM, Dominik J wrote:
<blockquote cite="mid:j7jbvf$blb$1@news.eclipse.org" type="cite">Hello,
<br>
<br>
I have a problem, using the inheritance across two different
ecore-files. <br>
I will give a short example to have a better understanding of my
issue.
<br>
<br>
My first ecore file is called A.ecore. It has several eClasses.
The root class is A, which has a containment towards B, B has a
containment towards C.
<br>
<br>
The second model I have is called B.ecore. B has as a root class
D, which has a containment to E and E has a containment to F. E
has as attribute value for eSupertypes B from the A.ecore.
(B.ecore is quite similar to A.ecore, only with other names)
<br>
<br>
I would now expect that I can assign below class A in the instance
of A.ecore(My.a) not only B, but also E, because E inherits from
B.</blockquote>
What do you mean by assign? Is this about child creation?<br>
<blockquote><a
href="http://ed-merks.blogspot.com/2008/01/creating-children-you-didnt-know.html">http://ed-merks.blogspot.com/2008/01/creating-children-you-didnt-know.html</a><br>
</blockquote>
<br>
<blockquote cite="mid:j7jbvf$blb$1@news.eclipse.org" type="cite">
But in fact I cannot do this. <br>
Has anyone an idea, what mistake I made? <br>
In the wizard for creating B.genmodel, I made a reference of
A.genmodel. I tried to open My.a with the Sample Ecore Editor and
go to "load Resource" and load B.ecore into it. The idea was, that
the knowledge of B.ecore is first available, after the resource
was added. <br>
(This project is just an example, I have a bigger project where I
need this inheritance. So I considered to solve this issue on a
small example project)
<br>
</blockquote>
</body>
</html>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| | | | |
Re: [EMF] Inheritance across two ecore-files [message #756014 is a reply to message #755945] |
Thu, 10 November 2011 13:30 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Dominik,
Comments below.
On 10/11/2011 10:38 AM, Dominik J wrote:
> Ok, I worked a little bit further on my project and have a new issue,
> where I do not know how to handle it.
>
> I extend my one ecore file with another file. Recently the project
> changed a little bit. Now I do not want to do a child creation, only a
> reference.
>
> So for example I want to assign in my base ecore file an element from
> the inheriting ecore.
Assign? You mean create a reference to?
> This works fine, but only after I created an instance from the element
> I want to reference.
Yes, the object has to be reachable somehow...
> I created a container where all the elements, which I want to
> reference are contained in. After they are contained, I can set the
> reference on them. Is it possible to provide a list of the inheriting
> elements,
Not sure what you mean by a list of the inheriting elements...
> without doing the detour of creating the elements?
Do you always want to create a new element when populating the reference?
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Re: [EMF] Inheritance across two ecore-files [message #756516 is a reply to message #756506] |
Mon, 14 November 2011 07:09 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Dominik,
Comments below.
On 14/11/2011 7:40 AM, Dominik J wrote:
> I want the object to be reachable without creating it explicitly.
So you want it to be created implicitly?
> Maybe I can compare it to an enumeration. I can only select the
> elements, which are available in the inheriting ecore file. Just like
> an enumeration, but without being actually one. :)
> At the moment I can do a child creation in an instance of my base
> ecore file, where all the elements from the inheriting ecore file are
> selectable. Now I only do not want a child creation, only a reference
> through a property.
Well, clearly if you want to refer to something that doesn't yet exist
you'll need to create it. Also, for serialization, you'll need to be
sure it's added to some containment reference as well.
>
> Many thanks for your help! :)
This posting doesn't have any question marks.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
| |
Re: [EMF] Inheritance across two ecore-files [message #756527 is a reply to message #756521] |
Mon, 14 November 2011 08:32 |
Ed Merks Messages: 33218 Registered: July 2009 |
Senior Member |
|
|
Dominik,
Comments below.
On 14/11/2011 8:48 AM, Dominik J wrote:
> OK, even without question marks you gave me the answer I needed. ;)
I try my best.
> So I need to create the object to use it for a reference :)
Yes, one way or another.
>
> Is it possible to do the creation of an object implicitly as you
> mentioned above?
Anything is possible if you specialize commands or property descriptors.
> For example, if I create an container, all elements from the
> inheriting ecore file are created as a child of this container.
When child creation descriptors are created, you can initialize those
new objects any way that makes sense.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Goto Forum:
Current Time: Tue Sep 24 17:33:45 GMT 2024
Powered by FUDForum. Page generated in 0.05898 seconds
|