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;
* @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()));
}
/**
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);
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 (