Stage with repetition, expected behavior of tasks and sentries

Hello,

I am trying to implement the following case, in the context of a simple “restaurant” example:

  • the user can notify that “a customer has arrived” (this user event has repetition enabled, without any rule)
  • when the event occurs, my only stage in the case is enabled; it also has repetition enabled
  • in the stage, there are “Take order” and a “Prepare food” human tasks; I have a sentry on “Prepare food”, to enforce a sequence between the tasks

I expected, using the flowable ui, to be able to click several times on the “A customer has arrived button” and to see a “Take order” task appear in my list every time. That works. I expected that when clicking on completing ONE of the “Take order” task, then ONLY ONE of the “Prepare food” tasks would be activated. This is not the case: as soon as I complete one task, ALL of the “Prepare food” tasks are enabled and appear in my inbox.

Is this the expected behavior?

If yes, what is the proper way to model my case? I am playing the idea of using a “Case Task” instead of a stage, but that would make the modeling/diagrams cumbersome.

<?xml version="1.0" encoding="UTF-8"?> occur complete

Hey @wasadigi,

Which version of Flowable are you using? What you are explaining sounds like something we have seen before and perhaps fixed alread.

Cheers,
Filip

Can you also share your CMMN XML so we can give it a go?

Hi Philip,

Thank you for your answer. I am on 6.7.0 and this morning, I also tried with the Flowable Trial and observed the same behavior. The CMMN was in the original post, but I try once again.
Cheers,

Olivier

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/CMMN/20151109/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:flowable="http://flowable.org/cmmn" xmlns:cmmndi="http://www.omg.org/spec/CMMN/20151109/CMMNDI" xmlns:dc="http://www.omg.org/spec/CMMN/20151109/DC" xmlns:di="http://www.omg.org/spec/CMMN/20151109/DI" targetNamespace="http://www.flowable.org/casedef" exporter="Flowable Open Source Modeler" exporterVersion="6.7.1-SNAPSHOT">
  <case id="case-model-restaurant" name="Restaurant" flowable:initiatorVariableName="initiator">
    <casePlanModel id="casePlanModel" flowable:formFieldValidation="true">
      <planItem id="planItem1" name="A customer has arrived!" definitionRef="sid-3B29854D-F9E4-4DB2-B357-4365A128EE66">
        <itemControl>
          <repetitionRule flowable:counterVariable="repetitionCounter">
            <extensionElements></extensionElements>
          </repetitionRule>
        </itemControl>
      </planItem>
      <planItem id="planItem4" definitionRef="sid-EF55FEDC-125A-4F86-A2D1-9A25EC59294D">
        <itemControl>
          <repetitionRule flowable:counterVariable="repetitionCounter">
            <extensionElements></extensionElements>
          </repetitionRule>
        </itemControl>
        <entryCriterion id="sid-B666F567-1548-4EE7-85C4-F64B501209BE" sentryRef="sentry2"></entryCriterion>
      </planItem>
      <sentry id="sentry2">
        <planItemOnPart id="sentryOnPart2" sourceRef="planItem1">
          <standardEvent>occur</standardEvent>
        </planItemOnPart>
      </sentry>
      <userEventListener id="sid-3B29854D-F9E4-4DB2-B357-4365A128EE66" name="A customer has arrived!"></userEventListener>
      <stage id="sid-EF55FEDC-125A-4F86-A2D1-9A25EC59294D">
        <planItem id="planItem2" name="Take order" definitionRef="sid-36A243E6-892B-407A-A30F-8E5308173B9D"></planItem>
        <planItem id="planItem3" name="Prepare food" definitionRef="sid-6CD631BF-577A-4455-A8B2-751AC0DCEA04">
          <entryCriterion id="sid-ABFECFBB-38D6-4496-8185-D4BE8D89C6DA" sentryRef="sentry1"></entryCriterion>
        </planItem>
        <sentry id="sentry1">
          <planItemOnPart id="sentryOnPart1" sourceRef="planItem2">
            <standardEvent>complete</standardEvent>
          </planItemOnPart>
        </sentry>
        <humanTask id="sid-36A243E6-892B-407A-A30F-8E5308173B9D" name="Take order" flowable:assignee="${initiator}" flowable:formFieldValidation="true">
          <extensionElements>
            <modeler:flowable-idm-initiator xmlns:modeler="http://flowable.org/modeler"><![CDATA[true]]></modeler:flowable-idm-initiator>
          </extensionElements>
        </humanTask>
        <humanTask id="sid-6CD631BF-577A-4455-A8B2-751AC0DCEA04" name="Prepare food" flowable:assignee="${initiator}" flowable:formFieldValidation="true">
          <extensionElements>
            <modeler:flowable-idm-initiator xmlns:modeler="http://flowable.org/modeler"><![CDATA[true]]></modeler:flowable-idm-initiator>
          </extensionElements>
        </humanTask>
      </stage>
    </casePlanModel>
  </case>
  <cmmndi:CMMNDI>
    <cmmndi:CMMNDiagram id="CMMNDiagram_case-model-restaurant">
      <cmmndi:CMMNShape id="CMMNShape_casePlanModel" cmmnElementRef="casePlanModel">
        <dc:Bounds height="714.0" width="718.0" x="270.0" y="45.0"></dc:Bounds>
        <cmmndi:CMMNLabel></cmmndi:CMMNLabel>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNShape id="CMMNShape_planItem1" cmmnElementRef="planItem1">
        <dc:Bounds height="30.501000000000005" width="30.49800000000002" x="330.0" y="228.25083215268486"></dc:Bounds>
        <cmmndi:CMMNLabel></cmmndi:CMMNLabel>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNShape id="CMMNShape_planItem4" cmmnElementRef="planItem4">
        <dc:Bounds height="216.0" width="349.0" x="480.0" y="146.0"></dc:Bounds>
        <cmmndi:CMMNLabel></cmmndi:CMMNLabel>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNShape id="CMMNShape_sid-B666F567-1548-4EE7-85C4-F64B501209BE" cmmnElementRef="sid-B666F567-1548-4EE7-85C4-F64B501209BE">
        <dc:Bounds height="22.0" width="14.0" x="472.6250775354628" y="232.50133215268485"></dc:Bounds>
        <cmmndi:CMMNLabel></cmmndi:CMMNLabel>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNShape id="CMMNShape_planItem2" cmmnElementRef="planItem2">
        <dc:Bounds height="80.0" width="100.0" x="525.0" y="205.7658275981052"></dc:Bounds>
        <cmmndi:CMMNLabel></cmmndi:CMMNLabel>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNShape id="CMMNShape_planItem3" cmmnElementRef="planItem3">
        <dc:Bounds height="80.0" width="100.0" x="690.0" y="205.7658275981052"></dc:Bounds>
        <cmmndi:CMMNLabel></cmmndi:CMMNLabel>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNShape id="CMMNShape_sid-ABFECFBB-38D6-4496-8185-D4BE8D89C6DA" cmmnElementRef="sid-ABFECFBB-38D6-4496-8185-D4BE8D89C6DA">
        <dc:Bounds height="22.0" width="14.0" x="682.5261985715337" y="235.03754188116878"></dc:Bounds>
        <cmmndi:CMMNLabel></cmmndi:CMMNLabel>
      </cmmndi:CMMNShape>
      <cmmndi:CMMNEdge id="CMMNEdge_sid-FAF2A7E3-1737-4260-B9F3-307157890CCA" cmmnElementRef="planItem1" targetCMMNElementRef="sid-B666F567-1548-4EE7-85C4-F64B501209BE">
        <di:extension>
          <flowable:docker type="source" x="15.497999999999994" y="15.501000000000001"></flowable:docker>
          <flowable:docker type="target" x="7.0" y="11.0"></flowable:docker>
        </di:extension>
        <di:waypoint x="360.94597360669223" y="243.7228876439516"></di:waypoint>
        <di:waypoint x="472.6333871104945" y="243.51429682572282"></di:waypoint>
        <cmmndi:CMMNLabel></cmmndi:CMMNLabel>
      </cmmndi:CMMNEdge>
      <cmmndi:CMMNEdge id="CMMNEdge_sid-5D1D01D0-814B-459D-9AAE-8E99D3976BEC" cmmnElementRef="planItem2" targetCMMNElementRef="sid-ABFECFBB-38D6-4496-8185-D4BE8D89C6DA">
        <di:extension>
          <flowable:docker type="source" x="50.0" y="40.0"></flowable:docker>
          <flowable:docker type="target" x="7.0" y="11.0"></flowable:docker>
        </di:extension>
        <di:waypoint x="624.9499999999688" y="245.8843343555834"></di:waypoint>
        <di:waypoint x="682.5261985715337" y="246.02095936348198"></di:waypoint>
        <cmmndi:CMMNLabel></cmmndi:CMMNLabel>
      </cmmndi:CMMNEdge>
    </cmmndi:CMMNDiagram>
  </cmmndi:CMMNDI>
</definitions>

I was able to implement my use case, by using a “Process Task” instead of a stage. However, as stated in my first post, one drawback of this solution is that I HAVE TO split the model in several parts (one diagram for the high-level view with references to repeated elements, another diagram for each repeated element).

I am trying to understand 1) if the CMMN 1.1 is complete and with regards to sentries WITHIN repeated stages and 2) if that is the case, if Flowable supports it.

Any idea?

After a debugging session, I am under the impression that the CMMN engine evaluates the sentry “onPart” using the planItem, and not the planItemInstance. In other words, the transition occurs as soon as ONE of the planItemInstances (one of the “task A” instances) completes. I did not find anything that makes it clear what the CMMN specification expects, so this might be a blank spot? I did not find anything in the flowable docs either.

I have a solution that seems to work, but I would be very keen to get your feedback on whether I am doing completely wrong or sub-optimal here.

What I did was remove the onPart on my Sentry (because it is essentially useless if I repeat the enclosing stage). But I have added an ifPart, with the following expression:

${planItemInstances.currentStage().definitionId('task_do_this').completed().count()==1}

In other words, to enable task_do_that, I wait until task_do_this IN THE SAME STAGE has completed.

I find it strange that I cannot use stages to reason about scopes, but it is what I think is happening here… Am I missing anything? If my solution is acceptable, then it makes the diagram not so easy to read (of course, I could keep the onPart so have a visual line between do_this and do_that, but…).

@filiphr if you have the time to have a look at my proposed workaround / solution and give some feedback, that would be great :slight_smile: