use of org.sonar.db.user.UserMembershipQuery in project sonarqube by SonarSource.
the class UsersAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
int pageSize = request.mandatoryParamAsInt(Param.PAGE_SIZE);
int page = request.mandatoryParamAsInt(Param.PAGE);
String queryString = request.param(Param.TEXT_QUERY);
String selected = request.mandatoryParam(Param.SELECTED);
try (DbSession dbSession = dbClient.openSession(false)) {
GroupId group = support.findGroup(dbSession, request);
userSession.checkPermission(OrganizationPermission.ADMINISTER, group.getOrganizationUuid());
UserMembershipQuery query = UserMembershipQuery.builder().groupId(group.getId()).memberSearch(queryString).membership(getMembership(selected)).pageIndex(page).pageSize(pageSize).build();
int total = dbClient.groupMembershipDao().countMembers(dbSession, query);
Paging paging = forPageIndex(page).withPageSize(pageSize).andTotal(total);
List<UserMembershipDto> users = dbClient.groupMembershipDao().selectMembers(dbSession, query, paging.offset(), paging.pageSize());
JsonWriter json = response.newJsonWriter().beginObject();
writeMembers(json, users);
writePaging(json, paging);
json.endObject().close();
}
}
use of org.sonar.db.user.UserMembershipQuery in project sonarqube by SonarSource.
the class UpdateAction method writeResponse.
private void writeResponse(DbSession dbSession, Request request, Response response, OrganizationDto organization, GroupDto group) {
UserMembershipQuery query = UserMembershipQuery.builder().groupId(group.getId()).membership(GroupMembershipQuery.IN).build();
int membersCount = dbClient.groupMembershipDao().countMembers(dbSession, query);
WsUserGroups.UpdateResponse.Builder respBuilder = WsUserGroups.UpdateResponse.newBuilder();
respBuilder.setGroup(toProtobuf(organization, group, membersCount));
writeProtobuf(respBuilder.build(), request, response);
}
Aggregations