1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd">
4 <mapper namespace="org.sonar.db.qualitygate.QualityGateGroupPermissionsMapper">
8 qggp.group_uuid as "groupUuid",
9 qggp.quality_gate_uuid as "qualityGateUuid"
12 <select id="selectByQualityGateAndGroup" parameterType="String" resultType="org.sonar.db.qualitygate.QualityGateGroupPermissionsDto">
14 <include refid="sqlColumns"/>
15 from qgate_group_permissions qggp
17 qggp.group_uuid = #{groupUuid}
18 and qggp.quality_gate_uuid = #{qualityGateUuid}
21 <select id="selectByQualityGateAndGroups" parameterType="map" resultType="org.sonar.db.qualitygate.QualityGateGroupPermissionsDto">
23 <include refid="sqlColumns"/>
24 from qgate_group_permissions qggp
26 <foreach collection="groupUuids" open="(" close=")" item="groupUuid" separator=" or ">
27 qggp.group_uuid = #{groupUuid, jdbcType=VARCHAR}
29 and qggp.quality_gate_uuid = #{qualityGateUuid, jdbcType=VARCHAR}
32 <select id="selectByQuery" parameterType="map" resultType="org.sonar.db.user.SearchGroupMembershipDto">
33 SELECT g.uuid as groupUuid, g.name as name, qggp.uuid as uuid
34 <include refid="sqlSelectByQuery"/>
36 LIMIT #{pagination.pageSize,jdbcType=INTEGER}
37 OFFSET #{pagination.offset,jdbcType=INTEGER}
40 <select id="selectByQuery" parameterType="map" resultType="org.sonar.db.user.SearchGroupMembershipDto" databaseId="mssql">
42 select row_number() over(order by g.name asc) as number,
43 g.uuid as groupUuid, g.name as name, qggp.uuid as uuid
44 <include refid="sqlSelectByQuery" />
47 query.number between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
48 order by query.name asc
51 <select id="selectByQuery" parameterType="map" resultType="org.sonar.db.user.SearchGroupMembershipDto" databaseId="oracle">
53 select rownum as rn, t.* from (
54 select g.uuid as groupUuid, g.name as name, qggp.uuid as uuid
55 <include refid="sqlSelectByQuery"/>
60 t.rn between #{pagination.startRowNumber,jdbcType=INTEGER} and #{pagination.endRowNumber,jdbcType=INTEGER}
63 <select id="countByQuery" resultType="int">
65 <include refid="sqlSelectByQuery" />
68 <sql id="sqlSelectByQuery">
70 LEFT JOIN qgate_group_permissions qggp ON qggp.group_uuid=g.uuid AND qggp.quality_gate_uuid=#{query.qualityGateUuid, jdbcType=VARCHAR}
73 <when test="query.getMembership() == 'IN'">
74 AND qggp.uuid IS NOT NULL
76 <when test="query.getMembership() == 'OUT'">
80 <if test="query.getQuery() != null">
81 AND (LOWER(g.name) LIKE #{query.querySqlLowercase} ESCAPE '/')
86 <insert id="insert" useGeneratedKeys="false" parameterType="map">
87 insert into qgate_group_permissions(
93 #{dto.uuid, jdbcType=VARCHAR},
94 #{dto.groupUuid, jdbcType=VARCHAR},
95 #{dto.qualityGateUuid, jdbcType=VARCHAR},
96 #{now, jdbcType=BIGINT}
101 delete from qgate_group_permissions
102 where quality_gate_uuid = #{qualityGateUuid, jdbcType=VARCHAR}
103 and group_uuid = #{groupUuid, jdbcType=VARCHAR}
106 <delete id="deleteByGroup">
107 delete from qgate_group_permissions
108 where group_uuid = #{groupUuid, jdbcType=VARCHAR}
111 <delete id="deleteByQualityGate">
112 delete from qgate_group_permissions
113 where quality_gate_uuid = #{qualityGateUuid, jdbcType=VARCHAR}