提交 c016d8b3 编写于 作者: T Tijs Rademakers
......@@ -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";
......
......@@ -71,6 +71,8 @@ public class CmmnEngineConfigurator extends AbstractEngineConfigurator {
cmmnEngineConfiguration.setHistoricTaskQueryLimit(processEngineConfiguration.getHistoricTaskQueryLimit());
initCmmnEngine();
initServiceConfigurations(processEngineConfiguration, cmmnEngineConfiguration);
}
protected void initProcessInstanceService(ProcessEngineConfigurationImpl processEngineConfiguration) {
......
......@@ -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());
......
......@@ -41,6 +41,8 @@ public class SpringCmmnEngineConfigurator extends CmmnEngineConfigurator {
springProcessEngineConfiguration.getApplicationContext(), springProcessEngineConfiguration.getBeans()));
initCmmnEngine();
initServiceConfigurations(processEngineConfiguration, cmmnEngineConfiguration);
}
@Override
......
......@@ -57,6 +57,8 @@ public class ContentEngineConfigurator extends AbstractEngineConfigurator {
initialiseCommonProperties(processEngineConfiguration, contentEngineConfiguration);
initContentEngine();
initServiceConfigurations(processEngineConfiguration, contentEngineConfiguration);
}
@Override
......
......@@ -36,6 +36,8 @@ public class SpringContentEngineConfigurator extends ContentEngineConfigurator {
contentEngineConfiguration.setTransactionManager(((SpringProcessEngineConfiguration) processEngineConfiguration).getTransactionManager());
initContentEngine();
initServiceConfigurations(processEngineConfiguration, contentEngineConfiguration);
}
@Override
......
......@@ -61,6 +61,8 @@ public class DmnEngineConfigurator extends AbstractEngineConfigurator {
initialiseCommonProperties(processEngineConfiguration, dmnEngineConfiguration);
initDmnEngine();
initServiceConfigurations(processEngineConfiguration, dmnEngineConfiguration);
}
@Override
......
......@@ -41,6 +41,8 @@ public class SpringDmnEngineConfigurator extends DmnEngineConfigurator {
springProcessEngineConfiguration.getApplicationContext(), springProcessEngineConfiguration.getBeans()));
initDmnEngine();
initServiceConfigurations(processEngineConfiguration, dmnEngineConfiguration);
}
@Override
......
......@@ -136,12 +136,14 @@ public abstract class AbstractSqlScriptBasedDbSchemaManager implements DbSchemaM
}
public String getProperty(String propertyName) {
String tableName = getPropertyTable();
if (!getDbSqlSession().getDbSqlSessionFactory().isTablePrefixIsSchema()) {
tableName = prependDatabaseTablePrefix(tableName);
}
PreparedStatement statement = null;
try {
String tableName = getPropertyTable();
if (!getDbSqlSession().getDbSqlSessionFactory().isTablePrefixIsSchema()) {
tableName = prependDatabaseTablePrefix(tableName);
}
statement = getDbSqlSession().getSqlSession().getConnection()
.prepareStatement("select VALUE_ from " + tableName + " where NAME_ = ?");
statement.setString(1, propertyName);
......@@ -152,7 +154,7 @@ public abstract class AbstractSqlScriptBasedDbSchemaManager implements DbSchemaM
return null;
}
} catch (SQLException e) {
throw new FlowableException("Could not read property " + propertyName + " from ACT_GE_PROPERTY", e);
return null;
} finally {
if (statement != null) {
try {
......@@ -164,30 +166,32 @@ public abstract class AbstractSqlScriptBasedDbSchemaManager implements DbSchemaM
}
public void setProperty(String propertyName, String value) {
String tableName = getPropertyTable();
if (!getDbSqlSession().getDbSqlSessionFactory().isTablePrefixIsSchema()) {
tableName = prependDatabaseTablePrefix(tableName);
}
PreparedStatement statement = null;
PreparedStatement statement2 = null;
try {
String tableName = getPropertyTable();
if (!getDbSqlSession().getDbSqlSessionFactory().isTablePrefixIsSchema()) {
tableName = prependDatabaseTablePrefix(tableName);
}
statement = getDbSqlSession().getSqlSession().getConnection()
.prepareStatement("update " + tableName + " set VALUE_ = ? where NAME_ = ?");
statement.setString(1, propertyName);
statement.setString(2, value);
statement.setString(1, value);
statement.setString(2, propertyName);
int result = statement.executeUpdate();
// Property does not exist yet, insert the property
if (result == 0) {
statement2 = getDbSqlSession().getSqlSession().getConnection()
.prepareStatement("insert into " + tableName + " values(?, ?, ?)");
.prepareStatement("insert into " + tableName + "(NAME_, VALUE_, REV_) values(?, ?, ?)");
statement2.setString(1, propertyName);
statement2.setString(2, value);
statement2.setInt(3, 1);
statement2.executeUpdate();
}
} catch (SQLException e) {
throw new FlowableException("Could not read property " + propertyName + " from ACT_GE_PROPERTY", e);
throw new FlowableException("Could not set property " + propertyName + " in " + tableName, e);
} finally {
if (statement != null) {
try {
......@@ -222,9 +226,7 @@ public abstract class AbstractSqlScriptBasedDbSchemaManager implements DbSchemaM
try {
inputStream = ReflectUtil.getResourceAsStream(resourceName);
if (inputStream == null) {
if (isOptional) {
LOGGER.debug("no schema resource {} for {}", resourceName, operation);
} else {
if (!isOptional) {
throw new FlowableException("resource '" + resourceName + "' is not available");
}
} else {
......
......@@ -35,7 +35,7 @@ public abstract class ServiceSqlScriptBasedDbSchemaManager extends AbstractSqlSc
@Override
public void dbSchemaCreate() {
if (isTablePresent(table)) {
if (isUpdateNeeded()) {
String dbVersion = getSchemaVersion();
if (!FlowableVersions.CURRENT_VERSION.equals(dbVersion)) {
throw new FlowableWrongDbException(FlowableVersions.CURRENT_VERSION, dbVersion);
......@@ -63,7 +63,7 @@ public abstract class ServiceSqlScriptBasedDbSchemaManager extends AbstractSqlSc
@Override
public String dbSchemaUpdate() {
String feedback = null;
if (isTablePresent(table)) {
if (isUpdateNeeded()) {
String dbVersion = getSchemaVersion();
String compareWithVersion = null;
if (dbVersion == null) {
......@@ -91,6 +91,10 @@ public abstract class ServiceSqlScriptBasedDbSchemaManager extends AbstractSqlSc
}
return feedback;
}
protected boolean isUpdateNeeded() {
return isTablePresent(table);
}
protected boolean isHistoryUsed() {
return getDbSqlSession().getDbSqlSessionFactory().isDbHistoryUsed() && schemaComponentHistory != null;
......
......@@ -151,7 +151,6 @@ public abstract class AbstractEngineConfigurator implements ProcessEngineConfigu
protected void initialiseCommonProperties(ProcessEngineConfigurationImpl processEngineConfiguration, AbstractEngineConfiguration targetEngineConfiguration) {
initEngineConfigurations(processEngineConfiguration, targetEngineConfiguration);
initServiceConfigurations(processEngineConfiguration, targetEngineConfiguration);
initCommandContextFactory(processEngineConfiguration, targetEngineConfiguration);
initIdGenerator(processEngineConfiguration, targetEngineConfiguration);
......@@ -171,7 +170,12 @@ public abstract class AbstractEngineConfigurator implements ProcessEngineConfigu
}
protected void initServiceConfigurations(ProcessEngineConfigurationImpl processEngineConfiguration, AbstractEngineConfiguration targetEngineConfiguration) {
targetEngineConfiguration.setServiceConfigurations(processEngineConfiguration.getServiceConfigurations());
for (String serviceConfigurationKey : processEngineConfiguration.getServiceConfigurations().keySet()) {
if (targetEngineConfiguration.getServiceConfigurations() == null
|| !targetEngineConfiguration.getServiceConfigurations().containsKey(serviceConfigurationKey)) {
targetEngineConfiguration.addServiceConfiguration(serviceConfigurationKey, processEngineConfiguration.getServiceConfigurations().get(serviceConfigurationKey));
}
}
}
protected void initCommandContextFactory(ProcessEngineConfigurationImpl processEngineConfiguration, AbstractEngineConfiguration targetEngineConfiguration) {
......
......@@ -73,6 +73,8 @@ public class IdmEngineConfigurator extends AbstractEngineConfigurator {
initialiseCommonProperties(processEngineConfiguration, idmEngineConfiguration);
idmEngineConfiguration.buildIdmEngine();
initServiceConfigurations(processEngineConfiguration, idmEngineConfiguration);
}
@Override
......
......@@ -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" />
......
alter table ACT_HI_VARINST add column CALLBACK_ID_ varchar(255);
alter table ACT_HI_VARINST add column CALLBACK_TYPE_ varchar(255);
\ No newline at end of file
alter table ACT_HI_PROCINST add column CALLBACK_ID_ varchar(255);
alter table ACT_HI_PROCINST add column CALLBACK_TYPE_ varchar(255);
\ No newline at end of file
......@@ -79,6 +79,8 @@ public class FormEngineConfigurator extends AbstractEngineConfigurator {
initialiseCommonProperties(processEngineConfiguration, formEngineConfiguration);
initFormEngine();
initServiceConfigurations(processEngineConfiguration, formEngineConfiguration);
}
@Override
......
......@@ -36,6 +36,8 @@ public class SpringFormEngineConfigurator extends FormEngineConfigurator {
formEngineConfiguration.setTransactionManager(((SpringProcessEngineConfiguration) processEngineConfiguration).getTransactionManager());
initFormEngine();
initServiceConfigurations(processEngineConfiguration, formEngineConfiguration);
}
@Override
......
......@@ -46,7 +46,7 @@ public class IdmDbSchemaManager extends ServiceSqlScriptBasedDbSchemaManager {
@Override
protected String getUpgradeStartVersion() {
return "59900";
return "5.99.0.0";
}
@Override
......@@ -60,6 +60,15 @@ public class IdmDbSchemaManager extends ServiceSqlScriptBasedDbSchemaManager {
}
}
@Override
protected boolean isUpdateNeeded() {
boolean propertyTablePresent = isTablePresent(IDM_PROPERTY_TABLE);
if (!propertyTablePresent) {
return isIdmGroupTablePresent();
}
return true;
}
public boolean isIdmGroupTablePresent() {
return isTablePresent("ACT_ID_GROUP");
}
......
......@@ -34,6 +34,8 @@ public class SpringIdmEngineConfigurator extends IdmEngineConfigurator {
idmEngineConfiguration.setTransactionManager(((SpringProcessEngineConfiguration) processEngineConfiguration).getTransactionManager());
idmEngineConfiguration.buildIdmEngine();
initServiceConfigurations(processEngineConfiguration, idmEngineConfiguration);
}
@Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册