Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Convert EObject to CDOObject *or* load ecore file as dynamic/native CDO object
[CDO] Convert EObject to CDOObject *or* load ecore file as dynamic/native CDO object [message #1015861] Sun, 03 March 2013 17:39 Go to next message
Kirsten M. Z. is currently offline Kirsten M. Z.
Messages: 131
Registered: July 2010
Senior Member
Hi there,

I am trying to figuring out more about the conjunction of regular EMF object (e.g. as loaded from files) and CDO objects. I understand the differences and can already work in both worlds, but I have no idea how these worlds can be connected (conversion/import/export). Either this is not supported well, or I haven't found the correct documentation/tutorial yet. In general, I want to work with dynamic/reflective (DynamicCDOObject) as much as possible (no GenModel).

What I am trying to do right now: loading an ecore file and save the structure within a CDO resource. I am failing, because I want to avoid the legacy mode (no legacy mode). Of course, if I load the Ecore file the regular way, I have EPackages (etc) which are not derived from CDOObject (would require legacy mode then). How is storing in the CDO repository possible then? I tried injecting in order to get DynamicCDOObjects:

EcorePackage.eINSTANCE.setEFactoryInstance(new CDOFactoryImpl(EcorePackage.eINSTANCE));


This does not work (still investigating why). I also tried changing the resource factory, but I think this is the wrong way...

Then I thought about converting, and I also found CDOUtil.getCDOObject(...). However, this method does not work recursivly, right?

Are there some import/export mechanisms?

I have many ideas... each idea means several hours of investigation Sad Could someone help and tell me how this is intended to work? Is there a tutorial/manual about that topic?

Thanks in advance!

[Updated on: Sun, 03 March 2013 17:42]

Report message to a moderator

Re: [CDO] Convert EObject to CDOObject *or* oad ecore file as dynamic/native CDO object [message #1015877 is a reply to message #1015861] Mon, 04 March 2013 01:20 Go to previous messageGo to next message
Eike Stepper is currently offline Eike Stepper
Messages: 5446
Registered: July 2009
Senior Member
Am 03.03.2013 23:39, schrieb Kirsten M. Z.:
> Hi there,
>
> I am trying to figuring out more about the conjunction of regular EMF object (e.g. as loaded from files) and CDO
> objects. I understand the differences and can already work in both worlds, but I have no idea how these worlds can be
> connected (conversion/import/export). Either this is not supported well, or I haven't found the correct
> documentation/tutorial yet. In general, I want to work with dynamic/reflective (DynamicCDOObject) as much as possible
> (no GenModel).
>
> What I am trying to do right now: loading an ecore file and save the structure within a CDO resource. I am failing,
> because I want to avoid the legacy mode (no legacy mode). Of course, if I load the Ecore file the regular way, I have
> EPackages (etc) which are not derived from CDOObject (=> legacy mode). How is storing in the CDO repository possible
> then?
You can store instances of Ecore in CDO but you must use the legacy mode then.

> I tried injecting in order to get DynamicCDOObjects:
>
> EcorePackage.eINSTANCE.setEFactoryInstance(new CDOFactoryImpl(EcorePackage.eINSTANCE));
This won't work.

> This does not work (still investigating why). I also tried changing the resource factory, but I think this is the
> wrong way...
>
> Then I thought about converting, and I also found CDOUtil.getCDOObject(...). However, this method does not work
> recursivly, right?
No, it's a convenience method to get access to the CDOLegacyAdapter of a legacy object.

> Are there some import/export mechanisms?
In CDO 4.2 we introduced a (resource) transfer framework but it also requires instances of Ecore to be wrapped by
CDOLegacyAdapters.

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Re: [CDO] Convert EObject to CDOObject *or* oad ecore file as dynamic/native CDO object [message #1015960 is a reply to message #1015877] Mon, 04 March 2013 07:26 Go to previous messageGo to next message
Kirsten M. Z. is currently offline Kirsten M. Z.
Messages: 131
Registered: July 2010
Senior Member
So the main message is that there is no easy way to do that (yet)?

However, I am a little bit confused. For example, if I load a XMI file without static (code generated) model, then I get dynamic objects. Together with CDO, I can even get DynamicCDOObject. Is that correct so far?
Why is this strategy not applicable for ecore files themselves. Is it a special case because of the used code which must be aware of the ecore meta model?

Second question is... you talk about "legacy mode" like there is no big deal about it. However, I am wondering about drawbacks next to scalability (cp. http://wiki.eclipse.org/CDO_Legacy_Mode). Havn't read other details about legacy mode yet. Are all basic features supported in legacy mode (offline work, Audits etc.)? "Legacy" sounds like: "deprecated soon", "do not use it", "if you have to use it, you have a wrong application architecture" Wink
Re: [CDO] Convert EObject to CDOObject *or* oad ecore file as dynamic/native CDO object [message #1015970 is a reply to message #1015960] Mon, 04 March 2013 07:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 25740
Registered: July 2009
Senior Member
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Kirsten,<br>
<br>
It sounds like what you really want to do is create a subclass of
EFactoryImpl, override this method to create the dynamic CDO
versions, and setEFactory that on your dynamic model.<br>
<blockquote>org.eclipse.emf.ecore.impl.EFactoryImpl.basicCreate(EClass)<br>
</blockquote>
I imagine CDO has such a thing already...<br>
<br>
<br>
<div class="moz-cite-prefix">On 04/03/2013 1:26 PM, Kirsten M. Z.
wrote:<br>
</div>
<blockquote cite="mid:kh23t0$49t$1@xxxxxxxxe.org" type="cite">So
the main message is that there is no easy way to do that (yet)?
<br>
<br>
However, I am a little bit confused. For example, if I load a XMI
file without static (code generated) model, then I get dynamic
objects. Together with CDO, I can even get DynamicCDOObject. Is
that correct so far?
<br>
Why is this strategy not applicable for ecore files themselves. Is
it a special case because of the used code which must be aware of
the ecore meta model?
<br>
<br>
Second question is... you talk about "legacy mode" like there is
no big deal about it. However, I am wondering about drawbacks next
to scalability (cp. <a class="moz-txt-link-freetext" href="http://wiki.eclipse.org/CDO_Legacy_Mode">http://wiki.eclipse.org/CDO_Legacy_Mode</a>).
Havn't read other details about legacy mode yet. Are all basic
features supported in legacy mode (offline work, Audits etc.)?
"Legacy" sounds like: "deprecated soon", "do not use it", "if you
have to use it, you have a wrong application architecture" ;)
<br>
</blockquote>
<br>
</body>
</html>
Re: [CDO] Convert EObject to CDOObject *or* oad ecore file as dynamic/native CDO object [message #1015975 is a reply to message #1015970] Mon, 04 March 2013 08:04 Go to previous message
Kirsten M. Z. is currently offline Kirsten M. Z.
Messages: 131
Registered: July 2010
Senior Member
You mean CDOFactoryImpl? (see my first post)

This is what I tried to do. My theory was also that this could work. However, I am not an expert yet, and I run into some trouble I could not classify. I was blaming EcorePackage for being a very special case: preregistered in CDO stuff, some special code about EPackage, EClass etc (I am just thinking load, not 100% sure).
Previous Topic:Custom PropertySheetPage based on selected EObject
Next Topic:[Teneo] Constraint validation exception, column ... cannot be null
Goto Forum:
  


Current Time: Wed Apr 16 12:01:47 EDT 2014

Powered by FUDForum. Page generated in 0.01789 seconds