Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc) » [EMF Compare] MergeService doesn't copy a child non-containment reference
[EMF Compare] MergeService doesn't copy a child non-containment reference [message #434768] |
Thu, 30 July 2009 20:05 ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Stephen McCants![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=smccants%40us.ibm.com) Messages: 92 Registered: July 2009 |
Member |
|
|
Resending with proper subject line.
--Stephen
-------- Original Message --------
Subject: MergeService doesn't copy a child non-containment reference
Date: Thu, 30 Jul 2009 13:39:39 -0500
From: Stephen McCants <stephenmccants@yahoo.com>
Organization: EclipseCorner
Newsgroups: eclipse.technology.emft
Hello,
We have a model and are doing the match, diff and merge. Everything is working correctly, except
the merge fails to merge in one object.
The diff correctly identifies an object that has been added to the model. That added object has a
non-containment reference to another object. When we do the merge, it correctly copies the added
object to the left model (from the right model), but the non-containment reference is never set.
Instead of being set, it is null.
We traced through the copy code and it is trying to copy it in
EMFComapreEObjectCopier.copyReferences() by calling copyReference(). However, the call to
copyReference() does nothing because we haven't copied it before (so it isn't returned by get()) and
the mergeLinkedDiff() function returns false.
The reason mergeLinkedDiff() returns false is because the reference being copied is a child of an
unmatched element and not an unmatched element itself.
We were going to try to override the Copier and make some adjustments to work around this problem,
but there seems to be no way to do that (MergeService is final and MergeService.getCopier() always
uses the EMFCompareEObjectCopier()).
Any ideas on what we can do to get the MergeService to copy the non-containment reference over?
Thanks!
--Stephen
|
|
|
Re: [EMF Compare] MergeService doesn't copy a child non-containment reference [message #467866 is a reply to message #434768] |
Mon, 03 August 2009 08:59 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
|
This is a multi-part message in MIME format.
--------------030300050307020905060403
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Hi Stephen,
With two differences as you've described, EMF Compare will indeed need
two steps for this child reference to be copied : you have an added
element A with a reference towards the child C of another added element
B. Merging only A will not copy C since B hasn't been copied yet, but
merging B subsequently will copy C _and_ restore the link from A to C.
We've implemented the merge as such so has to only merge the differences
the user selected, not ones that are not directly linked. MergeService
is final as it simply isn't meant to be subclassed, but you can force
EMF Compare to consider your two differences to be linked (and thus
needing to be merged together) through the use of the
org.eclipse.emf.compare.diff.extension extension point.
Laurent Goubet
Obeo
Stephen McCants a
|
|
|
Re: [EMF Compare] MergeService doesn't copy a child non-containment reference [message #468029 is a reply to message #467866] |
Mon, 03 August 2009 17:20 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Bryan Hunt![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=bhunt%40mac.com) Messages: 366 Registered: July 2009 |
Senior Member |
|
|
Laurent,
Do you have an example on how we would implement the extension point?
I looked at the extension point and didn't get very far. Some
documentation / examples would be helpful.
Bryan
On 2009-08-03 03:59:38 -0500, laurent Goubet <laurent.goubet@obeo.fr> said:
>
> Hi Stephen,
>
> With two differences as you've described, EMF Compare will indeed need
> two steps for this child reference to be copied : you have an added
> element A with a reference towards the child C of another added element
> B. Merging only A will not copy C since B hasn't been copied yet, but
> merging B subsequently will copy C _and_ restore the link from A to C.
>
> We've implemented the merge as such so has to only merge the differences
> the user selected, not ones that are not directly linked. MergeService
> is final as it simply isn't meant to be subclassed, but you can force
> EMF Compare to consider your two differences to be linked (and thus
> needing to be merged together) through the use of the
> org.eclipse.emf.compare.diff.extension extension point.
>
> Laurent Goubet
> Obeo
>
> Stephen McCants a écrit :
>> Resending with proper subject line.
>> --Stephen
>>
>> -------- Original Message --------
>> Subject: MergeService doesn't copy a child non-containment reference
>> Date: Thu, 30 Jul 2009 13:39:39 -0500
>> From: Stephen McCants <stephenmccants@yahoo.com>
>> Organization: EclipseCorner
>> Newsgroups: eclipse.technology.emft
>>
>> Hello,
>>
>> We have a model and are doing the match, diff and merge. Everything is
>> working correctly, except
>> the merge fails to merge in one object.
>>
>> The diff correctly identifies an object that has been added to the
>> model. That added object has a
>> non-containment reference to another object. When we do the merge, it
>> correctly copies the added
>> object to the left model (from the right model), but the non-containment
>> reference is never set.
>> Instead of being set, it is null.
>>
>> We traced through the copy code and it is trying to copy it in
>> EMFComapreEObjectCopier.copyReferences() by calling copyReference().
>> However, the call to
>> copyReference() does nothing because we haven't copied it before (so it
>> isn't returned by get()) and
>> the mergeLinkedDiff() function returns false.
>>
>> The reason mergeLinkedDiff() returns false is because the reference
>> being copied is a child of an
>> unmatched element and not an unmatched element itself.
>>
>> We were going to try to override the Copier and make some adjustments to
>> work around this problem,
>> but there seems to be no way to do that (MergeService is final and
>> MergeService.getCopier() always
>> uses the EMFCompareEObjectCopier()).
>>
>> Any ideas on what we can do to get the MergeService to copy the
>> non-containment reference over?
>>
>> Thanks!
>>
>> --Stephen
>
>
>
> This message has one or more attachments. Select "Save Attachments"
> from the File menu to save.
> begin:vcard
|
|
|
Re: [EMF Compare] MergeService doesn't copy a child non-containment reference [message #468110 is a reply to message #468029] |
Tue, 04 August 2009 08:01 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
|
This is a multi-part message in MIME format.
--------------090901010606050704050305
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Hi Bryan,
Well the "org.eclipse.emf.compare.examples.diff.extension" seems like a
good start for this extension point, yet we haven't got much
documentation on it beyond the example itself.
Cheers,
Laurent Goubet
Obeo
Bryan Hunt a
|
|
|
Re: [EMF Compare] MergeService doesn't copy a child non-containment reference [message #479886 is a reply to message #467866] |
Wed, 12 August 2009 22:02 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Stephen McCants![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=smccants%40us.ibm.com) Messages: 92 Registered: July 2009 |
Member |
|
|
Hello Laurent,
Thanks for your reply. I just got back from vacation today, so I just looked at your emails today.
>
> With two differences as you've described, EMF Compare will indeed need
> two steps for this child reference to be copied : you have an added
> element A with a reference towards the child C of another added element
> B. Merging only A will not copy C since B hasn't been copied yet, but
> merging B subsequently will copy C _and_ restore the link from A to C.
That makes sense, but I think where I may be running into problems is that A and B are in different
resources, but the same resource set. We are trying a MatchService.doMatch(A1, A2), so that will
only see the changes to A and not to B?
We tried switching to a doResourceSetMatch(...), but that ran into some problems. We got a
DiffResourceSet back, but DiffResourceSet.getSubDiffElements() returns an empty array so we have
nothing to merge with. Looking into the DiffResourceSet I can see it has a "root" object that is
contained by a DifferenceImpl (of some type).
Is there an example of how to merge differences between resource sets?
Thanks for your help!
--Stephen
|
|
|
Re: [EMF Compare] MergeService doesn't copy a child non-containment reference [message #481104 is a reply to message #479886] |
Wed, 19 August 2009 15:54 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Stephen McCants![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=smccants%40us.ibm.com) Messages: 92 Registered: July 2009 |
Member |
|
|
Anyone have any ideas? We are still stuck.
Thanks!
--Stephen
Stephen McCants wrote:
> Hello Laurent,
> Thanks for your reply. I just got back from vacation today, so I
> just looked at your emails today.
>>
>> With two differences as you've described, EMF Compare will indeed need
>> two steps for this child reference to be copied : you have an added
>> element A with a reference towards the child C of another added
>> element B. Merging only A will not copy C since B hasn't been copied
>> yet, but merging B subsequently will copy C _and_ restore the link
>> from A to C.
>
> That makes sense, but I think where I may be running into problems is
> that A and B are in different resources, but the same resource set. We
> are trying a MatchService.doMatch(A1, A2), so that will only see the
> changes to A and not to B?
>
> We tried switching to a doResourceSetMatch(...), but that ran into some
> problems. We got a DiffResourceSet back, but
> DiffResourceSet.getSubDiffElements() returns an empty array so we have
> nothing to merge with. Looking into the DiffResourceSet I can see it
> has a "root" object that is contained by a DifferenceImpl (of some type).
>
> Is there an example of how to merge differences between resource sets?
>
> Thanks for your help!
>
> --Stephen
|
|
|
Re: [EMF Compare] MergeService doesn't copy a child non-containment reference [message #481223 is a reply to message #481104] |
Thu, 20 August 2009 07:47 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
|
This is a multi-part message in MIME format.
--------------020803010804070705000802
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Hi Stephen,
MatchService.doResourcesetMatch should indeed be the way to go in your
case. Whether you merge the differences or not, using anything else to
match resources containing links to other resources would give erroneous
results.
Other than that ... DiffResourceSet.getSubDiffElements() doesn't exist.
DiffResourceSet.getDiffModels() will return a DiffModel for each
resources pair (Resource A from ResourceSet RS1 matched with Resource A'
from ResourceSet RS2 will yield on DiffModel, Resource B from RS1 and
Resource B' from RS2 ....).
DiffModel.getOwnedElements() will return a "root" DiffElement
corresponding to every root of the compared resources, and
DiffElement.getSubDiffElements() on these roots will give you the actual
changes detected, which you can then merge through the MergeService.
DiffResourceSet.getResourceDiffs() will contain DiffElements if there
are more resources in one ResourceSet than there are in the other
(namely, a resource now links to a new "other" resource).
Laurent Goubet
Obeo
P.S : just realized the copier we use to merge differences is contextual
to a DiffModel, not to the DiffResourceSet ... I don't know if we'll
properly restore dangling inter-model links because of that. I'll take a
look when I come back to EMF Compare.
Stephen McCants a
|
|
|
Re: [EMF Compare] MergeService doesn't copy a child non-containment reference [message #483917 is a reply to message #481223] |
Thu, 03 September 2009 15:25 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) ![Go to next message Go to next message](theme/Solstice/images/down.png) |
Bryan Hunt![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=bhunt%40mac.com) Messages: 366 Registered: July 2009 |
Senior Member |
|
|
Hi Laurent,
We are just now getting back to working on our merge problem. We are
now getting a ClassCastException when we try to do the merge. Here is
how are are setting up the merge:
Model model = library.getModel(false);
MatchResourceSet match =
MatchService.doResourceSetMatch(root.eResource().getResource Set(),
model.eResource().getResourceSet(), Collections.<String, Object>
emptyMap());
DiffResourceSet diff = DiffService.doDiff(match, false);
for (DiffModel resourceDiff : diff.getDiffModels())
{
List<DiffElement> differences = new
ArrayList<DiffElement>(resourceDiff.getOwnedElements());
MergeService.merge(differences, false);
}
When the merger gets to handleMutuallyDerrivedReferences() the switch
statement takes the case EcorePackage.ECLASS__ESUPER_TYPES and fails
when it tries to cast diff to a ReferenceChangeRightTarget. diff is of
the type UpdateReferenceImpl. Here is the section of code in question:
private void handleMutuallyDerivedReferences() {
DiffElement toRemove = null;
if (diff instanceof ReferenceChange) {
final EReference reference = ((ReferenceChange)diff).getReference();
switch (reference.getFeatureID()) {
case EcorePackage.ECLASS__ESUPER_TYPES:
final EObject referenceType;
if (diff instanceof ReferenceChangeLeftTarget) {
referenceType = ((ReferenceChangeLeftTarget)diff).getRightTarget();
} else {
referenceType =
((ReferenceChangeRightTarget)diff).getLeftTarget(); <<---- exception
here
}
Are we taking the right approach with our code? Any ideas on how to fix this?
Bryan
On 2009-08-20 02:47:21 -0500, laurent Goubet <laurent.goubet@obeo.fr> said:
>
> Hi Stephen,
>
> MatchService.doResourcesetMatch should indeed be the way to go in your
> case. Whether you merge the differences or not, using anything else to
> match resources containing links to other resources would give erroneous
> results.
>
> Other than that ... DiffResourceSet.getSubDiffElements() doesn't exist.
> DiffResourceSet.getDiffModels() will return a DiffModel for each
> resources pair (Resource A from ResourceSet RS1 matched with Resource A'
> from ResourceSet RS2 will yield on DiffModel, Resource B from RS1 and
> Resource B' from RS2 ....).
>
> DiffModel.getOwnedElements() will return a "root" DiffElement
> corresponding to every root of the compared resources, and
> DiffElement.getSubDiffElements() on these roots will give you the actual
> changes detected, which you can then merge through the MergeService.
>
> DiffResourceSet.getResourceDiffs() will contain DiffElements if there
> are more resources in one ResourceSet than there are in the other
> (namely, a resource now links to a new "other" resource).
>
> Laurent Goubet
> Obeo
>
> P.S : just realized the copier we use to merge differences is contextual
> to a DiffModel, not to the DiffResourceSet ... I don't know if we'll
> properly restore dangling inter-model links because of that. I'll take a
> look when I come back to EMF Compare.
>
> Stephen McCants a écrit :
>> Anyone have any ideas? We are still stuck.
>> Thanks!
>>
>> --Stephen
>>
>> Stephen McCants wrote:
>>> Hello Laurent,
>>> Thanks for your reply. I just got back from vacation today, so I
>>> just looked at your emails today.
>>>>
>>>> With two differences as you've described, EMF Compare will indeed
>>>> need two steps for this child reference to be copied : you have an
>>>> added element A with a reference towards the child C of another added
>>>> element B. Merging only A will not copy C since B hasn't been copied
>>>> yet, but merging B subsequently will copy C _and_ restore the link
>>>> from A to C.
>>>
>>> That makes sense, but I think where I may be running into problems is
>>> that A and B are in different resources, but the same resource set.
>>> We are trying a MatchService.doMatch(A1, A2), so that will only see
>>> the changes to A and not to B?
>>>
>>> We tried switching to a doResourceSetMatch(...), but that ran into
>>> some problems. We got a DiffResourceSet back, but
>>> DiffResourceSet.getSubDiffElements() returns an empty array so we have
>>> nothing to merge with. Looking into the DiffResourceSet I can see it
>>> has a "root" object that is contained by a DifferenceImpl (of some type).
>>>
>>> Is there an example of how to merge differences between resource sets?
>>>
>>> Thanks for your help!
>>>
>>> --Stephen
>
>
>
> This message has one or more attachments. Select "Save Attachments"
> from the File menu to save.
> begin:vcard
> fn:Laurent Goubet
|
|
|
Re: [EMF Compare] MergeService doesn't copy a child non-containment reference [message #484066 is a reply to message #483917] |
Fri, 04 September 2009 07:36 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
|
This is a multi-part message in MIME format.
--------------070903020305050600060409
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Bryan,
I believe this is indeed the right approach ... and that would mean
there is a case I haven't thought of, and that I didn't encouter in my
tests. Could you raise a bug with your stack trace and the models you've
used to produce this error?
Laurent Goubet
Obeo
Bryan Hunt a
|
|
|
Re: [EMF Compare] MergeService doesn't copy a child non-containment reference [message #621293 is a reply to message #434768] |
Mon, 03 August 2009 08:59 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
|
This is a multi-part message in MIME format.
--------------030300050307020905060403
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Hi Stephen,
With two differences as you've described, EMF Compare will indeed need
two steps for this child reference to be copied : you have an added
element A with a reference towards the child C of another added element
B. Merging only A will not copy C since B hasn't been copied yet, but
merging B subsequently will copy C _and_ restore the link from A to C.
We've implemented the merge as such so has to only merge the differences
the user selected, not ones that are not directly linked. MergeService
is final as it simply isn't meant to be subclassed, but you can force
EMF Compare to consider your two differences to be linked (and thus
needing to be merged together) through the use of the
org.eclipse.emf.compare.diff.extension extension point.
Laurent Goubet
Obeo
Stephen McCants a
|
|
|
Re: [EMF Compare] MergeService doesn't copy a child non-containment reference [message #621296 is a reply to message #467866] |
Mon, 03 August 2009 17:20 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Bryan Hunt![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=bhunt%40mac.com) Messages: 366 Registered: July 2009 |
Senior Member |
|
|
Laurent,
Do you have an example on how we would implement the extension point?
I looked at the extension point and didn't get very far. Some
documentation / examples would be helpful.
Bryan
On 2009-08-03 03:59:38 -0500, laurent Goubet <laurent.goubet@obeo.fr> said:
>
> Hi Stephen,
>
> With two differences as you've described, EMF Compare will indeed need
> two steps for this child reference to be copied : you have an added
> element A with a reference towards the child C of another added element
> B. Merging only A will not copy C since B hasn't been copied yet, but
> merging B subsequently will copy C _and_ restore the link from A to C.
>
> We've implemented the merge as such so has to only merge the differences
> the user selected, not ones that are not directly linked. MergeService
> is final as it simply isn't meant to be subclassed, but you can force
> EMF Compare to consider your two differences to be linked (and thus
> needing to be merged together) through the use of the
> org.eclipse.emf.compare.diff.extension extension point.
>
> Laurent Goubet
> Obeo
>
> Stephen McCants a écrit :
>> Resending with proper subject line.
>> --Stephen
>>
>> -------- Original Message --------
>> Subject: MergeService doesn't copy a child non-containment reference
>> Date: Thu, 30 Jul 2009 13:39:39 -0500
>> From: Stephen McCants <stephenmccants@yahoo.com>
>> Organization: EclipseCorner
>> Newsgroups: eclipse.technology.emft
>>
>> Hello,
>>
>> We have a model and are doing the match, diff and merge. Everything is
>> working correctly, except
>> the merge fails to merge in one object.
>>
>> The diff correctly identifies an object that has been added to the
>> model. That added object has a
>> non-containment reference to another object. When we do the merge, it
>> correctly copies the added
>> object to the left model (from the right model), but the non-containment
>> reference is never set.
>> Instead of being set, it is null.
>>
>> We traced through the copy code and it is trying to copy it in
>> EMFComapreEObjectCopier.copyReferences() by calling copyReference().
>> However, the call to
>> copyReference() does nothing because we haven't copied it before (so it
>> isn't returned by get()) and
>> the mergeLinkedDiff() function returns false.
>>
>> The reason mergeLinkedDiff() returns false is because the reference
>> being copied is a child of an
>> unmatched element and not an unmatched element itself.
>>
>> We were going to try to override the Copier and make some adjustments to
>> work around this problem,
>> but there seems to be no way to do that (MergeService is final and
>> MergeService.getCopier() always
>> uses the EMFCompareEObjectCopier()).
>>
>> Any ideas on what we can do to get the MergeService to copy the
>> non-containment reference over?
>>
>> Thanks!
>>
>> --Stephen
>
>
>
> This message has one or more attachments. Select "Save Attachments"
> from the File menu to save.
> begin:vcard
|
|
|
Re: [EMF Compare] MergeService doesn't copy a child non-containment reference [message #621298 is a reply to message #468029] |
Tue, 04 August 2009 08:01 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
|
This is a multi-part message in MIME format.
--------------090901010606050704050305
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Hi Bryan,
Well the "org.eclipse.emf.compare.examples.diff.extension" seems like a
good start for this extension point, yet we haven't got much
documentation on it beyond the example itself.
Cheers,
Laurent Goubet
Obeo
Bryan Hunt a
|
|
|
Re: [EMF Compare] MergeService doesn't copy a child non-containment reference [message #621306 is a reply to message #467866] |
Wed, 12 August 2009 22:02 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Stephen McCants![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=smccants%40us.ibm.com) Messages: 92 Registered: July 2009 |
Member |
|
|
Hello Laurent,
Thanks for your reply. I just got back from vacation today, so I just looked at your emails today.
>
> With two differences as you've described, EMF Compare will indeed need
> two steps for this child reference to be copied : you have an added
> element A with a reference towards the child C of another added element
> B. Merging only A will not copy C since B hasn't been copied yet, but
> merging B subsequently will copy C _and_ restore the link from A to C.
That makes sense, but I think where I may be running into problems is that A and B are in different
resources, but the same resource set. We are trying a MatchService.doMatch(A1, A2), so that will
only see the changes to A and not to B?
We tried switching to a doResourceSetMatch(...), but that ran into some problems. We got a
DiffResourceSet back, but DiffResourceSet.getSubDiffElements() returns an empty array so we have
nothing to merge with. Looking into the DiffResourceSet I can see it has a "root" object that is
contained by a DifferenceImpl (of some type).
Is there an example of how to merge differences between resource sets?
Thanks for your help!
--Stephen
|
|
|
Re: [EMF Compare] MergeService doesn't copy a child non-containment reference [message #621312 is a reply to message #621306] |
Wed, 19 August 2009 15:54 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Stephen McCants![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=smccants%40us.ibm.com) Messages: 92 Registered: July 2009 |
Member |
|
|
Anyone have any ideas? We are still stuck.
Thanks!
--Stephen
Stephen McCants wrote:
> Hello Laurent,
> Thanks for your reply. I just got back from vacation today, so I
> just looked at your emails today.
>>
>> With two differences as you've described, EMF Compare will indeed need
>> two steps for this child reference to be copied : you have an added
>> element A with a reference towards the child C of another added
>> element B. Merging only A will not copy C since B hasn't been copied
>> yet, but merging B subsequently will copy C _and_ restore the link
>> from A to C.
>
> That makes sense, but I think where I may be running into problems is
> that A and B are in different resources, but the same resource set. We
> are trying a MatchService.doMatch(A1, A2), so that will only see the
> changes to A and not to B?
>
> We tried switching to a doResourceSetMatch(...), but that ran into some
> problems. We got a DiffResourceSet back, but
> DiffResourceSet.getSubDiffElements() returns an empty array so we have
> nothing to merge with. Looking into the DiffResourceSet I can see it
> has a "root" object that is contained by a DifferenceImpl (of some type).
>
> Is there an example of how to merge differences between resource sets?
>
> Thanks for your help!
>
> --Stephen
|
|
|
Re: [EMF Compare] MergeService doesn't copy a child non-containment reference [message #621316 is a reply to message #481104] |
Thu, 20 August 2009 07:47 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
|
This is a multi-part message in MIME format.
--------------020803010804070705000802
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Hi Stephen,
MatchService.doResourcesetMatch should indeed be the way to go in your
case. Whether you merge the differences or not, using anything else to
match resources containing links to other resources would give erroneous
results.
Other than that ... DiffResourceSet.getSubDiffElements() doesn't exist.
DiffResourceSet.getDiffModels() will return a DiffModel for each
resources pair (Resource A from ResourceSet RS1 matched with Resource A'
from ResourceSet RS2 will yield on DiffModel, Resource B from RS1 and
Resource B' from RS2 ....).
DiffModel.getOwnedElements() will return a "root" DiffElement
corresponding to every root of the compared resources, and
DiffElement.getSubDiffElements() on these roots will give you the actual
changes detected, which you can then merge through the MergeService.
DiffResourceSet.getResourceDiffs() will contain DiffElements if there
are more resources in one ResourceSet than there are in the other
(namely, a resource now links to a new "other" resource).
Laurent Goubet
Obeo
P.S : just realized the copier we use to merge differences is contextual
to a DiffModel, not to the DiffResourceSet ... I don't know if we'll
properly restore dangling inter-model links because of that. I'll take a
look when I come back to EMF Compare.
Stephen McCants a
|
|
|
Re: [EMF Compare] MergeService doesn't copy a child non-containment reference [message #621352 is a reply to message #481223] |
Thu, 03 September 2009 15:25 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
Bryan Hunt![Friend of Eclipse Friend](/donate/web-api/friends_decorator.php?email=bhunt%40mac.com) Messages: 366 Registered: July 2009 |
Senior Member |
|
|
Hi Laurent,
We are just now getting back to working on our merge problem. We are
now getting a ClassCastException when we try to do the merge. Here is
how are are setting up the merge:
Model model = library.getModel(false);
MatchResourceSet match =
MatchService.doResourceSetMatch(root.eResource().getResource Set(),
model.eResource().getResourceSet(), Collections.<String, Object>
emptyMap());
DiffResourceSet diff = DiffService.doDiff(match, false);
for (DiffModel resourceDiff : diff.getDiffModels())
{
List<DiffElement> differences = new
ArrayList<DiffElement>(resourceDiff.getOwnedElements());
MergeService.merge(differences, false);
}
When the merger gets to handleMutuallyDerrivedReferences() the switch
statement takes the case EcorePackage.ECLASS__ESUPER_TYPES and fails
when it tries to cast diff to a ReferenceChangeRightTarget. diff is of
the type UpdateReferenceImpl. Here is the section of code in question:
private void handleMutuallyDerivedReferences() {
DiffElement toRemove = null;
if (diff instanceof ReferenceChange) {
final EReference reference = ((ReferenceChange)diff).getReference();
switch (reference.getFeatureID()) {
case EcorePackage.ECLASS__ESUPER_TYPES:
final EObject referenceType;
if (diff instanceof ReferenceChangeLeftTarget) {
referenceType = ((ReferenceChangeLeftTarget)diff).getRightTarget();
} else {
referenceType =
((ReferenceChangeRightTarget)diff).getLeftTarget(); <<---- exception
here
}
Are we taking the right approach with our code? Any ideas on how to fix this?
Bryan
On 2009-08-20 02:47:21 -0500, laurent Goubet <laurent.goubet@obeo.fr> said:
>
> Hi Stephen,
>
> MatchService.doResourcesetMatch should indeed be the way to go in your
> case. Whether you merge the differences or not, using anything else to
> match resources containing links to other resources would give erroneous
> results.
>
> Other than that ... DiffResourceSet.getSubDiffElements() doesn't exist.
> DiffResourceSet.getDiffModels() will return a DiffModel for each
> resources pair (Resource A from ResourceSet RS1 matched with Resource A'
> from ResourceSet RS2 will yield on DiffModel, Resource B from RS1 and
> Resource B' from RS2 ....).
>
> DiffModel.getOwnedElements() will return a "root" DiffElement
> corresponding to every root of the compared resources, and
> DiffElement.getSubDiffElements() on these roots will give you the actual
> changes detected, which you can then merge through the MergeService.
>
> DiffResourceSet.getResourceDiffs() will contain DiffElements if there
> are more resources in one ResourceSet than there are in the other
> (namely, a resource now links to a new "other" resource).
>
> Laurent Goubet
> Obeo
>
> P.S : just realized the copier we use to merge differences is contextual
> to a DiffModel, not to the DiffResourceSet ... I don't know if we'll
> properly restore dangling inter-model links because of that. I'll take a
> look when I come back to EMF Compare.
>
> Stephen McCants a écrit :
>> Anyone have any ideas? We are still stuck.
>> Thanks!
>>
>> --Stephen
>>
>> Stephen McCants wrote:
>>> Hello Laurent,
>>> Thanks for your reply. I just got back from vacation today, so I
>>> just looked at your emails today.
>>>>
>>>> With two differences as you've described, EMF Compare will indeed
>>>> need two steps for this child reference to be copied : you have an
>>>> added element A with a reference towards the child C of another added
>>>> element B. Merging only A will not copy C since B hasn't been copied
>>>> yet, but merging B subsequently will copy C _and_ restore the link
>>>> from A to C.
>>>
>>> That makes sense, but I think where I may be running into problems is
>>> that A and B are in different resources, but the same resource set.
>>> We are trying a MatchService.doMatch(A1, A2), so that will only see
>>> the changes to A and not to B?
>>>
>>> We tried switching to a doResourceSetMatch(...), but that ran into
>>> some problems. We got a DiffResourceSet back, but
>>> DiffResourceSet.getSubDiffElements() returns an empty array so we have
>>> nothing to merge with. Looking into the DiffResourceSet I can see it
>>> has a "root" object that is contained by a DifferenceImpl (of some type).
>>>
>>> Is there an example of how to merge differences between resource sets?
>>>
>>> Thanks for your help!
>>>
>>> --Stephen
>
>
>
> This message has one or more attachments. Select "Save Attachments"
> from the File menu to save.
> begin:vcard
> fn:Laurent Goubet
|
|
|
Re: [EMF Compare] MergeService doesn't copy a child non-containment reference [message #621353 is a reply to message #483917] |
Fri, 04 September 2009 07:36 ![Go to previous message Go to previous message](theme/Solstice/images/up.png) |
|
This is a multi-part message in MIME format.
--------------070903020305050600060409
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit
Bryan,
I believe this is indeed the right approach ... and that would mean
there is a case I haven't thought of, and that I didn't encouter in my
tests. Could you raise a bug with your stack trace and the models you've
used to produce this error?
Laurent Goubet
Obeo
Bryan Hunt a
|
|
|
Goto Forum:
Current Time: Sun Sep 01 01:03:27 GMT 2024
Powered by FUDForum. Page generated in 0.04800 seconds
|