Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to create a dynamic instances of two dependant Metamodels
How to create a dynamic instances of two dependant Metamodels [message #643122] Sat, 04 December 2010 20:05 Go to next message
bacha  is currently offline bacha Friend
Messages: 53
Registered: July 2009
Member
Hi,
I created two metamodels (A and B) that were implemented using Ecore format.
Each metamodel has a class that references an other class from the other metamodel. That means that A has a class x that references an other class y from the B metamodel.
The problem is that, when creating a dynamic instance of each one, I can not conserve that relationship between created instances, as if this two models are not related.
Could you tell me how to create two instances (One of each metamodel) that are related and where their relationship is conserved.

Thanks.
Regards.
Re: How to create a dynamic instances of two dependant Metamodels [message #643124 is a reply to message #643122] Sat, 04 December 2010 20:19 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Taupin,

Comments below.

taupin wrote:
> Hi,
> I created two metamodels (A and B) that were implemented using Ecore
> format.
> Each metamodel has a class that references an other class from the
> other metamodel. That means that A has a class x that references an
> other class y from the B metamodel.
And vice versa? Or does y itself reference x?
> The problem is that, when creating a dynamic instance of each one, I
> can not conserve that relationship between created instances,
What does "conserve" mean in this context? Serialize?
> as if this two models are not related.
What exactly have you tried?
> Could you tell me how to create two instances (One of each metamodel)
> that are related and where their relationship is conserved.
I don't understand how this is any different than if x and y are from
the same EPackage. Nothing about how the instances behave is affected
by the number of packages or how classes are distributed among packages.
You simply create instances and populate their features. What
specifically have you tried and what appears not to work?
> Thanks.
> Regards.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to create a dynamic instances of two dependant Metamodels [message #643130 is a reply to message #643124] Sat, 04 December 2010 21:40 Go to previous messageGo to next message
bacha  is currently offline bacha Friend
Messages: 53
Registered: July 2009
Member
Hello Ed and thank you for your fast reply. You find below my comments on red color.

> Hi,
> I created two metamodels (A and B) that were implemented using Ecore
> format.
> Each metamodel has a class that references an other class from the
> other metamodel. That means that A has a class x that references an
> other class y from the B metamodel.
And vice versa? Or does y itself reference x?
In fact x references y and y references x using the Eopposite option.

> The problem is that, when creating a dynamic instance of each one, I
> can not conserve that relationship between created instances,
What does "conserve" mean in this context? Serialize?
I would like that the relationship that I created on the metamodels could be transfered to the instances. What I realized is that as if instances are not related each other and as if I missed the link between A and B.
> as if this two models are not related.
What exactly have you tried?
> Could you tell me how to create two instances (One of each metamodel)
> that are related and where their relationship is conserved.
I don't understand how this is any different than if x and y are from
the same EPackage. Nothing about how the instances behave is affected
by the number of packages or how classes are distributed among packages.
You simply create instances and populate their features. What
specifically have you tried and what appears not to work?
I tried to create the instances of A and B using the Generic EMF form editor and when I would like to affect a value to x references (which has to be an y class) , the editor does not propose the created instances of the y class.

I hope I am more clear.
> Thanks.
> Regards.
Re: How to create a dynamic instances of two dependant Metamodels [message #643131 is a reply to message #643122] Sat, 04 December 2010 21:57 Go to previous messageGo to next message
bacha  is currently offline bacha Friend
Messages: 53
Registered: July 2009
Member
Hello Ed and thank you for your fast reply. You find below my comments on red color.

> Hi,
> I created two metamodels (A and B) that were implemented using Ecore
> format.
> Each metamodel has a class that references an other class from the
> other metamodel. That means that A has a class x that references an
> other class y from the B metamodel.
And vice versa? Or does y itself reference x?
In fact x references y and y references x using the Eopposite option.

> The problem is that, when creating a dynamic instance of each one, I
> can not conserve that relationship between created instances,
What does "conserve" mean in this context? Serialize?
I would like that the relationship that I created on the metamodels could be transfered to the instances. What I realized is that as if instances are not related each other and as if I missed the link between A and B.

> as if this two models are not related.
What exactly have you tried?
> Could you tell me how to create two instances (One of each metamodel)
> that are related and where their relationship is conserved.
I don't understand how this is any different than if x and y are from
the same EPackage. Nothing about how the instances behave is affected
by the number of packages or how classes are distributed among packages.
You simply create instances and populate their features. What
specifically have you tried and what appears not to work?
I tried to create the instances of A and B using the Generic EMF form editor and when I would like to affect a value to x references (which has to be an y class) , the editor does not propose the created instances of the y class.

I hope I am more clear.
> Thanks.
> Regards.
Re: How to create a dynamic instances of two dependant Metamodels [message #643132 is a reply to message #643130] Sat, 04 December 2010 21:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Taupin,

Comments below.

taupin wrote:
> Hello Ed and thank you for your fast reply. You find below my comments
> on red color.
>
>> Hi,
>> I created two metamodels (A and B) that were implemented using Ecore
>> format.
>> Each metamodel has a class that references an other class from the
>> other metamodel. That means that A has a class x that references an
>> other class y from the B metamodel.
> And vice versa? Or does y itself reference x?
> In fact x references y and y references x using the Eopposite option.
That's what I thought, but it wasn't explicit.
>
>> The problem is that, when creating a dynamic instance of each one, I
>> can not conserve that relationship between created instances,
> What does "conserve" mean in this context? Serialize?
> I would like that the relationship that I created on the metamodels
> could be transfered to the instances.
I find that a totally confusing sentence.
> What I realized is that as if instances are not related each other and
> as if I missed the link between A and B.
What makes you realize this?
>> as if this two models are not related.
> What exactly have you tried?
>> Could you tell me how to create two instances (One of each metamodel)
>> that are related and where their relationship is conserved.
> I don't understand how this is any different than if x and y are from
> the same EPackage. Nothing about how the instances behave is affected
> by the number of packages or how classes are distributed among packages.
> You simply create instances and populate their features. What
> specifically have you tried and what appears not to work?
> I tried to create the instances of A and B using the Generic EMF form
> editor and when I would like to affect a value to x references (which
> has to be an y class) , the editor does not propose the created
> instances of the y class.
It might be an issue in the Generic EMF form editor. Have you tried
using just the Sample Reflective Ecore Model Editor? There should be a
property for modifying the features of x and y and any instances
available in the editor that are of the correct type should be available
for populating such features.
> I hope I am more clear.
>> Thanks.
>> Regards.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to create a dynamic instances of two dependant Metamodels [message #643133 is a reply to message #643132] Sat, 04 December 2010 22:36 Go to previous messageGo to next message
bacha  is currently offline bacha Friend
Messages: 53
Registered: July 2009
Member
Hi,
I have tried the Sample Reflective Ecore Model Editor but the problem persist.

Thanks.
Taupin
Re: How to create a dynamic instances of two dependant Metamodels [message #643134 is a reply to message #643133] Sat, 04 December 2010 23:17 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33137
Registered: July 2009
Senior Member
Taupin,

You describe so little detail about what you've done...

Let's take a step back. Suppose you have an EClass X selected in the
Ecore editor. You can invoke Create Dynamic Instance... to create an
instance of X. Of course you can do this for EClass Y or any other
EClass. So you know how to create dynamic instances of anything
(regardless of the dependency between these classes). Now suppose
you've done that for X and Y and that X and Y have some non-containment
bidirectional reference between them. From either the editor for the X
instance or the editor for the Y instance, you can use Load Resource...
to load the resource containing the other instance. You then have an
editor with both an X and a Y instance in the resource set. At this
point you should be able to populate any reference of X that requires a
Y and vice versa.


taupin wrote:
> Hi,
> I have tried the Sample Reflective Ecore Model Editor but the problem
> persist.
> Thanks.
> Taupin


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to create a dynamic instances of two dependant Metamodels [message #643150 is a reply to message #643134] Sun, 05 December 2010 12:38 Go to previous message
bacha  is currently offline bacha Friend
Messages: 53
Registered: July 2009
Member
Hi Ed,
I would like to thank you very much because I follow your method and it works perfectly.
In fact, the problem is that I did the "load resource" operation only in metamodel and I did not know that I have to apply it to instances too.

Thank you again.
Best regards.

Taupin
Previous Topic:EClassifier.isInstance behavior
Next Topic:How to create an apply a UML2 stereo-type using EMF in a standalone app?
Goto Forum:
  


Current Time: Sat Apr 20 03:06:13 GMT 2024

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

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

Back to the top