
org.sonar.db.qualitygate.QualityGateMapper.xml Maven / Gradle / Ivy
The newest version!
<?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.qualitygate.QualityGateMapper"> <sql id="gateColumns"> id, name, uuid, is_built_in as isBuiltIn, created_at as createdAt, updated_at as updatedAt </sql> <sql id="qateWithOrgColumns"> qg.id as id, qg.uuid as uuid, qg.name as name, qg.is_built_in as isBuiltIn, oqg.organization_uuid as organizationUuid, qg.created_at as createdAt, qg.updated_at as updatedAd </sql> <insert id="insertQualityGate" parameterType="QualityGate" keyColumn="id" useGeneratedKeys="true" keyProperty="id"> insert into quality_gates (uuid, name, is_built_in, created_at, updated_at) values (#{uuid, jdbcType=VARCHAR}, #{name, jdbcType=VARCHAR}, #{isBuiltIn, jdbcType=BOOLEAN}, #{createdAt, jdbcType=TIMESTAMP}, #{updatedAt, jdbcType=TIMESTAMP}) </insert> <insert id="insertOrgQualityGate" parameterType="Map"> INSERT INTO org_quality_gates (uuid, organization_uuid, quality_gate_uuid) VALUES (#{uuid, jdbcType=VARCHAR}, #{organizationUuid, jdbcType=VARCHAR}, #{qualityGateUuid, jdbcType=VARCHAR}) </insert> <select id="selectAll" resultType="org.sonar.db.qualitygate.QGateWithOrgDto"> SELECT <include refid="qateWithOrgColumns"/> FROM quality_gates qg INNER JOIN org_quality_gates oqg ON oqg.quality_gate_uuid = qg.uuid AND oqg.organization_uuid = #{organizationUuid, jdbcType=VARCHAR} ORDER BY qg.name ASC </select> <select id="selectByName" parameterType="String" resultType="QualityGate"> select <include refid="gateColumns"/> from quality_gates where name=#{name, jdbcType=VARCHAR} </select> <select id="selectByUuidAndOrganization" parameterType="Map" resultType="org.sonar.db.qualitygate.QGateWithOrgDto"> SELECT <include refid="qateWithOrgColumns"/> FROM quality_gates qg INNER JOIN org_quality_gates oqg ON oqg.quality_gate_uuid = qg.uuid AND oqg.organization_uuid = #{organizationUuid, jdbcType=VARCHAR} WHERE qg.uuid = #{qualityGateUuid, jdbcType=VARCHAR} </select> <select id="selectByNameAndOrganization" parameterType="Map" resultType="org.sonar.db.qualitygate.QGateWithOrgDto"> SELECT <include refid="qateWithOrgColumns"/> FROM quality_gates qg INNER JOIN org_quality_gates oqg ON oqg.quality_gate_uuid = qg.uuid AND oqg.organization_uuid = #{organizationUuid, jdbcType=VARCHAR} WHERE qg.name = #{name, jdbcType=VARCHAR} </select> <select id="selectByIdAndOrganization" parameterType="Map" resultType="org.sonar.db.qualitygate.QGateWithOrgDto"> SELECT <include refid="qateWithOrgColumns"/> FROM quality_gates qg INNER JOIN org_quality_gates oqg ON oqg.quality_gate_uuid = qg.uuid AND oqg.organization_uuid = #{organizationUuid, jdbcType=VARCHAR} WHERE qg.id = #{id, jdbcType=BIGINT} </select> <select id="selectById" parameterType="long" resultType="QualityGate"> select <include refid="gateColumns"/> from quality_gates where id=#{id, jdbcType=BIGINT} </select> <select id="selectBuiltIn" resultType="org.sonar.db.qualitygate.QualityGateDto"> SELECT <include refid="gateColumns"/> FROM quality_gates WHERE is_built_in = ${_true} </select> <select id="selectDefault" resultType="org.sonar.db.qualitygate.QGateWithOrgDto"> SELECT <include refid="qateWithOrgColumns"/> FROM quality_gates qg INNER JOIN org_quality_gates oqg ON oqg.quality_gate_uuid = qg.uuid INNER JOIN organizations o ON o.default_quality_gate_uuid = qg.uuid AND o.uuid=#{organizationUuid, jdbcType=VARCHAR} </select> <update id="delete" parameterType="String"> delete from quality_gates where uuid=#{uuid} </update> <update id="deleteByUuids" parameterType="map"> delete from quality_gates where uuid in <foreach collection="uuids" open="(" close=")" item="uuid" separator=",">#{uuid, jdbcType=VARCHAR}</foreach> </update> <update id="deleteOrgQualityGatesByQualityGateUuid" parameterType="String"> delete from org_quality_gates where quality_gate_uuid=#{uuid} </update> <update id="deleteOrgQualityGatesByOrganization" parameterType="String"> delete from org_quality_gates where organization_uuid = #{organizationUuid, jdbcType=VARCHAR} </update> <update id="update" parameterType="QualityGate"> update quality_gates set name=#{name}, is_built_in=#{isBuiltIn, jdbcType=BOOLEAN}, updated_at=#{updatedAt, jdbcType=TIMESTAMP} where uuid=#{uuid, jdbcType=VARCHAR} </update> <update id="ensureOneBuiltInQualityGate" parameterType="string"> UPDATE quality_gates SET is_built_in=${_false} WHERE is_built_in=${_true} AND name <> #{builtInQualityName, jdbcType=VARCHAR} </update> </mapper>
© 2015 - 2025 Weber Informatics LLC | Privacy Policy