提交 f8046365 编写于 作者: T Tijs Rademakers

Merge pull request #59 from henningp/master

#ACT-1426: Nested multi-instance activities did not work
......@@ -84,7 +84,7 @@ public abstract class MultiInstanceActivityBehavior extends FlowNodeActivityBeha
}
public void execute(ActivityExecution execution) throws Exception {
if (getLoopVariable(execution, LOOP_COUNTER) == null) {
if (getLocalLoopVariable(execution, LOOP_COUNTER) == null) {
try {
createInstances(execution);
} catch (BpmnError error) {
......@@ -227,6 +227,10 @@ public abstract class MultiInstanceActivityBehavior extends FlowNodeActivityBeha
}
return (Integer) value;
}
protected Integer getLocalLoopVariable(ActivityExecution execution, String variableName) {
return (Integer) execution.getVariableLocal(variableName);
}
/**
* Since no transitions are followed when leaving the inner activity,
......
......@@ -1060,6 +1060,28 @@ public class MultiInstanceTest extends PluggableActivitiTestCase {
assertEquals(0, runtimeService.createExecutionQuery().count());
}
@Deployment(resources = { "org/activiti/engine/test/bpmn/multiinstance/MultiInstanceTest.testNestedMultiInstanceTasks.bpmn20.xml"})
public void testNestedMultiInstanceTasks() {
List<String> processes = Arrays.asList("process A", "process B");
List<String> assignees = Arrays.asList("kermit", "gonzo");
Map<String, Object> variableMap = new HashMap<String, Object>();
variableMap.put("subProcesses", processes);
variableMap.put("assignees", assignees);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("miNestedMultiInstanceTasks", variableMap);
List<Task> tasks = taskService.createTaskQuery().list();
assertEquals(processes.size() * assignees.size(), tasks.size());
for (Task t : tasks) {
taskService.complete(t.getId());
}
List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().processDefinitionKey("miNestedMultiInstanceTasks").list();
assertEquals(0, processInstances.size());
assertProcessEnded(processInstance.getId());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="Examples">
<process id="miNestedMultiInstanceTasks" isExecutable="true">
<startEvent id="theStart"></startEvent>
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="subprocess1"></sequenceFlow>
<sequenceFlow id="flow3" sourceRef="subprocess1" targetRef="theEnd"></sequenceFlow>
<endEvent id="theEnd"></endEvent>
<subProcess id="subprocess1" name="${subProcess}">
<multiInstanceLoopCharacteristics isSequential="false" activiti:collection="subProcesses" activiti:elementVariable="subProcess"></multiInstanceLoopCharacteristics>
<startEvent id="startevent1" name="Start"></startEvent>
<endEvent id="endevent1" name="End"></endEvent>
<userTask id="miTasks" name="My Task ${loopCounter}" activiti:assignee="kermit_${loopCounter}">
<multiInstanceLoopCharacteristics isSequential="false" activiti:collection="assignees" activiti:elementVariable="assignee"></multiInstanceLoopCharacteristics>
</userTask>
<sequenceFlow id="flow4" sourceRef="startevent1" targetRef="miTasks"></sequenceFlow>
<sequenceFlow id="flow5" sourceRef="miTasks" targetRef="endevent1"></sequenceFlow>
</subProcess>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_miNestedMultiInstanceTasks">
<bpmndi:BPMNPlane bpmnElement="miNestedMultiInstanceTasks" id="BPMNPlane_miNestedMultiInstanceTasks">
<bpmndi:BPMNShape bpmnElement="miTasks" id="BPMNShape_miTasks">
<omgdc:Bounds height="60.0" width="100.0" x="180.0" y="82.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="theEnd" id="BPMNShape_theEnd">
<omgdc:Bounds height="35.0" width="35.0" x="440.0" y="100.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="theStart" id="BPMNShape_theStart">
<omgdc:Bounds height="35.0" width="35.0" x="-10.0" y="94.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="subprocess1" id="BPMNShape_subprocess1" isExpanded="false">
<omgdc:Bounds height="171.0" width="291.0" x="90.0" y="24.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
<omgdc:Bounds height="35.0" width="35.0" x="110.0" y="94.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
<omgdc:Bounds height="35.0" width="35.0" x="330.0" y="94.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="381.0" y="109.0"></omgdi:waypoint>
<omgdi:waypoint x="440.0" y="117.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="25.0" y="111.0"></omgdi:waypoint>
<omgdi:waypoint x="42.0" y="107.0"></omgdi:waypoint>
<omgdi:waypoint x="90.0" y="109.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
<omgdi:waypoint x="145.0" y="111.0"></omgdi:waypoint>
<omgdi:waypoint x="180.0" y="112.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
<omgdi:waypoint x="280.0" y="112.0"></omgdi:waypoint>
<omgdi:waypoint x="330.0" y="111.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
</bpmndi:BPMNPlane>
</bpmndi:BPMNDiagram>
</definitions>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册