Home » Modeling » EMF » [CDO] Referencing between models
[CDO] Referencing between models [message #493402] |
Mon, 26 October 2009 00:38 |
Danya Messages: 5 Registered: October 2009 |
Junior Member |
|
|
Hello, everyone
I'm quite new to CDO and EMF (and this forum, as well ), and I'm doing a little research on CDO's abilities regarding referencing between multiple models.
I have several questions, but I would like to start with one:
I have two (meta)models/packages, defined in two .ecore files, and they look like this:
A.ecore:
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="packageA"
nsURI="http://mymodels.org/packageA" nsPrefix="pa">
<eClassifiers xsi:type="ecore:EClass" name="classA">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="attrA" unique="false" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EString"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="refB" upperBound="-1" eType="ecore:EClass B.ecore#//classB"
eOpposite="B.ecore#//classB/refA"/>
</eClassifiers>
</ecore:EPackage>
B.ecore:
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="packageB"
nsURI="http://mymodels.org/packageB" nsPrefix="pb">
<eClassifiers xsi:type="ecore:EClass" name="classB">
<eStructuralFeatures xsi:type="ecore:EAttribute" name="attrB" unique="false" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
<eStructuralFeatures xsi:type="ecore:EReference" name="refA" eType="ecore:EClass A.ecore#//classA"
eOpposite="A.ecore#//classA/refB"/>
</eClassifiers>
</ecore:EPackage>
As you can see, these models reference each other using bidirectional relationship, so that an instance of classA can reference multiple instances of classB, and an instance of classB can reference max. one instance of classB.
In my CDO client's editor, I created an instance of classA and a few instances of classB (all of them are root objects of the resource), and then set their references.
When I try to save a resource, everything seems to work fine. At least until I close my CDO client and run it again, when I see no references... which seems to be kind of expected, because I see that types of references in package definitions (stored in the database) were set to null. So, I guess that package registration didn't go well, and I also guess the problem is in bidirectional relationship, because I experienced no problems working with one-direction relationship between elements of two different packages(.ecore files).
So, did I do something wrong, or CDO is supposed to work this way?
Btw, I'm using CDO 2.0.
Thanks in advance.
|
|
|
Re: [CDO] Referencing between models [message #493417 is a reply to message #493402] |
Mon, 26 October 2009 07:08 |
|
Hi Danya,
Personally I don't think that bidirectional references across package
boundaries are a good idea. In pure Java you'd try to avoid cyclic
dependencies between packages, too.
That said, I feel like it should be supported by CDO. I'm at the Eclipse
Summit Europe this week. Can you please file a bugzilla and attach your
models there so that I don't forget about the investigation?
Cheers
/Eike
----
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Danya schrieb:
> Hello, everyone
>
> I'm quite new to CDO and EMF (and this forum, as well :)), and I'm
> doing a little research on CDO's abilities regarding referencing
> between multiple models.
>
> I have several questions, but I would like to start with one:
>
> I have two (meta)models/packages, defined in two .ecore files, and
> they look like this:
>
> A.ecore:
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="packageA"
> nsURI="http://mymodels.org/packageA" nsPrefix="pa">
> <eClassifiers xsi:type="ecore:EClass" name="classA">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="attrA"
> unique="false" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EString"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="refB"
> upperBound="-1" eType="ecore:EClass B.ecore#//classB"
> eOpposite="B.ecore#//classB/refA"/>
> </eClassifiers>
> </ecore:EPackage>
>
> B.ecore:
> <?xml version="1.0" encoding="UTF-8"?>
> <ecore:EPackage xmi:version="2.0"
> xmlns:xmi="http://www.omg.org/XMI"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:ecore="http://www.eclipse.org/emf/2002/Ecore" name="packageB"
> nsURI="http://mymodels.org/packageB" nsPrefix="pb">
> <eClassifiers xsi:type="ecore:EClass" name="classB">
> <eStructuralFeatures xsi:type="ecore:EAttribute" name="attrB"
> unique="false" eType="ecore:EDataType
> http://www.eclipse.org/emf/2002/Ecore#//EInt"/>
> <eStructuralFeatures xsi:type="ecore:EReference" name="refA"
> eType="ecore:EClass A.ecore#//classA"
> eOpposite="A.ecore#//classA/refB"/>
> </eClassifiers>
> </ecore:EPackage>
>
> As you can see, these models reference each other using bidirectional
> relationship, so that an instance of classA can reference multiple
> instances of classB, and an instance of classB can reference max. one
> instance of classB.
>
> In my CDO client's editor, I created an instance of classA and a few
> instances of classB (all of them are root objects of the resource),
> and then set their references.
>
> When I try to save a resource, everything seems to work fine. At least
> until I close my CDO client and run it again, when I see no
> references... which seems to be kind of expected, because I see that
> types of references in package definitions (stored in the database)
> were set to null. So, I guess that package registration didn't go
> well, and I also guess the problem is in bidirectional relationship,
> because I experienced no problems working with one-direction
> relationship between elements of two different packages(.ecore files).
> So, did I do something wrong, or CDO is supposed to work this way?
>
> Btw, I'm using CDO 2.0.
>
> Thanks in advance.
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Re: [CDO] Referencing between models [message #493569 is a reply to message #493417] |
Tue, 27 October 2009 00:45 |
Danya Messages: 5 Registered: October 2009 |
Junior Member |
|
|
Eike,
Thank you very much for the quick reply... Danke schön!
I filed a bug, and I have to mention that I made a mistake in my previous message - I have both CDO 2.0 and 3.0 installed, but I used 3.0 in this case.
I think I can see how this cyclic dependencies thing implies implementation issues. But, what I actually wanted, regardless of how meta-model is represented (via EPackage or something else), was to be able to define different meta-models (M2 level) and associate their instances (M1 level) according to relationships defined on M2, and using bidirectional relationships look pretty natural to me. Wouldn't it be nice if we could navigate from an element of one model (for example, data storage in data flow diagram) to an element of another model or the entire model (for example, UML class diagram or ER model) and vice-versa?
So, if EPackage is the equivalent of (meta)model, in order to do this, I have to use bidirectional relationships across package boundaries... or maybe there is an alternative way? Or maybe my understanding of EPackage is wrong...?
I know you must be quite busy, so I would appreciate whenever you find time to reply.
Also, everyone interested in sharing his opinions on this subject is welcome.
Cheers
|
|
|
Re: [CDO] Referencing between models [message #493586 is a reply to message #493569] |
Tue, 27 October 2009 05:28 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Danya,
Comments below.
Danya wrote:
> Eike,
> Thank you very much for the quick reply... Danke schön! :)
>
> I filed a bug, and I have to mention that I made a mistake in my
> previous message - I have both CDO 2.0 and 3.0 installed, but I used
> 3.0 in this case.
>
> I think I can see how this cyclic dependencies thing implies
> implementation issues. But, what I actually wanted, regardless of how
> meta-model is represented (via EPackage or something else), was to be
> able to define different meta-models (M2 level) and associate their
> instances (M1 level) according to relationships defined on M2, and
> using bidirectional relationships look pretty natural to me. Wouldn't
> it be nice if we could navigate from an element of one model (for
> example, data storage in data flow diagram) to an element of another
> model or the entire model (for example, UML class diagram or ER model)
> and vice-versa?
> So, if EPackage is the equivalent of (meta)model, in order to do this,
> I have to use bidirectional relationships across package boundaries...
> or maybe there is an alternative way? Or maybe my understanding of
> EPackage is wrong...?
> I know you must be quite busy, so I would appreciate whenever you find
> time to reply. :)
Keep in mind that in order to have a bidirectional reference between to
classes, both classes must be modified to add their half of that pair
of references and both instances must similarly be modified. So it's
generally not possible to reuse someone else's model and establish
bidirectional references with it. So while they're nice, they're not
always possible. Sometimes they're even a bad idea. For example,
consider why there is no bidirectional opposite for EClass.eSuperTypes.
It would certainly be nice for an EClass to know all its subtypes, but
we can't require that the base class be modified every time some wants
to create a derived class...
>
> Also, everyone interested in sharing his opinions on this subject is
> welcome.
> Cheers :)
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: [CDO] Referencing between models [message #493792 is a reply to message #493402] |
Wed, 28 October 2009 01:43 |
Danya Messages: 5 Registered: October 2009 |
Junior Member |
|
|
Ed Merks wrote on Tue, 27 October 2009 01:28 |
Keep in mind that in order to have a bidirectional reference between to
classes, both classes must be modified to add their half of that pair
of references and both instances must similarly be modified. So it's
generally not possible to reuse someone else's model and establish
bidirectional references with it. So while they're nice, they're not
always possible. Sometimes they're even a bad idea. For example,
consider why there is no bidirectional opposite for EClass.eSuperTypes.
It would certainly be nice for an EClass to know all its subtypes, but
we can't require that the base class be modified every time some wants
to create a derived class...
|
Ed,
Thank you for joining us.
Yes, I had that in my mind, and I actually assumed that all the meta-models needed for this purpose were built from the scratch. However, isn't the situation you are talking about a part of the bigger problem - making any kind of change of an existing meta-model and keeping its instances consistent with it?
If I understood that part of CDO 2.0 webinar right, packages registered in the database are once defined and unchangeable. But even if it was possible to change them by, for example, adding some attributes to a class (and not necessarily references), we would have to change every instance of that class, right?
[Updated on: Wed, 28 October 2009 01:45] Report message to a moderator
|
|
|
Re: [CDO] Referencing between models [message #493806 is a reply to message #493792] |
Wed, 28 October 2009 06:33 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Danya,
Comments below.
Danya wrote:
> Ed Merks wrote on Tue, 27 October 2009 01:28
>> Keep in mind that in order to have a bidirectional reference between
>> to classes, both classes must be modified to add their half of that
>> pair of references and both instances must similarly be modified. So
>> it's generally not possible to reuse someone else's model and
>> establish bidirectional references with it. So while they're nice,
>> they're not always possible. Sometimes they're even a bad idea. For
>> example, consider why there is no bidirectional opposite for
>> EClass.eSuperTypes. It would certainly be nice for an EClass to know
>> all its subtypes, but we can't require that the base class be
>> modified every time some wants to create a derived class...
>
>
> Ed,
> Thank you for joining us. :)
>
> Yes, I had that in my mind, and I actually assumed that all the
> meta-models needed for this purpose were built from the scratch.
> However, isn't the situation you are talking about a part of the
> bigger problem - making any kind of change of an existing meta-model
> and keeping its instances consistent with it?
That's an issue, but I don't see it's relation to bidirectional
references...
>
> If I understood that part of CDO 2.0 webinar right, packages
> registered in the database are once defined and unchangeable.
I think it's more the classes that should be unchangeable, but I'm not
sure if binary compatible changes (purely additions) are tolerated by CDO.
> But even if it was possible to change them by, for example, adding
> some attributes to a class (and not necessarily references), we would
> have to change every instance of that class, right?
I'm not sure...
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Re: [CDO] Referencing between models [message #493921 is a reply to message #493806] |
Wed, 28 October 2009 13:56 |
Victor Roldan Betancort Messages: 524 Registered: July 2009 |
Senior Member |
|
|
Danya, Ed,
For any discussion on model evolution in CDO, we have raised:
256856: Support model evolution
https://bugs.eclipse.org/bugs/show_bug.cgi?id=256856
Some comments below:
>> If I understood that part of CDO 2.0 webinar right, packages
>> registered in the database are once defined and unchangeable.
> I think it's more the classes that should be unchangeable, but I'm not
> sure if binary compatible changes (purely additions) are tolerated by CDO.
For most of our IStore implementations, the EPackage is stored as a
binary array in the server. I could imagine a client substituting
certain EPackage with a new binary-compatible one. However, it would
also imply adapting the persistence structures to the new model. For
instance, it might imply modifying Table definitions in the RDBMS-based
DBStore. In the case of an object-oriented database storage, the
adaptation could be easier.
>> But even if it was possible to change them by, for example, adding
>> some attributes to a class (and not necessarily references), we would
>> have to change every instance of that class, right?
> I'm not sure...
The backed doesn't have the concept of EObject, instead the CDO
Framework stores CDORevisions. I guess you'll have to update a subset of
the stored revisions: some revision might need update, other won't ...
Don't hesitate leaving any comment in the bug I suggested previously for
any further discussion on model evolution. We will also attend the
newsgroup, of course :D
Cheers,
Víctor.
|
|
|
Re: [CDO] Referencing between models [message #494535 is a reply to message #493806] |
Sat, 31 October 2009 08:49 |
|
Hi,
CDO tolerates no changes to an EPackage that has already been committed
to a repository. We have a crude mechanism (counting the number of
EModelElements) in CDO to detect such attempts and I would be willing to
investigate better solutions to do so (digests?). In general, changing
an EPackage in any way makes the resulting EPackage being different from
the original one and it *must not* be published under the same URI. It's
the same story as with your plugins, you would never consider
republishing a changed plugin with the same version number, right?
Cheers
/Eike
----
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Ed Merks schrieb:
> Danya,
>
> Comments below.
>
> Danya wrote:
>> Ed Merks wrote on Tue, 27 October 2009 01:28
>>> Keep in mind that in order to have a bidirectional reference between
>>> to classes, both classes must be modified to add their half of that
>>> pair of references and both instances must similarly be modified.
>>> So it's generally not possible to reuse someone else's model and
>>> establish bidirectional references with it. So while they're nice,
>>> they're not always possible. Sometimes they're even a bad idea.
>>> For example, consider why there is no bidirectional opposite for
>>> EClass.eSuperTypes. It would certainly be nice for an EClass to
>>> know all its subtypes, but we can't require that the base class be
>>> modified every time some wants to create a derived class...
>>
>>
>> Ed,
>> Thank you for joining us. :)
>>
>> Yes, I had that in my mind, and I actually assumed that all the
>> meta-models needed for this purpose were built from the scratch.
>> However, isn't the situation you are talking about a part of the
>> bigger problem - making any kind of change of an existing meta-model
>> and keeping its instances consistent with it?
> That's an issue, but I don't see it's relation to bidirectional
> references...
>>
>> If I understood that part of CDO 2.0 webinar right, packages
>> registered in the database are once defined and unchangeable.
> I think it's more the classes that should be unchangeable, but I'm
> not sure if binary compatible changes (purely additions) are tolerated
> by CDO.
>> But even if it was possible to change them by, for example, adding
>> some attributes to a class (and not necessarily references), we would
>> have to change every instance of that class, right?
> I'm not sure...
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Re: [CDO] Referencing between models [message #494658 is a reply to message #493402] |
Sun, 01 November 2009 23:49 |
Danya Messages: 5 Registered: October 2009 |
Junior Member |
|
|
Ed Merks wrote on Wed, 28 October 2009 02:33 | That's an issue, but I don't see it's relation to bidirectional references...
|
Ed, I just wanted to note that, when dealing with an existing model (someone else's or mine), either it completely satisfies my needs, or I will have to change it. In that case, adding a new reference is not more difficult than adding a new attribute (at least for me, as a user ).
Victor, Eike,
Thank you very much for the explanations and references (pun intended ).
Of course, I still have some questions, so:
What do you mean by "model integration" at http://wiki.eclipse.org/CDO#Model_Integration_Features?
Is it possible to establish a relation between models from multiple repositories?
[Updated on: Sun, 01 November 2009 23:53] Report message to a moderator
|
|
|
Re: [CDO] Referencing between models [message #494673 is a reply to message #494658] |
Mon, 02 November 2009 06:37 |
|
Danya schrieb:
> Ed Merks wrote on Wed, 28 October 2009 02:33
>> That's an issue, but I don't see it's relation to bidirectional
>> references...
>
> Ed, I just wanted to note that, when dealing with an existing model
> (someone else's or mine), either it completely satisfies my needs, or
> I will have to change it. In that case, adding a new reference is not
> more difficult than adding a new attribute (at least for me, as a user
> :)).
Not very recommendable, from a maintenance perspective.
> Victor, Eike, Thank you very much for the explanations and references
> (pun intended :)).
>
> Of course, I still have some questions, so:
>
> What do you mean by "model integration" at
> http://http://wiki.eclipse.org/CDO#Model_Integration_Feature s?
It is a category of CDO features that describes the interoperability
with EMF (or possibly other modeling frameworks).
>
> Is it possible to establish a relation between models from multiple
> repositories?
Yes, with CDO you can associate a ResourceSet (your application's main
hub for interacting with object graphs) with multiple CDO repositories
and other sources for EMF resources.
Did you find the link to the CDO webinar that Ed and I gave? Check out
http://www.eclipse.org/cdo/documentation/presentations
Cheers
/Eike
----
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Re: [CDO] Referencing between models [message #495157 is a reply to message #494673] |
Tue, 03 November 2009 22:46 |
Danya Messages: 5 Registered: October 2009 |
Junior Member |
|
|
Eike Stepper wrote on Mon, 02 November 2009 01:37 | Not very recommendable, from a maintenance perspective.
|
I'll keep that in mind.
Eike Stepper wrote on Mon, 02 November 2009 01:37 | It is a category of CDO features that describes the interoperability with EMF (or possibly other modeling frameworks).
|
Oh, interoperability, ok. I thought it was something else.
Eike Stepper wrote on Mon, 02 November 2009 01:37 | Yes, with CDO you can associate a ResourceSet (your application's main hub for interacting with object graphs) with multiple CDO repositories and other sources for EMF resources.
|
I supposed so, and it was logical, because the ResourceSet provides access to cross-referenced resources. But I wasn't able to do it from editor, that's why I was unsure.
Yes, thank you.
Regards,
Danya
|
|
| |
Re: [CDO] Referencing between models [message #495500 is a reply to message #495157] |
Thu, 05 November 2009 07:21 |
|
Hi Danya,
Yes, unfortunately our generic editor does not support all CDO core
features, yet. It would be cool if you would like to help us and make
more functionality available at the UI level ;-)
Cheers
/Eike
----
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Danya schrieb:
> Eike Stepper wrote on Mon, 02 November 2009 01:37
>> Not very recommendable, from a maintenance perspective.
>
> I'll keep that in mind.
>
> Eike Stepper wrote on Mon, 02 November 2009 01:37
>> It is a category of CDO features that describes the interoperability
>> with EMF (or possibly other modeling frameworks).
>
> Oh, interoperability, ok. I thought it was something else.
> Eike Stepper wrote on Mon, 02 November 2009 01:37
>> Yes, with CDO you can associate a ResourceSet (your application's
>> main hub for interacting with object graphs) with multiple CDO
>> repositories and other sources for EMF resources.
>
> I supposed so, and it was logical, because the ResourceSet provides
> access to cross-referenced resources. But I wasn't able to do it from
> editor, that's why I was unsure.
>
> Eike Stepper wrote on Mon, 02 November 2009 01:37
>> Did you find the link to the CDO webinar that Ed and I gave? Check
>> out http://www.eclipse.org/cdo/documentation/presentations
>
> Yes, thank you.
>
> Regards,
> Danya
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Re: [CDO] Referencing between models [message #495501 is a reply to message #495246] |
Thu, 05 November 2009 07:26 |
|
Hi Steffen,
I have the feeling that these qualifiers do not make real sense in an
environment where the modules can not be deployed and undeployed
whenever one likes to. If a model is work-in-progress, wouldn't a
temporary repository (for playing with the model) make more sense? Then
the version would not matter anyway so much.
Cheers
/Eike
----
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Steffen Stundzig schrieb:
> Hi,
>
> Eike wrote:
>
>> Hi,
>>
>> CDO tolerates no changes to an EPackage that has already been committed
>> to a repository. We have a crude mechanism (counting the number of
>> EModelElements) in CDO to detect such attempts and I would be willing to
>> investigate better solutions to do so (digests?). In general, changing
>> an EPackage in any way makes the resulting EPackage being different from
>> the original one and it *must not* be published under the same URI. It's
>> the same story as with your plugins, you would never consider
>> republishing a changed plugin with the same version number, right?
>>
>
> I like the comparison of metamodel-versioning with plugin-versioning
> very much, since for eclipse users/PDE developers it is habitual and so
> I think they expect it.
>
> But if i start with creating/preparing metamodels it is a work in
> progress and not a big bang. To increase the version in the
> namespace-URI on each change in my ecore could be expensive. In PDE
> plugin development and also in maven artifact development it is possible
> and usual to mark the 'work-in-progress'-Version with something like
> 1.0.0-SNAPSHOT or 1.0.0.classifier.
>
> Do you think a similar approach for package registration in CDO is
> possible and/or useful?
>
> regards
>
Cheers
/Eike
----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
|
|
|
Goto Forum:
Current Time: Mon Apr 29 06:39:44 GMT 2024
Powered by FUDForum. Page generated in 0.04746 seconds
|