You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RuleMapper.xml 19KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd">
  3. <mapper namespace="org.sonar.db.rule.RuleMapper">
  4. <sql id="ruleColumns">
  5. r.plugin_rule_key as "ruleKey",
  6. r.plugin_name as "repositoryKey",
  7. r.description_format as "descriptionFormat",
  8. r.status,
  9. r.name,
  10. r.plugin_config_key as "configKey",
  11. r.priority as "severity",
  12. r.is_template as "isTemplate",
  13. r.is_external as "isExternal",
  14. r.is_ad_hoc as "isAdHoc",
  15. r.language as "language",
  16. r.template_uuid as "templateUuid",
  17. r.def_remediation_function as "defRemediationFunction",
  18. r.def_remediation_gap_mult as "defRemediationGapMultiplier",
  19. r.def_remediation_base_effort as "defRemediationBaseEffort",
  20. r.gap_description as "gapDescription",
  21. r.system_tags as "systemTagsField",
  22. r.security_standards as "securityStandardsField",
  23. r.rule_type as "type",
  24. r.plugin_key as "pluginKey",
  25. r.scope,
  26. r.created_at as "createdAt",
  27. r.updated_at as "updatedAt",
  28. r.note_data as "noteData",
  29. r.note_user_uuid as "noteUserUuid",
  30. r.note_created_at as "noteCreatedAt",
  31. r.note_updated_at as "noteUpdatedAt",
  32. r.remediation_function as "remediationFunction",
  33. r.remediation_gap_mult as "remediationGapMultiplier",
  34. r.remediation_base_effort as "remediationBaseEffort",
  35. r.tags as "tagsField",
  36. r.ad_hoc_name as "adHocName",
  37. r.ad_hoc_description as "adHocDescription",
  38. r.ad_hoc_severity as "adHocSeverity",
  39. r.ad_hoc_type as "adHocType",
  40. r.education_principles as "educationPrinciplesField",
  41. r.clean_code_attribute as "cleanCodeAttribute"
  42. </sql>
  43. <sql id="leftOuterJoinRulesDescriptionSections">
  44. left outer join rule_desc_sections rds on
  45. rds.rule_uuid = r.uuid
  46. </sql>
  47. <sql id="leftOuterJoinRulesDefaultImpacts">
  48. left outer join rules_default_impacts rdi on
  49. rdi.rule_uuid = r.uuid
  50. </sql>
  51. <sql id="selectJoinedTablesColumns">
  52. <!-- rule default impacts -->
  53. rdi.uuid as "rdi_uuid",
  54. rdi.rule_uuid as "rdi_ruleUuid",
  55. rdi.software_quality as "rdi_softwareQuality",
  56. rdi.severity as "rdi_severity",
  57. <!-- rule description sections -->
  58. rds.content as "rds_content",
  59. rds.uuid as "rds_uuid",
  60. rds.kee as "rds_kee",
  61. rds.context_key as "rds_contextKey",
  62. rds.context_display_name as "rds_contextDisplayName",
  63. <!-- rule -->
  64. r.uuid as "r_uuid",
  65. <include refid="ruleColumns"/>
  66. </sql>
  67. <select id="selectAll" resultMap="ruleResultMap">
  68. select
  69. <include refid="selectJoinedTablesColumns"/>
  70. from
  71. rules r
  72. <include refid="leftOuterJoinRulesDescriptionSections"/>
  73. <include refid="leftOuterJoinRulesDefaultImpacts"/>
  74. order by r.uuid
  75. </select>
  76. <resultMap id="ruleResultMap" type="org.sonar.db.rule.RuleDto" autoMapping="true">
  77. <id property="uuid" column="r_uuid"/>
  78. <collection property="ruleDescriptionSectionDtos" ofType="org.sonar.db.rule.RuleDescriptionSectionDto" autoMapping="true"
  79. columnPrefix="rds_">
  80. <id property="uuid" column="uuid"/>
  81. <result property="key" column="kee"/>
  82. <association property="context" javaType="org.sonar.db.rule.RuleDescriptionSectionContextDto" autoMapping="false">
  83. <constructor>
  84. <arg column="contextKey" javaType="String"/>
  85. <arg column="contextDisplayName" javaType="String"/>
  86. </constructor>
  87. </association>
  88. </collection>
  89. <collection property="defaultImpacts" column="rdi_uuid" notNullColumn="rdi_uuid" javaType="java.util.Set" ofType="Impact">
  90. <id property="uuid" column="rdi_uuid"/>
  91. <result property="softwareQuality" column="rdi_softwareQuality"/>
  92. <result property="severity" column="rdi_severity"/>
  93. </collection>
  94. </resultMap>
  95. <select id="selectEnabled" resultMap="ruleResultMap">
  96. select
  97. <include refid="selectJoinedTablesColumns"/>
  98. from
  99. rules r
  100. <include refid="leftOuterJoinRulesDescriptionSections"/>
  101. <include refid="leftOuterJoinRulesDefaultImpacts"/>
  102. where
  103. r.status != 'REMOVED'
  104. order by r.uuid
  105. </select>
  106. <select id="selectByUuid" parameterType="map" resultMap="ruleResultMap">
  107. select
  108. <include refid="selectJoinedTablesColumns"/>
  109. from
  110. rules r
  111. <include refid="leftOuterJoinRulesDescriptionSections"/>
  112. <include refid="leftOuterJoinRulesDefaultImpacts"/>
  113. where
  114. r.uuid=#{uuid,jdbcType=VARCHAR}
  115. order by r.uuid
  116. </select>
  117. <select id="selectByUuids" parameterType="map" resultMap="ruleResultMap">
  118. select
  119. <include refid="selectJoinedTablesColumns"/>
  120. from
  121. rules r
  122. <include refid="leftOuterJoinRulesDescriptionSections"/>
  123. <include refid="leftOuterJoinRulesDefaultImpacts"/>
  124. where
  125. <foreach collection="uuids" index="index" item="uuid" open="" separator=" or " close="">
  126. r.uuid=#{uuid,jdbcType=VARCHAR}
  127. </foreach>
  128. order by r.uuid
  129. </select>
  130. <select id="selectByKey" parameterType="map" resultMap="ruleResultMap">
  131. select
  132. <include refid="selectJoinedTablesColumns"/>
  133. from
  134. rules r
  135. <include refid="leftOuterJoinRulesDescriptionSections"/>
  136. <include refid="leftOuterJoinRulesDefaultImpacts"/>
  137. where
  138. r.plugin_name=#{ruleKey.repository,jdbcType=VARCHAR}
  139. and r.plugin_rule_key=#{ruleKey.rule,jdbcType=VARCHAR}
  140. order by r.uuid
  141. </select>
  142. <select id="selectIndexingRuleExtensionsByIds" parameterType="map" resultType="org.sonar.db.rule.RuleExtensionForIndexingDto">
  143. <include refid="sqlSelectIndexingRuleExtensions"/>
  144. and
  145. <foreach collection="ruleExtensionIds" index="index" item="ruleExtId" open="" separator=" or " close="">
  146. ( r.uuid = #{ruleExtId, jdbcType=VARCHAR} )
  147. </foreach>
  148. </select>
  149. <sql id="sqlSelectIndexingRuleExtensions">
  150. select
  151. r.uuid as "ruleUuid",
  152. r.plugin_name as "pluginName",
  153. r.plugin_rule_key as "pluginRuleKey",
  154. r.tags as "tags"
  155. from rules r
  156. where
  157. r.tags is not null and
  158. r.tags != ''
  159. </sql>
  160. <sql id="sqlSelectIndexingRuleExtensions" databaseId="oracle">
  161. select
  162. r.uuid as "ruleUuid",
  163. r.plugin_name as "pluginName",
  164. r.plugin_rule_key as "pluginRuleKey",
  165. r.tags as "tags"
  166. from rules r
  167. where
  168. r.tags is not null
  169. </sql>
  170. <select id="selectByKeys" parameterType="map" resultMap="ruleResultMap">
  171. select
  172. <include refid="selectJoinedTablesColumns"/>
  173. from
  174. rules r
  175. <include refid="leftOuterJoinRulesDescriptionSections"/>
  176. <include refid="leftOuterJoinRulesDefaultImpacts"/>
  177. where
  178. <foreach collection="ruleKeys" index="index" item="ruleKey" open="" separator=" or " close="">
  179. (r.plugin_name=#{ruleKey.repository,jdbcType=VARCHAR} and r.plugin_rule_key=#{ruleKey.rule,jdbcType=VARCHAR})
  180. </foreach>
  181. order by r.uuid
  182. </select>
  183. <select id="selectByQuery" parameterType="map" resultMap="ruleResultMap">
  184. select
  185. <include refid="selectJoinedTablesColumns"/>
  186. from
  187. rules r
  188. <include refid="leftOuterJoinRulesDescriptionSections"/>
  189. <include refid="leftOuterJoinRulesDefaultImpacts"/>
  190. where
  191. r.status != 'REMOVED'
  192. <if test="query.repositoryKey!=null">
  193. and r.plugin_name = #{query.repositoryKey,jdbcType=VARCHAR}
  194. </if>
  195. <if test="query.key!=null">
  196. and r.plugin_rule_key = #{query.key,jdbcType=VARCHAR}
  197. </if>
  198. <if test="query.configKey!=null">
  199. and r.plugin_config_key = #{query.configKey,jdbcType=VARCHAR}
  200. </if>
  201. order by
  202. r.uuid,
  203. r.updated_at desc
  204. </select>
  205. <select id="selectByTypeAndLanguages" parameterType="map" resultMap="ruleResultMap">
  206. select
  207. <include refid="selectJoinedTablesColumns"/>
  208. from
  209. rules r
  210. <include refid="leftOuterJoinRulesDescriptionSections"/>
  211. <include refid="leftOuterJoinRulesDefaultImpacts"/>
  212. where
  213. r.status != 'REMOVED' and r.is_external=${_false} and r.is_template=${_false}
  214. and r.rule_type in
  215. <foreach collection="types" item="type" separator="," open="(" close=")">#{type, jdbcType=INTEGER}</foreach>
  216. and r.language in
  217. <foreach collection="languages" item="language" separator="," open="(" close=")">#{language, jdbcType=VARCHAR}</foreach>
  218. order by r.uuid
  219. </select>
  220. <select id="selectByLanguage" parameterType="String" resultType="org.sonar.db.rule.RuleDto" fetchSize="${_scrollFetchSize}"
  221. resultSetType="FORWARD_ONLY">
  222. select
  223. r.uuid as uuid,
  224. <include refid="ruleColumns"/>
  225. from
  226. rules r
  227. where
  228. <include refid="conditionNotExternalRulesByLanguage" />
  229. </select>
  230. <select id="countByLanguage" resultType="java.lang.Long">
  231. select count(*)
  232. from
  233. rules r
  234. where
  235. <include refid="conditionNotExternalRulesByLanguage" />
  236. </select>
  237. <sql id="conditionNotExternalRulesByLanguage">
  238. r.status in ('READY', 'DEPRECATED', 'BETA')
  239. and r.is_external=${_false}
  240. and r.language=#{language, jdbcType=VARCHAR}
  241. </sql>
  242. <insert id="insertRuleDescriptionSection" parameterType="Map" useGeneratedKeys="false">
  243. insert into rule_desc_sections (
  244. uuid,
  245. rule_uuid,
  246. kee,
  247. content,
  248. context_key,
  249. context_display_name
  250. )
  251. values (
  252. #{dto.uuid,jdbcType=VARCHAR},
  253. #{ruleUuid,jdbcType=VARCHAR},
  254. #{dto.key,jdbcType=VARCHAR},
  255. #{dto.content,jdbcType=VARCHAR},
  256. #{dto.context.key,jdbcType=VARCHAR},
  257. #{dto.context.displayName,jdbcType=VARCHAR}
  258. )
  259. </insert>
  260. <insert id="insertRule" parameterType="org.sonar.db.rule.RuleDto" useGeneratedKeys="false">
  261. insert into rules (
  262. uuid,
  263. plugin_key,
  264. plugin_rule_key,
  265. plugin_name,
  266. description_format,
  267. status,
  268. name,
  269. plugin_config_key,
  270. priority,
  271. is_template,
  272. is_external,
  273. is_ad_hoc,
  274. language,
  275. template_uuid,
  276. def_remediation_function,
  277. def_remediation_gap_mult,
  278. def_remediation_base_effort,
  279. gap_description,
  280. system_tags,
  281. security_standards,
  282. rule_type,
  283. scope,
  284. note_data,
  285. note_user_uuid,
  286. note_created_at,
  287. note_updated_at,
  288. remediation_function,
  289. remediation_gap_mult,
  290. remediation_base_effort,
  291. tags,
  292. ad_hoc_name,
  293. ad_hoc_description,
  294. ad_hoc_severity,
  295. ad_hoc_type,
  296. education_principles,
  297. clean_code_attribute,
  298. created_at,
  299. updated_at
  300. )
  301. values (
  302. #{uuid,jdbcType=VARCHAR},
  303. #{pluginKey,jdbcType=VARCHAR},
  304. #{ruleKey,jdbcType=VARCHAR},
  305. #{repositoryKey,jdbcType=VARCHAR},
  306. #{descriptionFormat,jdbcType=VARCHAR},
  307. #{status,jdbcType=VARCHAR},
  308. #{name,jdbcType=VARCHAR},
  309. #{configKey,jdbcType=VARCHAR},
  310. #{severity,jdbcType=INTEGER},
  311. #{isTemplate,jdbcType=BOOLEAN},
  312. #{isExternal,jdbcType=BOOLEAN},
  313. #{isAdHoc,jdbcType=BOOLEAN},
  314. #{language,jdbcType=VARCHAR},
  315. #{templateUuid,jdbcType=VARCHAR},
  316. #{defRemediationFunction,jdbcType=VARCHAR},
  317. #{defRemediationGapMultiplier,jdbcType=VARCHAR},
  318. #{defRemediationBaseEffort,jdbcType=VARCHAR},
  319. #{gapDescription,jdbcType=VARCHAR},
  320. #{systemTagsField,jdbcType=VARCHAR},
  321. #{securityStandardsField,jdbcType=VARCHAR},
  322. #{type,jdbcType=TINYINT},
  323. #{scope,jdbcType=VARCHAR},
  324. #{noteData,jdbcType=CLOB},
  325. #{noteUserUuid,jdbcType=VARCHAR},
  326. #{noteCreatedAt,jdbcType=BIGINT},
  327. #{noteUpdatedAt,jdbcType=BIGINT},
  328. #{remediationFunction,jdbcType=VARCHAR},
  329. #{remediationGapMultiplier,jdbcType=VARCHAR},
  330. #{remediationBaseEffort,jdbcType=VARCHAR},
  331. #{tagsField,jdbcType=VARCHAR},
  332. #{adHocName,jdbcType=VARCHAR},
  333. #{adHocDescription,jdbcType=CLOB},
  334. #{adHocSeverity,jdbcType=VARCHAR},
  335. #{adHocType,jdbcType=TINYINT},
  336. #{educationPrinciplesField,jdbcType=VARCHAR},
  337. #{cleanCodeAttribute,jdbcType=VARCHAR},
  338. #{createdAt,jdbcType=BIGINT},
  339. #{updatedAt,jdbcType=BIGINT}
  340. )
  341. </insert>
  342. <insert id="insertRuleDefaultImpact" parameterType="Map" useGeneratedKeys="false">
  343. INSERT INTO rules_default_impacts (uuid, rule_uuid, software_quality, severity)
  344. VALUES (
  345. #{dto.uuid,jdbcType=VARCHAR},
  346. #{ruleUuid,jdbcType=VARCHAR},
  347. #{dto.softwareQuality,jdbcType=VARCHAR},
  348. #{dto.severity,jdbcType=VARCHAR})
  349. </insert>
  350. <update id="updateRule" parameterType="org.sonar.db.rule.RuleDto">
  351. update rules set
  352. plugin_key=#{pluginKey,jdbcType=VARCHAR},
  353. plugin_rule_key=#{ruleKey,jdbcType=VARCHAR},
  354. plugin_name=#{repositoryKey,jdbcType=VARCHAR},
  355. description_format=#{descriptionFormat,jdbcType=VARCHAR},
  356. status=#{status,jdbcType=VARCHAR},
  357. name=#{name,jdbcType=VARCHAR},
  358. plugin_config_key=#{configKey,jdbcType=VARCHAR},
  359. priority=#{severity,jdbcType=INTEGER},
  360. is_template=#{isTemplate,jdbcType=BOOLEAN},
  361. is_external=#{isExternal,jdbcType=BOOLEAN},
  362. is_ad_hoc=#{isAdHoc,jdbcType=BOOLEAN},
  363. language=#{language,jdbcType=VARCHAR},
  364. template_uuid=#{templateUuid,jdbcType=VARCHAR},
  365. def_remediation_function=#{defRemediationFunction,jdbcType=VARCHAR},
  366. def_remediation_gap_mult=#{defRemediationGapMultiplier,jdbcType=VARCHAR},
  367. def_remediation_base_effort=#{defRemediationBaseEffort,jdbcType=VARCHAR},
  368. gap_description=#{gapDescription,jdbcType=VARCHAR},
  369. system_tags=#{systemTagsField,jdbcType=VARCHAR},
  370. security_standards=#{securityStandardsField,jdbcType=VARCHAR},
  371. scope=#{scope,jdbcType=VARCHAR},
  372. rule_type=#{type,jdbcType=TINYINT},
  373. note_data=#{noteData,jdbcType=CLOB},
  374. note_user_uuid=#{noteUserUuid,jdbcType=VARCHAR},
  375. note_created_at=#{noteCreatedAt,jdbcType=BIGINT},
  376. note_updated_at=#{noteUpdatedAt,jdbcType=BIGINT},
  377. remediation_function=#{remediationFunction,jdbcType=VARCHAR},
  378. remediation_gap_mult=#{remediationGapMultiplier,jdbcType=VARCHAR},
  379. remediation_base_effort=#{remediationBaseEffort,jdbcType=VARCHAR},
  380. tags=#{tagsField,jdbcType=VARCHAR},
  381. ad_hoc_name=#{adHocName,jdbcType=VARCHAR},
  382. ad_hoc_description=#{adHocDescription,jdbcType=CLOB},
  383. ad_hoc_severity=#{adHocSeverity,jdbcType=VARCHAR},
  384. ad_hoc_type=#{adHocType,jdbcType=TINYINT},
  385. education_principles=#{educationPrinciplesField,jdbcType=VARCHAR},
  386. clean_code_attribute=#{cleanCodeAttribute,jdbcType=VARCHAR},
  387. updated_at=#{updatedAt,jdbcType=BIGINT}
  388. where
  389. uuid=#{uuid,jdbcType=VARCHAR}
  390. </update>
  391. <delete id="deleteRuleDescriptionSection" parameterType="String">
  392. delete from
  393. rule_desc_sections
  394. where
  395. rule_uuid=#{ruleUuid,jdbcType=VARCHAR}
  396. </delete>
  397. <delete id="deleteRuleDefaultImpacts" parameterType="String">
  398. delete from
  399. rules_default_impacts
  400. where
  401. rule_uuid=#{ruleUuid,jdbcType=VARCHAR}
  402. </delete>
  403. <delete id="deleteParams" parameterType="String">
  404. delete from
  405. active_rule_parameters
  406. where
  407. rules_parameter_uuid=#{uuid,jdbcType=VARCHAR}
  408. </delete>
  409. <sql id="paramColumns">
  410. p.uuid as "uuid",
  411. p.rule_uuid as "ruleUuid",
  412. p.name as "name",
  413. p.param_type as "type",
  414. p.default_value as "defaultValue",
  415. p.description as "description"
  416. </sql>
  417. <select id="selectParamsByRuleUuids" resultType="RuleParam">
  418. select
  419. <include refid="paramColumns"/>
  420. from
  421. rules_parameters p
  422. where
  423. <foreach item="uuid" index="index" collection="ruleUuids" open="(" separator=" or " close=")">
  424. p.rule_uuid=#{uuid,jdbcType=VARCHAR}
  425. </foreach>
  426. </select>
  427. <select id="selectAllRuleParams" resultType="RuleParam">
  428. select
  429. <include refid="paramColumns"/>
  430. from
  431. rules_parameters p
  432. </select>
  433. <select id="selectParamsByRuleKey" resultType="RuleParam" parameterType="org.sonar.api.rule.RuleKey">
  434. select
  435. <include refid="paramColumns"/>
  436. from
  437. rules_parameters p, rules r
  438. where
  439. p.rule_uuid=r.uuid
  440. and r.plugin_name=#{repository,jdbcType=VARCHAR}
  441. and r.plugin_rule_key=#{rule,jdbcType=VARCHAR}
  442. </select>
  443. <select id="selectParamsByRuleKeys" resultType="RuleParam" parameterType="map">
  444. select
  445. <include refid="paramColumns"/>
  446. from
  447. rules_parameters p
  448. inner join rules r on
  449. r.uuid=p.rule_uuid
  450. where
  451. <foreach collection="ruleKeys" index="index" item="ruleKey" open="" separator=" or " close="">
  452. (r.plugin_name=#{ruleKey.repository,jdbcType=VARCHAR} AND r.plugin_rule_key=#{ruleKey.rule,jdbcType=VARCHAR})
  453. </foreach>
  454. </select>
  455. <delete id="deleteParameter" parameterType="String">
  456. delete from
  457. rules_parameters
  458. where
  459. uuid=#{uuid,jdbcType=INTEGER}
  460. </delete>
  461. <insert id="insertParameter" parameterType="RuleParam" useGeneratedKeys="false">
  462. insert into rules_parameters (
  463. uuid,
  464. rule_uuid,
  465. name,
  466. param_type,
  467. default_value,
  468. description
  469. )
  470. values (
  471. #{uuid,jdbcType=VARCHAR},
  472. #{ruleUuid,jdbcType=VARCHAR},
  473. #{name,jdbcType=VARCHAR},
  474. #{type,jdbcType=VARCHAR},
  475. #{defaultValue,jdbcType=VARCHAR},
  476. #{description,jdbcType=VARCHAR}
  477. )
  478. </insert>
  479. <update id="updateParameter" parameterType="RuleParam">
  480. update rules_parameters set
  481. param_type=#{type,jdbcType=VARCHAR},
  482. default_value=#{defaultValue,jdbcType=VARCHAR},
  483. description=#{description,jdbcType=VARCHAR}
  484. where
  485. uuid=#{uuid,jdbcType=VARCHAR}
  486. </update>
  487. <select id="selectAllDeprecatedRuleKeys" resultType="org.sonar.db.rule.DeprecatedRuleKeyDto">
  488. SELECT
  489. drk.uuid,
  490. drk.rule_uuid as "ruleUuid",
  491. drk.old_repository_key as "oldRepositoryKey",
  492. drk.old_rule_key as "oldRuleKey",
  493. r.plugin_rule_key as "newRuleKey",
  494. r.plugin_name as "newRepositoryKey",
  495. drk.created_at as "createdAt"
  496. FROM
  497. deprecated_rule_keys drk
  498. LEFT OUTER JOIN rules r on r.uuid = drk.rule_uuid
  499. </select>
  500. <select id="selectDeprecatedRuleKeysByRuleUuids" resultType="org.sonar.db.rule.DeprecatedRuleKeyDto">
  501. SELECT
  502. drk.uuid,
  503. drk.rule_uuid as "ruleUuid",
  504. drk.old_repository_key as "oldRepositoryKey",
  505. drk.old_rule_key as "oldRuleKey",
  506. r.plugin_rule_key as "newRuleKey",
  507. r.plugin_name as "newRepositoryKey",
  508. drk.created_at as "createdAt"
  509. FROM
  510. deprecated_rule_keys drk
  511. LEFT OUTER JOIN rules r on r.uuid = drk.rule_uuid
  512. WHERE
  513. <foreach item="uuid" index="index" collection="ruleUuids" open="(" separator=" or " close=")">
  514. drk.rule_uuid=#{uuid,jdbcType=VARCHAR}
  515. </foreach>
  516. </select>
  517. <delete id="deleteDeprecatedRuleKeys">
  518. DELETE FROM
  519. deprecated_rule_keys
  520. WHERE
  521. <foreach collection="uuids" index="index" item="uuid" open="" separator=" or " close="">
  522. uuid=#{uuid,jdbcType=INTEGER}
  523. </foreach>
  524. </delete>
  525. <insert id="insertDeprecatedRuleKey" parameterType="org.sonar.db.rule.DeprecatedRuleKeyDto" keyColumn="uuid" useGeneratedKeys="false"
  526. keyProperty="uuid">
  527. INSERT INTO deprecated_rule_keys (
  528. uuid,
  529. rule_uuid,
  530. old_repository_key,
  531. old_rule_key,
  532. created_at
  533. )
  534. values (
  535. #{uuid,jdbcType=VARCHAR},
  536. #{ruleUuid,jdbcType=VARCHAR},
  537. #{oldRepositoryKey,jdbcType=VARCHAR},
  538. #{oldRuleKey,jdbcType=VARCHAR},
  539. #{createdAt,jdbcType=BIGINT}
  540. )
  541. </insert>
  542. </mapper>