Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Compare » EMF Compare tries to match an added/new element with existing one
EMF Compare tries to match an added/new element with existing one [message #1749017] Thu, 01 December 2016 08:27 Go to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
I am using the API programmatically and facing this situation:

- left and right scope comparison (no origin)
- one element of left side is deleted
- a new element with several children is added to the right side
- EMF compare tries to match one of the child of the new element on the right side with the deleted element of the left side

I know this is very abstract, but maybe you have some hints where to debug and what part of the matching algorithm to adapt.

I think EMF Compare should be aware of the child being part of the whole new element (on right side) and hence should not be matched at all.
Re: EMF Compare tries to match an added/new element with existing one [message #1749025 is a reply to message #1749017] Thu, 01 December 2016 09:30 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
I have provided a custom distance function that handles this case but I am not sure if this is the proper way to go:

                @Override
                public double distance(Comparison inProgress, EObject a, EObject b) {
                    EObject leftParent = a;
                    do {
                        leftParent = leftParent.eContainer();
                        Match match = inProgress.getMatch(leftParent);
                        if (match != null && match.getRight() == null) {
                            // no right match, assume it is part of a later ADDITION
                            return Double.MAX_VALUE;
                        }
                    } while (leftParent != null);
                    return super.distance(inProgress, a, b);
                }
Re: EMF Compare tries to match an added/new element with existing one [message #1749296 is a reply to message #1749025] Mon, 05 December 2016 09:11 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
Hi,

EMF Compare will try and match all elements together: the children you "add" might very well have been moved there, so we try and get it matched to detect the move (for example, imagine a class "Writer" that's been moved from the top-level package to a sub-package for clarity). If there is never such kind of moves in your case, then you can probably refine the matching to exclude them, and the kind of approach you've used here seems like a good one.

Laurent Goubet
Obeo
Previous Topic:EMF Compare: Start over!?
Next Topic:Problem with merging multiplicity-many eOpposites
Goto Forum:
  


Current Time: Thu Dec 26 10:03:33 GMT 2024

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

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

Back to the top