提交 aba85cb9 编写于 作者: T tombaeyens

ACT-60 switching back from activity instances to executions: persistence mappings

上级 32e634c1
......@@ -34,7 +34,7 @@ public class BoundaryTimerEventTest extends ProcessEngineTestCase {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("interruptingBoundaryTimer");
// There should be one task, with a timer : first line support
Task task = taskService.createTaskQuery().processInstance(pi.getId()).singleResult();
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
assertEquals("First line support", task.getName());
// Set clock to the future such that the timer can fire
......@@ -42,7 +42,7 @@ public class BoundaryTimerEventTest extends ProcessEngineTestCase {
waitForJobExecutorToProcessAllJobs(10000L, 250L);
// The timer has fired, and the second task (secondlinesupport) now exists
task = taskService.createTaskQuery().processInstance(pi.getId()).singleResult();
task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
assertEquals("Second line support", task.getName());
}
......
......@@ -31,14 +31,14 @@ public class UelExpressionTest extends ProcessEngineTestCase {
UelExpressionTestOrder order = new UelExpressionTestOrder(150);
ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("uelExpressions",
CollectionUtil.singletonMap("order", order));
Task task = taskService.createTaskQuery().processInstance(processInstance.getId()).singleResult();
Task task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertEquals("Standard service", task.getName());
// While an order of 300, gives us a premium service (goes through an UEL method expression)
order = new UelExpressionTestOrder(300);
processInstance = runtimeService.startProcessInstanceByKey("uelExpressions",
CollectionUtil.singletonMap("order", order));
task = taskService.createTaskQuery().processInstance(processInstance.getId()).singleResult();
task = taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult();
assertEquals("Premium service", task.getName());
}
......
......@@ -41,19 +41,19 @@ public class ExclusiveGatewayTest extends ProcessEngineTestCase {
// Test with input == 1
variables.put("input", 1);
ProcessInstance pi = runtimeService.startProcessInstanceByKey("exclusiveGateway", variables);
Task task = taskService.createTaskQuery().processInstance(pi.getId()).singleResult();
Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
assertEquals("Send e-mail for more information", task.getName());
// Test with input == 2
variables.put("input", 2);
pi = runtimeService.startProcessInstanceByKey("exclusiveGateway", variables);
task = taskService.createTaskQuery().processInstance(pi.getId()).singleResult();
task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
assertEquals("Check account balance", task.getName());
// Test with input == 3
variables.put("input", 3);
pi = runtimeService.startProcessInstanceByKey("exclusiveGateway", variables);
task = taskService.createTaskQuery().processInstance(pi.getId()).singleResult();
task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
assertEquals("Call customer", task.getName());
// Test with input == 4
......
......@@ -32,7 +32,7 @@ public class ParallelGatewayTest extends ProcessEngineTestCase {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("forkJoin");
TaskQuery query = taskService
.createTaskQuery()
.processInstance(pi.getId())
.processInstanceId(pi.getId())
.orderAsc(TaskQuery.PROPERTY_NAME);
List<Task> tasks = query.list();
......@@ -57,7 +57,7 @@ public class ParallelGatewayTest extends ProcessEngineTestCase {
ProcessInstance pi = runtimeService.startProcessInstanceByKey("UnbalancedForkJoin");
TaskQuery query = taskService.createTaskQuery()
.processInstance(pi.getId())
.processInstanceId(pi.getId())
.orderAsc(TaskQuery.PROPERTY_NAME);
List<Task> tasks = query.list();
......
......@@ -37,7 +37,7 @@ public class SubProcessTest extends ProcessEngineTestCase {
// After staring the process, both tasks in the subprocess should be active
ProcessInstance pi = runtimeService.startProcessInstanceByKey("fixSystemFailure");
List<Task> tasks = taskService.createTaskQuery()
.processInstance(pi.getId())
.processInstanceId(pi.getId())
.orderAsc(TaskQuery.PROPERTY_NAME)
.list();
......@@ -50,7 +50,7 @@ public class SubProcessTest extends ProcessEngineTestCase {
// Completing boith the tasks finishes the subprocess and enables the task after the subprocess
taskService.complete(investigateHardwareTask.getId());
taskService.complete(investigateSoftwareTask.getId());
Task writeReportTask = taskService.createTaskQuery().processInstance(pi.getId()).singleResult();
Task writeReportTask = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
assertEquals("Write report", writeReportTask.getName());
// Clean up
......
......@@ -32,7 +32,9 @@ public interface TaskQuery {
TaskQuery candidateGroup(String candidateGroup);
TaskQuery processInstance(String processInstanceId);
TaskQuery processInstanceId(String processInstanceId);
TaskQuery executionId(String executionId);
TaskQuery orderAsc(String property);
......
......@@ -42,25 +42,30 @@ public class TaskQueryImpl extends AbstractQuery<Task> implements TaskQuery {
protected String processInstanceId;
protected String executionId;
protected String sortColumn;
protected SortOrder sortOrder;
public TaskQueryImpl() {
}
public TaskQueryImpl(CommandExecutor commandExecutor) {
super(commandExecutor);
}
public TaskQuery name(String name) {
public TaskQueryImpl name(String name) {
this.name = name;
return this;
}
public TaskQuery assignee(String assignee) {
public TaskQueryImpl assignee(String assignee) {
this.assignee = assignee;
return this;
}
public TaskQuery candidateUser(String candidateUser) {
public TaskQueryImpl candidateUser(String candidateUser) {
if (candidateGroup != null) {
throw new ActivitiException("Invalid query usage: cannot set both candidateUser and candidateGroup");
}
......@@ -68,7 +73,7 @@ public class TaskQueryImpl extends AbstractQuery<Task> implements TaskQuery {
return this;
}
public TaskQuery candidateGroup(String candidateGroup) {
public TaskQueryImpl candidateGroup(String candidateGroup) {
if (candidateUser != null) {
throw new ActivitiException("Invalid query usage: cannot set both candidateUser and candidateGroup");
}
......@@ -76,12 +81,17 @@ public class TaskQueryImpl extends AbstractQuery<Task> implements TaskQuery {
return this;
}
public TaskQuery processInstance(String processInstanceId) {
public TaskQueryImpl processInstanceId(String processInstanceId) {
this.processInstanceId = processInstanceId;
return this;
}
public TaskQuery orderAsc(String column) {
public TaskQueryImpl executionId(String executionId) {
this.executionId = executionId;
return this;
}
public TaskQueryImpl orderAsc(String column) {
if (sortColumn != null) {
throw new ActivitiException("Invalid usage: cannot use both orderAsc and orderDesc in same query");
}
......@@ -90,7 +100,7 @@ public class TaskQueryImpl extends AbstractQuery<Task> implements TaskQuery {
return this;
}
public TaskQuery orderDesc(String column) {
public TaskQueryImpl orderDesc(String column) {
if (sortColumn != null) {
throw new ActivitiException("Invalid usage: cannot use both orderAsc and orderDesc in same query");
}
......
......@@ -51,7 +51,7 @@ public class DbTaskSession implements TaskSession, Session {
@SuppressWarnings("unchecked")
public List<TaskEntity> findTasksByExecutionId(String executionId) {
return dbSqlSession.selectList("selectTaskByExecution", executionId);
return dbSqlSession.selectList("selectTasksByExecutionId", executionId);
}
@SuppressWarnings("unchecked")
......
......@@ -22,6 +22,7 @@ import javax.el.ELContext;
import org.activiti.engine.Execution;
import org.activiti.engine.ProcessInstance;
import org.activiti.engine.impl.TaskQueryImpl;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.PersistentObject;
import org.activiti.engine.impl.persistence.repository.ProcessDefinitionEntity;
......@@ -256,21 +257,22 @@ public class ExecutionEntity extends ExecutionImpl implements PersistentObject,
// customized persistence behaviour /////////////////////////////////////////
@SuppressWarnings("unchecked")
@Override
public void end() {
super.end();
ensureVariablesInitialized();
// delete all the variable instances
variables.clear();
// TODO add cancellation of timers
List<TaskEntity> tasks = CommandContext
.getCurrent()
.getTaskSession()
.findTasksByExecutionId(id);
// delete all the tasks
List<TaskEntity> tasks = (List) new TaskQueryImpl()
.executionId(id)
.executeList(CommandContext.getCurrent(), null);
for (TaskEntity task : tasks) {
task.delete();
}
......
......@@ -56,15 +56,15 @@ public class VariableInstanceEntity implements Serializable, PersistentObject {
public static VariableInstanceEntity createAndInsert(String name, Type type, Object value) {
VariableInstanceEntity variableInstance = new VariableInstanceEntity();
variableInstance.name = name;
variableInstance.type = type;
variableInstance.setValue(value);
CommandContext
.getCurrent()
.getDbSqlSession()
.insert(variableInstance);
variableInstance.name = name;
variableInstance.type = type;
variableInstance.setValue(value);
return variableInstance;
}
......
......@@ -66,6 +66,7 @@ public class ProcessEngineTestCase extends PvmTestCase {
protected ThreadLogMode threadRenderingMode;
protected String configurationResource;
protected List<String> deploymentsToDeleteAfterTestMethod = new ArrayList<String>();
protected Throwable exception;
protected ProcessEngine processEngine;
protected RepositoryService repositoryService;
......@@ -131,11 +132,13 @@ public class ProcessEngineTestCase extends PvmTestCase {
} catch (AssertionFailedError e) {
log.severe(EMPTY_LINE);
log.log(Level.SEVERE, "ASSERTION FAILED: "+e, e);
exception = e;
throw e;
} catch (Throwable e) {
log.severe(EMPTY_LINE);
log.log(Level.SEVERE, "EXCEPTION: "+e, e);
exception = e;
throw e;
} finally {
......@@ -148,8 +151,8 @@ public class ProcessEngineTestCase extends PvmTestCase {
/** Each test is assumed to clean up all DB content it entered.
* After a test method executed, this method scans all tables to see if the DB is completely clean.
* It throws AssertionFailed in case the DB is not clean.
* If the DB is not clean, it is cleaned by performing a create a drop. */
protected void assertAndEnsureCleanDb() {
* If the DB is not clean, it is cleaned by performing a create a drop. */
protected void assertAndEnsureCleanDb() throws Throwable {
log.fine("verifying that db is clean after test");
Map<String, Long> tableCounts = processEngine.getManagementService().getTableCount();
StringBuilder outputMessage = new StringBuilder();
......@@ -168,13 +171,15 @@ public class ProcessEngineTestCase extends PvmTestCase {
log.info("dropping and recreating db");
DbSqlSessionFactory dbSqlSessionFactory = ((ProcessEngineImpl)processEngine)
.getProcessEngineConfiguration()
.getDbSqlSessionFactory();
dbSqlSessionFactory.dbSchemaDrop();
dbSqlSessionFactory.dbSchemaCreate();
Assert.fail(outputMessage.toString());
processEngine.close();
processEngine = null;
processEngines.remove(configurationResource);
if (exception!=null) {
throw exception;
} else {
Assert.fail(outputMessage.toString());
}
}
}
......
......@@ -4,7 +4,37 @@
<mapper namespace="org.activiti.persistence">
<!-- RESULTMAP -->
<!-- USER INSERT -->
<insert id="insertUser" parameterType="org.activiti.engine.impl.persistence.identity.UserEntity">
insert into ACT_ID_USER (ID_, FIRST_, LAST_, EMAIL_, PWD_)
values (
#{id ,jdbcType=VARCHAR},
#{firstName ,jdbcType=VARCHAR},
#{lastName ,jdbcType=VARCHAR},
#{email ,jdbcType=VARCHAR},
#{password ,jdbcType=VARCHAR}
)
</insert>
<!-- USER UPDATE -->
<update id="updateUser" parameterType="org.activiti.engine.impl.persistence.identity.UserEntity">
update ACT_ID_USER set
FIRST_ = #{firstName ,jdbcType=VARCHAR},
LAST_ = #{lastName ,jdbcType=VARCHAR},
EMAIL_ = #{email ,jdbcType=VARCHAR},
PWD_ = #{password ,jdbcType=VARCHAR}
where ID_ = #{id}
</update>
<!-- USER DELETE -->
<delete id="deleteUser" parameterType="string">
delete from ACT_ID_USER where ID_ = #{userId}
</delete>
<!-- USER RESULTMAP -->
<resultMap id="userResultMap" type="org.activiti.engine.impl.persistence.identity.UserEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
......@@ -14,15 +44,8 @@
<result property="password" column="PWD_" jdbcType="VARCHAR" />
</resultMap>
<resultMap id="groupResultMap" type="org.activiti.engine.impl.persistence.identity.GroupEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="name" column="NAME_" jdbcType="VARCHAR" />
<result property="type" column="TYPE_" jdbcType="VARCHAR" />
</resultMap>
<!-- USER SELECT -->
<!-- SELECT -->
<select id="selectUser" parameterType="string" resultMap="userResultMap">
select * from ACT_ID_USER where ID_ = #{id}
</select>
......@@ -38,6 +61,43 @@
and membership.GROUP_ID_ = #{groupId}
</select>
<!-- GROUP INSERT -->
<insert id="insertGroup" parameterType="org.activiti.engine.impl.persistence.identity.GroupEntity">
insert into ACT_ID_GROUP (ID_, NAME_, TYPE_)
values (
#{id ,jdbcType=VARCHAR},
#{name ,jdbcType=VARCHAR},
#{type ,jdbcType=VARCHAR}
)
</insert>
<!-- GROUP UPDATE -->
<update id="updateGroup" parameterType="org.activiti.engine.impl.persistence.identity.GroupEntity">
update ACT_ID_GROUP set
NAME_ = #{name ,jdbcType=VARCHAR},
TYPE_ = #{type ,jdbcType=VARCHAR}
where ID_ = #{id}
</update>
<!-- GROUP DELETE -->
<delete id="deleteGroup" parameterType="string">
delete from ACT_ID_GROUP where ID_ = #{groupId}
</delete>
<!-- GROUP RESULTMAP -->
<resultMap id="groupResultMap" type="org.activiti.engine.impl.persistence.identity.GroupEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="name" column="NAME_" jdbcType="VARCHAR" />
<result property="type" column="TYPE_" jdbcType="VARCHAR" />
</resultMap>
<!-- GROUP SELECT -->
<select id="selectGroup" parameterType="string" resultMap="groupResultMap">
select * from ACT_ID_GROUP where ID_ = #{id}
</select>
......@@ -61,29 +121,9 @@
and g.TYPE_ = #{groupType}
</select>
<!-- INSERT -->
<insert id="insertUser" parameterType="org.activiti.engine.impl.persistence.identity.UserEntity">
insert into ACT_ID_USER (ID_, FIRST_, LAST_, EMAIL_, PWD_)
values (
#{id ,jdbcType=VARCHAR},
#{firstName ,jdbcType=VARCHAR},
#{lastName ,jdbcType=VARCHAR},
#{email ,jdbcType=VARCHAR},
#{password ,jdbcType=VARCHAR}
)
</insert>
<insert id="insertGroup" parameterType="org.activiti.engine.impl.persistence.identity.GroupEntity">
insert into ACT_ID_GROUP (ID_, NAME_, TYPE_)
values (
#{id ,jdbcType=VARCHAR},
#{name ,jdbcType=VARCHAR},
#{type ,jdbcType=VARCHAR}
)
</insert>
<!-- MEMBERSHIP INSERT -->
<insert id="insertMembership" parameterType="map">
insert into ACT_ID_MEMBERSHIP (USER_ID_, GROUP_ID_)
values (
......@@ -92,40 +132,9 @@
)
</insert>
<!-- MEMBERSHIP UPDATE -->
<!-- UPDATE -->
<update id="updateUser" parameterType="org.activiti.engine.impl.persistence.identity.UserEntity">
update ACT_ID_USER set
FIRST_ = #{firstName ,jdbcType=VARCHAR},
LAST_ = #{lastName ,jdbcType=VARCHAR},
EMAIL_ = #{email ,jdbcType=VARCHAR},
PWD_ = #{password ,jdbcType=VARCHAR}
where ID_ = #{id}
</update>
<update id="updateGroup" parameterType="org.activiti.engine.impl.persistence.identity.GroupEntity">
update ACT_ID_GROUP set
NAME_ = #{name ,jdbcType=VARCHAR},
TYPE_ = #{type ,jdbcType=VARCHAR}
where ID_ = #{id}
</update>
<!-- DELETE -->
<delete id="deleteUser" parameterType="string">
delete from ACT_ID_USER where ID_ = #{userId}
</delete>
<delete id="deleteGroup" parameterType="string">
delete from ACT_ID_GROUP where ID_ = #{groupId}
</delete>
<delete id="deleteMembershipsForGroup" parameterType="string">
delete from ACT_ID_MEMBERSHIP
where GROUP_ID_ = #{groupId}
</delete>
<!-- MEMBERSHIP DELETE -->
<delete id="deleteMembershipsForUser" parameterType="string">
delete from ACT_ID_MEMBERSHIP
......@@ -137,5 +146,14 @@
where USER_ID_ = #{userId}
and GROUP_ID_ = #{groupId}
</delete>
<!-- MEMBERSHIP RESULTMAP -->
<!-- MEMBERSHIP SELECT -->
<delete id="deleteMembershipsForGroup" parameterType="string">
delete from ACT_ID_MEMBERSHIP
where GROUP_ID_ = #{groupId}
</delete>
</mapper>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.activiti.persistence">
</mapper>
\ No newline at end of file
......@@ -4,23 +4,31 @@
<mapper namespace="org.activiti.persistence">
<!-- DEPLOYMENT -->
<!-- DEPLOYMENT INSERT -->
<insert id="insertDeployment" parameterType="org.activiti.engine.impl.persistence.repository.DeploymentEntity">
insert into ACT_DEPLOYMENT(ID_, NAME_, DEPLOY_TIME_)
values(#{id, jdbcType=VARCHAR}, #{name, jdbcType=VARCHAR}, #{deploymentTime, jdbcType=TIMESTAMP})
</insert>
<!-- DEPLOYMENT UPDATE -->
<!-- DEPLOYMENT DELETE -->
<delete id="deleteDeployment" parameterType="string">
delete from ACT_DEPLOYMENT where ID_ = #{id}
</delete>
<!-- DEPLOYMENT RESULTMAP -->
<resultMap id="deploymentResultMap" type="org.activiti.engine.impl.persistence.repository.DeploymentEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="name" column="NAME_" jdbcType="VARCHAR" />
<result property="deploymentTime" column="DEPLOY_TIME_" jdbcType="TIMESTAMP"/>
</resultMap>
<!-- DEPLOYMENT SELECT -->
<select id="selectDeployments" resultMap="deploymentResultMap">
select * from ACT_DEPLOYMENT D order by D.DEPLOY_TIME_ asc
</select>
......@@ -39,23 +47,31 @@
(select P.DEPLOYMENT_ID_ from ACT_PROCESSDEFINITION P where P.ID_ = #{processDefinitionId})
</select>
<!-- RESOURCE -->
<!-- RESOURCE INSERT -->
<insert id="insertResource" parameterType="org.activiti.engine.impl.persistence.repository.ResourceEntity">
insert into ACT_BYTEARRAY(ID_, NAME_, BYTES_, DEPLOYMENT_ID_)
values (#{id, jdbcType=VARCHAR}, #{name, jdbcType=VARCHAR}, #{bytes, jdbcType=BLOB}, #{deploymentId, jdbcType=VARCHAR})
</insert>
<!-- RESOURCE UPDATE -->
<!-- RESOURCE DELETE -->
<delete id="deleteResourcesByDeploymentId" parameterType="string">
delete from ACT_BYTEARRAY where DEPLOYMENT_ID_ = #{id}
</delete>
<!-- RESOURCE RESULTMAP -->
<resultMap id="resourceResultMap" type="org.activiti.engine.impl.persistence.repository.ResourceEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="name" column="NAME_" jdbcType="VARCHAR"/>
<result property="bytes" column="BYTES_" jdbcType="BLOB"/>
</resultMap>
<!-- RESOURCE SELECT -->
<select id="selectResourceNamesByDeploymentId" parameterType="string" resultType="string">
select NAME_ from ACT_BYTEARRAY where DEPLOYMENT_ID_ = #{deploymentId} order by NAME_ asc
</select>
......@@ -70,8 +86,8 @@
select * from ACT_BYTEARRAY where DEPLOYMENT_ID_ = #{deploymentId} order by NAME_ asc
</select>
<!-- PROCESSDEFINITION -->
<!-- PROCESSDEFINITION INSERT -->
<insert id="insertProcessDefinition" parameterType="org.activiti.engine.impl.persistence.repository.ProcessDefinitionEntity">
insert into ACT_PROCESSDEFINITION(ID_, NAME_, KEY_, VERSION_, DEPLOYMENT_ID_)
......@@ -82,10 +98,16 @@
#{deploymentId, jdbcType=VARCHAR})
</insert>
<!-- PROCESSDEFINITION UPDATE -->
<!-- PROCESSDEFINITION DELETE -->
<delete id="deleteProcessDefinitionsByDeploymentId" parameterType="string">
delete from ACT_PROCESSDEFINITION where DEPLOYMENT_ID_ = #{deploymenId}
</delete>
<!-- PROCESSDEFINITION RESULTMAP -->
<resultMap id="processDefinitionResultMap" type="org.activiti.engine.impl.persistence.repository.ProcessDefinitionEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="name" column="NAME_" />
......@@ -94,6 +116,8 @@
<result property="deploymentId" column="DEPLOYMENT_ID_" jdbcType="VARCHAR"/>
</resultMap>
<!-- PROCESSDEFINITION SELECT -->
<select id="selectProcessDefinitions" resultMap="processDefinitionResultMap">
select * from ACT_PROCESSDEFINITION
order by KEY_ ASC, VERSION_ DESC
......
......@@ -37,11 +37,13 @@
</update>
<!-- EXECUTION DELETE -->
<delete id="deleteExecution" parameterType="string">
delete from ACT_EXECUTION where ID_ = #{id}
</delete>
<!-- EXECUTION RESULTMAP -->
<resultMap id="executionResultMap" type="org.activiti.engine.impl.persistence.runtime.ExecutionEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="processInstanceId" column="PROC_INST_ID_" jdbcType="VARCHAR" />
......@@ -54,13 +56,13 @@
<result property="superExecutionId" column="SUPER_EXEC_" jdbcType="VARCHAR" />
</resultMap>
<!-- EXECUTION SELECTS -->
<!-- EXECUTION SELECT -->
<select id="selectExecutionById" parameterType="string" resultMap="executionResultMap">
select * from ACT_EXECUTION where ID_ = #{id}
</select>
<select id="selectChildExecutionsByParentExecutionId" parameterType="string" resultMap="executionResultMap">
<select id="selectExecutionsByParentExecutionId" parameterType="string" resultMap="executionResultMap">
select * from ACT_EXECUTION
where PARENT_ID_ = #{parentExecutionId}
</select>
......
......@@ -4,11 +4,12 @@
<mapper namespace="org.activiti.persistence">
<!-- RESULTMAP -->
<!-- TASK INSERT -->
<insert id="insertTask" parameterType="org.activiti.engine.impl.persistence.task.TaskEntity">
insert into ACT_TASK (ID_, NAME_, DESCRIPTION_, PRIORITY_, CREATE_TIME_, SKIPPABLE_,
START_DEADLINE_, COMPLETION_DEADLINE_, ASSIGNEE_,
ACT_INST_ID_, PROC_INST_ID_, PROC_DEF_ID_)
EXECUTION_ID_, PROC_INST_ID_, PROC_DEF_ID_)
values (#{id, jdbcType=VARCHAR},
#{name, jdbcType=VARCHAR},
#{description, jdbcType=VARCHAR},
......@@ -18,12 +19,14 @@
#{startDeadline, jdbcType=TIMESTAMP},
#{completionDeadline, jdbcType=TIMESTAMP},
#{assignee, jdbcType=VARCHAR},
#{activityInstanceId, jdbcType=VARCHAR},
#{executionId, jdbcType=VARCHAR},
#{processInstanceId, jdbcType=VARCHAR},
#{processDefinitionId, jdbcType=VARCHAR}
)
</insert>
<!-- TASK UPDATE -->
<update id="updateTask" parameterType="org.activiti.engine.impl.persistence.task.TaskEntity">
update ACT_TASK
<set>
......@@ -34,13 +37,14 @@
START_DEADLINE_ = #{startDeadline, jdbcType=TIMESTAMP},
COMPLETION_DEADLINE_ = #{completionDeadline, jdbcType=TIMESTAMP},
ASSIGNEE_ = #{assignee, jdbcType=VARCHAR},
ACT_INST_ID_ = #{activityInstanceId, jdbcType=VARCHAR},
EXECUTION_ID_ = #{executionId, jdbcType=VARCHAR},
PROC_INST_ID_ = #{processInstanceId, jdbcType=VARCHAR},
PROC_DEF_ID_ = #{processDefinitionId, jdbcType=VARCHAR}
</set>
where ID_= #{id, jdbcType=VARCHAR}
</update>
<!-- TASK DELETE -->
<delete id="deleteTask" parameterType="string">
delete from ACT_TASK where ID_ = #{id}
</delete>
......@@ -49,6 +53,24 @@
select * from ACT_TASK where ID_ = #{id}
</select>
<!-- TASK RESULTMAP -->
<resultMap id="taskResultMap" type="org.activiti.engine.impl.persistence.task.TaskEntity">
<id property="id" column="ID_" jdbcType="VARCHAR"/>
<result property="name" column="NAME_" jdbcType="VARCHAR"/>
<result property="description" column="DESCRIPTION_" jdbcType="VARCHAR"/>
<result property="priority" column="PRIORITY_" jdbcType="INTEGER"/>
<result property="createTime" column="CREATE_TIME_" jdbcType="TIMESTAMP" />
<result property="startDeadline" column="START_DEADLINE_" jdbcType="TIMESTAMP" />
<result property="completionDeadline" column="COMPLETION_DEADLINE_" jdbcType="TIMESTAMP" />
<result property="skippable" column="SKIPPABLE_" jdbcType="BOOLEAN"/>
<result property="assignee" column="ASSIGNEE_" jdbcType="VARCHAR"/>
<result property="executionId" column="EXECUTION_ID_" jdbcType="VARCHAR" />
<result property="processDefinitionId" column="PROC_DEF_ID_" jdbcType="VARCHAR"/>
</resultMap>
<!-- TASK SELECT -->
<select id="selectCandidateTasks" parameterType="map" resultMap="taskResultMap">
select T.* from ACT_TASK T inner join ACT_TASKINVOLVEMENT I ON T.ID_ = I.TASK_ID_
where T.ASSIGNEE_ IS NULL
......@@ -104,6 +126,9 @@
<if test="processInstanceId != null">
and T.PROC_INST_ID_ = #{processInstanceId}
</if>
<if test="executionId != null">
and T.EXECUTION_ID_ = #{executionId}
</if>
<if test="candidateUser != null || candidateGroups != null">
and T.ASSIGNEE_ is null
and I.TYPE_ = 'candidate'
......@@ -138,21 +163,7 @@
</if>
</select>
<resultMap id="taskResultMap" type="org.activiti.engine.impl.persistence.task.TaskEntity">
<id property="id" column="ID_" jdbcType="VARCHAR"/>
<result property="name" column="NAME_" jdbcType="VARCHAR"/>
<result property="description" column="DESCRIPTION_" jdbcType="VARCHAR"/>
<result property="priority" column="PRIORITY_" jdbcType="INTEGER"/>
<result property="createTime" column="CREATE_TIME_" jdbcType="TIMESTAMP" />
<result property="startDeadline" column="START_DEADLINE_" jdbcType="TIMESTAMP" />
<result property="completionDeadline" column="COMPLETION_DEADLINE_" jdbcType="TIMESTAMP" />
<result property="skippable" column="SKIPPABLE_" jdbcType="BOOLEAN"/>
<result property="assignee" column="ASSIGNEE_" jdbcType="VARCHAR"/>
<result property="activityInstanceId" column="ACT_INST_ID_" jdbcType="VARCHAR" />
<result property="processDefinitionId" column="PROC_DEF_ID_" jdbcType="VARCHAR"/>
</resultMap>
<!-- TASK INVOLVEMENT -->
<!-- INSERT TASK INVOLVEMENT -->
<insert id="insertTaskInvolvement" parameterType="org.activiti.engine.impl.persistence.task.TaskInvolvementEntity">
insert into ACT_TASKINVOLVEMENT (ID_, TYPE_, USER_ID_, GROUP_ID_, TASK_ID_)
......@@ -163,6 +174,8 @@
#{taskId, jdbcType=VARCHAR})
</insert>
<!-- TASK INVOLVEMENT INSERT -->
<update id="updateTaskInvolvement" parameterType="org.activiti.engine.impl.persistence.task.TaskInvolvementEntity">
update ACT_TASKINVOLVEMENT
<set>
......@@ -173,18 +186,14 @@
</set>
where ID_ = #{id, jdbcType=VARCHAR}
</update>
<!-- TASK INVOLVEMENT DELETE -->
<delete id="deleteTaskInvolvement" parameterType="string">
delete from ACT_TASKINVOLVEMENT where ID_ = #{id}
</delete>
<select id="selectTaskInvolvement" parameterType="string" resultMap="taskInvolvementResultMap">
select * from ACT_TASKINVOLVEMENT where ID_ = #{id}
</select>
<select id="selectTaskInvolvementsByTask" parameterType="string" resultMap="taskInvolvementResultMap">
select * from ACT_TASKINVOLVEMENT where TASK_ID_ = #{taskId}
</select>
<!-- TASK INVOLVEMENT RESULTMAP -->
<resultMap id="taskInvolvementResultMap" type="org.activiti.engine.impl.persistence.task.TaskInvolvementEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
......@@ -194,4 +203,14 @@
<result property="taskId" column="TASK_ID_" jdbcType="VARCHAR" />
</resultMap>
<!-- TASK INVOLVEMENT SELECT -->
<select id="selectTaskInvolvement" parameterType="string" resultMap="taskInvolvementResultMap">
select * from ACT_TASKINVOLVEMENT where ID_ = #{id}
</select>
<select id="selectTaskInvolvementsByTask" parameterType="string" resultMap="taskInvolvementResultMap">
select * from ACT_TASKINVOLVEMENT where TASK_ID_ = #{taskId}
</select>
</mapper>
\ No newline at end of file
......@@ -4,7 +4,49 @@
<mapper namespace="org.activiti.persistence">
<!-- RESULTMAP -->
<!-- VARIABLE INSTANCE INSERT -->
<insert id="insertVariableInstance" parameterType="org.activiti.engine.impl.persistence.runtime.VariableInstanceEntity">
insert into ACT_VARIABLE (ID_, REV_, TYPE_, NAME_,
EXECUTION_ID_, TASK_ID_,
BYTEARRAY_ID_, DOUBLE_, LONG_ , TEXT_)
values (
#{id, jdbcType=VARCHAR},
#{revision,
jdbcType=INTEGER},
#{type, jdbcType=VARCHAR },
#{name, jdbcType=VARCHAR},
#{executionId, jdbcType=VARCHAR},
#{taskId,
jdbcType=VARCHAR},
#{byteArrayValueId, jdbcType=VARCHAR},
#{doubleValue, jdbcType=DOUBLE},
#{longValue, jdbcType=BIGINT},
#{textValue, jdbcType=VARCHAR}
)
</insert>
<!-- VARIABLE INSTANCE UPDATE -->
<update id="updateVariableInstance" parameterType="org.activiti.engine.impl.persistence.runtime.VariableInstanceEntity">
update ACT_VARIABLE
set BYTEARRAY_ID_ = #{byteArrayValueId,
jdbcType=VARCHAR},
DOUBLE_ = #{doubleValue, jdbcType=DOUBLE},
LONG_ = #{longValue, jdbcType=BIGINT},
TEXT_ = #{textValue,
jdbcType=VARCHAR}
where ID_ = #{id, jdbcType=VARCHAR}
and REV_ = #{revision, jdbcType=INTEGER}
</update>
<!-- VARIABLE INSTANCE DELETE -->
<delete id="deleteVariableInstance" parameterType="string">
delete from ACT_VARIABLE where ID_ = #{id, jdbcType=VARCHAR}
</delete>
<!-- VARIABLE INSTANCE RESULTMAP -->
<resultMap id="variableInstanceResultMap" type="org.activiti.engine.impl.persistence.runtime.VariableInstanceEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
......@@ -20,7 +62,7 @@
<result property="longValue" column="LONG_" />
</resultMap>
<!-- SELECT -->
<!-- VARIABLE INSTANCE SELECT -->
<select id="selectVariableInstance" parameterType="string" resultMap="variableInstanceResultMap">
select * from ACT_VARIABLE where ID_ =
......@@ -38,61 +80,16 @@
= #{executionId, jdbcType=VARCHAR}
</select>
<!-- INSERT -->
<insert id="insertVariableInstance" parameterType="org.activiti.engine.impl.persistence.runtime.VariableInstanceEntity">
insert into ACT_VARIABLE (ID_, REV_, TYPE_, NAME_,
EXECUTION_ID_, TASK_ID_,
BYTEARRAY_ID_, DOUBLE_, LONG_ , TEXT_)
values (
#{id, jdbcType=VARCHAR},
#{revision,
jdbcType=INTEGER},
#{type, jdbcType=VARCHAR },
#{name, jdbcType=VARCHAR},
#{executionId, jdbcType=VARCHAR},
#{taskId,
jdbcType=VARCHAR},
#{byteArrayValueId, jdbcType=VARCHAR},
#{doubleValue, jdbcType=DOUBLE},
#{longValue, jdbcType=BIGINT},
#{textValue, jdbcType=VARCHAR}
)
</insert>
<!-- UPDATE -->
<update id="updateVariableInstance" parameterType="org.activiti.engine.impl.persistence.runtime.VariableInstanceEntity">
update ACT_VARIABLE
set BYTEARRAY_ID_ = #{byteArrayValueId,
jdbcType=VARCHAR},
DOUBLE_ = #{doubleValue, jdbcType=DOUBLE},
LONG_ = #{longValue, jdbcType=BIGINT},
TEXT_ = #{textValue,
jdbcType=VARCHAR}
where ID_ = #{id, jdbcType=VARCHAR}
and REV_ = #{revision, jdbcType=INTEGER}
</update>
<!-- DELETE -->
<delete id="deleteVariableInstance" parameterType="string">
delete from ACT_VARIABLE where ID_ = #{id, jdbcType=VARCHAR}
</delete>
<!-- ByteArrayImpl -->
<resultMap id="byteArrayResultMap" type="org.activiti.engine.impl.persistence.runtime.ByteArrayEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="name" column="NAME_" jdbcType="VARCHAR"/>
<result property="bytes" column="BYTES_" jdbcType="BLOB"/>
</resultMap>
<!-- BYTE ARRAY INSERT -->
<insert id="insertByteArray" parameterType="org.activiti.engine.impl.persistence.runtime.ByteArrayEntity">
insert into ACT_BYTEARRAY(ID_, NAME_, BYTES_, DEPLOYMENT_ID_)
values (#{id, jdbcType=VARCHAR}, #{name, jdbcType=VARCHAR}, #{bytes, jdbcType=BLOB}, #{deploymentId, jdbcType=VARCHAR})
</insert>
<!-- BYTE ARRAY UPDATE -->
<update id="updateByteArray" parameterType="org.activiti.engine.impl.persistence.runtime.ByteArrayEntity">
update ACT_BYTEARRAY
set
......@@ -100,6 +97,8 @@
where ID_ = #{id}
</update>
<!-- BYTE ARRAY DELETE -->
<select id="selectBytesOfByteArray" parameterType="string" resultType="hashmap">
select BYTES_ from ACT_BYTEARRAY where ID_ = #{id}
</select>
......@@ -112,6 +111,16 @@
delete from ACT_BYTEARRAY where ID_ = #{id}
</delete>
<!-- BYTE ARRAY RESULTMAP -->
<resultMap id="byteArrayResultMap" type="org.activiti.engine.impl.persistence.runtime.ByteArrayEntity">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="name" column="NAME_" jdbcType="VARCHAR"/>
<result property="bytes" column="BYTES_" jdbcType="BLOB"/>
</resultMap>
<!-- BYTE ARRAY SELECT -->
<select id="selectByteArrayById" parameterType="string" resultMap="byteArrayResultMap">
select * from ACT_BYTEARRAY where ID_ = #{id}
</select>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册