提交 b32e9ed8 编写于 作者: J Joram Barrez

Fix callback id/type not propagated to historic process instance when using cmmn process task

上级 6a8b80a1
......@@ -17,7 +17,7 @@ package org.flowable.cmmn.engine;
*/
public interface PlanItemInstanceCallbackType {
String CHILD_CASE = "cmmn-1.1-child-case";
String CHILD_CASE = "cmmn-1.1-to-cmmn-1.1-child-case";
String CHILD_PROCESS = "cmmn-1.1-to-bpmn-2.0-child-process";
......
......@@ -20,11 +20,15 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.flowable.cmmn.engine.PlanItemInstanceCallbackType;
import org.flowable.cmmn.engine.history.HistoricMilestoneInstance;
import org.flowable.cmmn.engine.runtime.CaseInstance;
import org.flowable.cmmn.engine.runtime.PlanItemInstance;
import org.flowable.cmmn.engine.runtime.PlanItemInstanceState;
import org.flowable.cmmn.engine.test.CmmnDeployment;
import org.flowable.engine.common.impl.history.HistoryLevel;
import org.flowable.engine.history.HistoricProcessInstance;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.task.service.Task;
import org.junit.Before;
import org.junit.Test;
......@@ -76,8 +80,22 @@ public class ProcessTaskTest extends AbstractProcessEngineIntegrationTest {
.list();
assertEquals(1, planItemInstances.size());
assertEquals("The Process", planItemInstances.get(0).getName());
assertNotNull(planItemInstances.get(0).getReferenceId());
assertEquals(PlanItemInstanceCallbackType.CHILD_PROCESS, planItemInstances.get(0).getReferenceType());
assertEquals(0, cmmnHistoryService.createHistoricMilestoneInstanceQuery().count());
ProcessInstance processInstance = processEngine.getRuntimeService().createProcessInstanceQuery().singleResult();
assertNotNull(processInstance);
assertNotNull(processInstance.getCallbackId());
assertNotNull(processInstance.getCallbackType());
if (processEngine.getProcessEngineConfiguration().getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
HistoricProcessInstance historicProcessInstance = processEngine.getHistoryService().createHistoricProcessInstanceQuery()
.processInstanceId(processInstance.getId()).singleResult();
assertEquals(processInstance.getCallbackId(), historicProcessInstance.getCallbackId());
assertEquals(processInstance.getCallbackType(), historicProcessInstance.getCallbackType());
}
// Completing task will trigger completion of process task plan item
processEngine.getTaskService().complete(task.getId());
......
......@@ -93,6 +93,8 @@ public class HistoricProcessInstanceEntityImpl extends HistoricScopeInstanceEnti
persistentState.put("processDefinitionName", processDefinitionName);
persistentState.put("processDefinitionVersion", processDefinitionVersion);
persistentState.put("deploymentId", deploymentId);
persistentState.put("callbackId", callbackId);
persistentState.put("callbackType", callbackType);
return persistentState;
}
......
......@@ -229,6 +229,15 @@ public class ProcessInstanceHelper {
initiatorVariableName, initialFlowElement.getId());
processInstance.setName(processInstanceName);
// Callbacks
if (callbackId != null) {
processInstance.setCallbackId(callbackId);
}
if (callbackType != null) {
processInstance.setCallbackType(callbackType);
}
CommandContextUtil.getHistoryManager(commandContext).recordProcessInstanceStart(processInstance);
......@@ -252,14 +261,6 @@ public class ProcessInstanceHelper {
}
}
// Callbacks
if (callbackId != null) {
processInstance.setCallbackId(callbackId);
}
if (callbackType != null) {
processInstance.setCallbackType(callbackType);
}
// Fire events
if (eventDispatcherEnabled) {
CommandContextUtil.getProcessEngineConfiguration().getEventDispatcher()
......
......@@ -176,13 +176,13 @@
DELETE_REASON_ = #{deleteReason, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.name != name">
NAME_ = #{name, jdbcType=VARCHAR}
NAME_ = #{name, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.callbackId != callbackId">
CALLBACK_ID_ = #{callbackId, jdbcType=VARCHAR}
CALLBACK_ID_ = #{callbackId, jdbcType=VARCHAR},
</if>
<if test="originalPersistentState.callbackType != callbackType">
CALLBACK_ID_ = #{callbackType, jdbcType=VARCHAR}
CALLBACK_TYPE_ = #{callbackType, jdbcType=VARCHAR}
</if>
</set>
where ID_ = #{id}
......@@ -224,6 +224,8 @@
<result property="deleteReason" column="DELETE_REASON_" jdbcType="VARCHAR" />
<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR" />
<result property="name" column="NAME_" jdbcType="VARCHAR" />
<result property="callbackId" column="CALLBACK_ID_" jdbcType="VARCHAR" />
<result property="callbackType" column="CALLBACK_TYPE_" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="historicProcessInstanceAndVariablesResultMap" type="org.flowable.engine.impl.persistence.entity.HistoricProcessInstanceEntityImpl">
......@@ -246,6 +248,8 @@
<result property="deleteReason" column="DELETE_REASON_" jdbcType="VARCHAR" />
<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR" />
<result property="name" column="NAME_" jdbcType="VARCHAR" />
<result property="callbackId" column="CALLBACK_ID_" jdbcType="VARCHAR" />
<result property="callbackType" column="CALLBACK_TYPE_" jdbcType="VARCHAR" />
<collection property="queryVariables" column="EXECUTION_ID_" javaType="ArrayList" ofType="org.flowable.variable.service.impl.persistence.entity.HistoricVariableInstanceEntityImpl">
<id property="id" column="VAR_ID_"/>
<result property="name" column="VAR_NAME_" javaType="String" jdbcType="VARCHAR" />
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册