How to copy a ResourceSet [message #422629] |
Thu, 11 September 2008 09:17  |
Eclipse User |
|
|
|
Hello,
I need to copy a ResourceSet (that is 2 resources depending on each other)
into memory in order to modify them without modifying the original
Resources.
I have looked a EcoreUtil to copy objects but I'd like the 2 copied
resources to reference each other and I do not know how to do that?
SeB.
|
|
|
Re: How to copy a ResourceSet [message #422630 is a reply to message #422629] |
Thu, 11 September 2008 09:26   |
Eclipse User |
|
|
|
Originally posted by: cdamus.zeligsoft.com
Hi, SeB,
You can collect the contents of both resources into a single collection
of EObjects, and use the EcoreUtil.Copier to copy the whole collection.
This ensures that internal references in the copied graph are copied
correctly.
After the copy is complete, the Copier provides a mapping from the
original objects to their copies, so that you can populate new resources
with the copies of the contents, respectively, of the original resources.
HTH,
Christian
SeB.fr wrote:
> Hello,
>
> I need to copy a ResourceSet (that is 2 resources depending on each
> other) into memory in order to modify them without modifying the
> original Resources.
> I have looked a EcoreUtil to copy objects but I'd like the 2 copied
> resources to reference each other and I do not know how to do that?
>
> SeB.
>
|
|
|
Re: How to copy a ResourceSet [message #422639 is a reply to message #422630] |
Thu, 11 September 2008 11:40   |
Eclipse User |
|
|
|
SeB,
You could also use an EcoreUtil.Copier directly to call copyAll for each
resource's contents and when you're done with them all, call
copyReferences to make sure that all the cross references among all the
copied objects are copied as well...
Christian W. Damus wrote:
> Hi, SeB,
>
> You can collect the contents of both resources into a single
> collection of EObjects, and use the EcoreUtil.Copier to copy the whole
> collection. This ensures that internal references in the copied graph
> are copied correctly.
>
> After the copy is complete, the Copier provides a mapping from the
> original objects to their copies, so that you can populate new
> resources with the copies of the contents, respectively, of the
> original resources.
>
> HTH,
>
> Christian
>
> SeB.fr wrote:
>> Hello,
>>
>> I need to copy a ResourceSet (that is 2 resources depending on each
>> other) into memory in order to modify them without modifying the
>> original Resources.
>> I have looked a EcoreUtil to copy objects but I'd like the 2 copied
>> resources to reference each other and I do not know how to do that?
>>
>> SeB.
>>
|
|
|
|
Re: How to copy a ResourceSet [message #422642 is a reply to message #422640] |
Thu, 11 September 2008 12:02  |
Eclipse User |
|
|
|
SeB,
It's not entirely clear how the resource itself should be copied. Just
create new ones with the same URI? But then there are issues like how
the content type (which will involve parsing the contents referenced by
the URI) determines the resource...
SeB.fr wrote:
> Thanks a lot.
>
> Would not it be great to have this method into the EcoreUtil class ?
>
>
> SeB.
>
|
|
|
Powered by
FUDForum. Page generated in 0.03413 seconds