Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 Go to next message
Dominik J is currently offline Dominik JFriend
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 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
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 #740227 is a reply to message #740179] Tue, 18 October 2011 09:38 Go to previous messageGo to next message
Dominik J is currently offline Dominik JFriend
Messages: 6
Registered: July 2011
Junior Member
Hello Ed, many thanks for your quick answer! Smile
It is in fact exactly the same thing as you explained in your blogpost. But I tried around a little bit and it did not work for me this way. I have now set the eClass B in A.ecore to abstract. In the genmodel I set "Extensible Provider Factory" to true. In B.genmodel I set "Child Creation Extenders" to true. Do I have to do something additional?
Re: [EMF] Inheritance across two ecore-files [message #740234 is a reply to message #740227] Tue, 18 October 2011 09:43 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
You've noted the comments about the fact that the plugin.xmls won't
update unless you delete them?


On 18/10/2011 11:38 AM, Dominik J wrote:
> Hello Ed, many thanks for your quick answer! :) It is in fact exactly
> the same thing as you explained in your blogpost. But I tried around a
> little bit and it did not work for me this way. I have now set the
> eClass B in A.ecore to abstract. In the genmodel I set "Extensible
> Provider Factory" to true. In B.genmodel I set "Child Creation
> Extenders" to true. Do I have to do something additional?


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: [EMF] Inheritance across two ecore-files [message #740274 is a reply to message #740234] Tue, 18 October 2011 10:31 Go to previous messageGo to next message
Dominik J is currently offline Dominik JFriend
Messages: 6
Registered: July 2011
Junior Member
No I just did overread this, to be honest Sad But now it works in my test environment.

Thank you very much for your quick help! Smile
Re: [EMF] Inheritance across two ecore-files [message #755945 is a reply to message #740162] Thu, 10 November 2011 09:38 Go to previous messageGo to next message
Dominik J is currently offline Dominik JFriend
Messages: 6
Registered: July 2011
Junior Member
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. This works fine, but only after I created an instance from the element I want to reference.
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, without doing the detour of creating the elements?
Re: [EMF] Inheritance across two ecore-files [message #756014 is a reply to message #755945] Thu, 10 November 2011 13:30 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
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 #756506 is a reply to message #740162] Mon, 14 November 2011 06:40 Go to previous messageGo to next message
Dominik J is currently offline Dominik JFriend
Messages: 6
Registered: July 2011
Junior Member
I want the object to be reachable without creating it explicitly.
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. Smile

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.

Many thanks for your help! Smile
Re: [EMF] Inheritance across two ecore-files [message #756516 is a reply to message #756506] Mon, 14 November 2011 07:09 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
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 #756521 is a reply to message #756516] Mon, 14 November 2011 07:48 Go to previous messageGo to next message
Dominik J is currently offline Dominik JFriend
Messages: 6
Registered: July 2011
Junior Member
OK, even without question marks you gave me the answer I needed. Wink
So I need to create the object to use it for a reference Smile

Is it possible to do the creation of an object implicitly as you mentioned above? For example, if I create an container, all elements from the inheriting ecore file are created as a child of this container.
Re: [EMF] Inheritance across two ecore-files [message #756527 is a reply to message #756521] Mon, 14 November 2011 08:32 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
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/
Previous Topic:Is it possible to modify/delete an eReference from an EObject?
Next Topic:EMF and JPA
Goto Forum:
  


Current Time: Sat Apr 20 03:26:02 GMT 2024

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

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

Back to the top