V1_0.java [src/java/m/cfa/durationcurve] Revision: ac969879044982a67abe2cc46e4699c8120d6e7b Date: Fri Feb 12 14:13:23 MST 2016
package m.cfa.durationcurve;
import csip.ModelDataService;
import csip.annotations.Resource;
import static csip.annotations.ResourceType.FILE;
import java.io.File;
import javax.ws.rs.Path;
import oms3.annotations.Description;
import oms3.annotations.Name;
import oms3.annotations.VersionInfo;
@Name("durationcurve")
@Description("durationcurve")
@VersionInfo("1.0")
@Path("m/cfa/durationcurve/1.0")
@Resource(file = "/python/driver.py", type = FILE, id = "driver")
public class V1_0 extends ModelDataService {
guiDC_Model model = new guiDC_Model();
@Override
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.setWaterQualityTest(getStringParam("wq_test"));
model.setWaterQualityTarget(getDoubleParam("wq_target"));
model.setBeginDate(getStringParam("begin_date"));
model.setEndDate(getStringParam("end_date"));
model.setSeasonBegin(getStringParam("season_begin"));
model.setSeasonEnd(getStringParam("season_end"));
model.setSeasonalAnalysisOnlyTF(getBooleanParam("seasonal_only"));
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.setHighPercentile(getDoubleParam("highPercentile"));
model.setLowPercentile(getDoubleParam("lowPercentile"));
model.setShowMonthlyStatsTF(getBooleanParam("showMonthlyStatsTF"));
model.setCalcFlowStatisticsFileTF(getBooleanParam("calcFlowStatisticsFileTF"));
model.setMQNperiod(getStringParam("mqn_period"));
model.setUseSTORETretrieval(getBooleanParam("useSTORETretrieval"));
model.setSTORETdata(getStringParam("STORETdata"));
model.setMergeDatasets(getBooleanParam("merge_datasets"));
model.setMergeMethod(getStringParam("merge_method"));
model.setUserData(getStringParam("user_data"));
File f = getResourceFile("driver");
model.run(f);
return EXEC_OK;
}
@Override
protected void postProcess() throws Exception {
// files
File wd = getWorkspaceDir();
if(model.getCalcFlowStatisticsFileTF()){
putResult(new File(wd, model.getGraph()),
model.getDurationCurve_results(),
model.getFlowStatistics_summary(),
//Below are the result graph files for use by JHighCharts on eRAMS for duplicating the above graphs
model.getDCgraphOutput());
}else{
putResult(new File(wd, model.getGraph()),
model.getDurationCurve_results(),
//Below are the result graph files for use by JHighCharts on eRAMS for duplicating the above graphs
model.getDCgraphOutput());
}
// values
putResult("flow_len", model.getFlowLen());
putResult("flow_median", model.getMedian(), null, "cfs");
putResult("flow_mean", model.getMean(), null, "cfs");
putResult("flow_len_period1", model.getFlowLen_period1());
putResult("flow_len_period2", model.getFlowLen_period2());
putResult("flow_len_period3", model.getFlowLen_period3());
putResult("wq_len", model.getWQLen());
putResult("wq_units", model.getWQUnits());
putResult("start", model.getStart());
putResult("end", model.getEnd());
putResult("duration_curve_summary", model.getSummaryParagraph());
putResult("duration_curve_table", model.getSummaryTable());
putResult("data_source", model.getDataSource());
putResult("mqn_val", model.getMQNval(), null, "cfs");
putResult("low_flow_error_message", model.getLowFlowErrorMessage());
putResult("graph", model.getGraph());
putResult("result_file", model.getDurationCurve_results().getName());
putResult("flow_statistics_summary",model.getFlowStatistics_summary().getName());
//Get result files for JSHighCharts
String graphDataFiles = model.getDCgraphOutput().getName();
putResult("graph_data_files", graphDataFiles);
}
}