Skip to content

Commit

Permalink
refinement of live validation in the ReconnectEdgeOperation
Browse files Browse the repository at this point in the history
Issue #346
  • Loading branch information
rsoika committed Jun 17, 2024
1 parent f1d96f3 commit 7bbafce
Showing 1 changed file with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ public Optional<Command> createCommand(ReconnectEdgeOperation operation) {
return commandOf(() -> executeOperation(operation));
}

/**
* This helper method re-validates the affected elements
*
* @param operation
*/
private void executeOperation(final ReconnectEdgeOperation operation) {

String edgeID = operation.getEdgeElementId();
Expand All @@ -59,6 +64,16 @@ private void executeOperation(final ReconnectEdgeOperation operation) {

BPMNElementEdge bpmnElementEdge = modelState.getBpmnModel().findElementEdgeById(edgeID);

// We need to identify the old element that lost its connection....
String oldSourceElementID = bpmnElementEdge.getSourceRef();
String oldTargetElementID = bpmnElementEdge.getTargetRef();
BPMNElementNode oldElement = null;
if (sourceElementID.equals(oldSourceElementID)) {
oldElement = modelState.getBpmnModel().findElementNodeById(oldTargetElementID);
} else {
oldElement = modelState.getBpmnModel().findElementNodeById(oldSourceElementID);
}

BPMNElementNode targetElement = modelState.getBpmnModel().findElementNodeById(targetElementID);
BPMNElementNode sourceElement = modelState.getBpmnModel().findElementNodeById(sourceElementID);

Expand All @@ -82,6 +97,10 @@ private void executeOperation(final ReconnectEdgeOperation operation) {
bpmnElementEdge.setSourceRef(sourceElementID);
bpmnElementEdge.setTargetRef(targetElementID);

// invalidate old oldElement
if (oldElement != null) {
oldElement.resetValidation();
}
// invalidate source/target
sourceElement.resetValidation();
targetElement.resetValidation();
Expand Down

0 comments on commit 7bbafce

Please sign in to comment.