|Re: Copy between resources - Dangling References [message #1009570 is a reply to message #1009516]
||Fri, 15 February 2013 10:29
| Ed Merks
Registered: July 2009
On 15/02/2013 10:07 AM, Ralph P wrote:
> I've implemented a mechanism to copy EObjects from one resource into
> another (via Drag & Drop). I'm basically using
> EcoreUtil#copyAll(Collection) and AddCommands.
> It works fine as long as there are no EObjects in the target model
> that have the same ID as the ones that should be copied.
> If that happens, I am trying to replace the existing EObjects with the
> new ones, but I failing here.
> First I tried RemoveCommand -> CreateCommand. This seems to work at
> first but on validation I get "The feature [...] contains a dangling
> reference [...]" on every other EObject that references the removed
> existing one.
Yes, you'd need to use a DeleteCommand, but that's probably not going to
do what you want either; I assume you'd want all those other things to
reference the replacement...
> Then I tried the ReplaceCommand - same Problem.
Yes, the incoming references to the thing you've replaced will still dangle.
> How can I replace an EObject and fix all references to it?
> Is there a way to completely replace every feature of an EObject
> (including containments) by using SetCommand(s)?
Yes, you'd have to have to compose such a SetCommand for each feature.
> Thanks in advance!
I think you'd want something very similar to what DeleteCommand does,
but instead of deleting the reference, you'd want to use a
ReplaceCommand to replace it with a reference to the replacement.
> Best regards,
Powered by FUDForum
. Page generated in 0.02685 seconds