use of au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult.ElementScore in project constellation by constellation-app.
the class SumScoreAggregator method aggregate.
@Override
public ScoreResult aggregate(final List<ScoreResult> results) {
final ScoreResult combinedResults = new ScoreResult();
final ScoreResult aggregateResult = new ScoreResult();
if (CollectionUtils.isEmpty(results)) {
return aggregateResult;
}
aggregateResult.setIgnoreNullResults(results.stream().anyMatch(result -> result.isIgnoreNullResults()));
results.forEach(scoreResult -> combinedResults.combine(scoreResult));
combinedResults.getResult().forEach((key, value) -> {
final Map<String, Float> aggregateScores = new HashMap<>();
aggregateScores.put(SCORE_NAME, value.getNamedScores().values().stream().reduce((x, y) -> x + y).orElse(0.0F));
aggregateResult.add(new ElementScore(key.getElementType(), key.getElementId(), key.getIdentifier(), false, aggregateScores));
});
return aggregateResult;
}
Aggregations