use of org.sonarqube.ws.WsComponents.SuggestionsWsResponse.Qualifier in project sonarqube by SonarSource.
the class SuggestionsAction method getResultsOfAllQualifiers.
private List<Qualifier> getResultsOfAllQualifiers(String query) {
ComponentIndexQuery componentIndexQuery = new ComponentIndexQuery(query).setQualifiers(Arrays.asList(QUALIFIERS)).setLimit(NUMBER_OF_RESULTS_PER_QUALIFIER);
List<ComponentsPerQualifier> componentsPerQualifiers = searchInIndex(componentIndexQuery);
if (componentsPerQualifiers.isEmpty()) {
return Collections.emptyList();
}
try (DbSession dbSession = dbClient.openSession(false)) {
return componentsPerQualifiers.stream().map(qualifier -> {
List<String> uuids = qualifier.getComponentUuids();
List<ComponentDto> componentDtos = dbClient.componentDao().selectByUuids(dbSession, uuids);
List<ComponentDto> sortedComponentDtos = Ordering.explicit(uuids).onResultOf(ComponentDto::uuid).immutableSortedCopy(componentDtos);
Map<String, String> organizationKeyByUuids = getOrganizationKeys(dbSession, componentDtos);
List<Component> results = sortedComponentDtos.stream().map(dto -> dtoToComponent(dto, organizationKeyByUuids)).collect(Collectors.toList());
return Qualifier.newBuilder().setQ(qualifier.getQualifier()).addAllItems(results).build();
}).collect(Collectors.toList());
}
}
Aggregations