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

org.sonar.db.qualityprofile.QProfileChangeMapper.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.qualityprofile.QProfileChangeMapper">

  <sql id="selectColumns">
    qpc.kee as "uuid",
    qpc.rules_profile_uuid as rulesProfileUuid,
    qpc.created_at as createdAt,
    qpc.user_uuid as userUuid,
    qpc.change_type as changeType,
    qpc.change_data as data
  </sql>

  <insert id="insert" useGeneratedKeys="false" parameterType="org.sonar.db.qualityprofile.QProfileChangeDto">
    insert into qprofile_changes
    (
      kee,
      rules_profile_uuid,
      created_at,
      user_uuid,
      change_type,
      change_data
    ) values (
      #{uuid, jdbcType=VARCHAR},
      #{rulesProfileUuid, jdbcType=VARCHAR},
      #{createdAt, jdbcType=BIGINT},
      #{userUuid, jdbcType=VARCHAR},
      #{changeType, jdbcType=VARCHAR},
      #{data, jdbcType=VARCHAR}
    )
  </insert>

  <select id="countByQuery" resultType="int">
    select count(qpc.kee)
    <include refid="sqlSelectByQuery" />
  </select>

  <select id="selectByQuery" resultType="org.sonar.db.qualityprofile.QProfileChangeDto">
    select <include refid="selectColumns" />
    <include refid="sqlSelectByQuery" />
    order by qpc.created_at desc
    limit #{query.limit}
    offset #{query.offset}
  </select>

  <select id="selectByQuery" databaseId="mssql" resultType="org.sonar.db.qualityprofile.QProfileChangeDto">
    select <include refid="selectColumns" />
    <include refid="sqlSelectByQuery" />
    order by qpc.created_at desc
    offset #{query.offset} rows
    fetch next #{query.limit} rows only
  </select>

  <select id="selectByQuery" databaseId="oracle" resultType="org.sonar.db.qualityprofile.QProfileChangeDto">
    select "uuid", rulesProfileUuid, createdAt, userUuid, changeType, data from (
    select rownum rnum, "uuid", rulesProfileUuid, createdAt, userUuid, changeType, data from (
    select <include refid="selectColumns" />
    <include refid="sqlSelectByQuery" />
    order by qpc.created_at desc
    )
    where rownum &lt;= #{query.total}
    )
    where rnum > #{query.offset}
  </select>

  <sql id="sqlSelectByQuery">
    from qprofile_changes qpc
    inner join rules_profiles rp on rp.kee = qpc.rules_profile_uuid
    inner join org_qprofiles oqp on oqp.rules_profile_uuid = rp.kee
    where
      oqp.uuid = #{query.profileUuid, jdbcType=VARCHAR}
      <if test="query.fromIncluded != null">
        and qpc.created_at &gt;= #{query.fromIncluded}
      </if>
      <if test="query.toExcluded != null">
        and qpc.created_at &lt; #{query.toExcluded}
      </if>
  </sql>

  <delete id="deleteByRuleProfileUuids" parameterType="String">
    delete from qprofile_changes
    where rules_profile_uuid in
    <foreach collection="ruleProfileUuids" open="(" close=")" item="ruleProfileUuid" separator=",">
      #{ruleProfileUuid, jdbcType=VARCHAR}
    </foreach>
  </delete>
</mapper>





© 2015 - 2025 Weber Informatics LLC | Privacy Policy