Parallel execution and task assignment

Hello,

I want to assign tasks to a list of users. They can work in parallel to review their tasks. My requirement is that when one of the assignees requests more information, a task should be assigned to the requester, and others can continue reviewing their tasks. When the requester provides more information, the task should be assigned back to the assignee. The task should be closed when all the reviewers are done.

In the current XML model, the task is assigned to the requester only when all the reviews are completed.

Script Task 1:
import java.util.stream.Collectors
import java.util.stream.Stream
org.slf4j.LoggerFactory.getLogger(“theScriptTask”).info(“executing Script Task 1”)
Map<String, Object> variableMap = new HashMap<>();
/* Get List of users by a role/group*/
variableMap.put(“usersList”, Stream.of(“admin”,“Qa_admin”).collect(Collectors.toList()));
variableMap.put(“taskCompletedList”, new ArrayList<>());
variableMap.put(“requestedMoreInfoUserList”, new ArrayList<>());
execution.setVariables(variableMap);

Admin Approval Task:

<?xml version="1.0" encoding="UTF-8"?>
<documentation>Workflow to request access to data asset</documentation>
<dataObject id="form_type" name="formType" itemSubjectRef="xsd:string">
  <extensionElements>
    <flowable:value>DATA_ASSET</flowable:value>
  </extensionElements>
</dataObject>
<dataObject id="not_enough_info" name="notEnoughInfo" itemSubjectRef="xsd:boolean">
  <extensionElements>
    <flowable:value>false</flowable:value>
  </extensionElements>
</dataObject>
<dataObject id="approved" name="approved" itemSubjectRef="xsd:string">
  <extensionElements>
    <flowable:value></flowable:value>
  </extensionElements>
</dataObject>
<dataObject id="isTaskReassigned" name="isTaskReassigned" itemSubjectRef="xsd:boolean">
  <extensionElements>
    <flowable:value>false</flowable:value>
  </extensionElements>
</dataObject>
<serviceTask id="approveDataAssetAccess" name="Extract Request Info" flowable:class="com.ch.com.ch.delegate.DataAssetAccessDelegate"></serviceTask>
<serviceTask id="rejectDataAssetAccess" name="Extract Request Info" flowable:class="com.ch.com.ch.delegate.DataAssetAccessDelegate"></serviceTask>
<userTask id="sid-46AD6217-FC9E-4FEE-8253-29DBFA47E290" name="Provide additional details" flowable:assignee="${userName}" flowable:category="REQUEST_INFORMATION" flowable:formFieldValidation="true">
  <extensionElements>
    <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
  </extensionElements>
</userTask>
<startEvent id="startEvent" name="start" flowable:formFieldValidation="true"></startEvent>
<exclusiveGateway id="decision" name="Decision"></exclusiveGateway>
<endEvent id="end" name="End"></endEvent>
<serviceTask id="sid-08AFD283-415E-4B5A-81D5-18244B53BF85" name="Approval Notification" flowable:class="com.ch.com.ch.delegate.EmailDelegate">
  <extensionElements>
    <flowable:field name="subject">
      <flowable:string><![CDATA[Notification of Data Asset Access Request Approval]]></flowable:string>
    </flowable:field>
    <flowable:field name="templateName">
      <flowable:string><![CDATA[DataAssetAccessApproval]]></flowable:string>
    </flowable:field>
  </extensionElements>
</serviceTask>
<serviceTask id="sid-F1E626DC-59F3-4CC9-8B09-35A6BB2DEE2A" name="Rejection Notification" flowable:class="com.ch.com.ch.delegate.EmailDelegate">
  <extensionElements>
    <flowable:field name="templateName">
      <flowable:string><![CDATA[DataAssetAccessRejection]]></flowable:string>
    </flowable:field>
    <flowable:field name="subject">
      <flowable:string><![CDATA[Notification of Data Asset Access Request Rejection]]></flowable:string>
    </flowable:field>
  </extensionElements>
</serviceTask>
<sequenceFlow id="sid-5A899B1E-9FB9-4ADF-9726-EBA0C8CB052D" sourceRef="approveDataAssetAccess" targetRef="sid-08AFD283-415E-4B5A-81D5-18244B53BF85"></sequenceFlow>
<sequenceFlow id="sid-1BE0FB0C-FDFB-4C29-BCE4-1E745791AC32" sourceRef="rejectDataAssetAccess" targetRef="sid-F1E626DC-59F3-4CC9-8B09-35A6BB2DEE2A"></sequenceFlow>
<serviceTask id="sid-D4787330-4255-435E-9075-BAAC376C84B1" name="Notify Manager" flowable:class="com.ch.com.ch.delegate.EmailDelegate">
  <extensionElements>
    <flowable:field name="subject">
      <flowable:string><![CDATA[Notification of Data Asset Access Request]]></flowable:string>
    </flowable:field>
    <flowable:field name="templateExpression">
      <flowable:string><![CDATA[getEmailTemplate]]></flowable:string>
    </flowable:field>
    <flowable:field name="recipientKey">
      <flowable:string><![CDATA[managerEmail]]></flowable:string>
    </flowable:field>
  </extensionElements>
</serviceTask>
<sequenceFlow id="sid-49C66BB7-E225-4AD9-9FDF-3E0FC1AC6041" sourceRef="startEvent" targetRef="sid-D4787330-4255-435E-9075-BAAC376C84B1"></sequenceFlow>
<serviceTask id="sid-218CDE90-0064-4D48-963B-526ACF7EAA70" name="Process Completion" flowable:class="com.ch.com.ch.delegate.ProcessCompletionDelegate"></serviceTask>
<sequenceFlow id="sid-C3849165-E2AF-48C8-A286-6228DE1737C4" sourceRef="sid-08AFD283-415E-4B5A-81D5-18244B53BF85" targetRef="sid-218CDE90-0064-4D48-963B-526ACF7EAA70"></sequenceFlow>
<sequenceFlow id="sid-26E99A99-E38A-4B88-9D13-7C7F7A4CE62A" sourceRef="sid-F1E626DC-59F3-4CC9-8B09-35A6BB2DEE2A" targetRef="sid-218CDE90-0064-4D48-963B-526ACF7EAA70"></sequenceFlow>
<sequenceFlow id="sid-8EB036A5-74EF-4C2B-B4B6-BB027C4C95D6" sourceRef="sid-218CDE90-0064-4D48-963B-526ACF7EAA70" targetRef="end"></sequenceFlow>
<sequenceFlow id="sid-B436FF1A-8268-40C8-A638-F278A1719436" sourceRef="sid-46AD6217-FC9E-4FEE-8253-29DBFA47E290" targetRef="sid-0D413747-D083-4737-9E09-0A1B63905CBD">
  <conditionExpression xsi:type="tFormalExpression"><![CDATA[${!isTaskReassigned}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="sid-CC088ACB-9A02-47C6-A1EC-DE3D1E4C86CB" sourceRef="sid-D4787330-4255-435E-9075-BAAC376C84B1" targetRef="sid-A16289AB-FECF-4310-B224-79425D492B26"></sequenceFlow>
<userTask id="adminApproval" name="Admin Approval" flowable:assignee="${element}" flowable:formFieldValidation="true">
  <documentation>Requesting data asset access</documentation>
  <extensionElements>
    <flowable:taskListener event="complete" class="com.ch.com.ch.listeners.ApprovalTaskListener"></flowable:taskListener>
    <modeler:initiator-can-complete xmlns:modeler="http://flowable.org/modeler"><![CDATA[false]]></modeler:initiator-can-complete>
  </extensionElements>
  <multiInstanceLoopCharacteristics isSequential="false" flowable:collection="usersList" flowable:elementVariable="element">
    <extensionElements></extensionElements>
  </multiInstanceLoopCharacteristics>
</userTask>
<sequenceFlow id="sid-293EC104-BE40-4323-A6A2-A4C42D065A0E" sourceRef="sid-A16289AB-FECF-4310-B224-79425D492B26" targetRef="adminApproval"></sequenceFlow>
<scriptTask id="sid-A16289AB-FECF-4310-B224-79425D492B26" name="Get List of approvers" scriptFormat="groovy" flowable:autoStoreVariables="false">
  <script><![CDATA[import java.util.stream.Collectors
    import java.util.stream.Stream
	org.slf4j.LoggerFactory.getLogger("theScriptTask").info("executing Script Task 1")
    Map<String, Object> variableMap = new HashMap<>();
    /* Get List of users by a role/group*/
    variableMap.put("usersList", Stream.of("admin","Qa_admin").collect(Collectors.toList()));
    variableMap.put("taskCompletedList", new ArrayList<>());
	 variableMap.put("requestedMoreInfoUserList", new ArrayList<>());
    execution.setVariables(variableMap);]]></script>
</scriptTask>
<sequenceFlow id="sid-FFD09675-66EA-4455-B215-B81A5CC36A4E" sourceRef="adminApproval" targetRef="decision"></sequenceFlow>
<scriptTask id="sid-0D413747-D083-4737-9E09-0A1B63905CBD" name="Get List of approvers" scriptFormat="groovy" flowable:autoStoreVariables="false">
  <script><![CDATA[import java.util.stream.Collectors
    import java.util.stream.Stream
	org.slf4j.LoggerFactory.getLogger("theScriptTask").info("executing Script Task 1")
    Map<String, Object> variableMap = new HashMap<>();
    /* Get List of users by a role/group*/
    variableMap.put("usersList", execution.getVariable("requestedMoreInfoUserList"));
    variableMap.put("taskCompletedList", new ArrayList<>());
	 variableMap.put("requestedMoreInfoUserList", new ArrayList<>());
    execution.setVariables(variableMap);]]></script>
</scriptTask>
<sequenceFlow id="sid-4B1AF3A3-EBC7-424D-BE26-C66278093016" sourceRef="sid-0D413747-D083-4737-9E09-0A1B63905CBD" targetRef="adminApproval"></sequenceFlow>
<sequenceFlow id="deniedAccess" name="Denied" sourceRef="decision" targetRef="rejectDataAssetAccess">
  <conditionExpression xsi:type="tFormalExpression"><![CDATA[${!approved && !notEnoughInfo}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="sequenceFlow-0dbbe61c-e6e8-4202-9c10-996b8f32089d" name="approved" sourceRef="decision" targetRef="approveDataAssetAccess">
  <conditionExpression xsi:type="tFormalExpression"><![CDATA[${approved && !notEnoughInfo}]]></conditionExpression>
</sequenceFlow>
<sequenceFlow id="sid-86F39707-B54C-43FD-A06C-FFBEFE7C4357" name="Request information" sourceRef="decision" targetRef="sid-46AD6217-FC9E-4FEE-8253-29DBFA47E290">
  <conditionExpression xsi:type="tFormalExpression"><![CDATA[${notEnoughInfo}]]></conditionExpression>
</sequenceFlow>