Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan-Philipp Steghöfer2020-12-21 15:31:04 +0000
committerJan-Philipp Steghöfer2020-12-21 19:56:11 +0000
commit050994cf46bd5f4fba8fa0717c155c754024c5af (patch)
tree6f5545a44df4ab3df2d1ed8b6483ddda185fb572
parent325916e0cf1d76921cfb3a850e8b474ddf95ca0a (diff)
downloadorg.eclipse.capra-050994cf46bd5f4fba8fa0717c155c754024c5af.tar.gz
org.eclipse.capra-050994cf46bd5f4fba8fa0717c155c754024c5af.tar.xz
org.eclipse.capra-050994cf46bd5f4fba8fa0717c155c754024c5af.zip
[Fix] Trace detection no longer dependent on object ref
The GenericTraceMetaModelAdapter for the standard trace meta model that Eclipse Capra ships with detected the presence of a link between two artifacts by using contains() which falls back on the objects' equals() implementation. This could cause problems if the underlying models were reloaded in a different ResourceSet. This commit now changes this behaviour and compares the elements using EMFHelper.isElementInList() which uses the identifiers of the artifacts instead. Change-Id: Ia83dd71d0329cc8bf4ffd2e09574d61620f37bae
-rw-r--r--bundles/org.eclipse.capra.generic.tracemodel/src/org/eclipse/capra/generic/tracemodel/GenericMetaModelAdapter.java10
1 files changed, 6 insertions, 4 deletions
diff --git a/bundles/org.eclipse.capra.generic.tracemodel/src/org/eclipse/capra/generic/tracemodel/GenericMetaModelAdapter.java b/bundles/org.eclipse.capra.generic.tracemodel/src/org/eclipse/capra/generic/tracemodel/GenericMetaModelAdapter.java
index 7b34a0b1..56ea5d78 100644
--- a/bundles/org.eclipse.capra.generic.tracemodel/src/org/eclipse/capra/generic/tracemodel/GenericMetaModelAdapter.java
+++ b/bundles/org.eclipse.capra.generic.tracemodel/src/org/eclipse/capra/generic/tracemodel/GenericMetaModelAdapter.java
@@ -22,6 +22,7 @@ import org.eclipse.capra.core.adapters.Connection;
import org.eclipse.capra.core.adapters.TraceMetaModelAdapter;
import org.eclipse.capra.core.adapters.TracePersistenceAdapter;
import org.eclipse.capra.core.helpers.ArtifactHelper;
+import org.eclipse.capra.core.helpers.EMFHelper;
import org.eclipse.capra.core.helpers.ExtensionPointHelper;
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EObject;
@@ -39,7 +40,6 @@ public class GenericMetaModelAdapter extends AbstractMetaModelAdapter implements
private static final int DEFAULT_INITIAL_TRANSITIVITY_DEPTH = 1;
-
public GenericMetaModelAdapter() {
// TODO Auto-generated constructor stub
}
@@ -91,7 +91,8 @@ public class GenericMetaModelAdapter extends AbstractMetaModelAdapter implements
for (RelatedTo trace : allTraces) {
if (!firstElement.equals(secondElement)) {
- if (trace.getItem().contains(firstElement) && trace.getItem().contains(secondElement)) {
+ if (EMFHelper.isElementInList(trace.getItem(), firstElement)
+ && EMFHelper.isElementInList(trace.getItem(), secondElement)) {
relevantLinks.add(trace);
}
}
@@ -203,9 +204,10 @@ public class GenericMetaModelAdapter extends AbstractMetaModelAdapter implements
for (Object trace : toRemove) {
tModel.getTraces().remove(trace);
}
-
+
TracePersistenceAdapter persistenceAdapter = ExtensionPointHelper.getTracePersistenceAdapter().get();
- persistenceAdapter.saveTracesAndArtifacts(tModel, persistenceAdapter.getArtifactWrappers(new ResourceSetImpl()));
+ persistenceAdapter.saveTracesAndArtifacts(tModel,
+ persistenceAdapter.getArtifactWrappers(new ResourceSetImpl()));
}
}

Back to the top