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;
}
Aggregations