Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » How to link meta-classes from different meta-models at the model level?
How to link meta-classes from different meta-models at the model level? [message #761358] |
Tue, 06 December 2011 10:45 |
Algar fr 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 |
Ed Merks 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 |
Algar fr 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:
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:
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:
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:
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 |
Ed Merks 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 #766149 is a reply to message #765559] |
Thu, 15 December 2011 09:31 |
Algar fr 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 |
Ed Merks 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 |
Algar fr 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 #766363 is a reply to message #766225] |
Thu, 15 December 2011 16:20 |
Ed Merks 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/
|
|
|
Goto Forum:
Current Time: Thu Apr 25 11:01:18 GMT 2024
Powered by FUDForum. Page generated in 0.03707 seconds
|