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

org.sonar.db.issue.IssueMapper.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.issue.IssueMapper">

  <sql id="issueColumns">
    i.id,
    i.kee as kee,
    i.rule_id as ruleId,
    i.action_plan_key as actionPlanKey,
    i.severity as severity,
    i.manual_severity as manualSeverity,
    i.message as message,
    i.line as line,
    i.locations as locations,
    i.effort_to_fix as effortToFix,
    i.technical_debt as debt,
    i.status as status,
    i.resolution as resolution,
    i.checksum as checksum,
    i.reporter as reporter,
    i.assignee as assignee,
    i.author_login as authorLogin,
    i.tags as tagsString,
    i.issue_attributes as issueAttributes,
    i.issue_creation_date as issueCreationTime,
    i.issue_update_date as issueUpdateTime,
    i.issue_close_date as issueCloseTime,
    i.created_at as createdAt,
    i.updated_at as updatedAt,
    r.plugin_rule_key as ruleKey,
    r.plugin_name as ruleRepo,
    r.language as language,
    p.kee as componentKey,
    i.component_uuid as componentUuid,
    p.module_uuid as moduleUuid,
    p.module_uuid_path as moduleUuidPath,
    p.path as filePath,
    root.kee as projectKey,
    i.project_uuid as projectUuid
  </sql>

  <sql id="sortColumn">
    <if test="query.sort() != null">,
      <choose>
        <when test="'SEVERITY'.equals(query.sort())">
          i.severity as severity
        </when>
        <when test="'STATUS'.equals(query.sort())">
          i.status as status
        </when>
        <when test="'ASSIGNEE'.equals(query.sort())">
          i.assignee as assignee
        </when>
        <when test="'CREATION_DATE'.equals(query.sort())">
          i.issue_creation_date as issueCreationTime
        </when>
        <when test="'UPDATE_DATE'.equals(query.sort())">
          i.issue_update_date as issueUpdateTime
        </when>
        <when test="'CLOSE_DATE'.equals(query.sort())">
          i.issue_close_date as issueCloseTime
        </when>
      </choose>
    </if>
  </sql>

  <insert id="insert" parameterType="Issue" useGeneratedKeys="false" keyProperty="id">
    INSERT INTO issues (kee, rule_id, action_plan_key, severity, manual_severity,
    message, line, locations, effort_to_fix, technical_debt, status, tags,
    resolution, checksum, reporter, assignee, author_login, issue_attributes, issue_creation_date, issue_update_date,
    issue_close_date, created_at, updated_at, component_uuid, project_uuid)
    VALUES (#{kee,jdbcType=VARCHAR}, #{ruleId,jdbcType=INTEGER}, #{actionPlanKey,jdbcType=VARCHAR},
    #{severity,jdbcType=VARCHAR},
    #{manualSeverity,jdbcType=BOOLEAN}, #{message,jdbcType=VARCHAR}, #{line,jdbcType=INTEGER},
    #{locations,jdbcType=BINARY},
    #{effortToFix,jdbcType=DOUBLE}, #{debt,jdbcType=INTEGER}, #{status,jdbcType=VARCHAR},
    #{tagsString,jdbcType=VARCHAR}, #{resolution,jdbcType=VARCHAR}, #{checksum,jdbcType=VARCHAR},
    #{reporter,jdbcType=VARCHAR}, #{assignee,jdbcType=VARCHAR}, #{authorLogin,jdbcType=VARCHAR},
    #{issueAttributes,jdbcType=VARCHAR},
    #{issueCreationTime,jdbcType=BIGINT},#{issueUpdateTime,jdbcType=BIGINT}, #{issueCloseTime,jdbcType=BIGINT},
    #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT},
    #{componentUuid,jdbcType=VARCHAR}, #{projectUuid,jdbcType=VARCHAR})
  </insert>

  <!--
    IMPORTANT - invariant columns can't be updated. See IssueDto#toDtoForUpdate()
  -->
  <update id="update" parameterType="Issue">
    update issues set
    action_plan_key=#{actionPlanKey,jdbcType=VARCHAR},
    severity=#{severity,jdbcType=VARCHAR},
    manual_severity=#{manualSeverity,jdbcType=BOOLEAN},
    message=#{message,jdbcType=VARCHAR},
    line=#{line,jdbcType=INTEGER},
    locations=#{locations,jdbcType=BINARY},
    effort_to_fix=#{effortToFix,jdbcType=DOUBLE},
    technical_debt=#{debt,jdbcType=INTEGER},
    status=#{status,jdbcType=VARCHAR},
    resolution=#{resolution,jdbcType=VARCHAR},
    checksum=#{checksum,jdbcType=VARCHAR},
    reporter=#{reporter,jdbcType=VARCHAR},
    assignee=#{assignee,jdbcType=VARCHAR},
    author_login=#{authorLogin,jdbcType=VARCHAR},
    tags=#{tagsString,jdbcType=VARCHAR},
    project_uuid=#{projectUuid,jdbcType=VARCHAR},
    issue_attributes=#{issueAttributes,jdbcType=VARCHAR},
    issue_creation_date=#{issueCreationTime,jdbcType=BIGINT},
    issue_update_date=#{issueUpdateTime,jdbcType=BIGINT},
    issue_close_date=#{issueCloseTime,jdbcType=BIGINT},
    updated_at=#{updatedAt,jdbcType=BIGINT}
    where kee = #{kee}
  </update>

  <!--
   IMPORTANT - invariant columns can't be updated. See IssueDto#toDtoForUpdate()
 -->
  <update id="updateIfBeforeSelectedDate" parameterType="Issue">
    update issues set
    action_plan_key=#{actionPlanKey,jdbcType=VARCHAR},
    severity=#{severity,jdbcType=VARCHAR},
    manual_severity=#{manualSeverity,jdbcType=BOOLEAN},
    message=#{message,jdbcType=VARCHAR},
    line=#{line,jdbcType=INTEGER},
    locations=#{locations,jdbcType=BINARY},
    effort_to_fix=#{effortToFix,jdbcType=DOUBLE},
    technical_debt=#{debt,jdbcType=INTEGER},
    status=#{status,jdbcType=VARCHAR},
    resolution=#{resolution,jdbcType=VARCHAR},
    checksum=#{checksum,jdbcType=VARCHAR},
    reporter=#{reporter,jdbcType=VARCHAR},
    assignee=#{assignee,jdbcType=VARCHAR},
    author_login=#{authorLogin,jdbcType=VARCHAR},
    tags=#{tagsString,jdbcType=VARCHAR},
    project_uuid=#{projectUuid,jdbcType=VARCHAR},
    issue_attributes=#{issueAttributes,jdbcType=VARCHAR},
    issue_creation_date=#{issueCreationTime,jdbcType=BIGINT},
    issue_update_date=#{issueUpdateTime,jdbcType=BIGINT},
    issue_close_date=#{issueCloseTime,jdbcType=BIGINT},
    updated_at=#{updatedAt,jdbcType=BIGINT}
    where kee = #{kee} and updated_at &lt;= #{selectedAt}
  </update>

  <select id="selectByKey" parameterType="String" resultType="Issue">
    select
    <include refid="issueColumns"/>
    from issues i
    inner join rules r on r.id=i.rule_id
    inner join projects p on p.uuid=i.component_uuid
    inner join projects root on root.uuid=i.project_uuid
    where i.kee=#{kee}
  </select>

  <select id="selectNonClosedByComponentUuid" parameterType="String" resultType="Issue">
    select
    <include refid="issueColumns"/>
    from issues i
    inner join rules r on r.id=i.rule_id
    inner join projects p on p.uuid=i.component_uuid
    inner join projects root on root.uuid=i.project_uuid
    where
    i.component_uuid=#{componentUuid} and
    i.status &lt;&gt; 'CLOSED'
  </select>

  <select id="selectNonClosedIssuesByModule" parameterType="long" resultType="Issue">
    select
    i.id,
    i.kee as kee,
    i.rule_id as ruleId,
    i.component_uuid as componentUuid,
    i.project_uuid as projectUuid,
    i.action_plan_key as actionPlanKey,
    i.severity as severity,
    i.manual_severity as manualSeverity,
    i.message as message,
    i.line as line,
    i.locations as locations,
    i.effort_to_fix as effortToFix,
    i.technical_debt as debt,
    i.status as status,
    i.resolution as resolution,
    i.checksum as checksum,
    i.reporter as reporter,
    i.assignee as assignee,
    i.author_login as authorLogin,
    i.tags as tagsString,
    i.issue_attributes as issueAttributes,
    i.issue_creation_date as issueCreationTime,
    i.issue_update_date as issueUpdateTime,
    i.issue_close_date as issueCloseTime,
    i.created_at as createdAt,
    i.updated_at as updatedAt,
    r.plugin_rule_key as ruleKey,
    r.plugin_name as ruleRepo,
    p.kee as componentKey,
    root.kee as projectKey
    from issues i
    inner join (select p.id, p.uuid,p.kee from projects p where (p.root_id=#{id} and p.qualifier &lt;&gt; 'BRC') or
    (p.id=#{id})) p on p.uuid=i.component_uuid
    inner join rules r on r.id=i.rule_id
    left outer join projects root on root.uuid=i.project_uuid
    where i.status &lt;&gt; 'CLOSED'
  </select>

  <select id="selectComponentUuidsOfOpenIssuesForProjectUuid" parameterType="string" resultType="string">
    select distinct(i.component_uuid)
    from issues i
    where i.project_uuid=#{projectUuid} and i.status &lt;&gt; 'CLOSED'
  </select>

  <select id="selectByKeys" parameterType="map" resultType="Issue">
    select
    <include refid="issueColumns"/>
    from issues i
    inner join rules r on r.id=i.rule_id
    inner join projects p on p.uuid=i.component_uuid
    inner join projects root on root.uuid=i.project_uuid
    where i.kee in
    <foreach collection="list" open="(" close=")" item="key" separator=",">
      #{key}
    </foreach>
  </select>

  <select id="selectByActionPlan" parameterType="map" resultType="Issue">
    select
    <include refid="issueColumns"/>
    from issues i
    inner join rules r on r.id=i.rule_id
    inner join projects p on p.uuid=i.component_uuid
    inner join projects root on root.uuid=i.project_uuid
    <where>
      and i.action_plan_key=#{action_plan}
    </where>
  </select>

</mapper>





© 2015 - 2025 Weber Informatics LLC | Privacy Policy