private SearchWsResponse call(SearchRequest wsRequest) { TestRequest request = ws.newRequest(); ofNullable(wsRequest.getOrganization()).ifPresent(p3 -> request.setParam(PARAM_ORGANIZATION, p3)); ofNullable(wsRequest.getLanguage()).ifPresent(p2 -> request.setParam(PARAM_LANGUAGE, p2)); ofNullable(wsRequest.getQualifiers()).ifPresent(p1 -> request.setParam(PARAM_QUALIFIERS, Joiner.on(",").join(p1))); ofNullable(wsRequest.getQuery()).ifPresent(p -> request.setParam(TEXT_QUERY, p)); ofNullable(wsRequest.getPage()).ifPresent(page -> request.setParam(PAGE, String.valueOf(page))); ofNullable(wsRequest.getPageSize()).ifPresent(pageSize -> request.setParam(PAGE_SIZE, String.valueOf(pageSize))); return request.executeProtobuf(SearchWsResponse.class); }
private SearchWsResponse doHandle(SearchRequest request) { try (DbSession dbSession = dbClient.openSession(false)) { OrganizationDto organization = getOrganization(dbSession, request); ComponentQuery esQuery = buildEsQuery(organization, request); SearchIdResult<String> results = componentIndex.search(esQuery, new SearchOptions().setPage(request.getPage(), request.getPageSize())); List<ComponentDto> components = dbClient.componentDao().selectByUuids(dbSession, results.getIds()); Map<String, String> projectKeysByUuids = searchProjectsKeysByUuids(dbSession, components); return buildResponse(components, organization, projectKeysByUuids, Paging.forPageIndex(request.getPage()).withPageSize(request.getPageSize()).andTotal((int) results.getTotal())); } }
private SearchWsResponse doHandle(SearchRequest request) { try (DbSession dbSession = dbClient.openSession(false)) { OrganizationDto organization = getOrganization(dbSession, request); ComponentQuery esQuery = buildEsQuery(organization, request); SearchIdResult<String> results = componentIndex.search(esQuery, new SearchOptions().setPage(request.getPage(), request.getPageSize())); List<ComponentDto> components = dbClient.componentDao().selectByUuids(dbSession, results.getIds()); Map<String, String> projectKeysByUuids = searchProjectsKeysByUuids(dbSession, components); return buildResponse(components, organization, projectKeysByUuids, Paging.forPageIndex(request.getPage()).withPageSize(request.getPageSize()).andTotal((int) results.getTotal())); } }