Search in sources :

Example 6 with ElementScore

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;
}
Also used : List(java.util.List) ElementScore(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult.ElementScore) Map(java.util.Map) ScoreResult(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult) ServiceProvider(org.openide.util.lookup.ServiceProvider) HashMap(java.util.HashMap) CollectionUtils(org.apache.commons.collections4.CollectionUtils) AnalyticResult(au.gov.asd.tac.constellation.views.analyticview.results.AnalyticResult) HashMap(java.util.HashMap) ElementScore(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult.ElementScore) ScoreResult(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult)

Aggregations

ElementScore (au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult.ElementScore)6 HashMap (java.util.HashMap)6 AnalyticResult (au.gov.asd.tac.constellation.views.analyticview.results.AnalyticResult)5 ScoreResult (au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult)5 List (java.util.List)5 Map (java.util.Map)5 CollectionUtils (org.apache.commons.collections4.CollectionUtils)4 ServiceProvider (org.openide.util.lookup.ServiceProvider)4 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)2 Graph (au.gov.asd.tac.constellation.graph.Graph)1 TRANSACTION (au.gov.asd.tac.constellation.graph.GraphElementType.TRANSACTION)1 VERTEX (au.gov.asd.tac.constellation.graph.GraphElementType.VERTEX)1 GraphReadMethods (au.gov.asd.tac.constellation.graph.GraphReadMethods)1 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)1 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)1 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)1 GraphRecordStoreUtilities (au.gov.asd.tac.constellation.graph.processing.GraphRecordStoreUtilities)1 RecordStore (au.gov.asd.tac.constellation.graph.processing.RecordStore)1 SchemaFactory (au.gov.asd.tac.constellation.graph.schema.SchemaFactory)1 SchemaFactoryUtilities (au.gov.asd.tac.constellation.graph.schema.SchemaFactoryUtilities)1