*/
public String processStatistics(GeoStoreUtil geostoreUtil, Resource statsDef, String year, String month, String day, Map<Statistics.Tokens, String> tokens)
throws FlowException {
if(tokens == null)
throw new FlowException("Tokens are null");
if(statsDef == null)
throw new FlowException("StatsDef is null");
if(statsDef.getData() == null)
throw new FlowException("StoredData is null");
if(statsDef.getData().getData() == null)
throw new FlowException("StoredData has no content");
LOGGER.info("Preparing to run statistics " + statsDef.getName() + " on " + tokens.get(Statistics.Tokens.FILEPATH));
File outStats = null;
// execute the statistics statdefres.getData().getData() substituting variable properties by those indicated in tokenProps
// and save the result on a file named outFileName
try {
outStats = File.createTempFile("statsresults", ".csv", tempDir);
Statistics statistics = new Statistics();
String statsDefinition = statsDef.getData().getData();
statistics.executeStatistics(statsDefinition, tokens, outStats.getAbsolutePath());
LOGGER.info("Statistics processed: " + statsDef.getName());
String statsContent = IOUtils.toString(new FileReader(outStats));
geostoreUtil.setStatsData(statsDef, statsContent, year, month, day);
return statsContent;
} catch (Exception ex) {
LOGGER.debug("ex!", ex);
throw new FlowException("Error while executing stats: " + ex.getMessage(), ex);
} catch (Error ex) { // just log it
LOGGER.error("ERROR", ex);
throw ex;
}