Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.activiti.db.mapping.entity.TimerJob.xml Maven / Gradle / Ivy
<?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.engine.impl.persistence.entity.TimerJobEntityImpl">
<!-- TIMER JOB RESULTMAP -->
<resultMap id="jobResultMap" type="org.activiti.engine.impl.persistence.entity.TimerJobEntityImpl">
<id property="id" column="ID_" jdbcType="VARCHAR" />
<result property="revision" column="REV_" jdbcType="INTEGER" />
<result property="jobType" column="TYPE_" jdbcType="VARCHAR" />
<result property="lockOwner" column="LOCK_OWNER_" jdbcType="VARCHAR" />
<result property="lockExpirationTime" column="LOCK_EXP_TIME_" jdbcType="TIMESTAMP" />
<result property="exclusive" column="EXCLUSIVE_" jdbcType="BOOLEAN" />
<result property="executionId" column="EXECUTION_ID_" jdbcType="VARCHAR" />
<result property="processInstanceId" column="PROCESS_INSTANCE_ID_" jdbcType="VARCHAR" />
<result property="processDefinitionId" column="PROC_DEF_ID_" jdbcType="VARCHAR" />
<result property="retries" column="RETRIES_" jdbcType="INTEGER" />
<result property="exceptionByteArrayRef" column="EXCEPTION_STACK_ID_" typeHandler="ByteArrayRefTypeHandler" />
<result property="exceptionMessage" column="EXCEPTION_MSG_" jdbcType="VARCHAR" />
<result property="jobHandlerType" column="HANDLER_TYPE_" jdbcType="VARCHAR" />
<result property="jobHandlerConfiguration" column="HANDLER_CFG_" jdbcType="VARCHAR" />
<result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR" />
<result property="duedate" column="DUEDATE_" jdbcType="TIMESTAMP" />
<result property="repeat" column="REPEAT_" jdbcType="VARCHAR" />
</resultMap>
<!-- TIMER JOB SELECT -->
<select id="selectTimerJob" parameterType="string" resultMap="jobResultMap">
select * from ${prefix}ACT_RU_TIMER_JOB where ID_ = #{id, jdbcType=VARCHAR}
</select>
<select id="selectTimerJobByQueryCriteria" parameterType="org.activiti.engine.impl.TimerJobQueryImpl" resultMap="jobResultMap">
${limitBefore}
select RES.* ${limitBetween}
<include refid="selectTimerJobByQueryCriteriaSql" />
${orderBy}
${limitAfter}
</select>
<select id="selectTimerJobCountByQueryCriteria" parameterType="org.activiti.engine.impl.TimerJobQueryImpl" resultType="long">
select count(distinct RES.ID_)
<include refid="selectTimerJobByQueryCriteriaSql" />
</select>
<sql id="selectTimerJobByQueryCriteriaSql">
from ${prefix}ACT_RU_TIMER_JOB RES
<if test="executable">
LEFT OUTER JOIN ${prefix}ACT_RU_EXECUTION PI ON PI.ID_ = RES.PROCESS_INSTANCE_ID_
</if>
<where>
<if test="id != null">
RES.ID_ = #{id}
</if>
<if test="processInstanceId != null">
and RES.PROCESS_INSTANCE_ID_ = #{processInstanceId}
</if>
<if test="executionId != null">
and RES.EXECUTION_ID_ = #{executionId}
</if>
<if test="processDefinitionId != null">
and RES.PROC_DEF_ID_ = #{processDefinitionId}
</if>
<if test="executable">
and RES.DUEDATE_ <= #{now, jdbcType=TIMESTAMP}
</if>
<if test="duedateHigherThan != null">
and RES.DUEDATE_ > #{duedateHigherThan}
</if>
<if test="duedateLowerThan != null">
and RES.DUEDATE_ < #{duedateLowerThan}
</if>
<if test="duedateHigherThanOrEqual != null">
and RES.DUEDATE_ >= #{duedateHigherThanOrEqual}
</if>
<if test="duedateLowerThanOrEqual != null">
and RES.DUEDATE_ <= #{duedateLowerThanOrEqual}
</if>
<if test="withException">
and (RES.EXCEPTION_MSG_ is not null or RES.EXCEPTION_STACK_ID_ is not null)
</if>
<if test="exceptionMessage">
and RES.EXCEPTION_MSG_ = #{exceptionMessage}
</if>
<if test="tenantId != null">
and RES.TENANT_ID_ = #{tenantId}
</if>
<if test="tenantIdLike != null">
and RES.TENANT_ID_ like #{tenantIdLike}${wildcardEscapeClause}
</if>
<if test="withoutTenantId">
and (RES.TENANT_ID_ = '' or RES.TENANT_ID_ is null)
</if>
</where>
</sql>
<select id="selectTimerJobsToExecute" parameterType="org.activiti.engine.impl.db.ListQueryParameterObject" resultMap="jobResultMap">
${limitBefore}
select
RES.* ${limitBetween}
from ${prefix}ACT_RU_TIMER_JOB RES
where DUEDATE_ <= #{parameter, jdbcType=TIMESTAMP}
and LOCK_OWNER_ is null
${limitAfter}
</select>
<!-- TIMER INSERT -->
<insert id="insertTimerJob" parameterType="org.activiti.engine.impl.persistence.entity.TimerJobEntityImpl">
insert into ${prefix}ACT_RU_TIMER_JOB (
ID_,
REV_,
TYPE_,
EXCLUSIVE_,
EXECUTION_ID_,
PROCESS_INSTANCE_ID_,
PROC_DEF_ID_,
RETRIES_,
EXCEPTION_STACK_ID_,
EXCEPTION_MSG_,
DUEDATE_,
REPEAT_,
HANDLER_TYPE_,
HANDLER_CFG_,
TENANT_ID_)
values (#{id, jdbcType=VARCHAR},
#{revision, jdbcType=INTEGER},
#{jobType, jdbcType=VARCHAR},
#{exclusive, jdbcType=BOOLEAN},
#{executionId, jdbcType=VARCHAR},
#{processInstanceId, jdbcType=VARCHAR},
#{processDefinitionId, jdbcType=VARCHAR},
#{retries, jdbcType=INTEGER},
#{exceptionByteArrayRef, typeHandler=ByteArrayRefTypeHandler},
#{exceptionMessage, jdbcType=VARCHAR},
#{duedate, jdbcType=TIMESTAMP},
#{repeat, jdbcType=VARCHAR},
#{jobHandlerType, jdbcType=VARCHAR},
#{jobHandlerConfiguration, jdbcType=VARCHAR},
#{tenantId, jdbcType=VARCHAR}
)
</insert>
<insert id="bulkInsertTimerJob" parameterType="java.util.List">
INSERT INTO ${prefix}ACT_RU_TIMER_JOB (
ID_,
REV_,
TYPE_,
EXCLUSIVE_,
EXECUTION_ID_,
PROCESS_INSTANCE_ID_,
PROC_DEF_ID_,
RETRIES_,
EXCEPTION_STACK_ID_,
EXCEPTION_MSG_,
DUEDATE_,
REPEAT_,
HANDLER_TYPE_,
HANDLER_CFG_,
TENANT_ID_) VALUES
<foreach collection="list" item="job" index="index" separator=",">
(#{job.id, jdbcType=VARCHAR},
#{job.revision, jdbcType=INTEGER},
#{job.jobType, jdbcType=VARCHAR},
#{job.exclusive, jdbcType=BOOLEAN},
#{job.executionId, jdbcType=VARCHAR},
#{job.processInstanceId, jdbcType=VARCHAR},
#{job.processDefinitionId, jdbcType=VARCHAR},
#{job.retries, jdbcType=INTEGER},
#{job.exceptionByteArrayRef, typeHandler=ByteArrayRefTypeHandler},
#{job.exceptionMessage, jdbcType=VARCHAR},
#{job.duedate, jdbcType=TIMESTAMP},
#{job.repeat, jdbcType=VARCHAR},
#{job.jobHandlerType, jdbcType=VARCHAR},
#{job.jobHandlerConfiguration, jdbcType=VARCHAR},
#{job.tenantId, jdbcType=VARCHAR})
</foreach>
</insert>
<insert id="bulkInsertTimerJob" databaseId="oracle"
parameterType="java.util.List">
INSERT ALL
<foreach collection="list" item="job" index="index">
INTO ${prefix}ACT_RU_TIMER_JOB (
ID_,
REV_,
TYPE_,
EXCLUSIVE_,
EXECUTION_ID_,
PROCESS_INSTANCE_ID_,
PROC_DEF_ID_,
RETRIES_,
EXCEPTION_STACK_ID_,
EXCEPTION_MSG_,
DUEDATE_,
REPEAT_,
HANDLER_TYPE_,
HANDLER_CFG_,
TENANT_ID_) VALUES
(#{job.id, jdbcType=VARCHAR},
#{job.revision, jdbcType=INTEGER},
#{job.jobType, jdbcType=VARCHAR},
#{job.exclusive, jdbcType=BOOLEAN},
#{job.executionId, jdbcType=VARCHAR},
#{job.processInstanceId, jdbcType=VARCHAR},
#{job.processDefinitionId, jdbcType=VARCHAR},
#{job.retries, jdbcType=INTEGER},
#{job.exceptionByteArrayRef, typeHandler=ByteArrayRefTypeHandler},
#{job.exceptionMessage, jdbcType=VARCHAR},
#{job.duedate, jdbcType=TIMESTAMP},
#{job.repeat, jdbcType=VARCHAR},
#{job.jobHandlerType, jdbcType=VARCHAR},
#{job.jobHandlerConfiguration, jdbcType=VARCHAR},
#{job.tenantId, jdbcType=VARCHAR})
</foreach>
SELECT * FROM dual
</insert>
<update id="updateTimerJob" parameterType="org.activiti.engine.impl.persistence.entity.TimerJobEntityImpl">
update ${prefix}ACT_RU_TIMER_JOB
<set>
REV_ = #{revisionNext, jdbcType=INTEGER},
LOCK_EXP_TIME_ = #{lockExpirationTime, jdbcType=TIMESTAMP},
LOCK_OWNER_ = #{lockOwner, jdbcType=VARCHAR},
RETRIES_ = #{retries, jdbcType=INTEGER},
DUEDATE_ = #{duedate, jdbcType=TIMESTAMP},
EXCEPTION_STACK_ID_ = #{exceptionByteArrayRef, typeHandler=ByteArrayRefTypeHandler},
EXCEPTION_MSG_ = #{exceptionMessage, jdbcType=VARCHAR}
</set>
where ID_= #{id, jdbcType=VARCHAR}
and REV_ = #{revision, jdbcType=INTEGER}
</update>
<select id="selectTimerJobByTypeAndProcessDefinitionId" parameterType="org.activiti.engine.impl.db.ListQueryParameterObject" resultMap="jobResultMap">
select J.*
from ${prefix}ACT_RU_TIMER_JOB J
where J.HANDLER_TYPE_ = #{parameter.handlerType}
and J.PROC_DEF_ID_ = #{parameter.processDefinitionId}
</select>
<select id="selectTimerJobsByProcessInstanceId" parameterType="org.activiti.engine.impl.db.ListQueryParameterObject" resultMap="jobResultMap">
select *
from ${prefix}ACT_RU_TIMER_JOB J
where J.PROCESS_INSTANCE_ID_ = #{parameter}
</select>
<select id="selectTimerJobsByExecutionId" parameterType="org.activiti.engine.impl.db.ListQueryParameterObject" resultMap="jobResultMap">
select *
from ${prefix}ACT_RU_TIMER_JOB J
where J.EXECUTION_ID_ = #{parameter}
</select>
<select id="selectTimerJobByTypeAndProcessDefinitionKeyNoTenantId" parameterType="org.activiti.engine.impl.db.ListQueryParameterObject" resultMap="jobResultMap">
select J.*
from ${prefix}ACT_RU_TIMER_JOB J
inner join ${prefix}ACT_RE_PROCDEF P on J.PROC_DEF_ID_ = P.ID_
where J.HANDLER_TYPE_ = #{parameter.handlerType}
and P.KEY_ = #{parameter.processDefinitionKey}
and (P.TENANT_ID_ = '' or P.TENANT_ID_ is null)
</select>
<select id="selectTimerJobByTypeAndProcessDefinitionKeyAndTenantId" parameterType="org.activiti.engine.impl.db.ListQueryParameterObject" resultMap="jobResultMap">
select J.*
from ${prefix}ACT_RU_TIMER_JOB J
inner join ${prefix}ACT_RE_PROCDEF P on J.PROC_DEF_ID_ = P.ID_
where J.HANDLER_TYPE_ = #{parameter.handlerType}
and P.KEY_ = #{parameter.processDefinitionKey}
and P.TENANT_ID_ = #{parameter.tenantId}
</select>
<!-- JOB DELETE STATEMENTS -->
<delete id="deleteTimerJob" parameterType="org.activiti.engine.impl.persistence.entity.TimerJobEntityImpl">
delete from ${prefix}ACT_RU_TIMER_JOB where ID_ = #{id} and REV_ = #{revision}
</delete>
<delete id="bulkDeleteTimerJob" parameterType="java.util.Collection">
delete from ${prefix}ACT_RU_TIMER_JOB where
<foreach item="job" collection="list" index="index" separator=" or ">
ID_ = #{job.id, jdbcType=VARCHAR}
</foreach>
</delete>
<!-- JOB UPDATE STATEMENTS -->
<update id="updateTimerJobTenantIdForDeployment" parameterType="java.util.Map">
update ${prefix}ACT_RU_TIMER_JOB set
TENANT_ID_ = #{tenantId, jdbcType=VARCHAR}
where
ID_ in (
SELECT J.ID_ from ${prefix}ACT_RU_TIMER_JOB J
inner join ${prefix}ACT_RE_PROCDEF P on J.PROC_DEF_ID_ = P.ID_
inner join ${prefix}ACT_RE_DEPLOYMENT D on P.DEPLOYMENT_ID_ = D.ID_
where D.ID_ = #{deploymentId, jdbcType=VARCHAR}
)
</update>
<!-- See http://stackoverflow.com/questions/4429319/you-cant-specify-target-table-for-update-in-from-clause
Tested this on MySQL 5.6: does NOT use a temporary table (so good, performance) -->
<update id="updateTimerJobTenantIdForDeployment" databaseId="mysql" parameterType="java.util.Map">
update ${prefix}ACT_RU_TIMER_JOB set
TENANT_ID_ = #{tenantId, jdbcType=VARCHAR}
where
ID_ in (
SELECT tempTask.tempId
FROM (
SELECT J.ID_ as tempId
FROM ${prefix}ACT_RU_TIMER_JOB J
inner join ${prefix}ACT_RE_PROCDEF P on J.PROC_DEF_ID_ = P.ID_
inner join ${prefix}ACT_RE_DEPLOYMENT D on P.DEPLOYMENT_ID_ = D.ID_
where D.ID_ = #{deploymentId, jdbcType=VARCHAR}
) AS tempTask
)
</update>
</mapper>