All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.camunda.bpm.engine.impl.mapping.entity.DecisionDefinition.xml Maven / Gradle / Ivy

There is a newer version: 7.22.0-alpha1
Show newest version
<?xml version="1.0" encoding="UTF-8" ?>
<!--

    Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
    under one or more contributor license agreements. See the NOTICE file
    distributed with this work for additional information regarding copyright
    ownership. Camunda licenses this file to you under the Apache License,
    Version 2.0; you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

        http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.

-->
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">

<mapper namespace="org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionEntity">

  <!-- DECISIONDEFINITION INSERT -->

  <insert id="insertDecisionDefinition" parameterType="org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionEntity">
    insert into ${prefix}ACT_RE_DECISION_DEF(
      ID_, 
      CATEGORY_, 
      NAME_, 
      KEY_, 
      VERSION_, 
      DEPLOYMENT_ID_, 
      RESOURCE_NAME_, 
      DGRM_RESOURCE_NAME_, 
      DEC_REQ_ID_,
      DEC_REQ_KEY_,
      TENANT_ID_,
      HISTORY_TTL_,
      VERSION_TAG_,
      REV_)
    values (#{id, jdbcType=VARCHAR},
            #{category, jdbcType=VARCHAR},
            #{name, jdbcType=VARCHAR},
            #{key, jdbcType=VARCHAR},
            #{version, jdbcType=INTEGER},
            #{deploymentId, jdbcType=VARCHAR},
            #{resourceName, jdbcType=VARCHAR},
            #{diagramResourceName, jdbcType=VARCHAR},
            #{decisionRequirementsDefinitionId, jdbcType=VARCHAR},
            #{decisionRequirementsDefinitionKey, jdbcType=VARCHAR},
            #{tenantId, jdbcType=VARCHAR},
            #{historyTimeToLive, jdbcType=INTEGER},
            #{versionTag, jdbcType=VARCHAR},
            1
           )
  </insert>

  <!-- DECISIONDEFINITION UPDATE -->

  <update id="updateDecisionDefinition" parameterType="org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionEntity">
    update ${prefix}ACT_RE_DECISION_DEF set
      REV_ = #{revisionNext, jdbcType=INTEGER},
      HISTORY_TTL_ = #{historyTimeToLive, jdbcType=INTEGER}
    where ID_ = #{id, jdbcType=VARCHAR}
      and REV_ = #{revision, jdbcType=INTEGER}
  </update>

  <!-- DECISIONDEFINITION DELETE -->

  <delete id="deleteDecisionDefinitionsByDeploymentId" parameterType="string">
    delete from ${prefix}ACT_RE_DECISION_DEF where DEPLOYMENT_ID_ = #{deploymentId}
  </delete>

  <!-- DECISIONDEFINITION RESULTMAP -->

  <resultMap id="decisionDefinitionResultMap" type="org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionEntity">
    <id property="id" column="ID_" jdbcType="VARCHAR" />
    <result property="revision" column="REV_" />
    <result property="category" column="CATEGORY_" />
    <result property="name" column="NAME_" />
    <result property="key" column="KEY_" jdbcType="VARCHAR" />
    <result property="version" column="VERSION_" jdbcType="INTEGER"/>
    <result property="deploymentId" column="DEPLOYMENT_ID_" jdbcType="VARCHAR"/>
    <result property="resourceName" column="RESOURCE_NAME_" jdbcType="VARCHAR"/>
    <result property="diagramResourceName" column="DGRM_RESOURCE_NAME_" jdbcType="VARCHAR"/>
    <result property="decisionRequirementsDefinitionId" column="DEC_REQ_ID_" jdbcType="VARCHAR"/>
    <result property="decisionRequirementsDefinitionKey" column="DEC_REQ_KEY_" jdbcType="VARCHAR"/>
    <result property="tenantId" column="TENANT_ID_" jdbcType="VARCHAR"/>
    <result property="historyTimeToLive" column="HISTORY_TTL_" jdbcType="INTEGER" />
    <result property="versionTag" column="VERSION_TAG_" jdbcType="VARCHAR" />
  </resultMap>

  <!-- DECISIONDEFINITION SELECT -->

  <select id="selectDecisionDefinition" parameterType="string" resultMap="decisionDefinitionResultMap">
    select * from ${prefix}ACT_RE_DECISION_DEF where ID_ = #{decisionDefinitionId}
  </select>

  <select id="selectDecisionDefinitionByDeploymentId" parameterType="string" resultMap="decisionDefinitionResultMap">
    select * from ${prefix}ACT_RE_DECISION_DEF where DEPLOYMENT_ID_ = #{parameter}
  </select>

  <select id="selectDecisionDefinitionByDeploymentAndKey" parameterType="map" resultMap="decisionDefinitionResultMap">
    select *
    from ${prefix}ACT_RE_DECISION_DEF
    where DEPLOYMENT_ID_ = #{deploymentId}
      and KEY_ = #{decisionDefinitionKey}
  </select>

  <select id="selectLatestDecisionDefinitionByKey" parameterType="org.camunda.bpm.engine.impl.db.ListQueryParameterObject" resultMap="decisionDefinitionResultMap">
    select *
    from ${prefix}ACT_RE_DECISION_DEF d1
      inner join
          (select KEY_, TENANT_ID_, max(VERSION_) as MAX_VERSION
          from ${prefix}ACT_RE_DECISION_DEF RES
          where KEY_ = #{parameter}
            <include refid="org.camunda.bpm.engine.impl.persistence.entity.TenantEntity.queryTenantCheck" />
          group by TENANT_ID_, KEY_) d2
        on d1.KEY_ = d2.KEY_
    where d1.VERSION_ = d2.MAX_VERSION and 
          (d1.TENANT_ID_ = d2.TENANT_ID_ or (d1.TENANT_ID_ is null and d2.TENANT_ID_ is null))
  </select>
  
  <select id="selectLatestDecisionDefinitionByKeyWithoutTenantId" parameterType="map" resultMap="decisionDefinitionResultMap">
    select *
    from ${prefix}ACT_RE_DECISION_DEF 
    where KEY_ = #{decisionDefinitionKey}
          and TENANT_ID_ is null
          and VERSION_ = (
              select max(VERSION_) 
              from ${prefix}ACT_RE_DECISION_DEF 
              where KEY_ = #{decisionDefinitionKey} and TENANT_ID_ is null)
  </select>
  
  <select id="selectLatestDecisionDefinitionByKeyAndTenantId" parameterType="map" resultMap="decisionDefinitionResultMap">
    select *
    from ${prefix}ACT_RE_DECISION_DEF RES
    where KEY_ = #{decisionDefinitionKey}
          and TENANT_ID_ = #{tenantId}
          and VERSION_ = (
              select max(VERSION_) 
              from ${prefix}ACT_RE_DECISION_DEF 
              where KEY_ = #{decisionDefinitionKey} and TENANT_ID_ = #{tenantId})
  </select>

  <select id="selectDecisionDefinitionByKeyAndVersion" parameterType="org.camunda.bpm.engine.impl.db.ListQueryParameterObject" resultMap="decisionDefinitionResultMap">
    select *
    from ${prefix}ACT_RE_DECISION_DEF RES
    where KEY_ = #{parameter.decisionDefinitionKey}
      and VERSION_ = #{parameter.decisionDefinitionVersion}
      <include refid="org.camunda.bpm.engine.impl.persistence.entity.TenantEntity.queryTenantCheck" />
  </select>

  <select id="selectDecisionDefinitionByKeyVersionWithoutTenantId" parameterType="map" resultMap="decisionDefinitionResultMap">
    select *
    from ${prefix}ACT_RE_DECISION_DEF
    where KEY_ = #{decisionDefinitionKey}
          and VERSION_ = #{decisionDefinitionVersion}
          and TENANT_ID_ is null
  </select>

  <select id="selectDecisionDefinitionByKeyVersionAndTenantId" parameterType="map" resultMap="decisionDefinitionResultMap">
    select *
    from ${prefix}ACT_RE_DECISION_DEF
    where KEY_ = #{decisionDefinitionKey}
          and VERSION_ = #{decisionDefinitionVersion}
          and TENANT_ID_ = #{tenantId}
  </select>

  <select id="selectDecisionDefinitionByKeyVersionTag" parameterType="org.camunda.bpm.engine.impl.db.ListQueryParameterObject" resultMap="decisionDefinitionResultMap">
    select *
    from ${prefix}ACT_RE_DECISION_DEF
    where KEY_ = #{parameter.decisionDefinitionKey}
          and VERSION_TAG_ = #{parameter.decisionDefinitionVersionTag}
          <if test="parameter.tenantId == null">
                and TENANT_ID_ is null
          </if>
          <if test="parameter.tenantId != null">
                and TENANT_ID_ = #{parameter.tenantId}
          </if>
  </select>

  <select id="selectPreviousDecisionDefinitionId" parameterType="map" resultType="string">
    select distinct RES.*
      from ${prefix}ACT_RE_DECISION_DEF RES
     where RES.KEY_ = #{key}
       <if test="tenantId != null">
          AND TENANT_ID_ = #{tenantId}
        </if>
        <if test="tenantId == null">
          AND TENANT_ID_ is null
        </if>
       and RES.VERSION_ = (
        select MAX(VERSION_) 
        from ${prefix}ACT_RE_DECISION_DEF 
        where KEY_ = #{key} 
          <if test="tenantId != null">
            AND TENANT_ID_ = #{tenantId}
          </if>
          <if test="tenantId == null">
            AND TENANT_ID_ is null
          </if>
          AND VERSION_ &lt; #{version})
  </select>

  <select id="selectDecisionDefinitionsByQueryCriteria" parameterType="org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionQueryImpl" resultMap="decisionDefinitionResultMap">
    <include refid="org.camunda.bpm.engine.impl.persistence.entity.Commons.bindOrderBy"/>
    ${limitBefore}
    select ${distinct} RES.*
    ${limitBetween}
    <include refid="org.camunda.bpm.engine.impl.persistence.entity.Commons.orderBySelection"/>
    <include refid="selectDecisionDefinitionsByQueryCriteriaSql"/>
    ${orderBy}
    ${limitAfter}
  </select>

  <select id="selectDecisionDefinitionCountByQueryCriteria" parameterType="org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionQueryImpl" resultType="long">
    ${countDistinctBeforeStart} RES.ID_ ${countDistinctBeforeEnd}
    <include refid="selectDecisionDefinitionsByQueryCriteriaSql"/>
    ${countDistinctAfterEnd}
  </select>

  <sql id="selectDecisionDefinitionsByQueryCriteriaSql">

    from ${prefix}ACT_RE_DECISION_DEF RES
    <if test="latest">
      inner join
          (select KEY_, TENANT_ID_, max(VERSION_) as MAX_VERSION
          from ${prefix}ACT_RE_DECISION_DEF
          <where>
            <if test="key != null">
              KEY_ = #{key}
            </if>
          </where>
          group by TENANT_ID_, KEY_) VER
        on RES.KEY_ = VER.KEY_
    </if>
    <if test="shouldJoinDeploymentTable">
      inner join ${prefix}ACT_RE_DEPLOYMENT DEP on RES.DEPLOYMENT_ID_ = DEP.ID_
    </if>

    <if test="authCheck.shouldPerformAuthorizatioCheck &amp;&amp; !authCheck.revokeAuthorizationCheckEnabled &amp;&amp; authCheck.authUserId != null">
      <include refid="org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity.authCheckJoinWithoutOnClause" />
      AUTH ON (AUTH.RESOURCE_ID_ ${authJoinStart} RES.ID_ ${authJoinSeparator} RES.KEY_ ${authJoinSeparator} '*' ${authJoinEnd})
    </if>

    <where>
      <if test="id != null">
        RES.ID_ = #{id}
      </if>
      <if test="ids != null &amp;&amp; ids.length > 0">
        and RES.ID_ in
        <foreach item="item" index="index" collection="ids"
                 open="(" separator="," close=")">
          #{item}
        </foreach>
      </if>
      <if test="category != null">
        and RES.CATEGORY_ = #{category}
      </if>
      <if test="categoryLike != null">
        and RES.CATEGORY_ like #{categoryLike} ESCAPE ${escapeChar}
      </if>
      <if test="name != null">
        and RES.NAME_ = #{name}
      </if>
      <if test="versionTag != null">
        and RES.VERSION_TAG_ = #{versionTag}
      </if>
      <if test="versionTagLike != null">
        and RES.VERSION_TAG_ like #{versionTagLike} ESCAPE ${escapeChar}
      </if>
      <if test="nameLike != null">
        and RES.NAME_ like #{nameLike} ESCAPE ${escapeChar}
      </if>
      <if test="key != null">
        and RES.KEY_ = #{key}
      </if>
      <if test="keyLike != null">
        and RES.KEY_ like #{keyLike} ESCAPE ${escapeChar}
      </if>
      <if test="resourceName != null">
        and RES.RESOURCE_NAME_ = #{resourceName}
      </if>
      <if test="resourceNameLike != null">
        and RES.RESOURCE_NAME_ like #{resourceNameLike} ESCAPE ${escapeChar}
      </if>
      <if test="version != null">
        and RES.VERSION_ = #{version}
      </if>
      <if test="deploymentId != null">
        and RES.DEPLOYMENT_ID_ = #{deploymentId}
      </if>
      <if test="deployedAfter != null">
        and DEP.DEPLOY_TIME_ &gt; #{deployedAfter}
      </if>
      <if test="deployedAt != null">
        and DEP.DEPLOY_TIME_ = #{deployedAt}
      </if>
      <if test="latest">
       and RES.VERSION_ = VER.MAX_VERSION and
          (RES.TENANT_ID_ = VER.TENANT_ID_ or (RES.TENANT_ID_ is null and VER.TENANT_ID_ is null))
      </if>
      <if test="decisionRequirementsDefinitionId != null">
        and RES.DEC_REQ_ID_ = #{decisionRequirementsDefinitionId}
      </if>
      <if test="decisionRequirementsDefinitionKey != null">
        and RES.DEC_REQ_KEY_ = #{decisionRequirementsDefinitionKey}
      </if>
      <if test="withoutDecisionRequirementsDefinition">
        and RES.DEC_REQ_ID_ is null
      </if>
      <if test="isTenantIdSet">
        <if test="tenantIds != null &amp;&amp; tenantIds.length > 0">
          and ( RES.TENANT_ID_ in
          <foreach item="tenantId" index="index" collection="tenantIds"
                   open="(" separator="," close=")">
            #{tenantId}
          </foreach>
          <if test="includeDefinitionsWithoutTenantId">
            or RES.TENANT_ID_ is null
          </if>
          )
        </if>
        <if test="tenantIds == null">
          and RES.TENANT_ID_ is null
        </if>
      </if>

      <include refid="org.camunda.bpm.engine.impl.persistence.entity.AuthorizationEntity.queryAuthorizationCheck" />
      <include refid="org.camunda.bpm.engine.impl.persistence.entity.TenantEntity.queryTenantCheck" />
      
    </where>
  </sql>

</mapper>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy