Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to copy a ResourceSet
How to copy a ResourceSet [message #422629] Thu, 11 September 2008 13:17 Go to next message
Sébastien  Gandon is currently offline Sébastien Gandon
Messages: 172
Registered: July 2009
Senior Member
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 13:26 Go to previous messageGo to next message
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 15:40 Go to previous messageGo to next message
Ed Merks is currently offline Ed Merks
Messages: 26087
Registered: July 2009
Senior Member
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 #422640 is a reply to message #422630] Thu, 11 September 2008 15:43 Go to previous messageGo to next message
Sébastien  Gandon is currently offline Sébastien Gandon
Messages: 172
Registered: July 2009
Senior Member
Thanks a lot.

Would not it be great to have this method into the EcoreUtil class ?


SeB.
Re: How to copy a ResourceSet [message #422642 is a reply to message #422640] Thu, 11 September 2008 16:02 Go to previous message
Ed Merks is currently offline Ed Merks
Messages: 26087
Registered: July 2009
Senior Member
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.
>
Previous Topic:short note: problem with domain names with "-" in XSD Schema
Next Topic:Bug: SetCommand changes order of elements in collection
Goto Forum:
  


Current Time: Tue Sep 30 21:59:35 GMT 2014

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

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