-
Notifications
You must be signed in to change notification settings - Fork 1.9k
/
IssueMapper.xml
247 lines (231 loc) · 8.85 KB
/
IssueMapper.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<?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.id,
i.kee as kee,
i.rule_id as ruleId,
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 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,
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 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>
<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.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" keyProperty="id">
INSERT INTO issues (kee, rule_id, 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}, #{ruleId,jdbcType=INTEGER},
#{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},
#{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}, #{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=#{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},
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=#{assignee,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.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,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.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,jdbcType=VARCHAR} and
i.status <> 'CLOSED'
</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.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,jdbcType=VARCHAR}
</foreach>
</select>
<select id="selectResolvedOrConfirmedByComponentUuids" parameterType="map" resultType="ShortBranchIssue">
select
i.kee as kee,
i.message as message,
i.line as line,
i.status as status,
i.checksum as checksum,
r.plugin_rule_key as ruleKey,
r.plugin_name as ruleRepo
from issues i
inner join rules r on r.id = i.rule_id
where i.component_uuid in
<foreach collection="list" open="(" close=")" item="key" separator=",">
#{key,jdbcType=VARCHAR}
</foreach>
and (i.status = 'CONFIRMED' OR i.status = 'RESOLVED')
</select>
<select id="scrollNonClosedByModuleOrProject" parameterType="map" resultType="Issue" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY">
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.project_uuid = #{projectUuid, jdbcType=VARCHAR} and
p.module_uuid_path like #{likeModuleUuidPath, jdbcType=VARCHAR} escape '/' and
i.status <> 'CLOSED'
</select>
</mapper>