如何在活动中修改多实例上的集合 [英] How to modify collection on multi-instance in activiti

查看:118
本文介绍了如何在活动中修改多实例上的集合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在为一个项目创建POC,我们将有4个审批阶段.假设四个阶段是

We are creating POC for a project where we will have 4 stages of approval. Let's say the 4 stages are

  1. 会计

经理

所有者

送货头

一个过程已经开始,现在用户任务(即批准)处于会计级别.多实例将循环从Java Service类返回的集合中.当循环针对该特定用户集运行时,我想在其中推送一个新用户.我可以在经理,所有者和交货负责人的集合中添加更多用户,因为批准阶段处于会计级别,并且尚未执行这些批准者的集合调用.

A process has started and right now the user task i.e. approval is at the Accountant level. The multi-instance will loop in a collection returned from Java Service class. While the loop is running for that particular set of users, I want to push a new user in it. I'm able to add more users in the collections of manager, owner and Delivery Head because the approval stage is on Accountant Level and the collection call for those approvers is not performed yet.

我的流程XML:

<startEvent id="startEvent1"></startEvent>
    <userTask id="accountantApproval" name="Accountant Approval" activiti:assignee="${accountant}">
      <extensionElements>
        <activiti:formProperty id="accountantApprovalValue" name="Accountant Approval Value" type="enum" required="true"></activiti:formProperty>
        <modeler:initiator-can-complete xmlns:modeler="http://activiti.com/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
      </extensionElements>
      <multiInstanceLoopCharacteristics isSequential="true" activiti:collection="${myService.fetchEmployeesByRole('Accountant')}" activiti:elementVariable="accountant">
        <completionCondition>${status != 'Submit'}</completionCondition>
      </multiInstanceLoopCharacteristics>
    </userTask>
    <userTask id="managerApproval" name="Manager Approval" activiti:assignee="${manager}">
      <extensionElements>
        <modeler:initiator-can-complete xmlns:modeler="http://activiti.com/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
      </extensionElements>
      <multiInstanceLoopCharacteristics isSequential="true" activiti:collection="${myService.fetchEmployeesByRole('Manager')}" activiti:elementVariable="manager">
        <completionCondition>${status != 'Submit'}</completionCondition>
      </multiInstanceLoopCharacteristics>
    </userTask>
    <exclusiveGateway id="accountantEXOR" name="Accountant EXOR"></exclusiveGateway>
    <serviceTask id="accountantRejectService" name="Accountant Reject Service" activiti:class="com.example.demo.RejectService"></serviceTask>
    <exclusiveGateway id="managerEXOR" name="Manager EXOR"></exclusiveGateway>
    <serviceTask id="managerRejectService" name="Manager Reject Service" activiti:class="com.example.demo.RejectService"></serviceTask>
    <endEvent id="endProcess" name="End Process">
      <terminateEventDefinition></terminateEventDefinition>
    </endEvent>
    <userTask id="OwnerApproval" name="Owner Approval" activiti:assignee="${accountant}">
      <extensionElements>
        <activiti:formProperty id="sid-52D1F400-4813-4B2F-856D-61FE4C41C6FEValue" name="Accountant Approval Value" type="enum" required="true"></activiti:formProperty>
        <modeler:initiator-can-complete xmlns:modeler="http://activiti.com/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
      </extensionElements>
      <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="${myService.fetchEmployeesByRole('Owner')}" activiti:elementVariable="owner">
        <completionCondition>${status == 'Submit'}</completionCondition>
      </multiInstanceLoopCharacteristics>
    </userTask>

现在,假设某个过程已经开始并且处于会计级别.多实例将从服务类中获取雇员并将其推送到集合中,然后它将开始遍历它.假设它获取了2位员工David&山姆David批准了该任务,该任务继续进行下一个批准,即Sam.Sam希望在循环中添加另一位会计师.

Now, Suppose if a process has started and it is at the Accountant Level. The multi-instance will fetch the employees from the service class and push it in the collection and it will start looping through it. Let's say it fetches 2 employees David & Sam. David approves the task and it moves on to the next approval i.e. Sam. Sam wants to add another accountant in the loop.

是否有一种方法可以在当前的运行循环集合(即Accountant集合)中添加新用户?如果是,请提出一种方法,最好使用Java.

Is there a way to add new users in the current running loop collection i.e. of Accountant collection? If yes, Please suggest a way, preferably using Java.

如果我们不能在集合中添加用户,是否有办法创建新的用户任务并将其分配给正在进行的流程?因此,一旦会计循环完成,在进入下一个批准阶段之前,它应该完成新创建的用户任务.

If we can not add a user in the collection, is there a way we can create a new user task and assign it to the ongoing process? So once the accountant loop is finished, before it moves on to the next approval stage, it should finish the newly created user task.

推荐答案

您可以在多实例使用任务/子流程上使用边界信号事件,这将取消所有当前正在运行的任务并为该任务创建新任务.更新的收藏集.

You can use a boundary signal event on your multi-instance use task/sub-process, which will cancel all the currently running tasks and create new tasks for the updated collection.

下面的图表可能有帮助

注意:使用 runtimeService.signalEventReceived("yourSignalId","yourProcessInstanceID");

这篇关于如何在活动中修改多实例上的集合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆