提交 f4651d3e 编写于 作者: T tijsrademakers

Fix for ACT-1054

上级 75a0ad7e
......@@ -59,7 +59,9 @@ import org.slf4j.LoggerFactory;
* @author Tom Baeyens
* @author Daniel Meyer
* @author Falko Menge
* @author Saeid Mirzaei
*/
public class ExecutionEntity extends VariableScopeImpl implements ActivityExecution, ExecutionListenerExecution, Execution, PvmExecution, ProcessInstance, InterpretableExecution, PersistentObject, HasRevision {
private static final long serialVersionUID = 1L;
......@@ -929,7 +931,17 @@ public class ExecutionEntity extends VariableScopeImpl implements ActivityExecut
// update the related tasks
for (TaskEntity task: getTasks()) {
task.setExecutionId(replacedBy.getId());
task.setExecution(this.replacedBy);
task.setExecution(this.replacedBy);
// update the related local task variables
List<VariableInstanceEntity> variables = (List) commandContext
.getVariableInstanceEntityManager()
.findVariableInstancesByTaskId(task.getId());
for (VariableInstanceEntity variable : variables) {
variable.setExecution(this.replacedBy);
}
this.replacedBy.addTask(task);
}
......
......@@ -50,6 +50,8 @@ public class VariableInstanceEntity implements ValueFields, PersistentObject, Ha
protected VariableType type;
boolean forcedUpdate;
// Default constructor for SQL mapping
protected VariableInstanceEntity() {
}
......@@ -77,6 +79,7 @@ public class VariableInstanceEntity implements ValueFields, PersistentObject, Ha
public void setExecution(ExecutionEntity execution) {
this.executionId = execution.getId();
this.processInstanceId = execution.getProcessInstanceId();
forcedUpdate = true;
}
public void delete() {
......@@ -103,6 +106,9 @@ public class VariableInstanceEntity implements ValueFields, PersistentObject, Ha
if (byteArrayValueId != null) {
persistentState.put("byteArrayValueId", byteArrayValueId);
}
if (forcedUpdate) {
persistentState.put("forcedUpdate", Boolean.TRUE);
}
return persistentState;
}
......
......@@ -30,6 +30,7 @@
update ${prefix}ACT_RU_VARIABLE
set
REV_ = #{revisionNext, jdbcType=INTEGER},
EXECUTION_ID_ = #{executionId, jdbcType=VARCHAR},
BYTEARRAY_ID_ = #{byteArrayValueId, jdbcType=VARCHAR},
DOUBLE_ = #{doubleValue, jdbcType=DOUBLE},
LONG_ = #{longValue, jdbcType=BIGINT},
......
......@@ -13,6 +13,8 @@
package org.activiti.engine.test.bpmn.usertask;
import java.util.List;
import org.activiti.engine.impl.history.HistoryLevel;
import org.activiti.engine.impl.test.PluggableActivitiTestCase;
import org.activiti.engine.runtime.ProcessInstance;
......@@ -53,4 +55,21 @@ public class UserTaskTest extends PluggableActivitiTestCase {
assertEquals(1, taskService.createTaskQuery().processInstanceId(processInstance.getId()).list().size());
}
@Deployment
public void testCompleteAfterParallelGateway() throws InterruptedException {
// related to http://jira.codehaus.org/browse/ACT-1054
// start the process
runtimeService.startProcessInstanceByKey("ForkProcess");
List<Task> taskList = taskService.createTaskQuery().list();
assertNotNull(taskList);
assertEquals(2, taskList.size());
// make sure user task exists
Task task = taskService.createTaskQuery().taskDefinitionKey("SimpleUser").singleResult();
assertNotNull(task);
// attempt to complete the task and get PersistenceException pointing to "referential integrity constraint violation"
taskService.complete(task.getId());
}
}
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.test.bpmn.usertask;
import org.activiti.engine.delegate.DelegateTask;
import org.activiti.engine.delegate.TaskListener;
import org.activiti.engine.impl.el.Expression;
/**
* @author Tom Baeyens
* @author Daniel Meyer
* @author Falko Menge
* @author Saeid Mirzaei
*/
/**
* This is for test case UserTaskTest.testCompleteAfterParallelGateway
*
*/
public class UserTaskTestCreateTaskListener implements TaskListener {
private static final long serialVersionUID = 1L;
private Expression expression;
@Override
public void notify(DelegateTask delegateTask) {
if (this.expression != null && this.expression.getValue(delegateTask) != null) {
// get the expression variable
String expression = this.expression.getValue(delegateTask).toString();
// this expression will be evaluated when completing the task
delegateTask.setVariableLocal("validationRule", expression);
}
}
}
<?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://activiti.org/bpmn20">
<process id="ForkProcess" name="Fork Process">
<startEvent id="theStart" name="Start"></startEvent>
<sequenceFlow id="flow1" name="" sourceRef="theStart" targetRef="initialFork"></sequenceFlow>
<parallelGateway id="initialFork" name="Parallel Gateway"></parallelGateway>
<sequenceFlow id="flow2" name="" sourceRef="initialFork" targetRef="SimpleUser"></sequenceFlow>
<sequenceFlow id="flow3" name="" sourceRef="initialFork" targetRef="UserwithListener"></sequenceFlow>
<userTask id="SimpleUser" name="Simple User"></userTask>
<userTask id="UserwithListener" name="User with Listener">
<extensionElements>
<activiti:taskListener event='create' class='org.activiti.engine.test.bpmn.usertask.UserTaskTestCreateTaskListener'>
<activiti:field name='expression' stringValue='some expression value' />
</activiti:taskListener>
</extensionElements>
</userTask>
<sequenceFlow id="flow4" name="" sourceRef="UserwithListener" targetRef="endevent2"></sequenceFlow>
<sequenceFlow id="flow5" name="" sourceRef="SimpleUser" targetRef="theEvent1"></sequenceFlow>
<endEvent id="theEvent1" name="End1"></endEvent>
<endEvent id="endevent2" name="End2"></endEvent>
</process>
<bpmndi:BPMNDiagram id="BPMNDiagram_ForkProcess">
<bpmndi:BPMNPlane bpmnElement="ForkProcess" id="BPMNPlane_ForkProcess">
<bpmndi:BPMNShape bpmnElement="theStart" id="BPMNShape_theStart">
<omgdc:Bounds height="35" width="35" x="50" y="163"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="theEvent1" id="BPMNShape_theEvent1">
<omgdc:Bounds height="35" width="35" x="650" y="120"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="initialFork" id="BPMNShape_initialFork">
<omgdc:Bounds height="40" width="40" x="160" y="160"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="SimpleUser" id="BPMNShape_SimpleUser">
<omgdc:Bounds height="55" width="105" x="370" y="110"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="UserwithListener" id="BPMNShape_UserwithListener">
<omgdc:Bounds height="55" width="105" x="370" y="250"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
<omgdc:Bounds height="35" width="35" x="650" y="260"></omgdc:Bounds>
</bpmndi:BPMNShape>
<bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
<omgdi:waypoint x="85" y="180"></omgdi:waypoint>
<omgdi:waypoint x="160" y="180"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
<omgdi:waypoint x="180" y="160"></omgdi:waypoint>
<omgdi:waypoint x="180" y="137"></omgdi:waypoint>
<omgdi:waypoint x="370" y="137"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
<omgdi:waypoint x="180" y="200"></omgdi:waypoint>
<omgdi:waypoint x="180" y="277"></omgdi:waypoint>
<omgdi:waypoint x="370" y="277"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
<omgdi:waypoint x="475" y="277"></omgdi:waypoint>
<omgdi:waypoint x="650" y="277"></omgdi:waypoint>
</bpmndi:BPMNEdge>
<bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
<omgdi:waypoint x="475" y="137"></omgdi:waypoint>
<omgdi:waypoint x="650" y="137"></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.
先完成此消息的编辑!
想要评论请 注册