Skip to main content


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 GandonFriend
Messages: 184
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 UserFriend
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 MerksFriend
Messages: 33142
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.
>>


Ed Merks
Professional Support: https://www.macromodeling.com/
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 GandonFriend
Messages: 184
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 MerksFriend
Messages: 33142
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.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
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: Sat Apr 27 05:06:07 GMT 2024

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

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

Back to the top