<select id="selectAll" resultType="Rule">
select
- <include refid="selectColumns"/>
- from rules r
+ <include refid="selectColumns"/>
+ from
+ rules r
</select>
<select id="selectEnabled" resultType="Rule">
select
- <include refid="selectColumns"/>
- from rules r
- where r.status != 'REMOVED'
+ <include refid="selectColumns"/>
+ from
+ rules r
+ where
+ r.status != 'REMOVED'
</select>
<select id="selectById" parameterType="Long" resultType="Rule">
select
- <include refid="selectColumns"/>
- from rules r WHERE r.id=#{id,jdbcType=INTEGER}
+ <include refid="selectColumns"/>
+ from
+ rules r
+ where
+ r.id=#{id,jdbcType=INTEGER}
</select>
<select id="selectByIds" parameterType="map" resultType="Rule">
- SELECT
- <include refid="selectColumns"/>
- FROM rules r
- WHERE
- <foreach collection="ids" index="index" item="id" open="" separator=" or " close="">
- r.id=#{id,jdbcType=INTEGER}
- </foreach>
+ select
+ <include refid="selectColumns"/>
+ from
+ rules r
+ where
+ <foreach collection="ids" index="index" item="id" open="" separator=" or " close="">
+ r.id=#{id,jdbcType=INTEGER}
+ </foreach>
</select>
<select id="selectByKey" parameterType="map" resultType="Rule">
- SELECT
- <include refid="selectColumns"/>
- FROM rules r WHERE r.plugin_name=#{repository,jdbcType=VARCHAR} AND r.plugin_rule_key=#{rule,jdbcType=VARCHAR}
+ select
+ <include refid="selectColumns"/>
+ from
+ rules r
+ where
+ r.plugin_name=#{repository,jdbcType=VARCHAR}
+ and r.plugin_rule_key=#{rule,jdbcType=VARCHAR}
</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,jdbcType=VARCHAR} and r.plugin_rule_key=#{ruleKey.rule,jdbcType=VARCHAR})
- </foreach>
+ select
+ <include refid="selectColumns"/>
+ from
+ rules r
+ 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>
<select id="selectByQuery" parameterType="map" resultType="Rule">
- SELECT
- <include refid="selectColumns"/>
- FROM rules r
- <where>
- AND r.status != 'REMOVED'
+ select
+ <include refid="selectColumns"/>
+ from
+ rules r
+ where
+ r.status != 'REMOVED'
<if test="query.repositoryKey!=null">
- AND r.plugin_name = #{query.repositoryKey,jdbcType=VARCHAR}
+ and r.plugin_name = #{query.repositoryKey,jdbcType=VARCHAR}
</if>
<if test="query.key!=null">
- AND r.plugin_rule_key = #{query.key,jdbcType=VARCHAR}
+ and r.plugin_rule_key = #{query.key,jdbcType=VARCHAR}
</if>
<if test="query.configKey!=null">
- AND r.plugin_config_key = #{query.configKey,jdbcType=VARCHAR}
+ and r.plugin_config_key = #{query.configKey,jdbcType=VARCHAR}
</if>
- </where>
- ORDER BY r.updated_at DESC
+ order by
+ r.updated_at desc
</select>
<update id="update" parameterType="Rule">
- UPDATE rules SET
- plugin_rule_key=#{ruleKey,jdbcType=VARCHAR},
- plugin_name=#{repositoryKey,jdbcType=VARCHAR},
- description=#{description,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},
- language=#{language,jdbcType=VARCHAR},
- template_id=#{templateId,jdbcType=INTEGER},
- note_data=#{noteData,jdbcType=CLOB},
- note_user_login=#{noteUserLogin,jdbcType=VARCHAR},
- note_created_at=#{noteCreatedAt,jdbcType=TIMESTAMP},
- note_updated_at=#{noteUpdatedAt,jdbcType=TIMESTAMP},
- remediation_function=#{remediationFunction,jdbcType=VARCHAR},
- def_remediation_function=#{defRemediationFunction,jdbcType=VARCHAR},
- remediation_gap_mult=#{remediationGapMultiplier,jdbcType=VARCHAR},
- def_remediation_gap_mult=#{defRemediationGapMultiplier,jdbcType=VARCHAR},
- remediation_base_effort=#{remediationBaseEffort,jdbcType=VARCHAR},
- def_remediation_base_effort=#{defRemediationBaseEffort,jdbcType=VARCHAR},
- gap_description=#{gapDescription,jdbcType=VARCHAR},
- tags=#{tagsField,jdbcType=VARCHAR},
- system_tags=#{systemTagsField,jdbcType=VARCHAR},
- rule_type=#{type,jdbcType=TINYINT},
- updated_at=#{updatedAt,jdbcType=BIGINT}
- WHERE id=#{id,jdbcType=INTEGER}
+ update rules set
+ plugin_rule_key=#{ruleKey,jdbcType=VARCHAR},
+ plugin_name=#{repositoryKey,jdbcType=VARCHAR},
+ description=#{description,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},
+ language=#{language,jdbcType=VARCHAR},
+ template_id=#{templateId,jdbcType=INTEGER},
+ note_data=#{noteData,jdbcType=CLOB},
+ note_user_login=#{noteUserLogin,jdbcType=VARCHAR},
+ note_created_at=#{noteCreatedAt,jdbcType=TIMESTAMP},
+ note_updated_at=#{noteUpdatedAt,jdbcType=TIMESTAMP},
+ remediation_function=#{remediationFunction,jdbcType=VARCHAR},
+ def_remediation_function=#{defRemediationFunction,jdbcType=VARCHAR},
+ remediation_gap_mult=#{remediationGapMultiplier,jdbcType=VARCHAR},
+ def_remediation_gap_mult=#{defRemediationGapMultiplier,jdbcType=VARCHAR},
+ remediation_base_effort=#{remediationBaseEffort,jdbcType=VARCHAR},
+ def_remediation_base_effort=#{defRemediationBaseEffort,jdbcType=VARCHAR},
+ gap_description=#{gapDescription,jdbcType=VARCHAR},
+ tags=#{tagsField,jdbcType=VARCHAR},
+ system_tags=#{systemTagsField,jdbcType=VARCHAR},
+ rule_type=#{type,jdbcType=TINYINT},
+ updated_at=#{updatedAt,jdbcType=BIGINT}
+ where
+ id=#{id,jdbcType=INTEGER}
</update>
- <sql id="insertColumns">
- (plugin_rule_key, plugin_name, description, description_format, status, name, plugin_config_key, priority,
- is_template, language, template_id,
- remediation_function, def_remediation_function,
- remediation_gap_mult, def_remediation_gap_mult, remediation_base_effort, def_remediation_base_effort,
- gap_description, tags, system_tags, rule_type, 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"/>
+ insert into rules (
+ plugin_rule_key,
+ plugin_name,
+ description,
+ description_format,
+ status,
+ name,
+ plugin_config_key,
+ priority,
+ is_template,
+ language,
+ template_id,
+ remediation_function,
+ def_remediation_function,
+ remediation_gap_mult,
+ def_remediation_gap_mult,
+ remediation_base_effort,
+ def_remediation_base_effort,
+ gap_description,
+ tags,
+ system_tags,
+ rule_type,
+ note_data,
+ note_user_login,
+ note_created_at,
+ note_updated_at,
+ created_at,
+ updated_at
+ )
values (
- #{ruleKey,jdbcType=VARCHAR}, #{repositoryKey,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{descriptionFormat,jdbcType=VARCHAR}, #{status,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{configKey,jdbcType=VARCHAR},
- #{severity,jdbcType=INTEGER}, #{isTemplate,jdbcType=BOOLEAN}, #{language,jdbcType=VARCHAR}, #{templateId,jdbcType=INTEGER},
- #{remediationFunction,jdbcType=VARCHAR}, #{defRemediationFunction,jdbcType=VARCHAR},
- #{remediationGapMultiplier,jdbcType=VARCHAR}, #{defRemediationGapMultiplier,jdbcType=VARCHAR}, #{remediationBaseEffort,jdbcType=VARCHAR}, #{defRemediationBaseEffort,jdbcType=VARCHAR},
- #{gapDescription,jdbcType=VARCHAR}, #{tagsField,jdbcType=VARCHAR}, #{systemTagsField,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT}, #{noteData,jdbcType=CLOB}, #{noteUserLogin,jdbcType=VARCHAR}, #{noteCreatedAt,jdbcType=TIMESTAMP},
- #{noteUpdatedAt,jdbcType=TIMESTAMP}, #{createdAt,jdbcType=BIGINT}, #{updatedAt,jdbcType=BIGINT})
+ #{ruleKey,jdbcType=VARCHAR},
+ #{repositoryKey,jdbcType=VARCHAR},
+ #{description,jdbcType=VARCHAR},
+ #{descriptionFormat,jdbcType=VARCHAR},
+ #{status,jdbcType=VARCHAR},
+ #{name,jdbcType=VARCHAR},
+ #{configKey,jdbcType=VARCHAR},
+ #{severity,jdbcType=INTEGER},
+ #{isTemplate,jdbcType=BOOLEAN},
+ #{language,jdbcType=VARCHAR},
+ #{templateId,jdbcType=INTEGER},
+ #{remediationFunction,jdbcType=VARCHAR},
+ #{defRemediationFunction,jdbcType=VARCHAR},
+ #{remediationGapMultiplier,jdbcType=VARCHAR},
+ #{defRemediationGapMultiplier,jdbcType=VARCHAR},
+ #{remediationBaseEffort,jdbcType=VARCHAR},
+ #{defRemediationBaseEffort,jdbcType=VARCHAR},
+ #{gapDescription,jdbcType=VARCHAR},
+ #{tagsField,jdbcType=VARCHAR},
+ #{systemTagsField,jdbcType=VARCHAR},
+ #{type,jdbcType=TINYINT},
+ #{noteData,jdbcType=CLOB},
+ #{noteUserLogin,jdbcType=VARCHAR},
+ #{noteCreatedAt,jdbcType=TIMESTAMP},
+ #{noteUpdatedAt,jdbcType=TIMESTAMP},
+ #{createdAt,jdbcType=BIGINT},
+ #{updatedAt,jdbcType=BIGINT}
+ )
</insert>
<delete id="deleteParams" parameterType="Integer">
- delete from active_rule_parameters where rules_parameter_id=#{id,jdbcType=INTEGER}
+ delete from
+ active_rule_parameters
+ where
+ rules_parameter_id=#{id,jdbcType=INTEGER}
</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.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="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,jdbcType=INTEGER}</foreach>)
- </where>
+ select
+ <include refid="paramColumns"/>
+ from
+ rules_parameters p
+ where
+ <foreach item="id" index="index" collection="ruleIds" open="(" separator=" or " close=")">
+ p.rule_id=#{id,jdbcType=INTEGER}
+ </foreach>
</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,jdbcType=VARCHAR} AND r.plugin_rule_key=#{rule,jdbcType=VARCHAR}
+ select
+ <include refid="paramColumns"/>
+ from
+ rules_parameters p, rules r
+ where
+ p.rule_id=r.id
+ 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.id=p.rule_id
- 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
+ <include refid="paramColumns"/>
+ from
+ rules_parameters p
+ inner join rules r on
+ r.id=p.rule_id
+ 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="Integer">
- delete from rules_parameters where id=#{id,jdbcType=INTEGER}
+ delete from
+ rules_parameters
+ where
+ id=#{id,jdbcType=INTEGER}
</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,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{defaultValue,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR})
+ insert into rules_parameters (
+ rule_id,
+ name,
+ param_type,
+ default_value,
+ description
+ )
+ values (
+ #{ruleId,jdbcType=INTEGER},
+ #{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 id=#{id,jdbcType=INTEGER}
+ update rules_parameters set
+ param_type=#{type,jdbcType=VARCHAR},
+ default_value=#{defaultValue,jdbcType=VARCHAR},
+ description=#{description,jdbcType=VARCHAR}
+ where
+ id=#{id,jdbcType=INTEGER}
</update>
</mapper>