Search in sources :

Example 6 with ValueType

use of org.sonar.api.measures.Metric.ValueType in project sonarqube by SonarSource.

the class ComponentTreeSort method metricPeriodOrdering.

private static Ordering<ComponentDto> metricPeriodOrdering(ComponentTreeRequest wsRequest, List<MetricDto> metrics, Table<String, MetricDto, ComponentTreeData.Measure> measuresByComponentUuidAndMetric) {
    if (wsRequest.getMetricSort() == null || wsRequest.getMetricPeriodSort() == null) {
        return componentNameOrdering(wsRequest.getAsc());
    }
    Map<String, MetricDto> metricsByKey = Maps.uniqueIndex(metrics, MetricDto::getKey);
    MetricDto metric = metricsByKey.get(wsRequest.getMetricSort());
    ValueType metricValueType = ValueType.valueOf(metric.getValueType());
    if (NUMERIC_VALUE_TYPES.contains(metricValueType)) {
        return numericalMetricPeriodOrdering(wsRequest, metric, measuresByComponentUuidAndMetric);
    }
    throw BadRequestException.create(format("Impossible to sort metric '%s' by measure period.", metric.getKey()));
}
Also used : MetricDto(org.sonar.db.metric.MetricDto) ValueType(org.sonar.api.measures.Metric.ValueType)

Aggregations

ValueType (org.sonar.api.measures.Metric.ValueType)6 MetricDto (org.sonar.db.metric.MetricDto)4