提交 e34a9229 编写于 作者: F fheremans

ACT-1949: Intermediate catching timer event should not repeat cycle

上级 da1ee027
......@@ -147,8 +147,15 @@ public class TimerDeclarationImpl implements Serializable {
if (type == TimerDeclarationType.CYCLE) {
// See ACT-1427: A boundary timer with a cancelActivity='true', doesn't need to repeat itself
if (!isInterruptingTimer) {
// See ACT-1427: A boundary timer with a cancelActivity='true', doesn't need to repeat itself
boolean repeat = !isInterruptingTimer;
// ACT-1951: intermediate catching timer events shouldn't repeat accoring to spec
if(TimerCatchIntermediateEventJobHandler.TYPE.equals(jobHandlerType)) {
repeat = false;
}
if (repeat) {
String prepared = prepareRepeat(dueDateString);
timer.setRepeat(prepared);
}
......
......@@ -89,5 +89,18 @@ public class IntermediateTimerEventTest extends PluggableActivitiTestCase {
assertProcessEnded(processInstance.getId());
}
@Deployment
public void testLoopWithCycle() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testLoop");
// After looping 3 times, the process should end. Cycle should NOT repeat itself
for (int i=0; i<3; i++) {
Job timer = managementService.createJobQuery().singleResult();
managementService.executeJob(timer.getId());
}
assertProcessEnded(processInstance.getId());
}
}
<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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"
xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:activiti="http://activiti.org/bpmn"
targetNamespace="Examples">
<process id="testLoop">
<startEvent id="theStart" />
<sequenceFlow id="flow1" sourceRef="theStart" targetRef="timer" />
<intermediateCatchEvent id="timer">
<timerEventDefinition>
<timeCycle>R3/P1D</timeCycle>
</timerEventDefinition>
</intermediateCatchEvent>
<sequenceFlow id="flow2" sourceRef="timer" targetRef="checkCompletion" />
<scriptTask id="checkCompletion" scriptFormat="javascript">
<script>
<![CDATA[
var counter = execution.getVariable('counter');
if (!counter) {
counter = 0;
}
var newCounter = counter + 1;
execution.setVariable('counter', newCounter);
if (newCounter == 3) {
execution.setVariable('completed', true);
} else {
execution.setVariable('completed', false);
}
]]>
</script>
</scriptTask>
<sequenceFlow id="flowToGW" sourceRef="checkCompletion" targetRef="exclusivegateway" />
<exclusiveGateway id="exclusivegateway" name="Exclusive Gateway" default="flow4"></exclusiveGateway>
<sequenceFlow id="flow3" sourceRef="exclusivegateway" targetRef="theEnd">
<conditionExpression xsi:type="tFormalExpression">${completed}</conditionExpression>
</sequenceFlow>
<sequenceFlow id="flow4" sourceRef="exclusivegateway" targetRef="timer"> </sequenceFlow>
<endEvent id="theEnd" />
</process>
</definitions>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册