Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCamille Letavernier2015-01-22 10:18:03 +0000
committerCamille Letavernier2015-01-22 10:18:03 +0000
commitf9220f97b9a798d171379cf8a177cbff23345cfc (patch)
tree8ba1a2cc48e861ab4f0ebb3340976ea40437599f
parenta61e78f9e505c6996f203fd76a126fdfcc509c05 (diff)
downloadorg.eclipse.papyrus-f9220f97b9a798d171379cf8a177cbff23345cfc.tar.gz
org.eclipse.papyrus-f9220f97b9a798d171379cf8a177cbff23345cfc.tar.xz
org.eclipse.papyrus-f9220f97b9a798d171379cf8a177cbff23345cfc.zip
457341: [Model Import] Identify and fix performances bottlenecks
https://bugs.eclipse.org/bugs/show_bug.cgi?id=457341 - Improved tentative fix for Dangling References Analysis in Phase 1: don't try to resolve mappings which are already known
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/DependencyAnalysisHelper.java89
-rw-r--r--extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/ImportTransformationLauncher.java42
2 files changed, 44 insertions, 87 deletions
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/DependencyAnalysisHelper.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/DependencyAnalysisHelper.java
index f3c79534e45..a6638c6e7a5 100644
--- a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/DependencyAnalysisHelper.java
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/DependencyAnalysisHelper.java
@@ -81,40 +81,67 @@ public class DependencyAnalysisHelper {
}
}
- public synchronized void resolveAllMappings() {
+ public synchronized void resolveAllMappings(Map<URI, URI> urisToReplace, Map<URI, URI> profileUrisToReplace) {
if (config.getMappingParameters() == null) {
config.setMappingParameters(RSAToPapyrusParametersFactory.eINSTANCE.createMappingParameters());
}
try {
for (Entry<URI, Set<String>> resourceToRepair : brokenUris.entrySet()) {
+
+ // Already known mapping
+ if (urisToReplace.containsKey(resourceToRepair.getKey())) {
+ continue;
+ }
findMatch(resourceToRepair.getKey(), resourceToRepair.getValue());
}
for (URI profileDefinition : brokenProfiles) {
+
+ // Already known mapping
+ if (profileUrisToReplace.containsKey(profileDefinition.trimFragment().trimQuery())) {
+ continue;
+ }
findMatch(profileDefinition);
}
} finally {
unloadResourceSet();
+ brokenUris.clear();
+ brokenProfiles.clear();
}
}
protected void findMatch(URI resourceURI, Set<String> fragments) {
+ URIMapping mapping = null;
+
for (String fragment : fragments) {
URI eObjectURI = resourceURI.appendFragment(fragment);
- URIMapping mapping = findExistingMapping(eObjectURI, localResourceSet);
+ mapping = findExistingMapping(eObjectURI, localResourceSet);
+
if (mapping != null) {
- config.getMappingParameters().getUriMappings().add(mapping);
- return;
+ break;
}
}
+
+ if (mapping == null) {
+ mapping = RSAToPapyrusParametersFactory.eINSTANCE.createURIMapping();
+ mapping.setSourceURI(resourceURI.toString());
+ mapping.setTargetURI(mapping.getSourceURI());
+ }
+
+ config.getMappingParameters().getUriMappings().add(mapping);
}
protected void findMatch(URI profileDefinitionURI) {
URIMapping match = findExistingProfileMapping(profileDefinitionURI, localResourceSet);
- if (match != null) {
- config.getMappingParameters().getProfileUriMappings().add(match);
+
+ if (match == null) {
+ match = RSAToPapyrusParametersFactory.eINSTANCE.createURIMapping();
+ match.setSourceURI(profileDefinitionURI.trimFragment().trimQuery().toString());
+ match.setTargetURI(match.getSourceURI());
}
+
+ config.getMappingParameters().getProfileUriMappings().add(match);
}
protected void doComputeURIMappings(Resource sourceModel) {
@@ -193,6 +220,7 @@ public class DependencyAnalysisHelper {
protected synchronized void handleBrokenReference(EObject proxy) {
URI proxyURI = EcoreUtil.getURI(proxy);
URI resourceURI = proxyURI.trimFragment().trimQuery();
+
String fragment = proxyURI.fragment();
Set<String> fragments = getFragments(resourceURI);
fragments.add(fragment);
@@ -207,28 +235,11 @@ public class DependencyAnalysisHelper {
EPackage profileDefinition = stereotypeApplication.eClass().getEPackage();
URI packageURI = EcoreUtil.getURI(profileDefinition);
+ if (packageURI.trimFragment().isEmpty()) {
+ packageURI = URI.createURI(profileDefinition.getNsURI());
+ }
addBrokenProfileDefinition(packageURI);
-
- // Collection<URIMapping> mappings = config.getMappingParameters().getProfileUriMappings();
- //
- // URIMapping existingMapping = findExistingProfileMapping(stereotypeApplication, resourceSet);
- // if (existingMapping == null) {
- // URI packageURI = EcoreUtil.getURI(stereotypeApplication.eClass().getEPackage());
- //
- // URIMapping mapping = RSAToPapyrusParametersFactory.eINSTANCE.createURIMapping();
- //
- // mapping.setSourceURI(packageURI.trimFragment().trimQuery().toString());
- // mapping.setTargetURI(packageURI.trimFragment().trimQuery().toString());
- //
- // synchronized (config) {
- // mappings.add(mapping);
- // }
- // } else {
- // synchronized (config) {
- // mappings.add(existingMapping);
- // }
- // }
}
protected void handleURIMapping(EObject eObject, ResourceSet resourceSet) {
@@ -246,30 +257,6 @@ public class DependencyAnalysisHelper {
}
}
- // Collection<URIMapping> mappings = config.getMappingParameters().getUriMappings();
- //
- // if (eObject.eIsProxy() || isRSAModelElement(eObject)) { // Not yet resolved, or still a reference to an RSA Model Element
- // eObject = EcoreUtil.resolve(eObject, resourceSet);
- // if (eObject.eIsProxy() || isRSAModelElement(eObject)) { // Can't be resolved
- //
- // URIMapping existingMapping = findExistingMapping(eObject, resourceSet);
- // if (existingMapping == null) {
- // URIMapping mapping = RSAToPapyrusParametersFactory.eINSTANCE.createURIMapping();
- // URI sourceURI = EcoreUtil.getURI(eObject);
- //
- // mapping.setSourceURI(sourceURI.trimFragment().trimQuery().toString());
- // mapping.setTargetURI(sourceURI.trimFragment().trimQuery().toString()); // By default, don't change anything
- //
- // synchronized (config) {
- // mappings.add(mapping);
- // }
- // } else {
- // synchronized (config) {
- // mappings.add(existingMapping);
- // }
- // }
- // }
- // }
}
protected URIMapping findExistingProfileMapping(URI profileDefinitionURI, ResourceSet resourceSet) {
@@ -395,7 +382,7 @@ public class DependencyAnalysisHelper {
protected boolean isPathFragment(URI proxyURI) {
String uriFragment = proxyURI.fragment();
- return uriFragment.charAt(0) == '/';
+ return uriFragment != null && uriFragment.charAt(0) == '/';
}
protected URIMapping findExistingMapping(EObject proxy, ResourceSet resourceSet) {
diff --git a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/ImportTransformationLauncher.java b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/ImportTransformationLauncher.java
index 2081db8d85e..5d42fd71ca8 100644
--- a/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/ImportTransformationLauncher.java
+++ b/extraplugins/migration/org.eclipse.papyrus.migration.rsa/src/org/eclipse/papyrus/migration/rsa/transformation/ImportTransformationLauncher.java
@@ -165,6 +165,10 @@ public class ImportTransformationLauncher {
protected IStatus run(IProgressMonitor monitor) {
IStatus result = ImportTransformationLauncher.this.importModels(monitor, transformations);
+ if (monitor.isCanceled()) {
+ return new Status(IStatus.CANCEL, Activator.PLUGIN_ID, "Operation Canceled");
+ }
+
long cumulatedLoadingTime = 0L;
long cumulatedTransformationTime = 0L;
long cumulatedHandleDanglingTime = 0L;
@@ -396,13 +400,12 @@ public class ImportTransformationLauncher {
profileUrisToReplace.putAll(transformation.getProfileURIMappings());
}
+ monitor.subTask("Analysing unresolved references...");
long startResolveAll = System.nanoTime();
- analysisHelper.resolveAllMappings();
+ analysisHelper.resolveAllMappings(urisToReplace, profileUrisToReplace);
long endResolveAll = System.nanoTime();
resolveAllDependencies = endResolveAll - startResolveAll;
- filterKnownMappings(config.getMappingParameters(), urisToReplace, profileUrisToReplace);
-
if (!config.getMappingParameters().getUriMappings().isEmpty() || !config.getMappingParameters().getProfileUriMappings().isEmpty()) {
long beginDialog = System.nanoTime();
@@ -644,39 +647,6 @@ public class ImportTransformationLauncher {
}
}
- /**
- * Remove automatic mappings (When multiple files are imported simultaneously) and duplicates
- *
- * @param mappingParameters
- * All unresolved proxies
- * @param currentMappings
- * The map of known (automatic) mappings
- */
- protected void filterKnownMappings(final MappingParameters mappingParameters, final Map<URI, URI> currentMappings, final Map<URI, URI> currentProfileMappings) {
- filterKnownMappings(mappingParameters.getUriMappings(), currentMappings);
- filterKnownMappings(mappingParameters.getProfileUriMappings(), currentProfileMappings);
- }
-
- protected void filterKnownMappings(List<URIMapping> allMappings, Map<URI, URI> knownMappings) {
-
- Set<URI> userMappings = new HashSet<URI>();
-
- Iterator<URIMapping> mappings = allMappings.iterator();
- while (mappings.hasNext()) {
- URIMapping mapping = mappings.next();
- if (mapping == null) {
- continue;
- }
- URI sourceURI = URI.createURI(mapping.getSourceURI());
- if (knownMappings.containsKey(sourceURI) || userMappings.contains(sourceURI)) {
- mappings.remove();
- } else {
- userMappings.add(sourceURI);
- }
- }
-
- }
-
protected MappingParameters confirmURIMappings(final MappingParameters mappingParameters) {
if (config.isAlwaysAcceptSuggestedMappings()) {
return mappingParameters;

Back to the top