use of org.sonarqube.ws.client.project.ProjectsWsParameters.FILTER_LANGUAGES in project sonarqube by SonarSource.
the class SearchProjectsAction method addFacets.
private static SearchProjectsWsResponse.Builder addFacets(SearchResults searchResults, SearchProjectsWsResponse.Builder wsResponse) {
Facets esFacets = searchResults.facets;
EsToWsFacet esToWsFacet = new EsToWsFacet();
searchResults.query.getLanguages().ifPresent(languages -> addMandatoryValuesToFacet(esFacets, FILTER_LANGUAGES, languages));
searchResults.query.getTags().ifPresent(tags -> addMandatoryValuesToFacet(esFacets, FILTER_TAGS, tags));
Common.Facets wsFacets = esFacets.getAll().entrySet().stream().map(esToWsFacet).collect(Collector.of(Common.Facets::newBuilder, Common.Facets.Builder::addFacets, (result1, result2) -> {
throw new IllegalStateException("Parallel execution forbidden");
}, Common.Facets.Builder::build));
wsResponse.setFacets(wsFacets);
return wsResponse;
}
use of org.sonarqube.ws.client.project.ProjectsWsParameters.FILTER_LANGUAGES in project sonarqube by SonarSource.
the class ProjectMeasuresIndex method createFilters.
private Map<String, QueryBuilder> createFilters(ProjectMeasuresQuery query) {
Map<String, QueryBuilder> filters = new HashMap<>();
filters.put("__authorization", authorizationTypeSupport.createQueryFilter());
Multimap<String, MetricCriterion> metricCriterionMultimap = ArrayListMultimap.create();
query.getMetricCriteria().forEach(metricCriterion -> metricCriterionMultimap.put(metricCriterion.getMetricKey(), metricCriterion));
metricCriterionMultimap.asMap().entrySet().forEach(entry -> {
BoolQueryBuilder metricFilters = boolQuery();
entry.getValue().stream().map(criterion -> nestedQuery(FIELD_MEASURES, boolQuery().filter(termQuery(FIELD_MEASURES_KEY, criterion.getMetricKey())).filter(toValueQuery(criterion)))).forEach(metricFilters::must);
filters.put(entry.getKey(), metricFilters);
});
query.getQualityGateStatus().ifPresent(qualityGateStatus -> filters.put(ALERT_STATUS_KEY, termQuery(FIELD_QUALITY_GATE_STATUS, QUALITY_GATE_STATUS.get(qualityGateStatus.name()))));
query.getProjectUuids().ifPresent(projectUuids -> filters.put("ids", termsQuery("_id", projectUuids)));
query.getLanguages().ifPresent(languages -> filters.put(FILTER_LANGUAGES, termsQuery(FIELD_LANGUAGES, languages)));
query.getOrganizationUuid().ifPresent(organizationUuid -> filters.put(FIELD_ORGANIZATION_UUID, termQuery(FIELD_ORGANIZATION_UUID, organizationUuid)));
query.getTags().ifPresent(tags -> filters.put(FIELD_TAGS, termsQuery(FIELD_TAGS, tags)));
createTextQueryFilter(query).ifPresent(queryBuilder -> filters.put("textQuery", queryBuilder));
return filters;
}
Aggregations