]> source.dussan.org Git - sonarqube.git/blob
029701e607214141f6ac2af7572826c7a82c665b
[sonarqube.git] /
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "mybatis-3-mapper.dtd">
3
4 <mapper namespace="org.sonar.db.qualitygate.QualityGateGroupPermissionsMapper">
5
6   <sql id="sqlColumns">
7     qggp.uuid as "uuid",
8     qggp.group_uuid as "groupUuid",
9     qggp.quality_gate_uuid as "qualityGateUuid"
10   </sql>
11
12   <select id="selectByQualityGateAndGroup" parameterType="String" resultType="org.sonar.db.qualitygate.QualityGateGroupPermissionsDto">
13     select
14     <include refid="sqlColumns"/>
15     from qgate_group_permissions qggp
16     where
17     qggp.group_uuid = #{groupUuid}
18     and qggp.quality_gate_uuid = #{qualityGateUuid}
19   </select>
20
21   <select id="selectByQualityGateAndGroups" parameterType="map" resultType="org.sonar.db.qualitygate.QualityGateGroupPermissionsDto">
22     select
23     <include refid="sqlColumns"/>
24     from qgate_group_permissions qggp
25     where
26     <foreach collection="groupUuids" open="(" close=")" item="groupUuid" separator=" or ">
27       qggp.group_uuid = #{groupUuid, jdbcType=VARCHAR}
28     </foreach>
29     and qggp.quality_gate_uuid = #{qualityGateUuid, jdbcType=VARCHAR}
30   </select>
31
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"/>
35     ORDER BY g.name ASC
36     offset #{pagination.offset,jdbcType=INTEGER} rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
37   </select>
38
39    <select id="countByQuery" resultType="int">
40     select count(g.uuid)
41     <include refid="sqlSelectByQuery" />
42   </select>
43
44   <sql id="sqlSelectByQuery">
45     FROM groups g
46     LEFT JOIN qgate_group_permissions qggp ON qggp.group_uuid=g.uuid AND qggp.quality_gate_uuid=#{query.qualityGateUuid, jdbcType=VARCHAR}
47     <where>
48       <choose>
49         <when test="query.getMembership() == 'IN'">
50           AND qggp.uuid IS NOT NULL
51         </when>
52         <when test="query.getMembership() == 'OUT'">
53           AND qggp.uuid IS NULL
54         </when>
55       </choose>
56       <if test="query.getQuery() != null">
57         AND (LOWER(g.name) LIKE #{query.querySqlLowercase} ESCAPE '/')
58       </if>
59     </where>
60   </sql>
61
62   <insert id="insert" useGeneratedKeys="false" parameterType="map">
63     insert into qgate_group_permissions(
64     uuid,
65     group_uuid,
66     quality_gate_uuid,
67     created_at
68     ) values (
69     #{dto.uuid, jdbcType=VARCHAR},
70     #{dto.groupUuid, jdbcType=VARCHAR},
71     #{dto.qualityGateUuid, jdbcType=VARCHAR},
72     #{now, jdbcType=BIGINT}
73     )
74   </insert>
75
76   <delete id="delete">
77     delete from qgate_group_permissions
78     where quality_gate_uuid = #{qualityGateUuid, jdbcType=VARCHAR}
79     and group_uuid = #{groupUuid, jdbcType=VARCHAR}
80   </delete>
81
82   <delete id="deleteByGroup">
83     delete from qgate_group_permissions
84     where group_uuid = #{groupUuid, jdbcType=VARCHAR}
85   </delete>
86
87   <delete id="deleteByQualityGate">
88     delete from qgate_group_permissions
89     where quality_gate_uuid = #{qualityGateUuid, jdbcType=VARCHAR}
90   </delete>
91
92 </mapper>