Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » CDO mapping with UUIDs
CDO mapping with UUIDs [message #1737337] Thu, 07 July 2016 11:25 Go to next message
Jeremy Di Terlizzi is currently offline Jeremy Di TerlizziFriend
Messages: 4
Registered: July 2016
Junior Member
Hi everyone, i'm working on a project which is supposed to use CDO to create a single file containing all the objects that are processed and used. It is currently based on 2 main files defining the objects and a third one using them.
Actually, the import of those resources on the server isn't an issue but the export of these resources is one.
I'm trying to create a single xmi resource containing the 3 resources from the server but i'm encountering some issues :
- i can't find a way to use the UUID of the objects as the mapping reference, since the project actually is based on this
- can't save it properly in an xmi file (xml or whatever) it only saves one of the referencing resource

Is there at least a way to set the id of the objects as their uuid?
Thanks for answering.

[Updated on: Fri, 08 July 2016 08:07]

Report message to a moderator

Re: CDO mapping with UUIDs [message #1737469 is a reply to message #1737337] Fri, 08 July 2016 13:22 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Hi Jeremy,

Most of what you explain is not fully clear to me. More comments below...

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



Am 07.07.2016 um 20:58 schrieb Jeremy Di Terlizzi:
> Hi everyone, i'm working on a project which is supposed to use CDO to create a single file containing all the objects
> that are processed and used. It is currently based on 2 main files defining the objects and a third one using them.
Do you mean file system files? How would that relate to CDO?

> Actually, the import of those resources on the server isn't an issue but the export of these resources is one.
> I'm trying to create a single xmi resource containing the 3 resources from the server
A resource can't contain other resources. Do you mean to create a file resource that contains (copies of) all root
objects of some CDO resources?

> but i'm encountering some issues :
> - i can't find a way to use the UUID of the objects as the mapping reference,
Are you actually using UUIDs? Or counter IDs?

What is a "mapping reference" and why do you need it?

> since the project actually is based on this
What is a "project" in this context?

> - can't save it properly in an xmi file (xml or whatever) it only saves one of the referencing resource
I have no idea what exactly you're trying to do. Maybe a test case or some source snippets can shed more light on it?

>
> Is there at least a way to set the id of the objects as their iduu?
If you're really using UUIDs (i.e., client-side assigned CDOIDs), you can hook up your own CDOIDGenerator via:

org.eclipse.emf.cdo.session.CDOSessionConfiguration.setIDGenerator(CDOIDGenerator)


Re: CDO mapping with UUIDs [message #1737471 is a reply to message #1737469] Fri, 08 July 2016 13:41 Go to previous messageGo to next message
Jeremy Di Terlizzi is currently offline Jeremy Di TerlizziFriend
Messages: 4
Registered: July 2016
Junior Member
Hi Eike, thanks for answering. Well you were right i didn't explain it correctly and apologize.
Let's explain it again :

I have 3 CDOResources. One of them contains EObjects that refer to those contained in the other ones.

I am trying to put the whole content (all the EObjects) of these CDOResources in a single xmi Resource, so that the references will mention objects that are contained in this Resource (and i will get rid of the uri, nsuri or whatever taht were used before).

But CDO maps these objects using its own generated ids, while i'm using something else that he can understand because all the references he makes are correct.


Example :
- In the XMI Resource before importing it to the CDO Server:
<blablabla UUID="This_Is_An_UUID_1">

<blablabla UUID="This_Is_An_UUID_2">
<bla href="This_Is_An_UUID_1">

- In the CDOResource :
<blablabla xmi:id="L25628" UUID="This_Is_An_UUID_1">

<blablabla xmi:id="L25629" UUID="This_Is_An_UUID_2">
<bla href="L25628">


So, is there any way to make the server not use its own ids and use for example the UUID i generated before putting it all on the server?

Well i hope this will be clear enough x)

Edit :
I actually use an emfmodel that already had its own generated id attributes (corresponding to the UUIDs in the example) . Is it possible to make CDO use this attribute instead of adding its generated xmi:id ?
Because this one makes the exported XMI Resource noncompliant with the models.

[Updated on: Fri, 08 July 2016 14:45]

Report message to a moderator

Re: CDO mapping with UUIDs [message #1737564 is a reply to message #1737471] Sun, 10 July 2016 05:41 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6682
Registered: July 2009
Senior Member
Am 08.07.2016 um 16:41 schrieb Jeremy Di Terlizzi:
> Hi Eike, thanks for answering. Well you were right i didn't explain it correctly and apologize.
> Let's explain it again :
>
> I have 3 CDOResources. One of them contains EObjects that refer to those contained in the other ones.
>
> I am trying to put the whole content (all the EObjects) of these CDOResources in a single xmi Resource, so that the
> references will mention objects that are contained in this Resource
So let me first ask, does your export code work or not? E.g, are all the cross references serialized correctly?

> (and i will get rid of the uri, nsuri or whatever taht were used before).
That seems unrelated.

>
> But CDO maps these objects using its own generated ids, while i'm using something else that he can understand because
> all the references he makes are correct.
Who is he? Do I know him?

More importantly, why does it matter how CDO internally identifies objects? Compare it to a normal Java object; you can
put it in any number of maps, each for its own purpose and with its own key set.

>
>
> Example : - In the XMI Resource before importing it to the CDO Server:
> <blablabla UUID="This_Is_An_UUID_1">
>
> <blablabla xmi:id="L25629" UUID="This_Is_An_UUID_2">
> <bla href="This_Is_An_UUID_1">
>
> - In the CDOResource : <blablabla xmi:id="L25628" UUID="This_Is_An_UUID_1">
Well, this is clearly an XMI text and not a CDOResource. How have you created this XMI text? Please provide the code to
prevent further misunderstandings.

>
> <blablabla xmi:id="L25629" UUID="This_Is_An_UUID_2">
> <bla href="L25629">
>
>
> So, is there any way to make the server not use its own ids and use for example the UUID i generated before putting it
> all on the server?
Yes, I told you about the CDOIDGenerator and how to hook it up. I forgot to mention that you also need to adjust your
cdo-server.xml *before* the first start of the repo:

<property name="idGenerationLocation" value="CLIENT"/> <!-- Possible values: STORE | CLIENT -->


>
> Well i hope this will be clear enough x)
Not really, but getting closer :P

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper


Re: CDO mapping with UUIDs [message #1737655 is a reply to message #1737564] Mon, 11 July 2016 15:33 Go to previous messageGo to next message
Jeremy Di Terlizzi is currently offline Jeremy Di TerlizziFriend
Messages: 4
Registered: July 2016
Junior Member
After some tests, i figured out the real issue. Sorry for lacking that much of precisions but i couldn't understand a lot of things through this problem.
So, ye you were right, i completely missunderstood the XMI text with the CDOResource and well, the mapping strategy isn't an issue actually i just misunderstood the problem.

The real problem here is that i can't manage to concatenate 3 CDOResources into an other one and save it as a XML file. For some reasons, CDO manages to create a correct CDORessource in its database (the concatenation is correct i've checked it through the CDO Session view) to be exported to a Resource but i can't get a correct Resource.
Here's the export code :

public static void exportCDO()
{
CDOResource rs1 = getOrCreateResource("res1");
CDOResource rs2 = getOrCreateResource("res2");
CDOResource rs3 = getOrCreateResource("res3");

CDOResource rs4 = getOrCreateResource("res4");

ResourceSet rss = new ResourceSetImpl();
Resource target = rss.createResource(URI.createURI("./output.xml"));
EList<EObject> targetContents = target.getContents();

rs4.addAll( rs1.getContents() );
rs4.addAll( rs2.getContents() );
rs4.addAll( rs3.getContents() );

transaction.commit();

target.getContents().addAll( rs4.getContents() );

target.save(null);
}

I can't figure out why the file "output.xml" only contains the elements of rs1. I tried a lot of different strategies (copiers, loops for the eobjects...) but none seem to work. Is there a special trick or something to do?
The Resource target only gets the elements that were placed first into rs4, so if i put rs2 first in rs4, target will only get rs2.

By the way, i thought it was a mapping issue because i was saving it through a ByteArray... Sorry for this :/
Re: CDO mapping with UUIDs [message #1737656 is a reply to message #1737564] Mon, 11 July 2016 15:33 Go to previous message
Jeremy Di Terlizzi is currently offline Jeremy Di TerlizziFriend
Messages: 4
Registered: July 2016
Junior Member
After some tests, i figured out the real issue. Sorry for lacking that much of precisions but i couldn't understand a lot of things through this problem.
So, ye you were right, i completely missunderstood the XMI text with the CDOResource and well, the mapping strategy isn't an issue actually i just misunderstood the problem.

The real problem here is that i can't manage to concatenate 3 CDOResources into an other one and save it as a XML file. For some reasons, CDO manages to create a correct CDORessource in its database (the concatenation is correct i've checked it through the CDO Session view) to be exported to a Resource but i can't get a correct Resource.
Here's the export code :

public static void exportCDO()
{
CDOResource rs1 = getOrCreateResource("res1");
CDOResource rs2 = getOrCreateResource("res2");
CDOResource rs3 = getOrCreateResource("res3");

CDOResource rs4 = getOrCreateResource("res4");

ResourceSet rss = new ResourceSetImpl();
Resource target = rss.createResource(URI.createURI("./output.xml"));
EList<EObject> targetContents = target.getContents();

rs4.addAll( rs1.getContents() );
rs4.addAll( rs2.getContents() );
rs4.addAll( rs3.getContents() );

transaction.commit();

target.getContents().addAll( rs4.getContents() );

target.save(null);
}

I can't figure out why the file "output.xml" only contains the elements of rs1. I tried a lot of different strategies (copiers, loops for the eobjects...) but none seem to work. Is there a special trick or something to do?
The Resource target only gets the elements that were placed first into rs4, so if i put rs2 first in rs4, target will only get rs2.

By the way, i thought it was a mapping issue because i was saving it through a ByteArray... Sorry for this :/
Previous Topic:[CDO] NPE in AbstractHorizintalClassMapping.initTable()
Next Topic:CDO failed to register channel eclipse on Neon
Goto Forum:
  


Current Time: Fri Apr 19 22:34:47 GMT 2024

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

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

Back to the top