insert into ${prefix}ACT_RE_PROCDEF(ID_, REV_, CATEGORY_, NAME_, KEY_, VERSION_, DEPLOYMENT_ID_, RESOURCE_NAME_, DGRM_RESOURCE_NAME_, DESCRIPTION_, HAS_START_FORM_KEY_, HAS_GRAPHICAL_NOTATION_ , SUSPENSION_STATE_, TENANT_ID_, ENGINE_VERSION_, APP_VERSION_)
values (#{id, jdbcType=VARCHAR},
1,
#{category, jdbcType=VARCHAR},
#{name, jdbcType=VARCHAR},
#{key, jdbcType=VARCHAR},
#{version, jdbcType=INTEGER},
#{deploymentId, jdbcType=VARCHAR},
#{resourceName, jdbcType=VARCHAR},
#{diagramResourceName, jdbcType=VARCHAR},
#{description, jdbcType=VARCHAR},
#{hasStartFormKey, jdbcType=BOOLEAN},
#{isGraphicalNotationDefined, jdbcType=BOOLEAN},
#{suspensionState, jdbcType=INTEGER},
#{tenantId, jdbcType=VARCHAR},
#{engineVersion, jdbcType=VARCHAR},
#{appVersion, jdbcType=INTEGER})
INSERT INTO ${prefix}ACT_RE_PROCDEF(ID_, REV_, CATEGORY_, NAME_, KEY_, VERSION_, DEPLOYMENT_ID_, RESOURCE_NAME_, DGRM_RESOURCE_NAME_, DESCRIPTION_, HAS_START_FORM_KEY_, HAS_GRAPHICAL_NOTATION_ , SUSPENSION_STATE_, TENANT_ID_, ENGINE_VERSION_, APP_VERSION_)
VALUES
(#{processDefinition.id, jdbcType=VARCHAR},
1,
#{processDefinition.category, jdbcType=VARCHAR},
#{processDefinition.name, jdbcType=VARCHAR},
#{processDefinition.key, jdbcType=VARCHAR},
#{processDefinition.version, jdbcType=INTEGER},
#{processDefinition.deploymentId, jdbcType=VARCHAR},
#{processDefinition.resourceName, jdbcType=VARCHAR},
#{processDefinition.diagramResourceName, jdbcType=VARCHAR},
#{processDefinition.description, jdbcType=VARCHAR},
#{processDefinition.hasStartFormKey, jdbcType=BOOLEAN},
#{processDefinition.isGraphicalNotationDefined, jdbcType=BOOLEAN},
#{processDefinition.suspensionState, jdbcType=INTEGER},
#{processDefinition.tenantId, jdbcType=VARCHAR},
#{processDefinition.engineVersion, jdbcType=VARCHAR},
#{processDefinition.appVersion, jdbcType=INTEGER})
INSERT ALL
INTO ${prefix}ACT_RE_PROCDEF(ID_, REV_, CATEGORY_, NAME_, KEY_, VERSION_, DEPLOYMENT_ID_, RESOURCE_NAME_,
DGRM_RESOURCE_NAME_, DESCRIPTION_, HAS_START_FORM_KEY_, HAS_GRAPHICAL_NOTATION_ , SUSPENSION_STATE_, TENANT_ID_, ENGINE_VERSION_) VALUES
(#{processDefinition.id, jdbcType=VARCHAR},
1,
#{processDefinition.category, jdbcType=VARCHAR},
#{processDefinition.name, jdbcType=VARCHAR},
#{processDefinition.key, jdbcType=VARCHAR},
#{processDefinition.version, jdbcType=INTEGER},
#{processDefinition.deploymentId, jdbcType=VARCHAR},
#{processDefinition.resourceName, jdbcType=VARCHAR},
#{processDefinition.diagramResourceName, jdbcType=VARCHAR},
#{processDefinition.description, jdbcType=VARCHAR},
#{processDefinition.hasStartFormKey, jdbcType=BOOLEAN},
#{processDefinition.isGraphicalNotationDefined, jdbcType=BOOLEAN},
#{processDefinition.suspensionState, jdbcType=INTEGER},
#{processDefinition.tenantId, jdbcType=VARCHAR},
#{processDefinition.engineVersion, jdbcType=VARCHAR})
SELECT * FROM dual
update ${prefix}ACT_RE_PROCDEF set
REV_ = #{revisionNext, jdbcType=INTEGER},
SUSPENSION_STATE_ = #{suspensionState, jdbcType=INTEGER},
CATEGORY_ = #{category, jdbcType=VARCHAR}
where ID_ = #{id, jdbcType=VARCHAR}
and REV_ = #{revision, jdbcType=INTEGER}
update ${prefix}ACT_RE_PROCDEF set
TENANT_ID_ = #{tenantId, jdbcType=VARCHAR}
where
DEPLOYMENT_ID_ = #{deploymentId, jdbcType=VARCHAR}
delete from ${prefix}ACT_RE_PROCDEF where ID_ = #{id} and REV_ = #{revision}
delete from ${prefix}ACT_RE_PROCDEF where DEPLOYMENT_ID_ = #{deploymenId}
from ${prefix}ACT_RE_PROCDEF RES
inner join ${prefix}ACT_RU_EVENT_SUBSCR EVT on RES.ID_ = EVT.CONFIGURATION_
RES.ID_ = #{id}
and RES.ID_ in
#{item}
and RES.CATEGORY_ = #{category}
and RES.CATEGORY_ like #{categoryLike}${wildcardEscapeClause}
and ( RES.CATEGORY_ <> #{categoryNotEquals} OR RES.CATEGORY_ is null )
and RES.NAME_ = #{name}
and RES.NAME_ like #{nameLike}${wildcardEscapeClause}
and RES.KEY_ = #{key}
and RES.KEY_ like #{keyLike}${wildcardEscapeClause}
and RES.KEY_ in
#{item}
and RES.RESOURCE_NAME_ = #{resourceName}
and RES.RESOURCE_NAME_ like #{resourceNameLike}${wildcardEscapeClause}
and RES.VERSION_ = #{version}
and RES.VERSION_ > #{versionGt}
and RES.VERSION_ >= #{versionGte}
and RES.VERSION_ < #{versionLt}
and RES.VERSION_ <= #{versionLte}
and RES.DEPLOYMENT_ID_ = #{deploymentId}
and RES.DEPLOYMENT_ID_ in
#{item}
and RES.VERSION_ = (select max(VERSION_) from ${prefix}ACT_RE_PROCDEF where KEY_ = RES.KEY_
and TENANT_ID_ = #{tenantId}
and TENANT_ID_ like #{tenantIdLike}${wildcardEscapeClause}
and (TENANT_ID_ = '' or TENANT_ID_ is null)
and ( (TENANT_ID_ IS NOT NULL and TENANT_ID_ = RES.TENANT_ID_) or (TENANT_ID_ IS NULL and RES.TENANT_ID_ IS NULL) )
)
and (RES.SUSPENSION_STATE_ = #{suspensionState.stateCode})
and RES.TENANT_ID_ = #{tenantId}
and RES.TENANT_ID_ like #{tenantIdLike}${wildcardEscapeClause}
and (RES.TENANT_ID_ = '' or RES.TENANT_ID_ is null)
and (EVT.EVENT_TYPE_ = #{eventSubscriptionType} and EVT.EVENT_NAME_ = #{eventSubscriptionName})
AND (exists (select ID_ from ${prefix}ACT_RU_IDENTITYLINK IDN where IDN.PROC_DEF_ID_ = RES.ID_ and IDN.USER_ID_ = #{authorizationUserId})
OR exists (select ID_ from ${prefix}ACT_RU_IDENTITYLINK IDN where IDN.PROC_DEF_ID_ = RES.ID_ and IDN.GROUP_ID_ IN
#{group}
)
)