Result result = algorithmRunner.getResult();
logger.debug("result=" + result);
if (result == null || result.getAggregates() == null || result.getAggregates().size() == 0) {
XulMessageBox box = (XulMessageBox) document.createElement("messagebox");
box.setTitle(Messages.getString("AlgorithmController.NoResultsTitle"));
box.setMessage(Messages.getString("AlgorithmController.NoResultsMessage"));
box.open();
return;
}
List<UIAggregate> algorithmAggs = new ArrayList<UIAggregate>();
for (Aggregate agg : result.getAggregates()) {
UIAggregateImpl cagg = new UIAggregateImpl();
cagg.setName(agg.getCandidateTableName());
cagg.setAlgoAgg(true);
cagg.setDescription(agg.getDescription());
cagg.setEstimateRowCount(agg.estimateRowCount());
cagg.setEstimateSpace(agg.estimateSpace());
List<Attribute> list = new ArrayList<Attribute>(agg.getAttributes());
cagg.setAttributes(list);
List<Measure> measureList = new ArrayList<Measure>(agg.getMeasures());
cagg.setMeasures(measureList);
algorithmAggs.add(cagg);
}
// reverse the collection, the results from the algorithm seem to
// come back in reverse order of benefit
Collections.reverse(algorithmAggs);
// rename the aggregates appropriately
aggNamingService.nameAggregates(algorithmAggs, getAggList(), connectionModel.getSchema());
// add all the uiaggs to the agg list
for (UIAggregate agg : algorithmAggs) {
try {
agg.setOutput(outputService.generateDefaultOutput(agg));
} catch (OutputValidationException e) {
System.err.println("Failed to create output, skipping UIAggregate");
e.printStackTrace();
}
// getAggList().addAgg(agg);
}
getAggList().addAggs(algorithmAggs);
closeDialog();
} catch (ValidationException validationException) {
logger.error("error", validationException);
XulMessageBox box = (XulMessageBox) document.createElement("messagebox");
box.setTitle(Messages.getString("AlgorithmController.ErrorTitle"));
box.setMessage(Messages.getString("AlgorithmController.ValidationErrorMessage", validationException.getMessage()));
box.open();
} catch (Throwable throwable) {
logger.error("error", throwable);
XulMessageBox box = (XulMessageBox) document.createElement("messagebox");
box.setTitle(Messages.getString("AlgorithmController.ErrorTitle"));
box.setMessage(Messages.getString("AlgorithmController.GeneralErrorMessage"));
box.open();
}
}