Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2015-01-15 09:06:21 +0000
committerCamille Letavernier2015-01-15 09:06:21 +0000
commit103e8a57aa13e06ef179caa96e3aa6ec81877df6 (patch)
tree42c32366d2b1fdb53f4b1565e2f4d977c4f7107d /extraplugins/migration
parent8337c868c5620fc103b86b5a3a8732d4cc6153fa (diff)
downloadorg.eclipse.papyrus-103e8a57aa13e06ef179caa96e3aa6ec81877df6.tar.gz
org.eclipse.papyrus-103e8a57aa13e06ef179caa96e3aa6ec81877df6.tar.xz
org.eclipse.papyrus-103e8a57aa13e06ef179caa96e3aa6ec81877df6.zip
457341: [Model Import] Identify and fix performances bottlenecks
https://bugs.eclipse.org/bugs/show_bug.cgi?id=457341 In individual model transformations: - Properly delete source diagrams after the migration - Clean up the target model *before* saving - Add new steps in the ProgressMonitor
Diffstat (limited to 'extraplugins/migration')
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/ImportTransformation.java60
1 files changed, 42 insertions, 18 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 63fe1623dbf..17997c71572 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
@@ -422,7 +422,7 @@ public class ImportTransformation {
if (generationStatus.getSeverity() <= Diagnostic.WARNING) {
- monitor.subTask("Saving models...");
+ monitor.subTask("Cleaning-up target model...");
URI notationModelURI = null;
URI sashModelURI = null;
// ResourceSet resourceSet = new ResourceSetImpl();
@@ -494,6 +494,8 @@ public class ImportTransformation {
}
}
+ monitor.subTask("Handling fragments...");
+
Collection<Resource> resourcesToSave = handleFragments(umlResource, notationResource, sashResource);
for (Resource resource : resourcesToSave) {
@@ -506,29 +508,38 @@ public class ImportTransformation {
}
}
- handleDanglingURIs(resourcesToSave);
-
- for (Resource resource : resourcesToSave) {
- try {
- resource.save(null);
- } catch (Exception ex) {
- Activator.log.error(ex);
- }
- }
+ monitor.subTask("Deleting source diagrams...");
for (Diagram diagram : diagramsToDelete) {
EObject container = diagram.eContainer();
delete(diagram);
if (container instanceof EAnnotation) {
- delete(container);
+ EAnnotation annotation = (EAnnotation) container;
+ if (annotation.getContents().isEmpty()) {
+ delete(annotation);
+ }
}
}
diagramsToDelete.clear();
- // unloadResourceSet(resourceSet);
+ monitor.subTask("Analyzing dangling references...");
+
+ handleDanglingURIs(resourcesToSave);
+
+ monitor.subTask("Saving models...");
+
+ for (Resource resource : resourcesToSave) {
+ try {
+ resource.save(null);
+ } catch (Exception ex) {
+ Activator.log.error(ex);
+ }
+ }
}
+ monitor.subTask("Releasing memory...");
+
unloadResourceSet(this.resourceSet);
this.resourceSet = null;
@@ -1040,7 +1051,7 @@ public class ImportTransformation {
/*
* Bug 447097: [Model Import] Importing a fragmented model causes stereotype applications to be lost in resulting submodel
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=447097
- *
+ *
* StereotypeApplications from Fragments are not considered "rootElements" by QVTo, and
* there is no logical link between UML Elements and stereotype applications in fragments
* We need to make all root Elements available to the QVTo ModelExtent (Including the ones
@@ -1155,14 +1166,27 @@ public class ImportTransformation {
job.cancel();
}
- public void delete(EObject rootElement) {
- CacheAdapter adapter = CacheAdapter.getCacheAdapter(rootElement);
+ public void delete(EObject elementToDelete) {
+ CacheAdapter adapter = CacheAdapter.getCacheAdapter(elementToDelete);
if (adapter == null) {
adapter = CacheAdapter.getInstance();
}
- adapter.unsetTarget(rootElement);
- if (rootElement.eResource() != null) {
- rootElement.eResource().getContents().remove(rootElement);
+ adapter.unsetTarget(elementToDelete);
+ if (elementToDelete.eResource() != null) {
+ elementToDelete.eResource().getContents().remove(elementToDelete);
+ }
+
+ EObject parent = elementToDelete.eContainer();
+ if (parent == null) {
+ return;
+ }
+ EReference containmentFeature = elementToDelete.eContainmentFeature();
+
+ if (containmentFeature.getUpperBound() == 1) {
+ parent.eUnset(containmentFeature);
+ } else {
+ List<?> values = (List<?>) parent.eGet(containmentFeature);
+ values.remove(elementToDelete);
}
}
}

Back to the top