use of org.sonar.server.component.ws.FilterParser.Criterion in project sonarqube by SonarSource.
the class SearchProjectsAction method searchData.
private SearchResults searchData(DbSession dbSession, SearchProjectsRequest request, @Nullable OrganizationDto organization) {
Set<String> favoriteProjectUuids = loadFavoriteProjectUuids(dbSession);
List<Criterion> criteria = FilterParser.parse(firstNonNull(request.getFilter(), ""));
ProjectMeasuresQuery query = newProjectMeasuresQuery(criteria, hasFavoriteFilter(criteria) ? favoriteProjectUuids : null).setSort(request.getSort()).setAsc(request.getAsc());
Optional.ofNullable(organization).map(OrganizationDto::getUuid).ifPresent(query::setOrganizationUuid);
queryValidator.validate(dbSession, query);
SearchIdResult<String> esResults = index.search(query, new SearchOptions().addFacets(request.getFacets()).setPage(request.getPage(), request.getPageSize()));
List<String> projectUuids = esResults.getIds();
Ordering<ComponentDto> ordering = Ordering.explicit(projectUuids).onResultOf(ComponentDto::uuid);
List<ComponentDto> projects = ordering.immutableSortedCopy(dbClient.componentDao().selectByUuids(dbSession, projectUuids));
Map<String, SnapshotDto> analysisByProjectUuid = getSnapshots(dbSession, request, projectUuids);
return new SearchResults(projects, favoriteProjectUuids, esResults, analysisByProjectUuid, query);
}
use of org.sonar.server.component.ws.FilterParser.Criterion in project sonarqube by SonarSource.
the class ProjectMeasuresQueryFactoryTest method create_query.
@Test
public void create_query() throws Exception {
List<Criterion> criteria = asList(Criterion.builder().setKey("ncloc").setOperator(GT).setValue("10").build(), Criterion.builder().setKey("coverage").setOperator(LTE).setValue("80").build());
ProjectMeasuresQuery underTest = newProjectMeasuresQuery(criteria, emptySet());
assertThat(underTest.getMetricCriteria()).extracting(MetricCriterion::getMetricKey, MetricCriterion::getOperator, MetricCriterion::getValue).containsOnly(tuple("ncloc", GT, 10d), tuple("coverage", Operator.LTE, 80d));
}
use of org.sonar.server.component.ws.FilterParser.Criterion in project sonarqube by SonarSource.
the class ProjectMeasuresQueryFactoryTest method create_query_having_q_ignore_case_sensitive.
@Test
public void create_query_having_q_ignore_case_sensitive() throws Exception {
List<Criterion> criteria = singletonList(Criterion.builder().setKey("query").setOperator(EQ).setValue("Sonar Qube").build());
ProjectMeasuresQuery underTest = newProjectMeasuresQuery(criteria, emptySet());
assertThat(underTest.getQueryText().get()).isEqualTo("Sonar Qube");
}
use of org.sonar.server.component.ws.FilterParser.Criterion in project sonarqube by SonarSource.
the class ProjectMeasuresQueryFactoryTest method create_query_having_q.
@Test
public void create_query_having_q() throws Exception {
List<Criterion> criteria = singletonList(Criterion.builder().setKey("query").setOperator(EQ).setValue("Sonar Qube").build());
ProjectMeasuresQuery underTest = newProjectMeasuresQuery(criteria, emptySet());
assertThat(underTest.getQueryText().get()).isEqualTo("Sonar Qube");
}
Aggregations