Skip to content

Commit

Permalink
Improve support for MI handling for process migration
Browse files Browse the repository at this point in the history
  • Loading branch information
tijsrademakers committed Nov 13, 2023
1 parent bd17ae7 commit b59a1f1
Show file tree
Hide file tree
Showing 12 changed files with 1,069 additions and 36 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public class MoveExecutionEntityContainer {
protected String newOwnerId;
protected Map<String, ExecutionEntity> continueParentExecutionMap = new HashMap<>();
protected Map<String, FlowElementMoveEntry> moveToFlowElementMap = new LinkedHashMap<>();
protected Map<String, Map<String, Object>> flowElementLocalVariableMap = new HashMap<>();
protected List<String> newExecutionIds = new ArrayList<>();

public MoveExecutionEntityContainer(List<ExecutionEntity> executions, List<String> moveToActivityIds) {
Expand Down Expand Up @@ -206,6 +207,18 @@ public void addNewExecutionId(String executionId) {
this.newExecutionIds.add(executionId);
}

public Map<String, Map<String, Object>> getFlowElementLocalVariableMap() {
return flowElementLocalVariableMap;
}

public void setFlowElementLocalVariableMap(Map<String, Map<String, Object>> flowElementLocalVariableMap) {
this.flowElementLocalVariableMap = flowElementLocalVariableMap;
}

public void addLocalVariableMap(String activityId, Map<String, Object> localVariables) {
this.flowElementLocalVariableMap.put(activityId, localVariables);
}

public static class FlowElementMoveEntry {

protected FlowElement originalFlowElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public class ProcessInstanceChangeState {
protected Map<String, List<ExecutionEntity>> processInstanceActiveEmbeddedExecutions;
protected List<MoveExecutionEntityContainer> moveExecutionEntityContainers;
protected HashMap<String, ExecutionEntity> createdEmbeddedSubProcess = new HashMap<>();
protected HashMap<String, ExecutionEntity> createdMultiInstanceRootExecution = new HashMap<>();
protected HashMap<StartEvent, ExecutionEntity> pendingEventSubProcessesStartEvents = new HashMap<>();

public ProcessInstanceChangeState() {
Expand Down Expand Up @@ -100,6 +101,18 @@ public void addCreatedEmbeddedSubProcess(String key, ExecutionEntity executionEn
this.createdEmbeddedSubProcess.put(key, executionEntity);
}

public HashMap<String, ExecutionEntity> getCreatedMultiInstanceRootExecution() {
return createdMultiInstanceRootExecution;
}

public void setCreatedMultiInstanceRootExecution(HashMap<String, ExecutionEntity> createdMultiInstanceRootExecution) {
this.createdMultiInstanceRootExecution = createdMultiInstanceRootExecution;
}

public void addCreatedMultiInstanceRootExecution(String key, ExecutionEntity executionEntity) {
this.createdMultiInstanceRootExecution.put(key, executionEntity);
}

public Map<String, List<ExecutionEntity>> getProcessInstanceActiveEmbeddedExecutions() {
return processInstanceActiveEmbeddedExecutions;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ public boolean isEnded() {
return isEnded;
}

public boolean setIsEnded() {
public boolean getIsEnded() {
return isEnded;
}

Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -1441,15 +1441,15 @@ public void testSimpleMigrationWithMultiInstanceTask() {
.contains("parallelTasks");

if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) {
checkActivityInstances(procDefTwoTasks, processInstance, "userTask", "beforeMultiInstance", "parallelTasks", "parallelTasks", "parallelTasks", "parallelTasks");
checkActivityInstances(procDefTwoTasks, processInstance, "userTask", "beforeMultiInstance", "parallelTasks", "parallelTasks");

checkTaskInstance(procDefTwoTasks, processInstance, "beforeMultiInstance", "parallelTasks", "parallelTasks", "parallelTasks", "parallelTasks");
}

completeProcessInstanceTasks(processInstance.getId());

if (HistoryTestHelper.isHistoryLevelAtLeast(HistoryLevel.ACTIVITY, processEngineConfiguration)) {
checkActivityInstances(procDefTwoTasks, processInstance, "userTask", "beforeMultiInstance", "parallelTasks", "parallelTasks", "parallelTasks", "parallelTasks");
checkActivityInstances(procDefTwoTasks, processInstance, "userTask", "beforeMultiInstance", "parallelTasks", "parallelTasks");

checkTaskInstance(procDefTwoTasks, processInstance, "beforeMultiInstance", "parallelTasks", "parallelTasks", "parallelTasks", "parallelTasks");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definition"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:flowable="http://flowable.org/bpmn"
targetNamespace="Examples">

<process id="parallelMultiInstanceSubProcess">

<startEvent id="theStart"/>
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="beforeMultiInstance"/>
<userTask id="beforeMultiInstance"/>
<sequenceFlow sourceRef="beforeMultiInstance" targetRef="callActivity"/>

<callActivity id="callActivity" calledElement="oneTaskProcess">
<multiInstanceLoopCharacteristics isSequential="false" flowable:collection="myCollection" flowable:elementVariable="myElement" />
</callActivity>

<sequenceFlow id="flow2" sourceRef="callActivity" targetRef="afterMultiInstance"/>
<userTask id="afterMultiInstance"/>
<sequenceFlow id="flow3" sourceRef="afterMultiInstance" targetRef="theEnd"/>
<endEvent id="theEnd"/>

</process>

</definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definition"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:flowable="http://flowable.org/bpmn"
targetNamespace="Examples">

<process id="parallelMultiInstanceSubProcess">

<startEvent id="theStart"/>
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="beforeMultiInstance"/>
<userTask id="beforeMultiInstance"/>
<sequenceFlow sourceRef="beforeMultiInstance" targetRef="task"/>

<serviceTask id="task" flowable:expression="${'test'}" flowable:async="true">
<multiInstanceLoopCharacteristics isSequential="false" flowable:collection="myCollection" flowable:elementVariable="myElement" />
</serviceTask>

<sequenceFlow id="flow2" sourceRef="task" targetRef="afterMultiInstance"/>
<userTask id="afterMultiInstance"/>
<sequenceFlow id="flow3" sourceRef="afterMultiInstance" targetRef="theEnd"/>
<endEvent id="theEnd"/>

</process>

</definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definition"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:flowable="http://flowable.org/bpmn"
targetNamespace="Examples">

<process id="parallelMultiInstanceSubProcess">

<startEvent id="theStart"/>
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="beforeMultiInstance"/>
<userTask id="beforeMultiInstance"/>
<sequenceFlow sourceRef="beforeMultiInstance" targetRef="parallelMISubProcess"/>

<subProcess id="parallelMISubProcess" name="Multi Instance Sequential SubProcess">
<multiInstanceLoopCharacteristics isSequential="false" flowable:collection="myCollection" flowable:elementVariable="myElement" />
<startEvent id="parallelSubProcStart"/>
<sequenceFlow id="subFlow1" sourceRef="parallelSubProcStart" targetRef="subtask"/>
<callActivity id="subtask" calledElement="oneTaskProcess" />
<sequenceFlow id="subFlow2" sourceRef="subtask" targetRef="parallelSubProcEnd"/>
<endEvent id="parallelSubProcEnd"/>
</subProcess>

<sequenceFlow id="flow2" sourceRef="parallelMISubProcess" targetRef="afterMultiInstance"/>
<userTask id="afterMultiInstance"/>
<sequenceFlow id="flow3" sourceRef="afterMultiInstance" targetRef="theEnd"/>
<endEvent id="theEnd"/>

</process>

</definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definition"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:flowable="http://flowable.org/bpmn"
targetNamespace="Examples">

<process id="parallelMultiInstanceSubProcess">

<startEvent id="theStart"/>
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="beforeMultiInstance"/>
<userTask id="beforeMultiInstance"/>
<sequenceFlow sourceRef="beforeMultiInstance" targetRef="parallelMISubProcess"/>

<subProcess id="parallelMISubProcess" name="Multi Instance Sequential SubProcess">
<multiInstanceLoopCharacteristics isSequential="false" flowable:collection="myCollection" flowable:elementVariable="myElement" />
<startEvent id="parallelSubProcStart"/>
<sequenceFlow id="subFlow1" sourceRef="parallelSubProcStart" targetRef="subTask1"/>
<userTask id="subTask1"/>
<sequenceFlow id="subFlow2" sourceRef="subTask1" targetRef="parallelSubProcEnd"/>
<endEvent id="parallelSubProcEnd"/>
</subProcess>

<sequenceFlow id="flow2" sourceRef="parallelMISubProcess" targetRef="afterMultiInstance"/>
<userTask id="afterMultiInstance"/>
<sequenceFlow id="flow3" sourceRef="afterMultiInstance" targetRef="theEnd"/>
<endEvent id="theEnd"/>

</process>

</definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definition"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:flowable="http://flowable.org/bpmn"
targetNamespace="Examples">

<process id="parallelMultiInstanceSubProcess">

<startEvent id="theStart"/>
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="beforeMultiInstance"/>
<userTask id="beforeMultiInstance"/>
<sequenceFlow sourceRef="beforeMultiInstance" targetRef="parallelMISubProcess"/>

<subProcess id="parallelMISubProcess" name="Multi Instance Sequential SubProcess">
<multiInstanceLoopCharacteristics isSequential="false" flowable:collection="myCollection" flowable:elementVariable="myElement" />
<startEvent id="parallelSubProcStart"/>
<sequenceFlow id="subFlow1" sourceRef="parallelSubProcStart" targetRef="subtask"/>
<serviceTask id="subtask" flowable:expression="${'test'}" flowable:async="true" />
<sequenceFlow id="subFlow2" sourceRef="subtask" targetRef="parallelSubProcEnd"/>
<endEvent id="parallelSubProcEnd"/>
</subProcess>

<sequenceFlow id="flow2" sourceRef="parallelMISubProcess" targetRef="afterMultiInstance"/>
<userTask id="afterMultiInstance"/>
<sequenceFlow id="flow3" sourceRef="afterMultiInstance" targetRef="theEnd"/>
<endEvent id="theEnd"/>

</process>

</definitions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definition"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:flowable="http://flowable.org/bpmn"
targetNamespace="Examples">

<process id="parallelMultiInstanceSubProcess">

<startEvent id="theStart"/>
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="beforeMultiInstance"/>
<userTask id="beforeMultiInstance"/>
<sequenceFlow sourceRef="beforeMultiInstance" targetRef="task"/>

<userTask id="task" flowable:assignee="kermit">
<multiInstanceLoopCharacteristics isSequential="false" flowable:collection="myCollection" flowable:elementVariable="myElement" />
</userTask>

<sequenceFlow id="flow2" sourceRef="task" targetRef="afterMultiInstance"/>
<userTask id="afterMultiInstance"/>
<sequenceFlow id="flow3" sourceRef="afterMultiInstance" targetRef="theEnd"/>
<endEvent id="theEnd"/>

</process>

</definitions>

0 comments on commit b59a1f1

Please sign in to comment.