Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 316589

Summary: [EMF Compare] EcoreIDSimilarityChecker#init(obj1, obj2) don't add compared objects to the left and right iterators
Product: [Modeling] EMFCompare Reporter: Ali AKAR <ali.akar82>
Component: CoreAssignee: EMF Compare <emf.compare-inbox>
Status: CLOSED FIXED QA Contact:
Severity: critical    
Priority: P3 CC: cedric.brun, romain.sezestre, stephaneberle9
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

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.