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

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

There is a newer version: 6.3.1
Show newest version
<?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.sonar.db.duplication.DuplicationMapper">

  <select id="selectCandidates" parameterType="map" resultType="DuplicationUnit">
    SELECT DISTINCT
    duplication_block.id as id,
    duplication_block.snapshot_id as snapshotId,
    duplication_block.project_snapshot_id as projectSnapshotId,
    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.snapshot_id=snapshot.id AND snapshot.islast=${_true}
    INNER JOIN projects file_component ON file_component.id=snapshot.project_id 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}</foreach>
      <if test="projectSnapshotId != null">
        AND duplication_block.project_snapshot_id &lt;&gt; #{projectSnapshotId}
      </if>
    </where>
  </select>

  <insert id="batchInsert" parameterType="DuplicationUnit" useGeneratedKeys="false">
    INSERT INTO duplications_index (snapshot_id, project_snapshot_id, hash, index_in_file, start_line, end_line)
    VALUES (#{snapshotId}, #{projectSnapshotId}, #{hash}, #{indexInFile}, #{startLine}, #{endLine})
  </insert>

</mapper>




© 2015 - 2025 Weber Informatics LLC | Privacy Policy