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 20KB

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