CDO mapping with UUIDs [message #1737337] |
Thu, 07 July 2016 07:25  |
Eclipse User |
|
|
|
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 04:07] by Moderator
|
|
|
|
|
Re: CDO mapping with UUIDs [message #1737564 is a reply to message #1737471] |
Sun, 10 July 2016 01:41   |
Eclipse User |
|
|
|
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 11:33   |
Eclipse User |
|
|
|
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 11:33  |
Eclipse User |
|
|
|
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 :/
|
|
|
Powered by
FUDForum. Page generated in 0.24684 seconds