Skip to content

Commit

Permalink
Small improvement to last commit c1adb7b : set completable to false t…
Browse files Browse the repository at this point in the history
…o indicate correct state
  • Loading branch information
jbarrez committed Aug 30, 2024
1 parent 7e509d4 commit 5262bef
Showing 1 changed file with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5262bef

Please sign in to comment.