|
Re: Bidirectional reference and CopyCommand understanding... [message #415262 is a reply to message #415261] |
Fri, 07 December 2007 20:30 |
Ed Merks Messages: 33140 Registered: July 2009 |
Senior Member |
|
|
Matthias,
The logic in the EcoreUtil.Copier is very similar. Here's the basic
problem to consider that's the same in both cases. One generally
expects to be able to make a copy of something and have that copy be a
brand new thing to which no existing object has a reference. I.e., you
do not (should not) expect any existing object to be modified by the act
of creating a copy. As such, when bidirectional references are
involved, the reference is copied over into the result only if both ends
of the reference are being copied so that the two ends will be related
in the same way as the original for which they are copies were related.
So if you want a copied task to have a specific owner you'll need to add
it to that owner separately just as when you copy a child object in a
containment you need to paste it into an owner.
Matthias wrote:
> Hello EMF enthusiasts!
>
> I have some problems understanding the bidirectional reference in
> Ecore models and the EMF.edit framework. I have the following scenario:
>
> Task Owner
> owners(1..n)---------tasks(0..n)
> The reference is not a containment reference!
>
>
> So now when i use the CopyToClipboardCommand like the following:
> EditingDomain = ..
> Task task = ..
> Owner owner = ..
> task.getOwners().add(owner);
>
> Command cmd = CopyToClipboardCommand.create(ed, task);
> ed.getCommandStack().execute(cmd);
>
> *ONLY* the owner gets copied when the reference is *NOT* a
> bidirectional reference (say when no eOpposite is set), otherwise the
> copied task has no owner!!!
>
> But why is this so?!? And why does it not work when eOpposite is set?!
> Do i misserstand something concerning the reference types in Ecore?
>
> Best Regards,
> Matthias
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03309 seconds