Package it.geosolutions.geobatch.unredd.script.exception

Examples of it.geosolutions.geobatch.unredd.script.exception.FlowException


     */
    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;
        }

View Full Code Here


                currentScript = scriptResource.getName() + "(id:"+scriptResource.getId()+")";
                LOGGER.info("Running " + currentScript);
                runScript(scriptResource, props);
            }
        } catch (ActionException e) {
            throw new FlowException("Error while running Chart Script " + currentScript, e);
        }
    }
View Full Code Here

        List<Resource> relatedStatsDef = null;
        try {
            relatedStatsDef = geostore.searchStatsDefByLayer(layername, false);
        } catch (Exception e) {
            LOGGER.debug("Parameter : [layername=" + layername + ", year=" + year + ", month=" + month + "]");
            throw new FlowException("Error while searching for StatsDef", e);
        }

        // ********************
        // Run statistics
        // --------------------
        // For each statsdef performs the statistics and collect the related chartScript.
        // This way, needed ChartScript will be run once even if related to more than one stat.
        // ********************

        Set<Resource> chartScript = new HashSet<Resource>();

        try {
            for (Resource statsDef : relatedStatsDef) {
                Map<Tokens,String> tok = fillTokens(rasterFile.getAbsolutePath(), layername, year, month, null);
                processStatistics(geostore, statsDef, year, month, day, tok);

                List<Resource> localChartScript = geostore.searchChartScriptByStatsDef(statsDef.getName());
                if(LOGGER.isInfoEnabled())
                    LOGGER.info("Found " + localChartScript.size() + " ChartsScript depending on StatsDef '"+statsDef.getName()+"'");

                chartScript.addAll(localChartScript);
            }
        } catch (Exception e) {
            throw new FlowException("Error while running stats", e);
        }

        // ********************
        // Run scripts
        // ********************

        try {
            runScripts(geostore, chartScript);
        } catch (Exception e) {
            throw new FlowException("Error while running scripts", e);
        }

    }
View Full Code Here

TOP

Related Classes of it.geosolutions.geobatch.unredd.script.exception.FlowException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.