Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » How to link meta-classes from different meta-models at the model level?
icon5.gif  How to link meta-classes from different meta-models at the model level? [message #761358] Tue, 06 December 2011 10:45 Go to next message
Algar fr is currently offline Algar frFriend
Messages: 19
Registered: December 2011
Junior Member
Hello,

This post is two-folded: Problem Explanation and The Problem in Eclipse

Problem Explanation
The problem is defined by the following statements:
- given two meta-models, A.ecore and B.ecore,
- their meta-classes (EClasses) inherit from a superclass S, defined in other meta-model S.ecore. So all the elements of A and B have S as a base class.

Example:
A.classA1 inherits from S.Superclass
B.classB1 inherits from S.Superclass

- A.classA1 has a reference (EReference) to the meta-class S.Superclass, this is, A.classA1 uses Superclass elements, so A.classA1 can reference the B.classB1 or the A.classA1 itself, as shown in the next example:

A.classA1 ----EReference---> S.Superclass

So in theory we can link model elements with meta-model elements such as:
ObjectA1 ----> B.classB1
ObjectA1 ----> A.classA1


The Problem in Eclipse
I want to do this in Eclipse. I have the three meta-models represented in Ecore. Everything works great. All the elements (EClasses) from the meta-models A and B inherit form the base class S.Superclass. I have also a link from A.classA1 --> S.Superclass.

Now, I create a dynamic instance of A (xmi). I load the resource B so I see the metamodel B inside the xmi file. When I open the ---EReference---> field that points to S.Superclass in the Property view, I cannot choose any meta-class from B. In fact, only the A meta-classes appears as available options.

Why I can't choose B meta-classes and only A meta-classes if both are derived from the same S.Superclass?

Thank you very much for your time and support.



EDIT: In fact, when I open the field ---EReference---> in the Sample Reflective Ecore Editor using the Property View, I can only choose instances of the A meta-class. But I am not able to do this:
ObjectA1 ---EReference--> A.class1

i.e., to link a meta-class, which in theory is correct because A.classA1 references Superclasses elements, and A.classA1 is a Superclass element itself.

Thank you again for feedback. If the problem is not clear I can upload the models, pictures of the problem, or everything you may need.
Thanks,
Best regards,

[Updated on: Tue, 06 December 2011 12:35]

Report message to a moderator

Re: How to link meta-classes from different meta-models at the model level? [message #762644 is a reply to message #761358] Thu, 08 December 2011 12:42 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Comments below.

On 06/12/2011 2:45 AM, algarfr wrote:
> Hello,
>
> This post is three-folded: Problem Explanation, The Problem in Eclipse
>
> Problem Explanation
> The problem is defined by the following statements:
> - given two meta-models, A.ecore and B.ecore,
> - their meta-classes (EClasses) inherit from a superclass S, defined
> in other meta-model S.ecore. So all the elements of A and B have S as
> a base class.
>
> Example:
> A.classA1 inherits from S.Superclass
> B.classB1 inherits from S.Superclass
>
> - A.classA1 has a reference (EReference) to the meta-class S, this is,
> A uses Superclass elements, so A can use B.classB1 or A.classA1 as
> shown in the next example:
>
> A.classA1 ----EReference---> S.Superclass
>
> So in theory we can link model elements with meta-model elements such as:
> ObjectA1 ----> B.classB1
> ObjectA1 ----> A.classA1
>
>
> The Problem in Eclipse
> I want to do this in Eclipse. I have the three meta-models represented
> in Ecore. Everything works great. All the elements (EClasses) from the
> meta-models A and B inherit form the base class S.Superclass. I have
> also a link from A.classA1 --> S.Superclass.
>
> Now, I create a dynamic instance of A (xmi). I load the resource B so
> I see the metamodel B inside the xmi file. When I open the
> ---EReference---> field that points to S.Superclass in the Property
> view, I cannot choose any meta-class from B. In fact, only the A
> meta-classes appears as available options.
You're talking about instances (I know because you said create dynamic
instance) but you're still using the word meta-class to describe them.
That's rather confusing.
>
> Why I can't choose B meta-classes and only A meta-classes if both are
> derived from the same S.Superclass?
It's impossible to say from what you've described. I'd certainly expect
it to work properly. In the end, EMF doesn't even care that you've
spread this model across several packages, so all that A, B, and S model
stuff doesn't matter. All that matters is you've got classes S, A, and
B where S is the superclass of A and B and A has a reference to S. For
sure you should expect to be able to populate that reference with
instances of A or B or S. So there must be something wrong but you've
not described that wrong thing, you've described something I'd expect to
work.
> Thank you very much for your time and support.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to link meta-classes from different meta-models at the model level? [message #764475 is a reply to message #762644] Mon, 12 December 2011 09:00 Go to previous messageGo to next message
Algar fr is currently offline Algar frFriend
Messages: 19
Registered: December 2011
Junior Member
Dear Ed,

thank you very much for your help.

I will try to explain it with images.

I have this meta-model and model:

http://s9.postimage.org/79lr53kz3/ed_Merks03.png

What I want to do is to know what kind of meta-class the instance is using, i.e., I want exactly the same information represented by the field "uses" in the following solution:

http://s7.postimage.org/szdv2sfu3/ed_Merks02.png

But this solution is no optimal because I need to include in the ClassType Enumeration all the different classes of the different packages of the project.

What I expected to find is that the "uses" eReference on the next picture will allow me to do this:

http://s7.postimage.org/v2jowpq97/ed_Merks01.png

So if I create a Dynamic Instance of ClassA, in the Property View of the Sample Reflective Ecore Editor:

http://s10.postimage.org/dn06jmpah/properties_View.png

I expected to find the meta-classes BaseClass, ClassA, ClassB as available options here:

http://s9.postimage.org/n4j0xy38v/Screenshot_Uses_Class_A.png

But as you see, only the ClassA appears because there are no instances of other classes. If I create an instance of the ClassB, the meta-class ClassB will be available as well. So I need to create instances if I want to reference meta-classes which is not a good solution either.

What do you think?

Thank you again for your time and support,
All the best,
Re: How to link meta-classes from different meta-models at the model level? [message #764501 is a reply to message #764475] Mon, 12 December 2011 10:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Comments below.

On 12/12/2011 10:00 AM, algarfr wrote:
> Dear Ed,
>
> thank you very much for your help.
>
> I will try to explain it with images.
>
> I have this meta-model and model:
I generally dislike the word meta... Better to talk about models and
instances.
>
>
>
> What I want to do is to know what kind of meta-class the instance is
> using,
See what I mean? You can just talk about the class of the instance,
without need of the word meta. And does "what kind of meta-class" mean
the same as "which meta-class"?
> i.e., I want exactly the same information represented by the field
> "uses" in the following solution:
In my nntp reader, I see nothing here. Need to go to web forum to see
pictures. (Not your fault! Just annoying...)
>
>
>
> But this solution is no optimal because I need to include in the
> ClassType Enumeration all the different classes of the different
> packages of the project.
What's wrong with using the eObject.eClass() directly?
>
> What I expected to find is that the "uses" eReference on the next
> picture will allow me to do this:
I'm confused by the link from the instance of the model? a.eClass() is
the EClass named ClassA ...
>
>
>
> So if I create a Dynamic Instance of ClassA, in the Property View of
> the Sample Reflective Ecore Editor:
>
>
>
> I expected to find the meta-classes BaseClass, ClassA, ClassB as
> available options here:
No you should expect to find instances of these EClasses, not the
EClasses themselves. You'd need a "uses" EReference to EClass not to
BaseClass if you expect to see EClass instances.
>
>
>
> But as you see, only the ClassA appears because there are no instances
> of other classes.
Yes, not surprising.
> If I create an instance of the ClassB, the meta-class ClassB will be
> available as well.
Exactly what you should expect.
> So I need to create instances if I want to reference meta-classes
> which is not a good solution either.
How do you expect them to exist if you don't create them?
>
> What do you think?
I'm not sure what you're expecting. Keep in mind that you can create a
dynamic instance of ClassB in a different resource, and then you can use
Load Resource... in the editor for "a" such that "a" can use "b".
>
> Thank you again for your time and support,
> All the best,
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to link meta-classes from different meta-models at the model level? [message #765518 is a reply to message #764501] Wed, 14 December 2011 08:35 Go to previous messageGo to next message
Algar fr is currently offline Algar frFriend
Messages: 19
Registered: December 2011
Junior Member
Dear Ed,

Thank you again for your answer. I really appreciate your comments on this.

I understand what you mean. The key point is exactly when you say:

Quote:
No you should expect to find instances of these EClasses, not the
EClasses themselves. You'd need a "uses" EReference to EClass not to
BaseClass if you expect to see EClass instances.


If ClassA inherits from EClass (is a type of EClass), and ClassA inherits also from BaseClass (is a type of BaseClass), then why I can only expect to see EClass instances using a "uses" EReference to EClass and not to BaseClass?

How can achieve the same behavior using BaseClass instead of EClass?

Thank you again for your help.
Re: How to link meta-classes from different meta-models at the model level? [message #765532 is a reply to message #765518] Wed, 14 December 2011 09:01 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Comments below.

On 14/12/2011 9:35 AM, algarfr wrote:
> Dear Ed,
>
> Thank you again for your answer. I really appreciate your comments on
> this.
>
> I understand what you mean. The key point is exactly when you say:
>
> Quote:
>> No you should expect to find instances of these EClasses, not the
>> EClasses themselves. You'd need a "uses" EReference to EClass not to
>> BaseClass if you expect to see EClass instances.
>
>
> If ClassA inherits from EClass (is a type of EClass),
Extending Ecore is strongly discouraged. Refering to x being of type y
is like saying x is an instance of y. But that's totally different from
x inherits from y. In one case x is an instance in the other case, it's
part of the model.
> and ClassA inherits also from BaseClass (is a type of BaseClass), then
> why I can only expect to see EClass instances using a "uses"
> EReference to EClass and not to BaseClass?
What's the type of the uses reference?
>
> How can achieve the same behavior using BaseClass instead of EClass?
There is just fundamental confusion in your statements here. Bottom
line: inheritance should work exactly as you'd expect and if it doesn't
no doubt you've done something wrong.
>
> Thank you again for your help.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to link meta-classes from different meta-models at the model level? [message #765549 is a reply to message #765532] Wed, 14 December 2011 09:37 Go to previous messageGo to next message
Algar fr is currently offline Algar frFriend
Messages: 19
Registered: December 2011
Junior Member
Thank you ED for your fast reply.

I agree with your statements. So in fact, what I want to accomplish are the following facts:


  1. ClassA is an instance of BaseClass
  2. ClassB is an instance of BaseClass
  3. ClassA uses instances of BaseClass


As I understand, I can't use EClass directly instead of my BaseClass because I want to have different BaseClasses.

After this, an instance of the ClassA should be able to use instances of BaseClass through a EReference "uses" between ClassA and BaseClass.

How to accomplish this? Maybe the option "Creating a dynamic instances" can produce .ecore files?

Thank you very much for your time.
I really appreciate your comments on this.

All the best,
Re: How to link meta-classes from different meta-models at the model level? [message #765559 is a reply to message #765549] Wed, 14 December 2011 09:54 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Comments below.

On 14/12/2011 10:37 AM, algarfr wrote:
> Thank you ED for your fast reply.
>
> I agree with your statements. So in fact, what I want to accomplish
> are the following facts:
>
>
> ClassA is an instance of BaseClass
In your diagram you show ClassA as inheriting from BaseClass. Now
you're saying it's an instance. That's confusing. I don't know how to
deal with that.
> ClassB is an instance of BaseClass
> ClassA uses instances of BaseClass
>
>
> As I understand, I can't use EClass directly instead of my BaseClass
> because I want to have different BaseClasses.
What do you mean by EClass? I see nothing to indicate BaseClass
inherits from EClass. Of course BaseClass is an EClass (is of type
EClass) so most certainly you can use it anywhere that requires an EClass.
>
> After this, an instance of the ClassA
See, you're back to talking about instances of ClassA so it can't be the
case that ClassA is a instance of BaseClass.
> should be able to use instances of BaseClass through a EReference
> "uses" between ClassA and BaseClass.
Yes.
>
> How to accomplish this?
Just do it.
> Maybe the option "Creating a dynamic instances" can produce .ecore files?
No, it creates instances. Again the never ending confusing.
>
> Thank you very much for your time.
There is some wire crossed in this conversation...
> I really appreciate your comments on this.
>
> All the best,
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to link meta-classes from different meta-models at the model level? [message #766149 is a reply to message #765559] Thu, 15 December 2011 09:31 Go to previous messageGo to next message
Algar fr is currently offline Algar frFriend
Messages: 19
Registered: December 2011
Junior Member
Thank you Ed for your time.

Please, forget the diagrams of the previous posts for the following question, I think they are confusing the discussion. I will use only the words models and instances as you suggested previously.

I follow the next steps in order:
1.- I create an EClass called BaseClass in a new "baseClass.ecore" file, so BaseClass is of type EClass.
2.- I create a dynamic instance of BaseClass called Instance (so I got a new file "inst.xmi").
3.- Now I would like to use the instance in the "inst.xmi" file as a new ECore, i.e., as a new model, so I can have instances of instances.

Is it possible? (maybe xmi to ecore ?)

So basically, in the same way my .ecore is defined by default with instances of EClass, is it possible to have instances of a different type?

Thank you for your patience,
Regards
Re: How to link meta-classes from different meta-models at the model level? [message #766189 is a reply to message #766149] Thu, 15 December 2011 10:38 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Comments below.

On 15/12/2011 10:32 AM, algarfr wrote:
> Thank you Ed for your time.
>
> Please, forget the diagrams of the previous posts for the following
> question, I think they are confusing the discussion. I will use only
> the words models and instances as you suggested previously.
>
> I follow the next steps in order:
> 1.- I create an EClass called BaseClass in a new "baseClass.ecore"
> file, so BaseClass is of type EClass.
> 2.- I create a dynamic instance of BaseClass called Instance (so I got
> a new file "inst.xmi").
> 3.- Now I would like to use the instance in the "inst.xmi" file as a
> new ECore, i.e., as a new model, so I can have instances of instances.
No, EMF can only create instances of EClass, so BaseClass would have to
extend EClass (have Ecore's EClass as its eSuperType) for this to be
possible. That's a bad idea.
>
> Is it possible? (maybe xmi to ecore ?)
There's no generic mapping from an arbitrary model to Ecore. Only
specific mappings, e.g., UML -> Ecore, XSD -> Ecore, annotated Java ->
Ecore.
>
> So basically, in the same way my .ecore is defined by default with
> instances of EClass, is it possible to have instances of a different
> type?
Only if you extend EClass, which is highly discouraged (and then nothing
in the framework will know anything about your extension anyway so
better to annotate Ecore with your additional decorations).
Otherwise, you need to build your whole own framework with your model as
the metamodel, but that's a huge job.
>
> Thank you for your patience,
> Regards


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: How to link meta-classes from different meta-models at the model level? [message #766225 is a reply to message #766189] Thu, 15 December 2011 12:03 Go to previous messageGo to next message
Algar fr is currently offline Algar frFriend
Messages: 19
Registered: December 2011
Junior Member
Thank you Ed,

I am really surprised to find this limitation, as all the "M levels" (M0, M1, M2 and so on) according to the OMG standardization seems here to be fixed and unmovable, which is highly surprising if we consider difference instantiation levels as a degree of flexibility that we are losing in ecore. As far as I understand, Ecore is then the M2 level (meta model), its instances (instances of meta models = instances of EClasses) represent models (M1 level), and instances of models (.xmi) represent the M0 level.

This limitation is a serious problem for us. Maybe EMF is not the most suited technology for our goal. I really need to think of this.

Thank you, again, for your infinite patience and your fast support.
All the best,
Re: How to link meta-classes from different meta-models at the model level? [message #766274 is a reply to message #766225] Thu, 15 December 2011 13:35 Go to previous messageGo to next message
Sylvain EVEILLARD is currently offline Sylvain EVEILLARDFriend
Messages: 556
Registered: July 2009
Senior Member
You're thinking using ontological concepts I think, where you have on the same layer the definition and the instances.
Re: How to link meta-classes from different meta-models at the model level? [message #766291 is a reply to message #766274] Thu, 15 December 2011 14:05 Go to previous messageGo to next message
Algar fr is currently offline Algar frFriend
Messages: 19
Registered: December 2011
Junior Member
Sylvain EVEILLARD wrote on Thu, 15 December 2011 08:35
You're thinking using ontological concepts I think, where you have on the same layer the definition and the instances.


Hello Sylvain,

Thank you very much for your sharing your thoughts. Can you please elaborate more on this?

Best regards,
Re: How to link meta-classes from different meta-models at the model level? [message #766363 is a reply to message #766225] Thu, 15 December 2011 16:20 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
Comments below.

On 15/12/2011 1:04 PM, algarfr wrote:
> Thank you Ed,
>
> I am really surprised to find this limitation, as all the "M levels"
> (M0, M1, M2 and so on)
Not those darn things against...
> according to the OMG standardization seems here to be fixed and unmovable,
These levels are always relative...
> which is highly surprising if we consider difference instantiation
> levels as a degree of flexibility that we are losing in ecore.
I think you're under some illusion of flexibility that exists nowhere.
If I have a model for a Person and I create a Person, "John Smith", now
can I expect to instantiate "John Smith"? A person isn't a meta model
for anything.
> As far as I understand, Ecore is then the M2 level (meta model), its
> instances (instances of meta models = instances of EClasses) represent
> models (M1 level), and instances of models (.xmi) represent the M0 level.
Yes, pretty much.
>
> This limitation is a serious problem for us.
With "us" being? Nothing theOMG talks about implies you can keep going
down the meta levels forever. The point is you can keep going up
forever, or at least until you loop back on something that's its own
meta model.
> Maybe EMF is not the most suited technology for our goal.
Nothing specified by the OMG supports what you seem to be assuming ought
to just work. Nothing dictates that an instance can act as a model. I
can think of countless models where that's just nonsensical. With
Person instance being a good example.
> I really need to think of this.
Indeed.
>
> Thank you, again, for your infinite patience and your fast support.
I'm not so patient. It only looks that way.
> All the best,


Ed Merks
Professional Support: https://www.macromodeling.com/
Previous Topic:[EEF] uncomplete model generation
Next Topic:Dynamic model load performance
Goto Forum:
  


Current Time: Thu Apr 25 11:01:18 GMT 2024

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

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

Back to the top