@@ -9,7 +9,7 @@ |
import oms3.annotations.VersionInfo; |
import org.codehaus.jettison.json.*; |
import csip.utils.JSONUtils; |
-import csip.AbstractModelService; |
+import csip.ModelDataService; |
import csip.utils.Services; |
import java.io.File; |
|
@@ -17,181 +17,172 @@ |
@Description("timeseries") |
@VersionInfo("1.0") |
@Path("m/cfa/timeseries/1.0") |
-public class Timeseries_V1_0 extends AbstractModelService { |
+public class Timeseries_V1_0 extends ModelDataService { |
|
guiTimeseries_Model model = new guiTimeseries_Model(); |
|
@Override |
- protected Callable<String> createCallable() throws Exception { |
- return new Callable<String>() { |
- @Override |
- public String call() throws Exception { |
- Map<String, JSONObject> m = getParamMap(); |
+ protected String process() throws Exception { |
+ model.setMainFolder(getWorkspaceDir().toString()); |
+ model.setDatabase(getStringParam("database")); |
+ model.setOrganizationName(getStringParam("org")); |
+ model.setStationID(getStringParam("station_id")); |
+ model.setStationName(getStringParam("station_name")); |
+ model.setWQtest(getStringParam("wq_test")); |
+ model.setBeginDate(getStringParam("begin_date")); |
+ model.setEndDate(getStringParam("end_date")); |
+ model.setTimeStep(getStringParam("time_step")); |
+ model.setMethod(getStringParam("method")); |
+ model.setNumberOfBins(getIntParam("numBins")); |
+ model.setLogarithmicHistogramBins(getBooleanParam("logarithmicTF")); |
+ model.setSeasonBegin(getStringParam("season_begin")); |
+ model.setSeasonEnd(getStringParam("season_end")); |
+ model.setPeriod1Begin(getStringParam("period1_begin")); |
+ model.setPeriod1End(getStringParam("period1_end")); |
+ model.setPeriod2Begin(getStringParam("period2_begin")); |
+ model.setPeriod2End(getStringParam("period2_end")); |
+ model.setPeriod3Begin(getStringParam("period3_begin")); |
+ model.setPeriod3End(getStringParam("period3_end")); |
+ model.setMedianTF(getBooleanParam("medianTF")); |
+ model.setHighPercentile(getDoubleParam("highPercentile")); |
+ model.setLowPercentile(getDoubleParam("lowPercentile")); |
+ model.setShowMonthlyStatsTF(getBooleanParam("showMonthlyStatsTF")); |
+ model.setCalcFlowStatisticsFileTF(getBooleanParam("calcFlowStatisticsFileTF")); |
+ model.setCalcCDPHElowflowTF(getBooleanParam("calcCDPHElowflowTF")); |
+ model.setCDPHE_lowFlowType(getStringParam("CDPHE_lowFlowType")); |
+ model.setCDPHE_m(getIntParam("CDPHE_m")); |
+ model.setCDPHE_R(getIntParam("CDPHE_R")); |
+ model.setCDPHE_waterYearBegin(getStringParam("CDPHE_waterYearBegin")); |
+ model.setCDPHE_clusterLength(getIntParam("CDPHE_clusterLength")); |
+ model.setCDPHE_clusterCountMax(getIntParam("CDPHE_clusterCountMax")); |
+ model.setUseSTORETretrieval(getBooleanParam("useSTORETretrieval")); |
+ model.setSTORETdata(getStringParam("STORETdata")); |
+ model.setMergeDatasets(getBooleanParam("merge_datasets")); |
+ model.setMergeMethod(getStringParam("merge_method")); |
+ model.setUserData(getStringParam("user_data")); |
|
- model.setMainFolder(getWorkspaceDir().toString()); |
- model.setDatabase(m.get("database").getString(VALUE)); |
- model.setOrganizationName(m.get("org").getString(VALUE)); |
- model.setStationID(m.get("station_id").getString(VALUE)); |
- model.setStationName(m.get("station_name").getString(VALUE)); |
- model.setWQtest(m.get("wq_test").getString(VALUE)); |
- model.setBeginDate(m.get("begin_date").getString(VALUE)); |
- model.setEndDate(m.get("end_date").getString(VALUE)); |
- model.setTimeStep(m.get("time_step").getString(VALUE)); |
- model.setMethod(m.get("method").getString(VALUE)); |
- model.setNumberOfBins(m.get("numBins").getInt(VALUE)); |
- model.setLogarithmicHistogramBins(m.get("logarithmicTF").getBoolean(VALUE)); |
- model.setSeasonBegin(m.get("season_begin").getString(VALUE)); |
- model.setSeasonEnd(m.get("season_end").getString(VALUE)); |
- model.setPeriod1Begin(m.get("period1_begin").getString(VALUE)); |
- model.setPeriod1End(m.get("period1_end").getString(VALUE)); |
- model.setPeriod2Begin(m.get("period2_begin").getString(VALUE)); |
- model.setPeriod2End(m.get("period2_end").getString(VALUE)); |
- model.setPeriod3Begin(m.get("period3_begin").getString(VALUE)); |
- model.setPeriod3End(m.get("period3_end").getString(VALUE)); |
- model.setMedianTF(m.get("medianTF").getBoolean(VALUE)); |
- model.setHighPercentile(m.get("highPercentile").getDouble(VALUE)); |
- model.setLowPercentile(m.get("lowPercentile").getDouble(VALUE)); |
- model.setShowMonthlyStatsTF(m.get("showMonthlyStatsTF").getBoolean(VALUE)); |
- model.setCalcFlowStatisticsFileTF(m.get("calcFlowStatisticsFileTF").getBoolean(VALUE)); |
- model.setCalcCDPHElowflowTF(m.get("calcCDPHElowflowTF").getBoolean(VALUE)); |
- model.setCDPHE_lowFlowType(m.get("CDPHE_lowFlowType").getString(VALUE)); |
- model.setCDPHE_m(m.get("CDPHE_m").getInt(VALUE)); |
- model.setCDPHE_R(m.get("CDPHE_R").getInt(VALUE)); |
- model.setCDPHE_waterYearBegin(m.get("CDPHE_waterYearBegin").getString(VALUE)); |
- model.setCDPHE_clusterLength(m.get("CDPHE_clusterLength").getInt(VALUE)); |
- model.setCDPHE_clusterCountMax(m.get("CDPHE_clusterCountMax").getInt(VALUE)); |
- model.setUseSTORETretrieval(m.get("useSTORETretrieval").getBoolean(VALUE)); |
- model.setSTORETdata(m.get("STORETdata").getString(VALUE)); |
- model.setMergeDatasets(m.get("merge_datasets").getBoolean(VALUE)); |
- model.setMergeMethod(m.get("merge_method").getString(VALUE)); |
- model.setUserData(m.get("user_data").getString(VALUE)); |
- |
- model.run(); |
- return EXEC_OK; |
- } |
- }; |
+ model.run(); |
+ return EXEC_OK; |
} |
|
@Override |
- public File[] postprocess() throws Exception { |
+ protected void postProcess() throws Exception { |
+ // files |
if(model.getCalcFlowStatisticsFileTF()){ |
- return Services.toFiles(model.getGraph(), |
- model.getBoxplot(), |
- model.getHistogram(), |
- model.getMonthlyGraph(), |
- //model.getTimeseriesEnvelope(), |
- model.getCDF(), |
- model.getFlowStatistics_summary().getName(), |
- //Below are the result graph files for use by JHighCharts on eRAMS for duplicating the above graphs |
- model.getTimeseriesOutput().getName(), |
- model.getBoxplotOutput().getName(), |
- model.getMonthlyTimeseriesOutput().getName(), |
- //model.getMonthlyBoxplotOutput().getName(), |
- //model.getTimeseriesEnvelopeOutput().getName(), |
- model.getHistogramOutput().getName(), |
- model.getCDFoutput().getName()); |
+ putResult(new File(model.getGraph()), |
+ new File(model.getBoxplot()), |
+ new File(model.getHistogram()), |
+ new File(model.getMonthlyGraph()), |
+ //new File(model.getTimeseriesEnvelope()), |
+ new File(model.getCDF()), |
+ model.getFlowStatistics_summary(), |
+ //Below are the result graph files for use by JHighCharts on eRAMS for duplicating the above graphs |
+ model.getTimeseriesOutput(), |
+ model.getBoxplotOutput(), |
+ model.getMonthlyTimeseriesOutput(), |
+ //model.getMonthlyBoxplotOutput(), |
+ //model.getTimeseriesEnvelopeOutput(), |
+ model.getHistogramOutput(), |
+ model.getCDFoutput()); |
}else{ |
- return Services.toFiles(model.getGraph(), |
- model.getBoxplot(), |
- model.getHistogram(), |
- model.getMonthlyGraph(), |
- //model.getTimeseriesEnvelope(), |
- model.getCDF(), |
- //Below are the result graph files for use by JHighCharts on eRAMS for duplicating the above graphs |
- model.getTimeseriesOutput().getName(), |
- model.getBoxplotOutput().getName(), |
- model.getMonthlyTimeseriesOutput().getName(), |
- //model.getMonthlyBoxplotOutput().getName(), |
- //model.getTimeseriesEnvelopeOutput().getName(), |
- model.getHistogramOutput().getName(), |
- model.getCDFoutput().getName()); |
+ putResult(new File(model.getGraph()), |
+ new File(model.getBoxplot()), |
+ new File(model.getHistogram()), |
+ new File(model.getMonthlyGraph()), |
+ //new File(model.getTimeseriesEnvelope()), |
+ new File(model.getCDF()), |
+ //Below are the result graph files for use by JHighCharts on eRAMS for duplicating the above graphs |
+ model.getTimeseriesOutput(), |
+ model.getBoxplotOutput(), |
+ model.getMonthlyTimeseriesOutput(), |
+ //model.getMonthlyBoxplotOutput(), |
+ //model.getTimeseriesEnvelopeOutput(), |
+ model.getHistogramOutput(), |
+ model.getCDFoutput()); |
} |
- } |
- |
- @Override |
- protected JSONArray createResults() throws Exception { |
- JSONArray result = new JSONArray(); |
- result.put(JSONUtils.data("len", model.getLen())); |
- result.put(JSONUtils.data("start", model.getStart())); |
- result.put(JSONUtils.data("end", model.getEnd())); |
- result.put(JSONUtils.data("units", model.getUnits())); |
- result.put(JSONUtils.data("data_source", model.getDataSource())); |
+ |
+ // values |
+ putResult("len", model.getLen()); |
+ putResult("start", model.getStart()); |
+ putResult("end", model.getEnd()); |
+ putResult("units", model.getUnits()); |
+ putResult("data_source", model.getDataSource()); |
//Get CDPHE low flow results |
- result.put(JSONUtils.data("cdphe_extremeValueDFLOW", model.getCDPHE_ExtremeValueDFLOW())); |
- result.put(JSONUtils.data("cdphe_biologicalDFLOW_all", model.getCDPHE_BiologicalDFLOW_all())); |
- result.put(JSONUtils.data("cdphe_biologicalDFLOW_jan", model.getCDPHE_BiologicalDFLOW_jan())); |
- result.put(JSONUtils.data("cdphe_biologicalDFLOW_feb", model.getCDPHE_BiologicalDFLOW_feb())); |
- result.put(JSONUtils.data("cdphe_biologicalDFLOW_mar", model.getCDPHE_BiologicalDFLOW_mar())); |
- result.put(JSONUtils.data("cdphe_biologicalDFLOW_apr", model.getCDPHE_BiologicalDFLOW_apr())); |
- result.put(JSONUtils.data("cdphe_biologicalDFLOW_may", model.getCDPHE_BiologicalDFLOW_may())); |
- result.put(JSONUtils.data("cdphe_biologicalDFLOW_jun", model.getCDPHE_BiologicalDFLOW_jun())); |
- result.put(JSONUtils.data("cdphe_biologicalDFLOW_jul", model.getCDPHE_BiologicalDFLOW_jul())); |
- result.put(JSONUtils.data("cdphe_biologicalDFLOW_aug", model.getCDPHE_BiologicalDFLOW_aug())); |
- result.put(JSONUtils.data("cdphe_biologicalDFLOW_sep", model.getCDPHE_BiologicalDFLOW_sep())); |
- result.put(JSONUtils.data("cdphe_biologicalDFLOW_oct", model.getCDPHE_BiologicalDFLOW_oct())); |
- result.put(JSONUtils.data("cdphe_biologicalDFLOW_nov", model.getCDPHE_BiologicalDFLOW_nov())); |
- result.put(JSONUtils.data("cdphe_biologicalDFLOW_dec", model.getCDPHE_BiologicalDFLOW_dec())); |
- result.put(JSONUtils.data("cdphe_humanHealthDFLOW", model.getCDPHE_HumanHealthDFLOW())); |
- result.put(JSONUtils.data("cdphe_reg31DFLOWsummary", model.getCDPHE_Reg31DFLOWsummary())); |
+ putResult("cdphe_extremeValueDFLOW", model.getCDPHE_ExtremeValueDFLOW()); |
+ putResult("cdphe_biologicalDFLOW_all", model.getCDPHE_BiologicalDFLOW_all()); |
+ putResult("cdphe_biologicalDFLOW_jan", model.getCDPHE_BiologicalDFLOW_jan()); |
+ putResult("cdphe_biologicalDFLOW_feb", model.getCDPHE_BiologicalDFLOW_feb()); |
+ putResult("cdphe_biologicalDFLOW_mar", model.getCDPHE_BiologicalDFLOW_mar()); |
+ putResult("cdphe_biologicalDFLOW_apr", model.getCDPHE_BiologicalDFLOW_apr()); |
+ putResult("cdphe_biologicalDFLOW_may", model.getCDPHE_BiologicalDFLOW_may()); |
+ putResult("cdphe_biologicalDFLOW_jun", model.getCDPHE_BiologicalDFLOW_jun()); |
+ putResult("cdphe_biologicalDFLOW_jul", model.getCDPHE_BiologicalDFLOW_jul()); |
+ putResult("cdphe_biologicalDFLOW_aug", model.getCDPHE_BiologicalDFLOW_aug()); |
+ putResult("cdphe_biologicalDFLOW_sep", model.getCDPHE_BiologicalDFLOW_sep()); |
+ putResult("cdphe_biologicalDFLOW_oct", model.getCDPHE_BiologicalDFLOW_oct()); |
+ putResult("cdphe_biologicalDFLOW_nov", model.getCDPHE_BiologicalDFLOW_nov()); |
+ putResult("cdphe_biologicalDFLOW_dec", model.getCDPHE_BiologicalDFLOW_dec()); |
+ putResult("cdphe_humanHealthDFLOW", model.getCDPHE_HumanHealthDFLOW()); |
+ putResult("cdphe_reg31DFLOWsummary", model.getCDPHE_Reg31DFLOWsummary()); |
//Get all data results |
- result.put(JSONUtils.data("max", model.getMax())); |
- result.put(JSONUtils.data("min", model.getMin())); |
- result.put(JSONUtils.data("upperQuartile", model.getUpperQuartile())); |
- result.put(JSONUtils.data("lowerQuartile", model.getLowerQuartile())); |
- result.put(JSONUtils.data("median", model.getMedian())); |
- result.put(JSONUtils.data("mean", model.getMean())); |
- result.put(JSONUtils.data("standardDeviation", model.getStandardDeviation())); |
- result.put(JSONUtils.data("variance", model.getVariance())); |
- result.put(JSONUtils.data("skewness", model.getSkewness())); |
- result.put(JSONUtils.data("coefficientOfVariation", model.getCoefficientOfVariation())); |
- result.put(JSONUtils.data("kendalCorrelationCoefficient", model.getKendallCorrelationCoefficient())); |
+ putResult("max", model.getMax()); |
+ putResult("min", model.getMin()); |
+ putResult("upperQuartile", model.getUpperQuartile()); |
+ putResult("lowerQuartile", model.getLowerQuartile()); |
+ putResult("median", model.getMedian()); |
+ putResult("mean", model.getMean()); |
+ putResult("standardDeviation", model.getStandardDeviation()); |
+ putResult("variance", model.getVariance()); |
+ putResult("skewness", model.getSkewness()); |
+ putResult("coefficientOfVariation", model.getCoefficientOfVariation()); |
+ putResult("kendalCorrelationCoefficient", model.getKendallCorrelationCoefficient()); |
//Get Period 1 results |
- result.put(JSONUtils.data("len_period1", model.getLen_period1())); |
- result.put(JSONUtils.data("max_period1", model.getMax_period1())); |
- result.put(JSONUtils.data("min_period1", model.getMin_period1())); |
- result.put(JSONUtils.data("upperQuartile_period1", model.getUpperQuartile_period1())); |
- result.put(JSONUtils.data("lowerQuartile_period1", model.getLowerQuartile_period1())); |
- result.put(JSONUtils.data("median_period1", model.getMedian_period1())); |
- result.put(JSONUtils.data("mean_period1", model.getMean_period1())); |
- result.put(JSONUtils.data("standardDeviation_period1", model.getStandardDeviation_period1())); |
- result.put(JSONUtils.data("variance_period1", model.getVariance_period1())); |
- result.put(JSONUtils.data("skewness_period1", model.getSkewness_period1())); |
- result.put(JSONUtils.data("coefficientOfVariation_period1", model.getCoefficientOfVariation_period1())); |
- result.put(JSONUtils.data("kendalCorrelationCoefficient_period1", model.getKendallCorrelationCoefficient_period1())); |
+ putResult("len_period1", model.getLen_period1()); |
+ putResult("max_period1", model.getMax_period1()); |
+ putResult("min_period1", model.getMin_period1()); |
+ putResult("upperQuartile_period1", model.getUpperQuartile_period1()); |
+ putResult("lowerQuartile_period1", model.getLowerQuartile_period1()); |
+ putResult("median_period1", model.getMedian_period1()); |
+ putResult("mean_period1", model.getMean_period1()); |
+ putResult("standardDeviation_period1", model.getStandardDeviation_period1()); |
+ putResult("variance_period1", model.getVariance_period1()); |
+ putResult("skewness_period1", model.getSkewness_period1()); |
+ putResult("coefficientOfVariation_period1", model.getCoefficientOfVariation_period1()); |
+ putResult("kendalCorrelationCoefficient_period1", model.getKendallCorrelationCoefficient_period1()); |
//Get Period 2 results |
- result.put(JSONUtils.data("len_period2", model.getLen_period2())); |
- result.put(JSONUtils.data("max_period2", model.getMax_period2())); |
- result.put(JSONUtils.data("min_period2", model.getMin_period2())); |
- result.put(JSONUtils.data("upperQuartile_period2", model.getUpperQuartile_period2())); |
- result.put(JSONUtils.data("lowerQuartile_period2", model.getLowerQuartile_period2())); |
- result.put(JSONUtils.data("median_period2", model.getMedian_period2())); |
- result.put(JSONUtils.data("mean_period2", model.getMean_period2())); |
- result.put(JSONUtils.data("standardDeviation_period2", model.getStandardDeviation_period2())); |
- result.put(JSONUtils.data("variance_period2", model.getVariance_period2())); |
- result.put(JSONUtils.data("skewness_period2", model.getSkewness_period2())); |
- result.put(JSONUtils.data("coefficientOfVariation_period2", model.getCoefficientOfVariation_period2())); |
- result.put(JSONUtils.data("kendalCorrelationCoefficient_period2", model.getKendallCorrelationCoefficient_period2())); |
+ putResult("len_period2", model.getLen_period2()); |
+ putResult("max_period2", model.getMax_period2()); |
+ putResult("min_period2", model.getMin_period2()); |
+ putResult("upperQuartile_period2", model.getUpperQuartile_period2()); |
+ putResult("lowerQuartile_period2", model.getLowerQuartile_period2()); |
+ putResult("median_period2", model.getMedian_period2()); |
+ putResult("mean_period2", model.getMean_period2()); |
+ putResult("standardDeviation_period2", model.getStandardDeviation_period2()); |
+ putResult("variance_period2", model.getVariance_period2()); |
+ putResult("skewness_period2", model.getSkewness_period2()); |
+ putResult("coefficientOfVariation_period2", model.getCoefficientOfVariation_period2()); |
+ putResult("kendalCorrelationCoefficient_period2", model.getKendallCorrelationCoefficient_period2()); |
//Get Period 3 results |
- result.put(JSONUtils.data("len_period3", model.getLen_period3())); |
- result.put(JSONUtils.data("max_period3", model.getMax_period3())); |
- result.put(JSONUtils.data("min_period3", model.getMin_period3())); |
- result.put(JSONUtils.data("upperQuartile_period3", model.getUpperQuartile_period3())); |
- result.put(JSONUtils.data("lowerQuartile_period3", model.getLowerQuartile_period3())); |
- result.put(JSONUtils.data("median_period3", model.getMedian_period3())); |
- result.put(JSONUtils.data("mean_period3", model.getMean_period3())); |
- result.put(JSONUtils.data("standardDeviation_period3", model.getStandardDeviation_period3())); |
- result.put(JSONUtils.data("variance_period3", model.getVariance_period3())); |
- result.put(JSONUtils.data("skewness_period3", model.getSkewness_period3())); |
- result.put(JSONUtils.data("coefficientOfVariation_period3", model.getCoefficientOfVariation_period3())); |
- result.put(JSONUtils.data("kendalCorrelationCoefficient_period3", model.getKendallCorrelationCoefficient_period3())); |
+ putResult("len_period3", model.getLen_period3()); |
+ putResult("max_period3", model.getMax_period3()); |
+ putResult("min_period3", model.getMin_period3()); |
+ putResult("upperQuartile_period3", model.getUpperQuartile_period3()); |
+ putResult("lowerQuartile_period3", model.getLowerQuartile_period3()); |
+ putResult("median_period3", model.getMedian_period3()); |
+ putResult("mean_period3", model.getMean_period3()); |
+ putResult("standardDeviation_period3", model.getStandardDeviation_period3()); |
+ putResult("variance_period3", model.getVariance_period3()); |
+ putResult("skewness_period3", model.getSkewness_period3()); |
+ putResult("coefficientOfVariation_period3", model.getCoefficientOfVariation_period3()); |
+ putResult("kendalCorrelationCoefficient_period3", model.getKendallCorrelationCoefficient_period3()); |
//Get other results |
- result.put(JSONUtils.data("flow_statistics_summary",model.getFlowStatistics_summary().getName())); |
- result.put(JSONUtils.data("graph", model.getGraph())); |
- result.put(JSONUtils.data("boxplot", model.getBoxplot())); |
- result.put(JSONUtils.data("histogram", model.getHistogram())); |
- result.put(JSONUtils.data("cdf_graph", model.getCDF())); |
- result.put(JSONUtils.data("monthlyAverage_graph", model.getMonthlyGraph())); |
- //result.put(JSONUtils.data("timeseries_envelope_graph", model.getTimeseriesEnvelope())); |
+ putResult("flow_statistics_summary",model.getFlowStatistics_summary().getName()); |
+ putResult("graph", model.getGraph()); |
+ putResult("boxplot", model.getBoxplot()); |
+ putResult("histogram", model.getHistogram()); |
+ putResult("cdf_graph", model.getCDF()); |
+ putResult("monthlyAverage_graph", model.getMonthlyGraph()); |
+ //putResult("timeseries_envelope_graph", model.getTimeseriesEnvelope()); |
|
//Get result files for JSHighCharts |
String graphDataFiles = model.getTimeseriesOutput().getName() + "|" + |
@@ -201,7 +192,6 @@ |
//model.getTimeseriesEnvelopeOutput().getName() + "|" + |
model.getHistogramOutput().getName() + "|" + |
model.getCDFoutput().getName(); |
- result.put(JSONUtils.data("graph_data_files", graphDataFiles)); |
- return result; |
+ putResult("graph_data_files", graphDataFiles); |
} |
} |