Repeat Task/Stage without entry criteria upon completion of previous instance
This proposal extends the proposal CR-130 to allow repetition of Tasks or Stages without entry criteria. In this case, the evaluation of the repetition rule and creation of new instances happens, when the previous instance completes or terminates.
In a nutshell this scenario works like a do while loop in programming languages. Or speaking in terms of CMMN, one could think of it as an implicit onPart pointing to itself, which is ignored for the first instance.
All the relevant paragraphs in the specification
Section 5.4.11 PlanItemControl, Figure 5.12 - PlanItemControl attributes and associations, cell (2,4), page 41 (PDF 55)
Third paragraph can be deleted completely, as the alternative semantics do work for DiscretionaryItems:
A PlanItemControl that is the itemControl of a DiscretionaryItem, MUST NOT contain a RepetitionRule. (This is because the concept of “repetition” depends on the semantics of Sentries (see 5.4.11.3), and DiscretionaryItems are not associated with Sentries.)
Fifth paragraph:
A PlanItem that has a PlanItemControl that contains a RepetitionRule, MUST have either an entry criterion that refers to a Sentry that has at least one OnPart or no entry criteria at all. (This is because the concept of “repetition” depends on the semantics of Sentries with onParts (see 5.4.11.3)).
Section 5.4.11.3 RepetitionRule, page 42 (PDF 56)
The trigger for the repetition is a Sentry, that is referenced as entry criterion, being satisfied, whereby an OnPart of that Sentry occurs.
New text after first paragraph:
Alternatively, a RepetitionRule MAY be used on a Task or Stage that does not have any entry criteria. In that case, the RepetitionRule is evaluated when an instance of the Task or Stage completes or terminates. If it evaluates to "true", a new instance will be created.
Section 7.4.2 Stage and Task Lifecycle, Table 7.8 - Stage and Task instance transitions, transition complete, cell (4, 9), page 73 (PDF 87)
New text at the end:
If the Task or Stage has a RepetitionRule but no entry criteria, the RepetitionRule Boolean expression MUST be re-evaluated in this transition and if the expression evaluates to “true”, a new instance is created.
Section 7.4.2 Stage and Task Lifecycle, Table 7.8 - Stage and Task instance transitions, transition terminate, cell (4, 10), page 73 (PDF 87)
New text at the end:
If the Task or Stage has a RepetitionRule but no entry criteria, the RepetitionRule Boolean expression MUST be re-evaluated in this transition and if the expression evaluates to “true”, a new instance is created.
Section 7.6.4 RepetitionRule, page 79 (PDF 93)
text of CMMN 1.0:
This rule MUST be evaluated when the Milestone, Stage, or Task instance is instantiated and transitions to the Available state, and their Boolean value SHOULD be maintained for the rest of the life of the Milestone, Stage, or Task instance.
Stage and Task instances with a RepetitionRule evaluating to “true” will create an instance every time an entry criterion with an onPart is satisfied. Under that condition a new instance is created and because the entry criteria is satisfied it moves from the Available state to either Active or Enabled state depending on the ManualActivationRule .
revised text of CR-130:
This rule MUST be evaluated when the Milestone, Stage, or Task instance is instantiated and transitions to the Available state. The first time, a Milestone, Stage, or Task instance is instantiated and transitions to the Available state, it is not considered a repetition, nevertheless the RepetitionRule MUST be evaluated and its result discarded.
Stage and Task instances with a RepetitionRule, will try to create a new instance every time an entry criterion with an onPart is satisfied. Under that condition the RepetitionRule is re-evaluated and if the Expression evaluates to “true,” then the new instance is created and because the entry criteria is satisfied it moves from the Available state to either Active or Enabled state depending on the ManualActivationRule.
New text after second paragraph:
Stage and Task instances with a RepetitionRule that do not have any entry criteria, will try to create a new instance every time an instance transitions into the Complete or Terminate state. Under that condition the RepetitionRule is re-evaluated and if the Expression evaluates to “true,” a new instance is created.