Search in sources :

Example 1 with AnalyticException

use of au.gov.asd.tac.constellation.views.analyticview.utilities.AnalyticException in project constellation by constellation-app.

the class AnalyticConfigurationPane method answerCurrentQuestion.

/**
 * Answer the question which is currently selected in this pane.
 *
 * @return the answered {@link AnalyticQuestion}.
 */
protected final AnalyticQuestion<?> answerCurrentQuestion() throws AnalyticException {
    // build question
    final AnalyticQuestion<?> question = new AnalyticQuestion<>(currentQuestion);
    // retrieve and set any global parameters in the question
    final AnalyticAggregatorParameterValue aggregatorParameterValue = (AnalyticAggregatorParameterValue) globalAnalyticParameters.getSingleChoice(AGGREGATOR_PARAMETER_ID);
    if (aggregatorParameterValue == null) {
        throw new AnalyticException("You must select an aggregation method!");
    }
    final AnalyticAggregator aggregator = (AnalyticAggregator<?>) aggregatorParameterValue.getObjectValue();
    question.setAggregator(aggregator);
    // add and set parameters for each plugin in the question
    final List<SelectableAnalyticPlugin> selectedPlugins = new ArrayList<>();
    pluginList.getItems().forEach(selectablePlugin -> {
        if (selectablePlugin.checkbox.isSelected()) {
            selectedPlugins.add(selectablePlugin);
            question.addPlugin(selectablePlugin.plugin, selectablePlugin.getPluginSpecificParameters());
        }
    });
    if (selectedPlugins.isEmpty()) {
        throw new AnalyticException("You must select at least one analytic!");
    }
    final Graph currentGraph = GraphManager.getDefault().getActiveGraph();
    // update the analytic view state
    PluginExecution.withPlugin(new AnalyticViewStateWriter(currentQuestion, selectedPlugins)).executeLater(currentGraph);
    // answer the question
    return question.answer(currentGraph);
}
Also used : Graph(au.gov.asd.tac.constellation.graph.Graph) AnalyticException(au.gov.asd.tac.constellation.views.analyticview.utilities.AnalyticException) ArrayList(java.util.ArrayList) AnalyticAggregator(au.gov.asd.tac.constellation.views.analyticview.aggregators.AnalyticAggregator) AnalyticQuestion(au.gov.asd.tac.constellation.views.analyticview.questions.AnalyticQuestion)

Example 2 with AnalyticException

use of au.gov.asd.tac.constellation.views.analyticview.utilities.AnalyticException in project constellation by constellation-app.

the class AppendScoreAggregator method aggregate.

@Override
public ScoreResult aggregate(final List<ScoreResult> results) throws AnalyticException {
    final ScoreResult aggregateResult = new ScoreResult();
    if (CollectionUtils.isEmpty(results)) {
        return aggregateResult;
    }
    aggregateResult.setIgnoreNullResults(results.stream().anyMatch(result -> result.isIgnoreNullResults()));
    results.forEach(scoreResult -> aggregateResult.combine(scoreResult));
    return aggregateResult;
}
Also used : List(java.util.List) AnalyticException(au.gov.asd.tac.constellation.views.analyticview.utilities.AnalyticException) ScoreResult(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult) ServiceProvider(org.openide.util.lookup.ServiceProvider) CollectionUtils(org.apache.commons.collections4.CollectionUtils) AnalyticResult(au.gov.asd.tac.constellation.views.analyticview.results.AnalyticResult) ScoreResult(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult)

Aggregations

AnalyticException (au.gov.asd.tac.constellation.views.analyticview.utilities.AnalyticException)2 Graph (au.gov.asd.tac.constellation.graph.Graph)1 AnalyticAggregator (au.gov.asd.tac.constellation.views.analyticview.aggregators.AnalyticAggregator)1 AnalyticQuestion (au.gov.asd.tac.constellation.views.analyticview.questions.AnalyticQuestion)1 AnalyticResult (au.gov.asd.tac.constellation.views.analyticview.results.AnalyticResult)1 ScoreResult (au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 CollectionUtils (org.apache.commons.collections4.CollectionUtils)1 ServiceProvider (org.openide.util.lookup.ServiceProvider)1