org.sonar.db.qualityprofile.ActiveRuleMapper.xml Maven / Gradle / Ivy
<?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.qualityprofile.ActiveRuleMapper"> <sql id="activeRuleKeyColumns"> a.id, a.profile_id as "profileId", a.rule_id as "ruleId", a.failure_level as "severity", a.inheritance as "inheritance", r.plugin_rule_key as "rulefield", r.plugin_name as "repository", qp.kee as "profileKey", a.created_at as "createdAt", a.updated_at as "updatedAt" </sql> <sql id="activeRuleKeyJoin"> INNER JOIN rules_profiles qp ON qp.id=a.profile_id INNER JOIN rules r ON r.id = a.rule_id </sql> <sql id="activeRuleColumns"> a.id, a.profile_id as profileId, a.rule_id as ruleId, a.failure_level as severity, a.inheritance as inheritance, active_rule_parent.id as parentId, a.created_at as "createdAt", a.updated_at as "updatedAt" </sql> <sql id="activeRuleJoin"> INNER JOIN rules_profiles qp ON qp.id=a.profile_id LEFT JOIN rules_profiles profile_parent ON profile_parent.kee=qp.parent_kee LEFT JOIN active_rules active_rule_parent ON active_rule_parent.profile_id=profile_parent.id AND a.rule_id=active_rule_parent.rule_id </sql> <select id="selectAfterDate" parameterType="Date" resultType="ActiveRule" fetchSize="${_scrollFetchSize}" resultSetType="FORWARD_ONLY"> select <include refid="activeRuleKeyColumns"/> from active_rules a <include refid="activeRuleKeyJoin"/> <where> <if test="date != null"> a.updated_at IS NULL or a.updated_at >= #{date} </if> </where> </select> <insert id="insert" parameterType="ActiveRule" keyColumn="id" useGeneratedKeys="true" keyProperty="id"> INSERT INTO active_rules (profile_id, rule_id, failure_level, inheritance, created_at, updated_at) VALUES (#{profileId}, #{ruleId}, #{severity}, #{inheritance}, #{createdAt}, #{updatedAt}) </insert> <update id="update" parameterType="ActiveRule"> UPDATE active_rules SET profile_id=#{profileId}, rule_id=#{ruleId}, failure_level=#{severity}, inheritance=#{inheritance}, updated_at=#{updatedAt} WHERE id=#{id} </update> <update id="delete" parameterType="int"> DELETE FROM active_rules WHERE id=#{id} </update> <select id="selectById" parameterType="int" resultType="ActiveRule"> SELECT <include refid="activeRuleColumns"/> FROM active_rules a <include refid="activeRuleJoin"/> WHERE a.id=#{id} </select> <select id="selectByKey" parameterType="map" resultType="ActiveRule"> SELECT <include refid="activeRuleKeyColumns"/> FROM active_rules a <include refid="activeRuleKeyJoin"/> WHERE qp.kee = #{profileKey} AND r.plugin_rule_key = #{rule} AND r.plugin_name = #{repository} </select> <select id="selectByProfileKey" parameterType="string" resultType="ActiveRule"> SELECT <include refid="activeRuleKeyColumns"/> FROM active_rules a <include refid="activeRuleKeyJoin"/> where qp.kee=#{id} </select> <select id="selectByRuleId" parameterType="Integer" resultType="ActiveRule"> SELECT <include refid="activeRuleKeyColumns"/> FROM active_rules a <include refid="activeRuleKeyJoin"/> WHERE a.rule_id=#{ruleId} </select> <select id="selectAll" parameterType="map" resultType="ActiveRule"> select <include refid="activeRuleColumns"/> from active_rules a <include refid="activeRuleJoin"/> </select> <!-- Parameters --> <sql id="activeRuleParamColumns"> p.id, p.active_rule_id as activeRuleId, p.rules_parameter_id as rulesParameterId, p.rules_parameter_key as kee, p.value as value </sql> <insert id="insertParameter" parameterType="ActiveRuleParam" keyColumn="id" useGeneratedKeys="true" keyProperty="id"> INSERT INTO active_rule_parameters (active_rule_id, rules_parameter_id, rules_parameter_key, value) VALUES (#{activeRuleId}, #{rulesParameterId}, #{key}, #{value}) </insert> <update id="updateParameter" parameterType="ActiveRuleParam"> UPDATE active_rule_parameters SET active_rule_id=#{activeRuleId}, rules_parameter_id=#{rulesParameterId}, rules_parameter_key=#{key}, value=#{value} WHERE id=#{id} </update> <update id="deleteParameters" parameterType="int"> DELETE FROM active_rule_parameters WHERE active_rule_id=#{id} </update> <update id="deleteParameter" parameterType="int"> DELETE FROM active_rule_parameters WHERE id=#{id} </update> <select id="selectParamsByActiveRuleId" parameterType="Integer" resultType="ActiveRuleParam"> select <include refid="activeRuleParamColumns"/> from active_rule_parameters p <where> p.active_rule_id=#{id} </where> </select> <select id="selectParamsByActiveRuleIds" parameterType="map" resultType="ActiveRuleParam"> select <include refid="activeRuleParamColumns"/> from active_rule_parameters p <where> (<foreach collection="list" item="id" open="(" separator=" or " close=")"> p.active_rule_id=#{id} </foreach>) </where> </select> <select id="selectParamByActiveRuleAndKey" parameterType="map" resultType="ActiveRuleParam"> SELECT <include refid="activeRuleParamColumns"/> FROM active_rule_parameters p <where> AND p.active_rule_id=#{activeRuleId} AND p.rules_parameter_key=#{key} </where> </select> <select id="selectParamsByProfileKey" parameterType="string" resultType="ActiveRuleParam"> select <include refid="activeRuleParamColumns"/> from active_rule_parameters p inner join active_rules ar on ar.id=p.active_rule_id inner join rules_profiles rp on rp.id=ar.profile_id where rp.kee=#{id} </select> <select id="selectAllParams" resultType="ActiveRuleParam"> select <include refid="activeRuleParamColumns"/> from active_rule_parameters p </select> </mapper>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy