AnsweredAssumed Answered

Adding item to sub process loop

Question asked by kccoyote on Aug 19, 2013
Latest reply on Sep 2, 2013 by trademak
I have a (working) process where a query gets executed as a service task, and the results get stored in a database.
The next task is modelled as a subprocess for each of these items (populated with a function defined in a  multiInstanceLoopCharacteristics).

Once all of these items' subprocesses are handled (or aborted), the main process continues.

Now a new requirement came up that the query must be able to run again at any time (as long as the main process hasn't continued, that is). If any new items get returned, they each should get an instance of the sub process as well (as if they were originally part of the collection in the multiInstanceLoopCharacteristics).

Is this possible?

It doesn't really matter if it can't be modelled in bpmn: if I can add an item programmatically to the sub process, that's fine as well.

Excerpt:


    <signal id="endHandleItemsSignal" name="endHandleItemsSignal" />

    <process id="processId">

        <startEvent id="startProcess" name="starts the porcess"/>

        <sequenceFlow sourceRef="startProcess" targetRef="executyQuery"/>

        <serviceTask id="executyQuery" name="executes the query"
                     activiti:expression="#{springBean.executeQuery(instance_id)}"
                     activiti:async="${activiti.execution.async}"/>

        <sequenceFlow sourceRef="executyQuery" targetRef="handleItems"/>

        <subProcess id="handleItems">
            <multiInstanceLoopCharacteristics isSequential="false"
                                              activiti:collection="${springBean.getSubprocessItems(instance_id)}"
                                              activiti:elementVariable="item_id">
            </multiInstanceLoopCharacteristics>

            <startEvent id="startHandleItems" />
            …
            <endEvent id="endHandlePatient" />
        </subProcess>

        <boundaryEvent id="boundary" attachedToRef="handleItems" cancelActivity="true">
            <signalEventDefinition signalRef="endHandleItemsSignal"/>
        </boundaryEvent>

        <sequenceFlow sourceRef="boundary" targetRef="endProcess"/>

        <sequenceFlow sourceRef="handleItems" targetRef="endProcess"/>

        <endEvent id="end"/>
    </process>

Outcomes