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

org.flowable.db.mapping.entity.Attachment.xml Maven / Gradle / Ivy

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

<!--
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ 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.flowable.engine.impl.persistence.entity.AttachmentEntityImpl">

  <!-- ATTACHMENT INSERT -->

  <insert id="insertAttachment" parameterType="org.flowable.engine.impl.persistence.entity.AttachmentEntityImpl">
    insert into ${prefix}ACT_HI_ATTACHMENT (ID_, REV_, USER_ID_, NAME_, DESCRIPTION_, TYPE_, TASK_ID_, PROC_INST_ID_, URL_, CONTENT_ID_, TIME_)
    values (
      #{id ,jdbcType=VARCHAR},
      1, #{userId ,jdbcType=VARCHAR},
      #{name ,jdbcType=VARCHAR},
      #{description ,jdbcType=VARCHAR},
      #{type ,jdbcType=VARCHAR},
      #{taskId ,jdbcType=VARCHAR},
      #{processInstanceId ,jdbcType=VARCHAR},
      #{url ,jdbcType=VARCHAR},
      #{contentId ,jdbcType=VARCHAR},
      #{time ,jdbcType=TIMESTAMP}
    )
  </insert>

  <insert id="bulkInsertAttachment" parameterType="java.util.List">
    insert into ${prefix}ACT_HI_ATTACHMENT (ID_, REV_, USER_ID_, NAME_, DESCRIPTION_, TYPE_, TASK_ID_, PROC_INST_ID_, URL_, CONTENT_ID_, TIME_)
    values 
      <foreach collection="list" item="attachment" index="index" separator=","> 
        (#{attachment.id ,jdbcType=VARCHAR},
         1, #{attachment.userId ,jdbcType=VARCHAR},
         #{attachment.name ,jdbcType=VARCHAR},
         #{attachment.description ,jdbcType=VARCHAR},
         #{attachment.type ,jdbcType=VARCHAR},
         #{attachment.taskId ,jdbcType=VARCHAR},
         #{attachment.processInstanceId ,jdbcType=VARCHAR},
         #{attachment.url ,jdbcType=VARCHAR},
         #{attachment.contentId ,jdbcType=VARCHAR},
         #{attachment.time ,jdbcType=TIMESTAMP})
      </foreach>
  </insert>

  <insert id="bulkInsertAttachment" databaseId="oracle" parameterType="java.util.List">
    INSERT ALL 
      <foreach collection="list" item="attachment" index="index"> 
        INTO ${prefix}ACT_HI_ATTACHMENT (ID_, REV_, USER_ID_, NAME_, DESCRIPTION_, TYPE_, TASK_ID_, PROC_INST_ID_, URL_, CONTENT_ID_, TIME_) VALUES 
          (#{attachment.id ,jdbcType=VARCHAR},
           1, #{attachment.userId ,jdbcType=VARCHAR},
           #{attachment.name ,jdbcType=VARCHAR},
           #{attachment.description ,jdbcType=VARCHAR},
           #{attachment.type ,jdbcType=VARCHAR},
           #{attachment.taskId ,jdbcType=VARCHAR},
           #{attachment.processInstanceId ,jdbcType=VARCHAR},
           #{attachment.url ,jdbcType=VARCHAR},
           #{attachment.contentId ,jdbcType=VARCHAR},
           #{attachment.time ,jdbcType=TIMESTAMP})
      </foreach>
    SELECT * FROM dual
  </insert>

  <!-- ATTACHMENT UPDATE -->

  <update id="updateAttachment" parameterType="org.flowable.engine.impl.persistence.entity.AttachmentEntityImpl">
    update ${prefix}ACT_HI_ATTACHMENT 
    <set>
        REV_ = #{revisionNext, jdbcType=INTEGER},
        <if test="originalPersistentState.name != name">
          NAME_ = #{name, jdbcType=VARCHAR},
        </if>
        <if test="originalPersistentState.description != description">
          DESCRIPTION_ = #{description, jdbcType=TIMESTAMP}
        </if>
    </set>
    where ID_ = #{id}
      and REV_ = #{revision, jdbcType=INTEGER}
  </update>

  <!-- ATTACHMENT DELETE -->

  <delete id="deleteAttachment" parameterType="org.flowable.engine.impl.persistence.entity.AttachmentEntityImpl">
    delete from ${prefix}ACT_HI_ATTACHMENT 
    where ID_ = #{id} and REV_ = #{revision} 
  </delete>
  
  <!-- ATTACHMENT RESULTMAP -->

  <resultMap id="attachmentResultMap" type="org.flowable.engine.impl.persistence.entity.AttachmentEntityImpl">
    <id property="id" column="ID_" jdbcType="VARCHAR" />
    <result property="revision" column="REV_" jdbcType="INTEGER" />
    <result property="name" column="NAME_" jdbcType="VARCHAR" />
    <result property="description" column="DESCRIPTION_" jdbcType="VARCHAR" />
    <result property="type" column="TYPE_" jdbcType="VARCHAR" />
    <result property="taskId" column="TASK_ID_" jdbcType="VARCHAR" />
    <result property="processInstanceId" column="PROC_INST_ID_" jdbcType="VARCHAR" />
    <result property="url" column="URL_" jdbcType="VARCHAR" />
    <result property="contentId" column="CONTENT_ID_" jdbcType="VARCHAR" />
    <result property="userId" column="USER_ID_" jdbcType="VARCHAR" />
    <result property="time" column="TIME_" jdbcType="TIMESTAMP" />
  </resultMap>
  
  <!-- ATTACHMENT SELECT -->

  <select id="selectAttachment" parameterType="string" resultMap="attachmentResultMap">
    select *
    from ${prefix}ACT_HI_ATTACHMENT
    where ID_ = #{id,jdbcType=VARCHAR}
  </select>
  
  <select id="selectAttachmentsByTaskId" parameterType="org.flowable.common.engine.impl.db.ListQueryParameterObject" resultMap="attachmentResultMap">
    select *
    from ${prefix}ACT_HI_ATTACHMENT
    where TASK_ID_ = #{parameter,jdbcType=VARCHAR}
    order by TIME_ desc
  </select>
  
  <select id="selectAttachmentsByProcessInstanceId" parameterType="org.flowable.common.engine.impl.db.ListQueryParameterObject" resultMap="attachmentResultMap">
    select *
    from ${prefix}ACT_HI_ATTACHMENT
    where PROC_INST_ID_ = #{parameter,jdbcType=VARCHAR}
    order by TIME_ desc
  </select>

</mapper>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy