Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2015-09-30 04:57:28 -0400
committerCamille Letavernier2015-09-30 05:02:57 -0400
commitd476ecdc2f2beec2cc37be5e06b75f6eaebe7173 (patch)
tree695164cf60b27fd2ee43c0eace95d081bad853a5
parent614deb3ec1a502cd2f3c674bce57edc2102cb4fc (diff)
downloadorg.eclipse.papyrus-d476ecdc2f2beec2cc37be5e06b75f6eaebe7173.tar.gz
org.eclipse.papyrus-d476ecdc2f2beec2cc37be5e06b75f6eaebe7173.tar.xz
org.eclipse.papyrus-d476ecdc2f2beec2cc37be5e06b75f6eaebe7173.zip
471684: [RSA Import] Strange import result for showListStereotype
property https://bugs.eclipse.org/bugs/show_bug.cgi?id=471684 - Workaround: Clean up invalid metadata EAnnotations at the root of each resource Change-Id: I0c3250ae896b106a303475bca012641c34e6134a Signed-off-by: Camille Letavernier <camille.letavernier@cea.fr>
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/ImportTransformation.java20
1 files changed, 20 insertions, 0 deletions
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/ImportTransformation.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/ImportTransformation.java
index c8de57ff773..962ebb06766 100644
--- a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/ImportTransformation.java
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/ImportTransformation.java
@@ -49,6 +49,7 @@ import org.eclipse.emf.ecore.EReference;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.util.EcoreUtil;
+import org.eclipse.emf.ecore.util.ExtendedMetaData;
import org.eclipse.emf.ecore.xmi.XMIResource;
import org.eclipse.emf.ecore.xmi.XMLResource;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
@@ -566,6 +567,7 @@ public class ImportTransformation {
for (Resource resource : resourcesToSave) {
try {
+ cleanMetadataAnnotations(resource);
ResourceAccessHelper.INSTANCE.saveResource(resource, null);
} catch (Exception ex) {
Activator.log.error(ex);
@@ -586,6 +588,24 @@ public class ImportTransformation {
return generationStatus;
}
+ /**
+ * @param resource
+ */
+ private void cleanMetadataAnnotations(Resource resource) {
+ // Bug 471684: UML2.x to UML2.5 creates (invalid) Ecore Metadata EAnnotations, which then cause OCL validation to fail
+ // Remove these EAnnotations from the model to avoid side effects
+ Iterator<EObject> rootElementsIterator = resource.getContents().iterator();
+ while (rootElementsIterator.hasNext()) {
+ EObject root = rootElementsIterator.next();
+ if (root instanceof EAnnotation) {
+ EAnnotation annotation = (EAnnotation) root;
+ if (ExtendedMetaData.ANNOTATION_URI.equals(annotation.getSource())) {
+ rootElementsIterator.remove();
+ }
+ }
+ }
+ }
+
protected void handleDanglingURIs(Collection<Resource> resourcesToSave) {
if (analysisHelper != null) {
resourceSet.freeze();

Back to the top