Search in sources :

Example 1 with MeasureTreeQuery

use of org.sonar.db.measure.MeasureTreeQuery in project sonarqube by SonarSource.

the class ComponentTreeDataLoader method searchMeasuresByComponentUuidAndMetric.

private Table<String, MetricDto, MeasureDto> searchMeasuresByComponentUuidAndMetric(DbSession dbSession, ComponentDto baseComponent, ComponentTreeQuery componentTreeQuery, List<ComponentDto> components, List<MetricDto> metrics, @Nullable Long developerId) {
    Map<Integer, MetricDto> metricsById = Maps.uniqueIndex(metrics, MetricDto::getId);
    MeasureTreeQuery measureQuery = MeasureTreeQuery.builder().setStrategy(MeasureTreeQuery.Strategy.valueOf(componentTreeQuery.getStrategy().name())).setNameOrKeyQuery(componentTreeQuery.getNameOrKeyQuery()).setQualifiers(componentTreeQuery.getQualifiers()).setPersonId(developerId).setMetricIds(new ArrayList<>(metricsById.keySet())).build();
    List<MeasureDto> measureDtos = dbClient.measureDao().selectTreeByQuery(dbSession, baseComponent, measureQuery);
    Table<String, MetricDto, MeasureDto> measuresByComponentUuidAndMetric = HashBasedTable.create(components.size(), metrics.size());
    for (MeasureDto measureDto : measureDtos) {
        measuresByComponentUuidAndMetric.put(measureDto.getComponentUuid(), metricsById.get(measureDto.getMetricId()), measureDto);
    }
    addBestValuesToMeasures(measuresByComponentUuidAndMetric, components, metrics);
    return measuresByComponentUuidAndMetric;
}
Also used : MeasureDto(org.sonar.db.measure.MeasureDto) MeasureTreeQuery(org.sonar.db.measure.MeasureTreeQuery) MetricDto(org.sonar.db.metric.MetricDto) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)1 MeasureDto (org.sonar.db.measure.MeasureDto)1 MeasureTreeQuery (org.sonar.db.measure.MeasureTreeQuery)1 MetricDto (org.sonar.db.metric.MetricDto)1