From d6b9b433692672a3f68e15fdc3f190baddb09094 Mon Sep 17 00:00:00 2001 From: Arthur Daussy Date: Thu, 4 Sep 2014 15:45:25 +0200 Subject: [PATCH] [443330] Avoid getting a "Profile version change" error. Previously in order to check that the version of a profile had not change the program was using URI comparison in order to compare that the EPackage pointed by the two URI were identical. In some case, when the profile was referenced using PATHMAP, it happens that the uri comparison fail whereas the to uri point to the same object (One of the uri was referencing the object using a pathmap whereas the other was using the resolved uri). Normalizing uris before comparison corrects this problem. Bug: 443330 Change-Id: I046dad5edf68aa9a59dbe347a8302ab91b49357e Signed-off-by: Arthur Daussy --- .../internal/postprocessor/UMLPostProcessor.java | 29 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/UMLPostProcessor.java b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/UMLPostProcessor.java index 06282b6e4..bb421951b 100644 --- a/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/UMLPostProcessor.java +++ b/plugins/org.eclipse.emf.compare.uml2/src/org/eclipse/emf/compare/uml2/internal/postprocessor/UMLPostProcessor.java @@ -45,6 +45,9 @@ import org.eclipse.emf.ecore.EAnnotation; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EReference; import org.eclipse.emf.ecore.EcorePackage; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; +import org.eclipse.emf.ecore.resource.URIConverter; import org.eclipse.emf.ecore.util.EcoreUtil; import org.eclipse.uml2.uml.ProfileApplication; @@ -140,9 +143,9 @@ public class UMLPostProcessor implements IPostProcessor { */ private boolean checkProfileVersion(Comparison comparison, ProfileApplication profileApplication, EAnnotation leftAnnot, EAnnotation rightAnnot) { - Collection leftUris = getURIs(ReferenceUtil.getAsList(leftAnnot, + Collection leftUris = getNormalizedURIs(ReferenceUtil.getAsList(leftAnnot, EcorePackage.Literals.EANNOTATION__REFERENCES)); - Collection rightUris = getURIs(ReferenceUtil.getAsList(rightAnnot, + Collection rightUris = getNormalizedURIs(ReferenceUtil.getAsList(rightAnnot, EcorePackage.Literals.EANNOTATION__REFERENCES)); if (leftUris.size() != rightUris.size() || !leftUris.containsAll(rightUris)) { org.eclipse.uml2.uml.Package impactedPackage = profileApplication.getApplyingPackage(); @@ -179,17 +182,33 @@ public class UMLPostProcessor implements IPostProcessor { } /** - * Get the URI of the given ecore objects. + * Get the normalized URI of the given ecore objects. * * @param eObjects * The ecore objects. * @return the list of the URI. */ - private Collection getURIs(List eObjects) { + private Collection getNormalizedURIs(List eObjects) { Function eObjectToURI = new Function() { public URI apply(Object input) { if (input instanceof EObject) { - return EcoreUtil.getURI((EObject)input); + URI uri = EcoreUtil.getURI((EObject)input); + URIConverter uriConverter = getURIConverter((EObject)input); + if (uriConverter != null) { + uri = uriConverter.normalize(uri); + } + return uri; + } + return null; + } + + private URIConverter getURIConverter(EObject eObject) { + Resource resource = eObject.eResource(); + if (resource != null) { + ResourceSet resourceSet = resource.getResourceSet(); + if (resourceSet != null) { + return resourceSet.getURIConverter(); + } } return null; } -- 2.11.4.GIT