From 5262befd57822394aa78a8fd7f09f80ecf488bfd Mon Sep 17 00:00:00 2001 From: Joram Barrez Date: Fri, 30 Aug 2024 15:03:49 +0200 Subject: [PATCH] Small improvement to last commit c1adb7bf82ea2dba6488edd0e3c66b2edbd4b150 : set completable to false to indicate correct state --- .../AbstractEvaluationCriteriaOperation.java | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/AbstractEvaluationCriteriaOperation.java b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/AbstractEvaluationCriteriaOperation.java index 7f8f4e4dcb7..41856e008fe 100644 --- a/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/AbstractEvaluationCriteriaOperation.java +++ b/modules/flowable-cmmn-engine/src/main/java/org/flowable/cmmn/engine/impl/agenda/operation/AbstractEvaluationCriteriaOperation.java @@ -145,18 +145,24 @@ public boolean evaluateForCompletion(PlanItemInstanceEntity planItemInstanceEnti } else if (planItem.getPlanItemDefinition() instanceof Stage) { - if (PlanItemInstanceState.ACTIVE.equals(state) && !planItemInstanceEntity.isStateChangeUnprocessed()) { - boolean criteriaChangeOrActiveChildrenForStage = evaluatePlanItemsCriteria(planItemInstanceEntity, null); - if (criteriaChangeOrActiveChildrenForStage) { - evaluationResult.markCriteriaChanged(); - planItemInstanceEntity.setCompletable(false); // an active child = stage cannot be completed anymore - } else { - Stage stage = (Stage) planItem.getPlanItemDefinition(); - if (isStageCompletable(planItemInstanceEntity, stage)) { + if (PlanItemInstanceState.ACTIVE.equals(state)) { + + if (!planItemInstanceEntity.isStateChangeUnprocessed()) { // when the stage plan item instance state is not stable yet, don't evaluate yet + boolean criteriaChangeOrActiveChildrenForStage = evaluatePlanItemsCriteria(planItemInstanceEntity, null); + if (criteriaChangeOrActiveChildrenForStage) { evaluationResult.markCriteriaChanged(); - CommandContextUtil.getAgenda(commandContext).planCompletePlanItemInstanceOperation(planItemInstanceEntity); + planItemInstanceEntity.setCompletable(false); // an active child = stage cannot be completed anymore + } else { + Stage stage = (Stage) planItem.getPlanItemDefinition(); + if (isStageCompletable(planItemInstanceEntity, stage)) { + evaluationResult.markCriteriaChanged(); + CommandContextUtil.getAgenda(commandContext).planCompletePlanItemInstanceOperation(planItemInstanceEntity); + } } + } else { + planItemInstanceEntity.setCompletable(false); } + } } else if (PlanItemInstanceState.ACTIVE.equals(state)) { // check, if the plan item can be ignored for further processing and if so, immediately return