123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660 |
- <?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.rule.RuleMapper">
-
- <sql id="ruleColumns">
- r.plugin_rule_key as "ruleKey",
- r.plugin_name as "repositoryKey",
- r.description_format as "descriptionFormat",
- r.status,
- r.name,
- r.plugin_config_key as "configKey",
- r.priority as "severity",
- r.is_template as "isTemplate",
- r.is_external as "isExternal",
- r.is_ad_hoc as "isAdHoc",
- r.language as "language",
- r.template_uuid as "templateUuid",
- r.def_remediation_function as "defRemediationFunction",
- r.def_remediation_gap_mult as "defRemediationGapMultiplier",
- r.def_remediation_base_effort as "defRemediationBaseEffort",
- r.gap_description as "gapDescription",
- r.security_standards as "securityStandardsField",
- r.rule_type as "type",
- r.plugin_key as "pluginKey",
- r.scope,
- r.created_at as "createdAt",
- r.updated_at as "updatedAt",
- r.note_data as "noteData",
- r.note_user_uuid as "noteUserUuid",
- r.note_created_at as "noteCreatedAt",
- r.note_updated_at as "noteUpdatedAt",
- r.remediation_function as "remediationFunction",
- r.remediation_gap_mult as "remediationGapMultiplier",
- r.remediation_base_effort as "remediationBaseEffort",
- r.ad_hoc_name as "adHocName",
- r.ad_hoc_description as "adHocDescription",
- r.ad_hoc_severity as "adHocSeverity",
- r.ad_hoc_type as "adHocType",
- r.education_principles as "educationPrinciplesField",
- r.clean_code_attribute as "cleanCodeAttribute"
- </sql>
-
- <sql id="leftOuterJoinRulesDescriptionSections">
- left outer join rule_desc_sections rds on
- rds.rule_uuid = r.uuid
- </sql>
-
- <sql id="leftOuterJoinRulesDefaultImpacts">
- left outer join rules_default_impacts rdi on
- rdi.rule_uuid = r.uuid
- </sql>
-
- <sql id="leftOuterJoinRulesTags">
- left outer join rule_tags rt on
- rt.rule_uuid = r.uuid
- </sql>
-
- <sql id="selectJoinedTablesColumns">
- <!-- rule default impacts -->
- rdi.uuid as "rdi_uuid",
- rdi.rule_uuid as "rdi_ruleUuid",
- rdi.software_quality as "rdi_softwareQuality",
- rdi.severity as "rdi_severity",
- <!-- rule tags -->
- CASE WHEN rt.is_system_tag = ${_true} THEN rt.value ELSE NULL END as rt_systemTags,
- CASE WHEN rt.is_system_tag = ${_false} THEN rt.value ELSE NULL END as rt_tags,
- rt.is_system_tag as "rt_isSystemTag",
- rt.value as "rt_value",
- <!-- rule description sections -->
- rds.content as "rds_content",
- rds.uuid as "rds_uuid",
- rds.kee as "rds_kee",
- rds.context_key as "rds_contextKey",
- rds.context_display_name as "rds_contextDisplayName",
- <!-- rule -->
- r.uuid as "r_uuid",
- <include refid="ruleColumns"/>
- </sql>
-
- <select id="selectAll" resultMap="ruleResultMap">
- select
- <include refid="selectJoinedTablesColumns"/>
- from
- rules r
- <include refid="leftOuterJoinRulesDescriptionSections"/>
- <include refid="leftOuterJoinRulesDefaultImpacts"/>
- <include refid="leftOuterJoinRulesTags"/>
- order by r.uuid
- </select>
-
- <resultMap id="ruleResultMap" type="org.sonar.db.rule.RuleDto" autoMapping="true">
- <id property="uuid" column="r_uuid"/>
-
- <collection property="ruleDescriptionSectionDtos" ofType="org.sonar.db.rule.RuleDescriptionSectionDto" autoMapping="true"
- columnPrefix="rds_">
- <id property="uuid" column="uuid"/>
- <result property="key" column="kee"/>
- <association property="context" javaType="org.sonar.db.rule.RuleDescriptionSectionContextDto" autoMapping="false">
- <constructor>
- <arg column="contextKey" javaType="String"/>
- <arg column="contextDisplayName" javaType="String"/>
- </constructor>
- </association>
- </collection>
- <collection property="defaultImpacts" column="rdi_uuid" notNullColumn="rdi_uuid" javaType="java.util.Set" ofType="Impact">
- <id property="uuid" column="rdi_uuid"/>
- <result property="softwareQuality" column="rdi_softwareQuality"/>
- <result property="severity" column="rdi_severity"/>
- </collection>
- <collection property="systemTags" column="rt_systemTags" notNullColumn="rt_systemTags" javaType="java.util.Set" ofType="string">
- <result column="rt_systemTags"/>
- </collection>
- <collection property="tags" column="rt_tags" notNullColumn="rt_tags" javaType="java.util.Set" ofType="string">
- <result column="rt_tags"/>
- </collection>
- </resultMap>
-
- <select id="selectEnabled" resultMap="ruleResultMap">
- select
- <include refid="selectJoinedTablesColumns"/>
- from
- rules r
- <include refid="leftOuterJoinRulesDescriptionSections"/>
- <include refid="leftOuterJoinRulesDefaultImpacts"/>
- <include refid="leftOuterJoinRulesTags"/>
- where
- r.status != 'REMOVED'
- order by r.uuid
- </select>
-
- <select id="selectByUuid" parameterType="map" resultMap="ruleResultMap">
- select
- <include refid="selectJoinedTablesColumns"/>
- from
- rules r
- <include refid="leftOuterJoinRulesDescriptionSections"/>
- <include refid="leftOuterJoinRulesDefaultImpacts"/>
- <include refid="leftOuterJoinRulesTags"/>
- where
- r.uuid=#{uuid,jdbcType=VARCHAR}
- order by r.uuid
- </select>
-
- <select id="selectByUuids" parameterType="map" resultMap="ruleResultMap">
- select
- <include refid="selectJoinedTablesColumns"/>
- from
- rules r
- <include refid="leftOuterJoinRulesDescriptionSections"/>
- <include refid="leftOuterJoinRulesDefaultImpacts"/>
- <include refid="leftOuterJoinRulesTags"/>
- where
- <foreach collection="uuids" index="index" item="uuid" open="" separator=" or " close="">
- r.uuid=#{uuid,jdbcType=VARCHAR}
- </foreach>
- order by r.uuid
- </select>
-
- <select id="selectByKey" parameterType="map" resultMap="ruleResultMap">
- select
- <include refid="selectJoinedTablesColumns"/>
- from
- rules r
- <include refid="leftOuterJoinRulesDescriptionSections"/>
- <include refid="leftOuterJoinRulesDefaultImpacts"/>
- <include refid="leftOuterJoinRulesTags"/>
- where
- r.plugin_name=#{ruleKey.repository,jdbcType=VARCHAR}
- and r.plugin_rule_key=#{ruleKey.rule,jdbcType=VARCHAR}
- order by r.uuid
- </select>
-
- <select id="selectIndexingRuleExtensionsByIds" parameterType="map" resultType="org.sonar.db.rule.RuleExtensionForIndexingDto">
- <include refid="sqlSelectIndexingRuleExtensions"/>
- and
- <foreach collection="ruleExtensionIds" index="index" item="ruleExtId" open="" separator=" or " close="">
- ( r.uuid = #{ruleExtId, jdbcType=VARCHAR} )
- </foreach>
- </select>
-
- <sql id="sqlSelectIndexingRuleExtensions">
- select
- r.uuid as "ruleUuid",
- r.plugin_name as "pluginName",
- r.plugin_rule_key as "pluginRuleKey",
- r.tags as "tags"
- from rules r
- where
- r.tags is not null and
- r.tags != ''
- </sql>
-
- <sql id="sqlSelectIndexingRuleExtensions" databaseId="oracle">
- select
- r.uuid as "ruleUuid",
- r.plugin_name as "pluginName",
- r.plugin_rule_key as "pluginRuleKey",
- r.tags as "tags"
- from rules r
- where
- r.tags is not null
- </sql>
-
- <select id="selectByKeys" parameterType="map" resultMap="ruleResultMap">
- select
- <include refid="selectJoinedTablesColumns"/>
- from
- rules r
- <include refid="leftOuterJoinRulesDescriptionSections"/>
- <include refid="leftOuterJoinRulesDefaultImpacts"/>
- <include refid="leftOuterJoinRulesTags"/>
- where
- <foreach collection="ruleKeys" index="index" item="ruleKey" open="" separator=" or " close="">
- (r.plugin_name=#{ruleKey.repository,jdbcType=VARCHAR} and r.plugin_rule_key=#{ruleKey.rule,jdbcType=VARCHAR})
- </foreach>
- order by r.uuid
- </select>
-
- <select id="selectByQuery" parameterType="map" resultMap="ruleResultMap">
- select
- <include refid="selectJoinedTablesColumns"/>
- from
- rules r
- <include refid="leftOuterJoinRulesDescriptionSections"/>
- <include refid="leftOuterJoinRulesDefaultImpacts"/>
- <include refid="leftOuterJoinRulesTags"/>
- where
- r.status != 'REMOVED'
- <if test="query.repositoryKey!=null">
- and r.plugin_name = #{query.repositoryKey,jdbcType=VARCHAR}
- </if>
- <if test="query.key!=null">
- and r.plugin_rule_key = #{query.key,jdbcType=VARCHAR}
- </if>
- <if test="query.configKey!=null">
- and r.plugin_config_key = #{query.configKey,jdbcType=VARCHAR}
- </if>
- order by
- r.uuid,
- r.updated_at desc
- </select>
-
- <select id="selectByTypeAndLanguages" parameterType="map" resultMap="ruleResultMap">
- select
- <include refid="selectJoinedTablesColumns"/>
- from
- rules r
- <include refid="leftOuterJoinRulesDescriptionSections"/>
- <include refid="leftOuterJoinRulesDefaultImpacts"/>
- <include refid="leftOuterJoinRulesTags"/>
- where
- r.status != 'REMOVED' and r.is_external=${_false} and r.is_template=${_false}
- and r.rule_type in
- <foreach collection="types" item="type" separator="," open="(" close=")">#{type, jdbcType=INTEGER}</foreach>
- and r.language in
- <foreach collection="languages" item="language" separator="," open="(" close=")">#{language, jdbcType=VARCHAR}</foreach>
- order by r.uuid
- </select>
-
- <select id="selectByLanguage" parameterType="String" resultType="org.sonar.db.rule.RuleDto" fetchSize="${_scrollFetchSize}"
- resultSetType="FORWARD_ONLY">
- select
- r.uuid as uuid,
- <include refid="ruleColumns"/>
- from
- rules r
- where
- <include refid="conditionNotExternalRulesByLanguage" />
- </select>
-
- <select id="countByLanguage" resultType="java.lang.Long">
- select count(*)
- from
- rules r
- where
- <include refid="conditionNotExternalRulesByLanguage" />
- </select>
-
- <sql id="conditionNotExternalRulesByLanguage">
- r.status in ('READY', 'DEPRECATED', 'BETA')
- and r.is_external=${_false}
- and r.language=#{language, jdbcType=VARCHAR}
- </sql>
-
- <insert id="insertRuleDescriptionSection" parameterType="Map" useGeneratedKeys="false">
- insert into rule_desc_sections (
- uuid,
- rule_uuid,
- kee,
- content,
- context_key,
- context_display_name
- )
- values (
- #{dto.uuid,jdbcType=VARCHAR},
- #{ruleUuid,jdbcType=VARCHAR},
- #{dto.key,jdbcType=VARCHAR},
- #{dto.content,jdbcType=VARCHAR},
- #{dto.context.key,jdbcType=VARCHAR},
- #{dto.context.displayName,jdbcType=VARCHAR}
- )
- </insert>
-
- <insert id="insertRule" parameterType="org.sonar.db.rule.RuleDto" useGeneratedKeys="false">
- insert into rules (
- uuid,
- plugin_key,
- plugin_rule_key,
- plugin_name,
- description_format,
- status,
- name,
- plugin_config_key,
- priority,
- is_template,
- is_external,
- is_ad_hoc,
- language,
- template_uuid,
- def_remediation_function,
- def_remediation_gap_mult,
- def_remediation_base_effort,
- gap_description,
- security_standards,
- rule_type,
- scope,
- note_data,
- note_user_uuid,
- note_created_at,
- note_updated_at,
- remediation_function,
- remediation_gap_mult,
- remediation_base_effort,
- ad_hoc_name,
- ad_hoc_description,
- ad_hoc_severity,
- ad_hoc_type,
- education_principles,
- clean_code_attribute,
- created_at,
- updated_at
- )
- values (
- #{uuid,jdbcType=VARCHAR},
- #{pluginKey,jdbcType=VARCHAR},
- #{ruleKey,jdbcType=VARCHAR},
- #{repositoryKey,jdbcType=VARCHAR},
- #{descriptionFormat,jdbcType=VARCHAR},
- #{status,jdbcType=VARCHAR},
- #{name,jdbcType=VARCHAR},
- #{configKey,jdbcType=VARCHAR},
- #{severity,jdbcType=INTEGER},
- #{isTemplate,jdbcType=BOOLEAN},
- #{isExternal,jdbcType=BOOLEAN},
- #{isAdHoc,jdbcType=BOOLEAN},
- #{language,jdbcType=VARCHAR},
- #{templateUuid,jdbcType=VARCHAR},
- #{defRemediationFunction,jdbcType=VARCHAR},
- #{defRemediationGapMultiplier,jdbcType=VARCHAR},
- #{defRemediationBaseEffort,jdbcType=VARCHAR},
- #{gapDescription,jdbcType=VARCHAR},
- #{securityStandardsField,jdbcType=VARCHAR},
- #{type,jdbcType=TINYINT},
- #{scope,jdbcType=VARCHAR},
- #{noteData,jdbcType=CLOB},
- #{noteUserUuid,jdbcType=VARCHAR},
- #{noteCreatedAt,jdbcType=BIGINT},
- #{noteUpdatedAt,jdbcType=BIGINT},
- #{remediationFunction,jdbcType=VARCHAR},
- #{remediationGapMultiplier,jdbcType=VARCHAR},
- #{remediationBaseEffort,jdbcType=VARCHAR},
- #{adHocName,jdbcType=VARCHAR},
- #{adHocDescription,jdbcType=CLOB},
- #{adHocSeverity,jdbcType=VARCHAR},
- #{adHocType,jdbcType=TINYINT},
- #{educationPrinciplesField,jdbcType=VARCHAR},
- #{cleanCodeAttribute,jdbcType=VARCHAR},
- #{createdAt,jdbcType=BIGINT},
- #{updatedAt,jdbcType=BIGINT}
- )
- </insert>
-
- <insert id="insertRuleDefaultImpact" parameterType="Map" useGeneratedKeys="false">
- INSERT INTO rules_default_impacts (uuid, rule_uuid, software_quality, severity)
- VALUES (
- #{dto.uuid,jdbcType=VARCHAR},
- #{ruleUuid,jdbcType=VARCHAR},
- #{dto.softwareQuality,jdbcType=VARCHAR},
- #{dto.severity,jdbcType=VARCHAR})
- </insert>
-
- <insert id="insertRuleTag" parameterType="Map" useGeneratedKeys="false">
- INSERT INTO rule_tags (rule_uuid, value, is_system_tag)
- VALUES (
- #{ruleUuid,jdbcType=VARCHAR},
- #{value,jdbcType=VARCHAR},
- #{isSystemTag,jdbcType=BOOLEAN})
- </insert>
-
- <update id="updateRule" parameterType="org.sonar.db.rule.RuleDto">
- update rules set
- plugin_key=#{pluginKey,jdbcType=VARCHAR},
- plugin_rule_key=#{ruleKey,jdbcType=VARCHAR},
- plugin_name=#{repositoryKey,jdbcType=VARCHAR},
- description_format=#{descriptionFormat,jdbcType=VARCHAR},
- status=#{status,jdbcType=VARCHAR},
- name=#{name,jdbcType=VARCHAR},
- plugin_config_key=#{configKey,jdbcType=VARCHAR},
- priority=#{severity,jdbcType=INTEGER},
- is_template=#{isTemplate,jdbcType=BOOLEAN},
- is_external=#{isExternal,jdbcType=BOOLEAN},
- is_ad_hoc=#{isAdHoc,jdbcType=BOOLEAN},
- language=#{language,jdbcType=VARCHAR},
- template_uuid=#{templateUuid,jdbcType=VARCHAR},
- def_remediation_function=#{defRemediationFunction,jdbcType=VARCHAR},
- def_remediation_gap_mult=#{defRemediationGapMultiplier,jdbcType=VARCHAR},
- def_remediation_base_effort=#{defRemediationBaseEffort,jdbcType=VARCHAR},
- gap_description=#{gapDescription,jdbcType=VARCHAR},
- security_standards=#{securityStandardsField,jdbcType=VARCHAR},
- scope=#{scope,jdbcType=VARCHAR},
- rule_type=#{type,jdbcType=TINYINT},
- note_data=#{noteData,jdbcType=CLOB},
- note_user_uuid=#{noteUserUuid,jdbcType=VARCHAR},
- note_created_at=#{noteCreatedAt,jdbcType=BIGINT},
- note_updated_at=#{noteUpdatedAt,jdbcType=BIGINT},
- remediation_function=#{remediationFunction,jdbcType=VARCHAR},
- remediation_gap_mult=#{remediationGapMultiplier,jdbcType=VARCHAR},
- remediation_base_effort=#{remediationBaseEffort,jdbcType=VARCHAR},
- ad_hoc_name=#{adHocName,jdbcType=VARCHAR},
- ad_hoc_description=#{adHocDescription,jdbcType=CLOB},
- ad_hoc_severity=#{adHocSeverity,jdbcType=VARCHAR},
- ad_hoc_type=#{adHocType,jdbcType=TINYINT},
- education_principles=#{educationPrinciplesField,jdbcType=VARCHAR},
- clean_code_attribute=#{cleanCodeAttribute,jdbcType=VARCHAR},
- updated_at=#{updatedAt,jdbcType=BIGINT}
- where
- uuid=#{uuid,jdbcType=VARCHAR}
- </update>
-
- <delete id="deleteRuleDescriptionSection" parameterType="String">
- delete from
- rule_desc_sections
- where
- rule_uuid=#{ruleUuid,jdbcType=VARCHAR}
- </delete>
-
- <delete id="deleteRuleDefaultImpacts" parameterType="String">
- delete from
- rules_default_impacts
- where
- rule_uuid=#{ruleUuid,jdbcType=VARCHAR}
- </delete>
-
- <delete id="deleteRuleTags" parameterType="String">
- delete from
- rule_tags
- where
- rule_uuid=#{ruleUuid,jdbcType=VARCHAR}
- </delete>
-
- <delete id="deleteParams" parameterType="String">
- delete from
- active_rule_parameters
- where
- rules_parameter_uuid=#{uuid,jdbcType=VARCHAR}
- </delete>
-
- <sql id="paramColumns">
- p.uuid as "uuid",
- p.rule_uuid as "ruleUuid",
- p.name as "name",
- p.param_type as "type",
- p.default_value as "defaultValue",
- p.description as "description"
- </sql>
-
- <select id="selectParamsByRuleUuids" resultType="RuleParam">
- select
- <include refid="paramColumns"/>
- from
- rules_parameters p
- where
- <foreach item="uuid" index="index" collection="ruleUuids" open="(" separator=" or " close=")">
- p.rule_uuid=#{uuid,jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <select id="selectAllRuleParams" resultType="RuleParam">
- select
- <include refid="paramColumns"/>
- from
- rules_parameters p
- </select>
-
- <select id="selectParamsByRuleKey" resultType="RuleParam" parameterType="org.sonar.api.rule.RuleKey">
- select
- <include refid="paramColumns"/>
- from
- rules_parameters p, rules r
- where
- p.rule_uuid=r.uuid
- and r.plugin_name=#{repository,jdbcType=VARCHAR}
- and r.plugin_rule_key=#{rule,jdbcType=VARCHAR}
- </select>
-
- <select id="selectParamsByRuleKeys" resultType="RuleParam" parameterType="map">
- select
- <include refid="paramColumns"/>
- from
- rules_parameters p
- inner join rules r on
- r.uuid=p.rule_uuid
- where
- <foreach collection="ruleKeys" index="index" item="ruleKey" open="" separator=" or " close="">
- (r.plugin_name=#{ruleKey.repository,jdbcType=VARCHAR} AND r.plugin_rule_key=#{ruleKey.rule,jdbcType=VARCHAR})
- </foreach>
- </select>
-
- <delete id="deleteParameter" parameterType="String">
- delete from
- rules_parameters
- where
- uuid=#{uuid,jdbcType=INTEGER}
- </delete>
-
- <insert id="insertParameter" parameterType="RuleParam" useGeneratedKeys="false">
- insert into rules_parameters (
- uuid,
- rule_uuid,
- name,
- param_type,
- default_value,
- description
- )
- values (
- #{uuid,jdbcType=VARCHAR},
- #{ruleUuid,jdbcType=VARCHAR},
- #{name,jdbcType=VARCHAR},
- #{type,jdbcType=VARCHAR},
- #{defaultValue,jdbcType=VARCHAR},
- #{description,jdbcType=VARCHAR}
- )
- </insert>
-
- <update id="updateParameter" parameterType="RuleParam">
- update rules_parameters set
- param_type=#{type,jdbcType=VARCHAR},
- default_value=#{defaultValue,jdbcType=VARCHAR},
- description=#{description,jdbcType=VARCHAR}
- where
- uuid=#{uuid,jdbcType=VARCHAR}
- </update>
-
- <select id="selectAllDeprecatedRuleKeys" resultType="org.sonar.db.rule.DeprecatedRuleKeyDto">
- SELECT
- drk.uuid,
- drk.rule_uuid as "ruleUuid",
- drk.old_repository_key as "oldRepositoryKey",
- drk.old_rule_key as "oldRuleKey",
- r.plugin_rule_key as "newRuleKey",
- r.plugin_name as "newRepositoryKey",
- drk.created_at as "createdAt"
- FROM
- deprecated_rule_keys drk
- LEFT OUTER JOIN rules r on r.uuid = drk.rule_uuid
- </select>
-
- <select id="selectDeprecatedRuleKeysByRuleUuids" resultType="org.sonar.db.rule.DeprecatedRuleKeyDto">
- SELECT
- drk.uuid,
- drk.rule_uuid as "ruleUuid",
- drk.old_repository_key as "oldRepositoryKey",
- drk.old_rule_key as "oldRuleKey",
- r.plugin_rule_key as "newRuleKey",
- r.plugin_name as "newRepositoryKey",
- drk.created_at as "createdAt"
- FROM
- deprecated_rule_keys drk
- LEFT OUTER JOIN rules r on r.uuid = drk.rule_uuid
- WHERE
- <foreach item="uuid" index="index" collection="ruleUuids" open="(" separator=" or " close=")">
- drk.rule_uuid=#{uuid,jdbcType=VARCHAR}
- </foreach>
- </select>
-
- <delete id="deleteDeprecatedRuleKeys">
- DELETE FROM
- deprecated_rule_keys
- WHERE
- <foreach collection="uuids" index="index" item="uuid" open="" separator=" or " close="">
- uuid=#{uuid,jdbcType=INTEGER}
- </foreach>
- </delete>
-
- <insert id="insertDeprecatedRuleKey" parameterType="org.sonar.db.rule.DeprecatedRuleKeyDto" keyColumn="uuid" useGeneratedKeys="false"
- keyProperty="uuid">
- INSERT INTO deprecated_rule_keys (
- uuid,
- rule_uuid,
- old_repository_key,
- old_rule_key,
- created_at
- )
- values (
- #{uuid,jdbcType=VARCHAR},
- #{ruleUuid,jdbcType=VARCHAR},
- #{oldRepositoryKey,jdbcType=VARCHAR},
- #{oldRuleKey,jdbcType=VARCHAR},
- #{createdAt,jdbcType=BIGINT}
- )
- </insert>
-
- <select id="selectTags" resultType="string">
- SELECT DISTINCT value FROM
- rule_tags rt
- WHERE lower(value) like #{query}
- ORDER BY value
- <include refid="org.sonar.db.common.Common.pagination"/>
- </select>
-
- <select id="selectRules">
- select r.uuid from rules r
- <include refid="queryList"/>
- <choose>
- <when test="query.sortField == 'createdAt'">
- order by r.created_at ${query.sortDirection}
- </when>
- <otherwise>
- order by r.uuid
- </otherwise>
- </choose>
- <include refid="org.sonar.db.common.Common.pagination"/>
- </select>
-
- <select id="countByQuery" resultType="long">
- select count(r.uuid) from rules r
- <include refid="queryList"/>
- </select>
-
- <sql id="queryList">
- <if test="query.profileUuid != null">
- inner join active_rules ar on ar.rule_uuid = r.uuid
- </if>
- where
- r.status != 'REMOVED'
- and r.is_external = ${_false}
- <if test="query.createdAt != null">
- and r.created_at >= #{query.createdAt,jdbcType=BIGINT}
- </if>
- <if test="query.language != null">
- and r.language = #{query.language,jdbcType=VARCHAR}
- </if>
- <if test="query.profileUuid != null">
- and ar.profile_uuid = #{query.profileUuid,jdbcType=VARCHAR}
- </if>
- </sql>
-
- </mapper>
|