@Override public void handle(Request request, Response response) { try (DbSession dbSession = dbClient.openSession(false)) { OrganizationDto organization = wsSupport.getOrganization(dbSession, request); QGateWithOrgDto qualityGate = qualityGateFinder.getByOrganizationAndId(dbSession, organization, request.mandatoryParamAsLong(PARAM_GATE_ID)); Association associations = find(dbSession, ProjectQgateAssociationQuery.builder() .qualityGate(qualityGate) .membership(request.param(PARAM_QUERY) == null ? request.param(SELECTED) : ANY) .projectSearch(request.param(PARAM_QUERY)) .pageIndex(request.paramAsInt(PARAM_PAGE)) .pageSize(request.paramAsInt(PARAM_PAGE_SIZE)) .build()); Qualitygates.SearchResponse.Builder createResponse = Qualitygates.SearchResponse.newBuilder() .setMore(associations.hasMoreResults()); for (ProjectQgateAssociation project : associations.projects()) { createResponse.addResultsBuilder() .setId(project.id()) .setName(project.name()) .setSelected(project.isMember()); } writeProtobuf(createResponse.build(), request, response); } }
@Override public void handle(Request request, Response response) { try (DbSession dbSession = dbClient.openSession(false)) { OrganizationDto organization = wsSupport.getOrganization(dbSession, request); QGateWithOrgDto qualityGate = wsSupport.getByOrganizationAndId(dbSession, organization, request.mandatoryParamAsLong(PARAM_GATE_ID)); Association associations = find(dbSession, ProjectQgateAssociationQuery.builder() .qualityGate(qualityGate) .membership(request.param(PARAM_QUERY) == null ? request.param(SELECTED) : ANY) .projectSearch(request.param(PARAM_QUERY)) .pageIndex(request.paramAsInt(PARAM_PAGE)) .pageSize(request.paramAsInt(PARAM_PAGE_SIZE)) .build()); Qualitygates.SearchResponse.Builder createResponse = Qualitygates.SearchResponse.newBuilder() .setMore(associations.hasMoreResults()); for (ProjectQgateAssociation project : associations.projects()) { createResponse.addResultsBuilder() .setId(project.id()) .setName(project.name()) .setSelected(project.isMember()); } writeProtobuf(createResponse.build(), request, response); } }