org.sonar.db.rule.RuleMapper.xml Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sonar-db Show documentation
Show all versions of sonar-db Show documentation
Create and request SonarQube schema
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="org.sonar.db.rule.RuleMapper"> <sql id="selectColumns"> r.id, r.plugin_rule_key as "ruleKey", r.plugin_name as "repositoryKey", r.description, 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.language as "language", r.template_id as "templateId", r.note_data as "noteData", r.note_user_login as "noteUserLogin", r.note_created_at as "noteCreatedAt", r.note_updated_at as "noteUpdatedAt", r.characteristic_id as "subCharacteristicId", r.default_characteristic_id as "defaultSubCharacteristicId", r.remediation_function as "remediationFunction", r.default_remediation_function as "defaultRemediationFunction", r.remediation_coeff as "remediationCoefficient", r.default_remediation_coeff as "defaultRemediationCoefficient", r.remediation_offset as "remediationOffset", r.default_remediation_offset as "defaultRemediationOffset", r.effort_to_fix_description as "effortToFixDescription", r.tags as "tagsField", r.system_tags as "systemTagsField", r.created_at as "createdAt", r.updated_at as "updatedAt" </sql> <select id="selectAll" resultType="Rule"> select <include refid="selectColumns"/> from rules r </select> <select id="selectAfterDate" resultType="Rule" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY"> select <include refid="selectColumns"/> from rules r <where> <if test="date != null"> r.updated_at IS NULL or r.updated_at >= #{date} </if> </where> </select> <select id="selectEnabledAndNonManual" resultType="Rule"> select <include refid="selectColumns"/> from rules r where r.status != 'REMOVED' and r.plugin_name != 'manual' </select> <select id="selectById" parameterType="Long" resultType="Rule"> select <include refid="selectColumns"/> from rules r WHERE r.id=#{id} </select> <select id="selectByKey" parameterType="map" resultType="Rule"> SELECT <include refid="selectColumns"/> FROM rules r WHERE r.plugin_name=#{repository} AND r.plugin_rule_key=#{rule} </select> <select id="selectByKeys" parameterType="map" resultType="Rule"> SELECT <include refid="selectColumns"/> FROM rules r WHERE <foreach collection="ruleKeys" index="index" item="ruleKey" open="" separator=" or " close=""> (r.plugin_name=#{ruleKey.repository} and r.plugin_rule_key=#{ruleKey.rule}) </foreach> </select> <select id="selectByName" parameterType="String" resultType="Rule"> select <include refid="selectColumns"/> from rules r WHERE r.name=#{name} </select> <select id="selectNonManual" resultType="Rule"> select <include refid="selectColumns"/> from rules r where r.plugin_name != 'manual' </select> <select id="selectBySubCharacteristicId" resultType="Rule"> select <include refid="selectColumns"/> from rules r where (r.characteristic_id=#{subCharacteristicId} or r.default_characteristic_id=#{subCharacteristicId}) </select> <update id="update" parameterType="Rule"> UPDATE rules SET plugin_rule_key=#{ruleKey}, plugin_name=#{repositoryKey}, description=#{description}, description_format=#{descriptionFormat}, status=#{status}, name=#{name}, plugin_config_key=#{configKey}, priority=#{severity}, is_template=#{isTemplate}, language=#{language}, template_id=#{templateId}, note_data=#{noteData}, note_user_login=#{noteUserLogin}, note_created_at=#{noteCreatedAt}, note_updated_at=#{noteUpdatedAt}, characteristic_id=#{subCharacteristicId}, default_characteristic_id=#{defaultSubCharacteristicId}, remediation_function=#{remediationFunction}, default_remediation_function=#{defaultRemediationFunction}, remediation_coeff=#{remediationCoefficient}, default_remediation_coeff=#{defaultRemediationCoefficient}, remediation_offset=#{remediationOffset}, default_remediation_offset=#{defaultRemediationOffset}, effort_to_fix_description=#{effortToFixDescription}, updated_at=#{updatedAt}, tags=#{tagsField}, system_tags=#{systemTagsField} WHERE id=#{id} </update> <sql id="insertColumns"> (plugin_rule_key, plugin_name, description, description_format, status, name, plugin_config_key, priority, is_template, language, template_id, characteristic_id, default_characteristic_id, remediation_function, default_remediation_function, remediation_coeff, default_remediation_coeff, remediation_offset, default_remediation_offset, effort_to_fix_description, tags, system_tags, note_data, note_user_login, note_created_at, note_updated_at, created_at, updated_at) </sql> <insert id="insert" parameterType="Rule" keyColumn="id" useGeneratedKeys="true" keyProperty="id"> insert into rules <include refid="insertColumns"/> values (#{ruleKey}, #{repositoryKey}, #{description}, #{descriptionFormat}, #{status}, #{name}, #{configKey}, #{severity}, #{isTemplate}, #{language}, #{templateId}, #{subCharacteristicId}, #{defaultSubCharacteristicId}, #{remediationFunction}, #{defaultRemediationFunction}, #{remediationCoefficient}, #{defaultRemediationCoefficient}, #{remediationOffset}, #{defaultRemediationOffset}, #{effortToFixDescription}, #{tagsField}, #{systemTagsField}, #{noteData}, #{noteUserLogin}, #{noteCreatedAt}, #{noteUpdatedAt}, #{createdAt}, #{updatedAt}) </insert> <insert id="batchInsert" parameterType="Rule" useGeneratedKeys="false"> insert into rules <include refid="insertColumns"/> values (#{ruleKey,jdbcType=VARCHAR}, #{repositoryKey,jdbcType=VARCHAR}, #{description,jdbcType=CLOB}, #{descriptionFormat,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{configKey,jdbcType=VARCHAR}, #{severity,jdbcType=INTEGER}, #{isTemplate,jdbcType=BOOLEAN}, #{language,jdbcType=VARCHAR}, #{templateId,jdbcType=INTEGER}, #{subCharacteristicId,jdbcType=INTEGER}, #{defaultSubCharacteristicId,jdbcType=INTEGER}, #{remediationFunction,jdbcType=VARCHAR}, #{defaultRemediationFunction,jdbcType=VARCHAR}, #{remediationCoefficient,jdbcType=VARCHAR}, #{defaultRemediationCoefficient,jdbcType=VARCHAR}, #{remediationOffset,jdbcType=VARCHAR}, #{defaultRemediationOffset,jdbcType=VARCHAR}, #{effortToFixDescription}, #{tagsField}, #{systemTagsField}, #{noteData}, #{noteUserLogin}, #{noteCreatedAt}, #{noteUpdatedAt,jdbcType=TIMESTAMP}, #{createdAt,jdbcType=TIMESTAMP}, #{updatedAt,jdbcType=TIMESTAMP}) </insert> <delete id="deleteParams" parameterType="Integer"> delete from active_rule_parameters where rules_parameter_id=#{id} </delete> <sql id="paramColumns"> p.id as "id", p.rule_id as "ruleId", p.name as "name", p.param_type as "type", p.default_value as "defaultValue", p.description as "description" </sql> <select id="selectAllParams" resultType="RuleParam"> select <include refid="paramColumns"/> from rules_parameters p </select> <select id="selectParamsByRuleIds" resultType="RuleParam"> SELECT <include refid="paramColumns"/> FROM rules_parameters p <where> AND (<foreach item="id" index="index" collection="ruleIds" open="(" separator=" or " close=")"> p.rule_id=#{id}</foreach>) </where> </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_id=r.id AND r.plugin_name=#{repository} AND r.plugin_rule_key=#{rule} </select> <select id="selectParamByRuleAndKey" resultType="RuleParam"> SELECT <include refid="paramColumns"/> FROM rules_parameters p WHERE p.rule_id=#{ruleId} AND p.name=#{key} </select> <delete id="deleteParameter" parameterType="Integer"> delete from rules_parameters where id=#{id} </delete> <insert id="insertParameter" parameterType="RuleParam" keyColumn="id" useGeneratedKeys="true" keyProperty="id"> INSERT INTO rules_parameters (rule_id, name, param_type, default_value, description) VALUES (#{ruleId}, #{name}, #{type}, #{defaultValue}, #{description}) </insert> <update id="updateParameter" parameterType="RuleParam"> UPDATE rules_parameters SET param_type=#{type}, default_value=#{defaultValue}, description=#{description} WHERE id=#{id} </update> </mapper>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy