use of org.sonar.server.measure.index.ProjectMeasuresQuery.Operator in project sonarqube by SonarSource.
the class ProjectMeasuresQueryFactory method processQuery.
private static void processQuery(Criterion criterion, ProjectMeasuresQuery query) {
checkOperator(criterion);
Operator operatorValue = criterion.getOperator();
String value = criterion.getValue();
checkArgument(value != null, "Query is invalid");
checkArgument(EQ.equals(operatorValue), "Query should only be used with equals operator");
query.setQueryText(value);
}
use of org.sonar.server.measure.index.ProjectMeasuresQuery.Operator in project sonarqube by SonarSource.
the class ProjectMeasuresQueryFactory method processLanguages.
private static void processLanguages(Criterion criterion, ProjectMeasuresQuery query) {
checkOperator(criterion);
Operator operator = criterion.getOperator();
String value = criterion.getValue();
List<String> values = criterion.getValues();
if (value != null && EQ.equals(operator)) {
query.setLanguages(singleton(value));
return;
}
if (!values.isEmpty() && IN.equals(operator)) {
query.setLanguages(new HashSet<>(values));
return;
}
throw new IllegalArgumentException("Languages should be set either by using 'languages = java' or 'languages IN (java, js)'");
}
use of org.sonar.server.measure.index.ProjectMeasuresQuery.Operator in project sonarqube by SonarSource.
the class ProjectMeasuresQueryFactory method processQualifier.
private static void processQualifier(Criterion criterion, ProjectMeasuresQuery query) {
checkOperator(criterion);
checkValue(criterion);
Operator operator = criterion.getOperator();
String value = criterion.getValue();
checkArgument(EQ.equals(operator), "Only equals operator is available for qualifier criteria");
String qualifier = Stream.of(Qualifiers.APP, Qualifiers.PROJECT).filter(q -> q.equalsIgnoreCase(value)).findFirst().orElseThrow(() -> new IllegalArgumentException(format("Unknown qualifier : '%s'", value)));
query.setQualifiers(Sets.newHashSet(qualifier));
}
use of org.sonar.server.measure.index.ProjectMeasuresQuery.Operator in project sonarqube by SonarSource.
the class ProjectMeasuresQueryFactory method processQualityGateStatus.
private static void processQualityGateStatus(Criterion criterion, ProjectMeasuresQuery query) {
checkOperator(criterion);
checkValue(criterion);
Operator operator = criterion.getOperator();
String value = criterion.getValue();
checkArgument(EQ.equals(operator), "Only equals operator is available for quality gate criteria");
Level qualityGate = Arrays.stream(Level.values()).filter(level -> level.name().equalsIgnoreCase(value)).findFirst().orElseThrow(() -> new IllegalArgumentException(format("Unknown quality gate status : '%s'", value)));
query.setQualityGateStatus(qualityGate);
}
use of org.sonar.server.measure.index.ProjectMeasuresQuery.Operator in project sonarqube by SonarSource.
the class ProjectMeasuresQueryFactory method processTags.
private static void processTags(Criterion criterion, ProjectMeasuresQuery query) {
checkOperator(criterion);
Operator operator = criterion.getOperator();
String value = criterion.getValue();
List<String> values = criterion.getValues();
if (value != null && EQ.equals(operator)) {
query.setTags(singleton(value));
return;
}
if (!values.isEmpty() && IN.equals(operator)) {
query.setTags(new HashSet<>(values));
return;
}
throw new IllegalArgumentException("Tags should be set either by using 'tags = java' or 'tags IN (finance, platform)'");
}