123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361 |
- <?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.issue.IssueMapper">
-
- <sql id="issueColumns">
- i.kee as kee,
- i.rule_uuid as ruleUuid,
- i.severity as severity,
- i.manual_severity as manualSeverity,
- i.message as message,
- i.line as line,
- i.locations as locations,
- i.gap as gap,
- i.effort as effort,
- i.status as status,
- i.resolution as resolution,
- i.checksum as checksum,
- i.assignee as assigneeUuid,
- 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.is_external as "isExternal",
- 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,
- i.issue_type as type
- </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 assigneeUuid
- </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>
-
- <sql id="issueForIndexingColumns">
- i.kee as "key",
- root.uuid as "projectUuid",
- i.updated_at as "updatedAt",
- i.assignee,
- i.gap,
- i.issue_attributes as "attributes",
- i.line,
- i.message,
- i.resolution,
- i.severity,
- i.manual_severity as "manualSeverity",
- i.checksum,
- i.status,
- i.effort,
- i.author_login as "authorLogin",
- i.issue_close_date as "issueCloseDate",
- i.issue_creation_date as "issueCreationDate",
- i.issue_update_date as "issueUpdateDate",
- r.is_external as "isExternal",
- r.plugin_name as "pluginName",
- r.plugin_rule_key as "pluginRuleKey",
- r.language,
- p.uuid as "projectUuid",
- p.module_uuid_path as "moduleUuidPath",
- p.path,
- p.scope,
- p.organization_uuid as "organizationUuid",
- i.tags,
- i.issue_type as "issueType"
- </sql>
-
-
- <insert id="insert" parameterType="Issue" useGeneratedKeys="false">
- INSERT INTO issues (kee, rule_uuid, severity, manual_severity,
- message, line, locations, gap, effort, status, tags,
- resolution, checksum, assignee, author_login, issue_attributes, issue_creation_date, issue_update_date,
- issue_close_date, created_at, updated_at, component_uuid, project_uuid, issue_type)
- VALUES (
- #{kee,jdbcType=VARCHAR},
- #{ruleUuid,jdbcType=VARCHAR},
- #{severity,jdbcType=VARCHAR},
- #{manualSeverity,jdbcType=BOOLEAN}, #{message,jdbcType=VARCHAR}, #{line,jdbcType=INTEGER},
- #{locations,jdbcType=BINARY},
- #{gap,jdbcType=DOUBLE}, #{effort,jdbcType=INTEGER}, #{status,jdbcType=VARCHAR},
- #{tagsString,jdbcType=VARCHAR}, #{resolution,jdbcType=VARCHAR},
- #{checksum,jdbcType=VARCHAR},
- #{assigneeUuid,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}, #{type,jdbcType=INTEGER})
- </insert>
-
- <!--
- IMPORTANT - invariant columns can't be updated. See IssueDto#toDtoForUpdate()
- -->
- <update id="update" parameterType="Issue">
- update issues set
- severity=#{severity,jdbcType=VARCHAR},
- manual_severity=#{manualSeverity,jdbcType=BOOLEAN},
- message=#{message,jdbcType=VARCHAR},
- line=#{line,jdbcType=INTEGER},
- locations=#{locations,jdbcType=BINARY},
- gap=#{gap,jdbcType=DOUBLE},
- effort=#{effort,jdbcType=INTEGER},
- status=#{status,jdbcType=VARCHAR},
- resolution=#{resolution,jdbcType=VARCHAR},
- checksum=#{checksum,jdbcType=VARCHAR},
- assignee=#{assigneeUuid,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},
- issue_type=#{type,jdbcType=INTEGER}
- where kee = #{kee}
- </update>
-
- <!--
- IMPORTANT - invariant columns can't be updated. See IssueDto#toDtoForUpdate()
- -->
- <update id="updateIfBeforeSelectedDate" parameterType="Issue">
- update issues set
- severity=#{severity,jdbcType=VARCHAR},
- manual_severity=#{manualSeverity,jdbcType=BOOLEAN},
- message=#{message,jdbcType=VARCHAR},
- line=#{line,jdbcType=INTEGER},
- locations=#{locations,jdbcType=BINARY},
- gap=#{gap,jdbcType=DOUBLE},
- effort=#{effort,jdbcType=INTEGER},
- status=#{status,jdbcType=VARCHAR},
- resolution=#{resolution,jdbcType=VARCHAR},
- checksum=#{checksum,jdbcType=VARCHAR},
- assignee=#{assigneeUuid,jdbcType=VARCHAR},
- author_login=#{authorLogin,jdbcType=VARCHAR},
- tags=#{tagsString,jdbcType=VARCHAR},
- component_uuid=#{componentUuid,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},
- issue_type=#{type,jdbcType=INTEGER}
- where kee = #{kee} and updated_at <= #{selectedAt}
- </update>
-
- <select id="selectByKey" parameterType="String" resultType="Issue">
- select
- <include refid="issueColumns"/>
- from issues i
- inner join rules r on r.uuid=i.rule_uuid
- inner join components p on p.uuid=i.component_uuid
- inner join components root on root.uuid=i.project_uuid
- where i.kee=#{kee,jdbcType=VARCHAR}
- </select>
-
- <select id="scrollNonClosedByComponentUuid" parameterType="String" resultType="Issue" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
- select
- <include refid="issueColumns"/>
- from issues i
- inner join rules r on r.uuid=i.rule_uuid
- inner join components p on p.uuid=i.component_uuid
- inner join components root on root.uuid=i.project_uuid
- where
- i.component_uuid = #{componentUuid,jdbcType=VARCHAR} and
- i.status <> 'CLOSED'
- </select>
-
- <select id="selectNonClosedByComponentUuidExcludingExternals" parameterType="String" resultType="Issue">
- select
- <include refid="issueColumns"/>
- from issues i
- inner join rules r on r.uuid=i.rule_uuid
- inner join components p on p.uuid=i.component_uuid
- inner join components root on root.uuid=i.project_uuid
- where
- (r.is_external is NULL or r.is_external = ${_false}) and
- i.component_uuid = #{componentUuid,jdbcType=VARCHAR} and
- i.status <> 'CLOSED' and
- i.issue_type <> 4
- </select>
-
- <select id="scrollClosedByComponentUuid" resultType="Issue" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
- select
- <include refid="issueColumns"/>,
- ic.change_data as closedChangeData
- from issues i
- inner join rules r on
- r.uuid = i.rule_uuid
- inner join components p on
- p.uuid = i.component_uuid
- inner join components root on
- root.uuid = i.project_uuid
- inner join issue_changes ic on
- ic.issue_key = i.kee
- and ic.change_type = 'diff'
- and ic.change_data like '%status=%|CLOSED%'
- where
- i.component_uuid = #{componentUuid,jdbcType=VARCHAR}
- and i.status = 'CLOSED'
- and i.issue_close_date is not null
- and i.issue_close_date >= #{closeDateAfter,jdbcType=BIGINT}
- and i.issue_type <> 4
- order by
- i.kee, ic.issue_change_creation_date desc
- </select>
-
- <select id="selectModuleAndDirComponentUuidsOfOpenIssuesForProjectUuid" parameterType="string" resultType="string">
- select
- distinct(i.component_uuid)
- from issues i
- inner join components p on
- p.uuid = i.component_uuid
- and p.enabled = ${_true}
- where
- i.project_uuid=#{projectUuid,jdbcType=VARCHAR}
- and i.status <> 'CLOSED'
- and (p.qualifier = 'DIR' OR p.qualifier = 'BRC')
- </select>
-
- <select id="selectComponentUuidsOfOpenIssuesForProjectUuid" parameterType="string" resultType="string">
- select distinct(i.component_uuid)
- from issues i
- where i.project_uuid=#{projectUuid,jdbcType=VARCHAR} and i.status <> 'CLOSED'
- </select>
-
- <select id="selectByKeys" parameterType="map" resultType="Issue">
- select
- <include refid="issueColumns"/>
- from issues i
- inner join rules r on r.uuid=i.rule_uuid
- inner join components p on p.uuid=i.component_uuid
- inner join components root on root.uuid=i.project_uuid
- where i.kee in
- <foreach collection="list" open="(" close=")" item="key" separator=",">
- #{key,jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <select id="selectByKeysIfNotUpdatedAt" parameterType="map" resultType="Issue">
- select
- <include refid="issueColumns"/>
- from issues i
- inner join rules r on r.uuid=i.rule_uuid
- inner join components p on p.uuid=i.component_uuid
- inner join components root on root.uuid=i.project_uuid
- where
- i.kee in
- <foreach collection="keys" open="(" close=")" item="key" separator=",">
- #{key,jdbcType=VARCHAR}
- </foreach>
- and i.updated_at <> #{updatedAt,jdbcType=BIGINT}
- </select>
-
- <select id="selectOpenByComponentUuids" parameterType="map" resultType="PrIssue">
- select
- i.kee as kee,
- i.message as message,
- i.line as line,
- i.status as status,
- i.checksum as checksum,
- i.issue_update_date as issueUpdateDate,
- r.plugin_rule_key as ruleKey,
- r.plugin_name as ruleRepo,
- b.kee as branchKey,
- b.key_type as keyType
- from issues i
- inner join rules r on r.uuid = i.rule_uuid
- inner join project_branches b on i.project_uuid = b.uuid
- where i.component_uuid in
- <foreach collection="list" open="(" close=")" item="key" separator=",">
- #{key,jdbcType=VARCHAR}
- </foreach>
- and i.status <> 'CLOSED'
- </select>
-
- <select id="selectNonClosedByModuleOrProject" parameterType="map" resultType="Issue">
- select
- <include refid="issueColumns"/>
- from issues i
- inner join rules r on r.uuid = i.rule_uuid
- inner join components p on p.uuid = i.component_uuid
- inner join components root on root.uuid = i.project_uuid
- where
- (r.is_external is NULL or r.is_external = ${_false}) and
- i.project_uuid = #{projectUuid, jdbcType=VARCHAR} and
- p.module_uuid_path like #{likeModuleUuidPath, jdbcType=VARCHAR} escape '/' and
- i.status <> 'CLOSED' and
- i.issue_type <> 4
- </select>
-
- <select id="selectIssueGroupsByBaseComponent" resultType="org.sonar.db.issue.IssueGroupDto" parameterType="map">
- select i.issue_type as ruleType, i.severity as severity, i.resolution as resolution, i.status as status, sum(i.effort) as effort, count(i.issue_type) as "count", (i.issue_creation_date > #{leakPeriodBeginningDate,jdbcType=BIGINT}) as inLeak
- from issues i
- inner join components p on p.uuid = i.component_uuid and p.project_uuid = i.project_uuid
- where i.status !='CLOSED'
- and i.project_uuid = #{baseComponent.projectUuid,jdbcType=VARCHAR}
- and (p.uuid_path like #{baseComponent.uuidPathLikeIncludingSelf,jdbcType=VARCHAR} escape '/' or p.uuid = #{baseComponent.uuid,jdbcType=VARCHAR})
- group by i.issue_type, i.severity, i.resolution, i.status, inLeak
- </select>
-
- <select id="selectIssueGroupsByBaseComponent" resultType="org.sonar.db.issue.IssueGroupDto" parameterType="map" databaseId="oracle">
- select i2.issue_type as ruleType, i2.severity as severity, i2.resolution as resolution, i2.status as status, sum(i2.effort) as effort, count(i2.issue_type) as "count", i2.inLeak as inLeak
- from (
- select i.issue_type, i.severity, i.resolution, i.status, i.effort, case when i.issue_creation_date > #{leakPeriodBeginningDate,jdbcType=BIGINT} then 1 else 0 end as inLeak
- from issues i
- inner join components p on p.uuid = i.component_uuid and p.project_uuid = i.project_uuid
- where i.status !='CLOSED'
- and i.project_uuid = #{baseComponent.projectUuid,jdbcType=VARCHAR}
- and (p.uuid_path like #{baseComponent.uuidPathLikeIncludingSelf,jdbcType=VARCHAR} escape '/' or p.uuid = #{baseComponent.uuid,jdbcType=VARCHAR})
- ) i2
- group by i2.issue_type, i2.severity, i2.resolution, i2.status, i2.inLeak
- </select>
-
- <select id="selectIssueGroupsByBaseComponent" resultType="org.sonar.db.issue.IssueGroupDto" parameterType="map" databaseId="mssql">
- select i2.issue_type as ruleType, i2.severity as severity, i2.resolution as resolution, i2.status as status, sum(i2.effort) as effort, count(i2.issue_type) as "count", i2.inLeak as inLeak
- from (
- select i.issue_type, i.severity, i.resolution, i.status, i.effort, case when i.issue_creation_date > #{leakPeriodBeginningDate,jdbcType=BIGINT} then 1 else 0 end as inLeak
- from issues i
- inner join components p on p.uuid = i.component_uuid and p.project_uuid = i.project_uuid
- where i.status !='CLOSED'
- and i.project_uuid = #{baseComponent.projectUuid,jdbcType=VARCHAR}
- and (p.uuid_path like #{baseComponent.uuidPathLikeIncludingSelf,jdbcType=VARCHAR} escape '/' or p.uuid = #{baseComponent.uuid,jdbcType=VARCHAR})
- ) i2
- group by i2.issue_type, i2.severity, i2.resolution, i2.status, i2.inLeak
- </select>
- </mapper>
|