Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 316589 - [EMF Compare] EcoreIDSimilarityChecker#init(obj1, obj2) don't add compared objects to the left and right iterators
Summary: [EMF Compare] EcoreIDSimilarityChecker#init(obj1, obj2) don't add compared ob...
Status: CLOSED FIXED
Alias: None
Product: EMFCompare
Classification: Modeling
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 critical (vote)
Target Milestone: ---   Edit
Assignee: EMF Compare CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-11 07:15 EDT by Ali AKAR CLA
Modified: 2010-06-11 08:10 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ali AKAR CLA 2010-06-11 07:15:41 EDT
Build Identifier: 1.1.0.v201005050957 (EMF Compare Version)

Comparing two objects don't work properly since EcoreIDSimilarityChecker is unable to find similarity between these two objects. The problem is when initializing the checker these 2 objects are not included in the left and right iterators. I propose the solution below.

1- Added method to EcoreIDSimilarityChecker :

protected AbstractTreeIterator<EObject> getAllContentsIncludingRoot(EObject contextObject) {
		AbstractTreeIterator<EObject> allContents = new AbstractTreeIterator<EObject>(contextObject, true) {
			private static final long serialVersionUID = 1L;

			@Override
			public Iterator<EObject> getChildren(Object object) {
				return ((EObject) object).eContents().iterator();
			}
		};
		return allContents;
	}
2 - Modified EcoreIDSimilarityChecker#init(EObject, EObject) to call the added method

public void init(EObject obj1, EObject obj2) throws FactoryException {
		leftToRight.clear();
		nonIdentified.clear();
		final Iterator<EObject> leftIterator = getAllContentsIncludingRoot(obj1);
		final Iterator<EObject> rightIterator = getAllContentsIncludingRoot(obj2);
		browseComputingId(leftIterator, rightIterator);
		delegate.init(obj1, obj2);
	}


Reproducible: Always
Comment 1 Cedric Brun CLA 2010-06-11 08:10:10 EDT
Hi, it's been fixed since the 18th of May, please have a try with the last build.