diff options
| author | Laurent Redor | 2014-03-06 13:20:56 +0000 |
|---|---|---|
| committer | Laurent Redor | 2014-03-13 10:44:37 +0000 |
| commit | c088cb034e68b59d082d0c26043dbff111f9c266 (patch) | |
| tree | 5adb48f8774b47762b5011ef6a5c0d5d7ba3e975 | |
| parent | c0961643b1874d65d2b1f304b3e42aa02af85424 (diff) | |
| download | org.eclipse.sirius-c088cb034e68b59d082d0c26043dbff111f9c266.tar.gz org.eclipse.sirius-c088cb034e68b59d082d0c26043dbff111f9c266.tar.xz org.eclipse.sirius-c088cb034e68b59d082d0c26043dbff111f9c266.zip | |
[429753] Potential invalid egdes with unsynchronized mode
Add validation to check if semantic source is always in the list
returned by the source finder expression for this edge and if semantic
target is always in the list returned by the target finder expression
for
this edge
Bug: 429753
Change-Id: Idf8690023a6a250dd24f63c283d39b077e3f527c
Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
2 files changed, 26 insertions, 25 deletions
diff --git a/plugins/org.eclipse.sirius.tests.support/src/org/eclipse/sirius/tests/support/api/SiriusDiagramTestCase.java b/plugins/org.eclipse.sirius.tests.support/src/org/eclipse/sirius/tests/support/api/SiriusDiagramTestCase.java index 851f9caa32..51bf961d65 100644 --- a/plugins/org.eclipse.sirius.tests.support/src/org/eclipse/sirius/tests/support/api/SiriusDiagramTestCase.java +++ b/plugins/org.eclipse.sirius.tests.support/src/org/eclipse/sirius/tests/support/api/SiriusDiagramTestCase.java @@ -120,7 +120,7 @@ public class SiriusDiagramTestCase extends SiriusTestCase { private static final String TOOL_NAME_INCORRECT = "The tool name is not correct"; - private static final String LAYER_NAME_INCORRECT = "The layer name is not correct"; + private static final String LAYER_NAME_INCORRECT = "The layer name is not correct (not found in the diagram description of this diagram)"; private static final String FILTER_NAME_INCORRECT = "The filter name is not correct"; diff --git a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/experimental/sync/DEdgeSynchronizerHelper.java b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/experimental/sync/DEdgeSynchronizerHelper.java index 23201b2c83..d838d2e147 100644 --- a/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/experimental/sync/DEdgeSynchronizerHelper.java +++ b/plugins/org.eclipse.sirius/src/org/eclipse/sirius/business/internal/experimental/sync/DEdgeSynchronizerHelper.java @@ -137,16 +137,37 @@ public class DEdgeSynchronizerHelper extends AbstractSynchronizerHelper { private void handlePreviousCandidates(final Collection<DEdgeCandidate> result, final Iterable<DDiagramElement> previousDiagramElements, final EdgeMapping mapping, final Map<EObject, Collection<EdgeTarget>> sourceViewsSemantics, final Map<EObject, Collection<EdgeTarget>> targetViewsSemantics) { + final EdgeMappingQuery edgeMappingQuery = new EdgeMappingQuery(mapping); + Predicate<DEdge> stillCandidate = new Predicate<DEdge>() { public boolean apply(DEdge input) { + // Validate source node (and its semantic target) exists in the + // sourceViewsSemantics boolean stillCandidate = validateNode(input.getSourceNode(), sourceViewsSemantics); + // Validate target node (and its semantic target) exists in the + // targetViewsSemantics stillCandidate = stillCandidate && validateNode(input.getTargetNode(), targetViewsSemantics); + if (stillCandidate) { + EObject target = input.getTarget(); + if (mapping.isUseDomainElement()) { + // Validate that semantic source is always in the list + // returns by the source finder expression for this + // edge. This is necessary only for edge that use domain + // element as target. + Collection<EObject> edgeSourceSemantics = edgeMappingQuery.evaluateSourceFinderExpression(diagram, interpreter, target); + stillCandidate = edgeSourceSemantics.contains(((DSemanticDecorator) input.getSourceNode()).getTarget()); + } + if (stillCandidate) { + // Validate that semantic target is always in the list + // returns by the target finder expression for this edge + Collection<EObject> edgeTargetSemantics = edgeMappingQuery.evaluateTargetFinderExpression(diagram, interpreter, target); + stillCandidate = edgeTargetSemantics.contains(((DSemanticDecorator) input.getTargetNode()).getTarget()); + } + } return stillCandidate; } }; - EdgeMappingQuery edgeMappingQuery = new EdgeMappingQuery(mapping); - for (DEdge prevDEdge : Iterables.filter(Iterables.filter(previousDiagramElements, DEdge.class), stillCandidate)) { final EdgeTarget sourceView = prevDEdge.getSourceNode(); final EdgeTarget targetView = prevDEdge.getTargetNode(); @@ -169,29 +190,9 @@ public class DEdgeSynchronizerHelper extends AbstractSynchronizerHelper { private void handleCandidatesFromSemanticTargets(Collection<DEdgeCandidate> result, EObject target, EdgeMapping mapping, Map<EObject, Collection<EdgeTarget>> sourceViewsSemantics, Map<EObject, Collection<EdgeTarget>> targetViewsSemantics) { - Collection<EObject> edgeSourceSemantics = new ArrayList<EObject>(); - Collection<EObject> edgeTargetSemantics = new ArrayList<EObject>(); - - interpreter.setVariable(IInterpreterSiriusVariables.VIEWPOINT_2, diagram); - interpreter.setVariable(IInterpreterSiriusVariables.VIEWPOINT, diagram); - interpreter.setVariable(IInterpreterSiriusVariables.DIAGRAM, diagram); - - try { - edgeSourceSemantics = interpreter.evaluateCollection(target, mapping.getSourceFinderExpression()); - } catch (final EvaluationException e) { - RuntimeLoggerManager.INSTANCE.error(mapping, DescriptionPackage.eINSTANCE.getEdgeMapping_SourceFinderExpression(), e); - } - try { - edgeTargetSemantics = interpreter.evaluateCollection(target, mapping.getTargetFinderExpression()); - } catch (final EvaluationException e) { - RuntimeLoggerManager.INSTANCE.error(mapping, DescriptionPackage.eINSTANCE.getEdgeMapping_TargetFinderExpression(), e); - } - - interpreter.unSetVariable(IInterpreterSiriusVariables.DIAGRAM); - interpreter.unSetVariable(IInterpreterSiriusVariables.VIEWPOINT); - interpreter.unSetVariable(IInterpreterSiriusVariables.VIEWPOINT_2); - EdgeMappingQuery edgeMappingQuery = new EdgeMappingQuery(mapping); + Collection<EObject> edgeSourceSemantics = edgeMappingQuery.evaluateSourceFinderExpression(diagram, interpreter, target); + Collection<EObject> edgeTargetSemantics = edgeMappingQuery.evaluateTargetFinderExpression(diagram, interpreter, target); for (final EObjectCouple couple : new CartesianProduct(edgeSourceSemantics, edgeTargetSemantics)) { final Collection<EdgeTarget> sourceViews = sourceViewsSemantics.get(couple.getObj1()); |
