Manually complete a Stage in CMMN with autoComplete=false

Hello,

i’m new to CMMN and i have written a GUI Application like in this underwriting-example. There it is really simple to get the active and enabled tasks with:

List caseExceutions = engine.getCaseService()
.createCaseExecutionQuery()
.caseInstanceId(this.caseInstance.getId())
.list();

Then they used CaseExecution Object to check it:

for (CaseExecution caseExecution : caseExecutions) {
if (caseExcecution.isActive()) {
activeCaseExecutions.add(caseExecution);
} else if (caseExcecution.isEnabled()) {
this.enabledCaseExecutions.add(caseExecution);
}
}

Let’s say i have a more complex case instance with two Stages named “s1” and “s2” with a set of tasks. I would like to give the responsibility to the user to complete a stage ( manually with a button), once it is possible. This button should only be rendered, if it is possible. I know from the above code, that a stage would be in this list as a CaseExecution object with type “stage” / “casePlanModel”

  1. How do i check if a stage can be completed? Is it possible from an CaseExecution-Object or in another handy way?
    The OMG specification says, that a stage can be completed if: There are no Active children, AND all required (requiredRule evaluates to “true”) children are in {Disabled, Completed, Terminated, Failed}_
    Do i have to iterate through all children elements of the stage and check their status? If so, how can i do it? Or do you have a better approach?

  2. If we assume the stage is completable: How do complete the stage? Do i have to disable tasks manually before or can i complete a stage in a cascading way?

I’m in my Master Thesis and there i have a much more complex CMMN Case. So this would be really important for me.

Thanks a lot for your help =)