提交 0eeca188 编写于 作者: J Joram Barrez

ACT-1967: Signal boundary event to none end event causes foreign key violation exception

上级 41a01f2d
...@@ -86,7 +86,11 @@ public class CommandContext { ...@@ -86,7 +86,11 @@ public class CommandContext {
if (log.isTraceEnabled()) { if (log.isTraceEnabled()) {
log.trace("AtomicOperation: {} on {}", currentOperation, this); log.trace("AtomicOperation: {} on {}", currentOperation, this);
} }
currentOperation.execute(execution); if (execution.getReplacedBy() == null) {
currentOperation.execute(execution);
} else {
currentOperation.execute(execution.getReplacedBy());
}
} }
} finally { } finally {
Context.removeExecutionContext(); Context.removeExecutionContext();
......
...@@ -966,7 +966,18 @@ public class ExecutionEntity extends VariableScopeImpl implements ActivityExecut ...@@ -966,7 +966,18 @@ public class ExecutionEntity extends VariableScopeImpl implements ActivityExecut
DbSqlSession dbSqlSession = commandContext.getDbSqlSession(); DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
// update the related tasks // update the related tasks
for (TaskEntity task: getTasks()) {
List<TaskEntity> allTasks = new ArrayList<TaskEntity>();
allTasks.addAll(getTasks());
List<TaskEntity> cachedTasks = dbSqlSession.findInCache(TaskEntity.class);
for (TaskEntity cachedTask : cachedTasks) {
if (cachedTask.getExecutionId().equals(this.getId())) {
allTasks.add(cachedTask);
}
}
for (TaskEntity task: allTasks) {
task.setExecutionId(replacedBy.getId()); task.setExecutionId(replacedBy.getId());
task.setExecution(this.replacedBy); task.setExecution(this.replacedBy);
...@@ -1377,12 +1388,18 @@ public class ExecutionEntity extends VariableScopeImpl implements ActivityExecut ...@@ -1377,12 +1388,18 @@ public class ExecutionEntity extends VariableScopeImpl implements ActivityExecut
} }
public void setTransition(TransitionImpl transition) { public void setTransition(TransitionImpl transition) {
this.transition = transition; this.transition = transition;
if (replacedBy != null) {
replacedBy.setTransition(transition);
}
} }
public TransitionImpl getTransitionBeingTaken() { public TransitionImpl getTransitionBeingTaken() {
return transitionBeingTaken; return transitionBeingTaken;
} }
public void setTransitionBeingTaken(TransitionImpl transitionBeingTaken) { public void setTransitionBeingTaken(TransitionImpl transitionBeingTaken) {
this.transitionBeingTaken = transitionBeingTaken; this.transitionBeingTaken = transitionBeingTaken;
if (replacedBy != null) {
replacedBy.setTransitionBeingTaken(transitionBeingTaken);
}
} }
public Integer getExecutionListenerIndex() { public Integer getExecutionListenerIndex() {
return executionListenerIndex; return executionListenerIndex;
......
...@@ -13,6 +13,9 @@ ...@@ -13,6 +13,9 @@
package org.activiti.engine.test.bpmn.event.signal; package org.activiti.engine.test.bpmn.event.signal;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -28,6 +31,7 @@ import org.activiti.engine.runtime.ProcessInstance; ...@@ -28,6 +31,7 @@ import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.task.Task; import org.activiti.engine.task.Task;
import org.activiti.engine.test.Deployment; import org.activiti.engine.test.Deployment;
import org.activiti.validation.validator.Problems; import org.activiti.validation.validator.Problems;
import org.junit.Test;
/** /**
...@@ -553,5 +557,19 @@ public class SignalEventTest extends PluggableActivitiTestCase { ...@@ -553,5 +557,19 @@ public class SignalEventTest extends PluggableActivitiTestCase {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callerProcess"); ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("callerProcess");
assertNotNull(processInstance.getId()); assertNotNull(processInstance.getId());
} }
@Deployment
public void testNoneEndEventAfterSignalInConcurrentProcess() {
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("my-process");
assertNotNull(processInstance);
Task task = taskService.createTaskQuery().taskDefinitionKey("usertask1").singleResult();
taskService.claim(task.getId(), "user");
taskService.complete(task.getId());
task = taskService.createTaskQuery().singleResult();
assertEquals("usertask2", task.getTaskDefinitionKey());
}
} }
<?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="http://www.activiti.org/test">
<signal id="theSignal" name="theSignal"></signal>
<process id="my-process" isExecutable="true">
<startEvent id="start"></startEvent>
<sequenceFlow id="flow1" sourceRef="start" targetRef="parallelgateway1"></sequenceFlow>
<userTask id="someTask" name="Activiti is awesome!"></userTask>
<sequenceFlow id="flow2" sourceRef="someTask" targetRef="end"></sequenceFlow>
<endEvent id="end"></endEvent>
<parallelGateway id="parallelgateway1" name="Parallel Gateway"></parallelGateway>
<sequenceFlow id="flow3" sourceRef="parallelgateway1" targetRef="someTask"></sequenceFlow>
<userTask id="usertask1" name="User Task"></userTask>
<sequenceFlow id="flow4" sourceRef="parallelgateway1" targetRef="usertask1"></sequenceFlow>
<intermediateThrowEvent id="signalintermediatethrowevent1" name="SignalThrowEvent">
<signalEventDefinition signalRef="theSignal"></signalEventDefinition>
</intermediateThrowEvent>
<sequenceFlow id="flow5" sourceRef="usertask1" targetRef="signalintermediatethrowevent1"></sequenceFlow>
<userTask id="usertask2" name="User Task"></userTask>
<sequenceFlow id="flow6" sourceRef="signalintermediatethrowevent1" targetRef="usertask2"></sequenceFlow>
<endEvent id="endevent1" name="End"></endEvent>
<sequenceFlow id="flow7" sourceRef="usertask2" targetRef="endevent1"></sequenceFlow>
<boundaryEvent id="boundarysignal1" name="Signal" attachedToRef="someTask" cancelActivity="true">
<signalEventDefinition signalRef="theSignal"></signalEventDefinition>
</boundaryEvent>
<endEvent id="endevent2" name="End"></endEvent>
<sequenceFlow id="flow8" sourceRef="boundarysignal1" targetRef="endevent2"></sequenceFlow>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_my-process">
<bpmndi:BPMNPlane bpmnElement="my-process" id="BPMNPlane_my-process">
<bpmndi:BPMNShape bpmnElement="start" id="BPMNShape_start">
<omgdc:Bounds height="35.0" width="35.0" x="20.0" y="270.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="someTask" id="BPMNShape_someTask">
<omgdc:Bounds height="60.0" width="100.0" x="143.0" y="127.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="boundarysignal1" id="BPMNShape_boundarysignal1">
<omgdc:Bounds height="30.0" width="30.0" x="193.0" y="173.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="end" id="BPMNShape_end">
<omgdc:Bounds height="35.0" width="35.0" x="438.0" y="70.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="parallelgateway1" id="BPMNShape_parallelgateway1">
<omgdc:Bounds height="40.0" width="40.0" x="172.0" y="234.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
<omgdc:Bounds height="55.0" width="105.0" x="140.0" y="340.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="signalintermediatethrowevent1" id="BPMNShape_signalintermediatethrowevent1">
<omgdc:Bounds height="35.0" width="35.0" x="360.0" y="350.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
<omgdc:Bounds height="55.0" width="105.0" x="530.0" y="340.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
<omgdc:Bounds height="35.0" width="35.0" x="710.0" y="350.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
<omgdc:Bounds height="35.0" width="35.0" x="311.0" y="250.0"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="55.0" y="287.0"></omgdi:waypoint>
<omgdi:waypoint x="192.0" y="274.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="193.0" y="127.0"></omgdi:waypoint>
<omgdi:waypoint x="192.0" y="30.0"></omgdi:waypoint>
<omgdi:waypoint x="192.0" y="30.0"></omgdi:waypoint>
<omgdi:waypoint x="455.0" y="70.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="192.0" y="234.0"></omgdi:waypoint>
<omgdi:waypoint x="193.0" y="187.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
<omgdi:waypoint x="192.0" y="274.0"></omgdi:waypoint>
<omgdi:waypoint x="192.0" y="340.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
<omgdi:waypoint x="245.0" y="367.0"></omgdi:waypoint>
<omgdi:waypoint x="360.0" y="367.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow6" id="BPMNEdge_flow6">
<omgdi:waypoint x="395.0" y="367.0"></omgdi:waypoint>
<omgdi:waypoint x="530.0" y="367.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow7" id="BPMNEdge_flow7">
<omgdi:waypoint x="635.0" y="367.0"></omgdi:waypoint>
<omgdi:waypoint x="710.0" y="367.0"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow8" id="BPMNEdge_flow8">
<omgdi:waypoint x="208.0" y="203.0"></omgdi:waypoint>
<omgdi:waypoint x="328.0" y="250.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.
先完成此消息的编辑!
想要评论请 注册