use of org.sonar.db.user.SearchGroupMembershipDto in project sonarqube by SonarSource.
the class SearchGroupsAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
SearchQualityGateUsersRequest wsRequest = buildRequest(request);
try (DbSession dbSession = dbClient.openSession(false)) {
QualityGateDto gate = wsSupport.getByName(dbSession, wsRequest.getQualityGate());
wsSupport.checkCanLimitedEdit(dbSession, gate);
SearchPermissionQuery query = builder().setQualityGate(gate).setQuery(wsRequest.getQuery()).setMembership(MEMBERSHIP.get(fromParam(wsRequest.getSelected()))).build();
int total = dbClient.qualityGateGroupPermissionsDao().countByQuery(dbSession, query);
List<SearchGroupMembershipDto> groupMemberships = dbClient.qualityGateGroupPermissionsDao().selectByQuery(dbSession, query, forPage(wsRequest.getPage()).andSize(wsRequest.getPageSize()));
Map<String, GroupDto> groupsByUuid = dbClient.groupDao().selectByUuids(dbSession, groupMemberships.stream().map(SearchGroupMembershipDto::getGroupUuid).collect(MoreCollectors.toList())).stream().collect(MoreCollectors.uniqueIndex(GroupDto::getUuid));
writeProtobuf(Qualitygates.SearchGroupsResponse.newBuilder().addAllGroups(groupMemberships.stream().map(groupsMembership -> toGroup(groupsByUuid.get(groupsMembership.getGroupUuid()), groupsMembership.isSelected())).collect(toList())).setPaging(buildPaging(wsRequest, total)).build(), request, response);
}
}
use of org.sonar.db.user.SearchGroupMembershipDto in project sonarqube by SonarSource.
the class SearchGroupsAction method handle.
@Override
public void handle(Request request, Response response) throws Exception {
SearchQualityProfileUsersRequest wsRequest = buildRequest(request);
try (DbSession dbSession = dbClient.openSession(false)) {
QProfileDto profile = wsSupport.getProfile(dbSession, wsRequest.getQualityProfile(), wsRequest.getLanguage());
wsSupport.checkCanEdit(dbSession, profile);
SearchQualityProfilePermissionQuery query = builder().setProfile(profile).setQuery(wsRequest.getQuery()).setMembership(MEMBERSHIP.get(fromParam(wsRequest.getSelected()))).build();
int total = dbClient.qProfileEditGroupsDao().countByQuery(dbSession, query);
List<SearchGroupMembershipDto> groupMemberships = dbClient.qProfileEditGroupsDao().selectByQuery(dbSession, query, forPage(wsRequest.getPage()).andSize(wsRequest.getPageSize()));
Map<String, GroupDto> groupsByUuid = dbClient.groupDao().selectByUuids(dbSession, groupMemberships.stream().map(SearchGroupMembershipDto::getGroupUuid).collect(MoreCollectors.toList())).stream().collect(MoreCollectors.uniqueIndex(GroupDto::getUuid));
writeProtobuf(Qualityprofiles.SearchGroupsResponse.newBuilder().addAllGroups(groupMemberships.stream().map(groupsMembership -> toGroup(groupsByUuid.get(groupsMembership.getGroupUuid()), groupsMembership.isSelected())).collect(toList())).setPaging(buildPaging(wsRequest, total)).build(), request, response);
}
}
Aggregations