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

org.sonar.db.duplication.DuplicationMapper.xml Maven / Gradle / Ivy

The newest version!
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd">

<mapper namespace="org.sonar.db.duplication.DuplicationMapper">

  <select id="selectCandidates" parameterType="map" resultType="DuplicationUnit">
    SELECT DISTINCT
    duplication_block.id as id,
    duplication_block.analysis_uuid as analysisUuid,
    duplication_block.component_uuid as componentUuid,
    duplication_block.hash as hash,
    duplication_block.index_in_file as indexInFile,
    duplication_block.start_line as startLine,
    duplication_block.end_line as endLine,
    file_component.kee as componentKey
    FROM duplications_index duplication_block
    INNER JOIN snapshots snapshot ON duplication_block.analysis_uuid=snapshot.uuid AND snapshot.islast=${_true}
    INNER JOIN projects file_component ON file_component.uuid=duplication_block.component_uuid AND file_component.language=#{language}
    AND file_component.enabled=${_true}
    <where>
      AND duplication_block.hash in
      <foreach collection="hashes" open="(" close=")" item="hash" separator=",">#{hash,jdbcType=VARCHAR}</foreach>
      <if test="analysisUuid != null">
        AND duplication_block.analysis_uuid &lt;&gt; #{analysisUuid,jdbcType=VARCHAR}
      </if>
    </where>
  </select>
  
  <select id="selectComponent" parameterType="map" resultType="DuplicationUnit">
    SELECT DISTINCT
    dup.id as id,
    dup.analysis_uuid as analysisUuid,
    dup.component_uuid as componentUuid,
    dup.hash as hash,
    dup.index_in_file as indexInFile,
    dup.start_line as startLine,
    dup.end_line as endLine
    FROM duplications_index dup
    WHERE
      dup.component_uuid = #{componentUuid,jdbcType=VARCHAR} AND
      dup.analysis_uuid = #{analysisUuid,jdbcType=VARCHAR} 
  </select>

  <insert id="batchInsert" parameterType="DuplicationUnit" useGeneratedKeys="false">
    INSERT INTO duplications_index (
    analysis_uuid, component_uuid, hash,
    index_in_file, start_line, end_line
    )
    VALUES (
    #{analysisUuid,jdbcType=VARCHAR}, #{componentUuid,jdbcType=VARCHAR}, #{hash,jdbcType=VARCHAR},
    #{indexInFile,jdbcType=INTEGER}, #{startLine,jdbcType=INTEGER}, #{endLine,jdbcType=INTEGER}
    )
  </insert>

</mapper>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy