]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-20315 update GroupPermissionDao queries
authorPierre <pierre.guillot@sonarsource.com>
Mon, 25 Sep 2023 16:11:05 +0000 (18:11 +0200)
committersonartech <sonartech@sonarsource.com>
Thu, 28 Sep 2023 20:03:13 +0000 (20:03 +0000)
server/sonar-db-dao/src/main/java/org/sonar/db/permission/GroupPermissionDao.java
server/sonar-db-dao/src/main/java/org/sonar/db/permission/GroupPermissionMapper.java
server/sonar-db-dao/src/main/resources/org/sonar/db/permission/GroupPermissionMapper.xml

index 39d0d8cfb22a0d6b8da6b2e14d7b1fef608ae548..8aff217a7c56328bf64a021d00d1fd7a0e3578ac 100644 (file)
@@ -25,10 +25,10 @@ import java.util.Map;
 import java.util.Set;
 import javax.annotation.Nullable;
 import org.apache.ibatis.session.ResultHandler;
-import org.apache.ibatis.session.RowBounds;
 import org.sonar.api.security.DefaultGroups;
 import org.sonar.db.Dao;
 import org.sonar.db.DbSession;
+import org.sonar.db.Pagination;
 import org.sonar.db.audit.AuditPersister;
 import org.sonar.db.audit.model.GroupPermissionNewValue;
 import org.sonar.db.entity.EntityDto;
@@ -54,7 +54,7 @@ public class GroupPermissionDao implements Dao {
    * @return group names, sorted in alphabetical order
    */
   public List<String> selectGroupNamesByQuery(DbSession dbSession, PermissionQuery query) {
-    return mapper(dbSession).selectGroupNamesByQuery(query, new RowBounds(query.getPageOffset(), query.getPageSize()));
+    return mapper(dbSession).selectGroupNamesByQuery(query, Pagination.forPage(query.getPageIndex()).andSize(query.getPageSize()));
   }
 
   /**
index f3d2934b39fa7d8d8ad168f76cd2e133bc859443..b548d8f1ca8dc4109c40df22293fdccca7d869e5 100644 (file)
@@ -25,11 +25,11 @@ import java.util.Set;
 import javax.annotation.Nullable;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.session.ResultHandler;
-import org.apache.ibatis.session.RowBounds;
+import org.sonar.db.Pagination;
 
 public interface GroupPermissionMapper {
 
-  List<String> selectGroupNamesByQuery(@Param("query") PermissionQuery query, RowBounds rowBounds);
+  List<String> selectGroupNamesByQuery(@Param("query") PermissionQuery query, @Param("pagination") Pagination pagination);
 
   int countGroupsByQuery(@Param("query") PermissionQuery query);
 
index 78d5f251ecdd927ff58f4bf6377de771df670065..3a214437939c0ab503bad1d247b0ab2851a96846 100644 (file)
     from group_roles gr where gr.group_uuid is null and gr.entity_uuid is not null
   </select>
 
-  <select id="selectGroupNamesByQuery" parameterType="map" resultType="string">
+  <select id="selectGroupNamesByQuery" resultType="string">
     select sub.name, lower(sub.name), sub.groupUuid
     <include refid="groupsByQuery"/>
     group by sub.name, lower(sub.name), sub.groupUuid
     order by case when (count(sub.permission) > 0) then 1 else 2 end asc, lower(sub.name), sub.name, sub.groupUuid
+    <include refid="pagination"/>
   </select>
 
+  <sql id="pagination">
+    offset (#{pagination.startRowNumber,jdbcType=INTEGER}-1) rows fetch next #{pagination.pageSize,jdbcType=INTEGER} rows only
+  </sql>
+
   <select id="countGroupsByQuery" parameterType="map" resultType="int">
     select count(1)
     from (