RegionalFlowDurationCurve_V1_0.java [src/java/m/cfa] Revision: 8a14a1f39c57cef453909e98f684e27c55143917 Date: Tue Oct 28 12:06:29 MDT 2014
package m.cfa;
import cfa.guiRegionalFDC_Model;
import csip.AbstractModelService;
import java.util.Map;
import java.util.concurrent.Callable;
import javax.ws.rs.Path;
import oms3.annotations.Description;
import oms3.annotations.Name;
import oms3.annotations.VersionInfo;
import org.codehaus.jettison.json.*;
import csip.utils.JSONUtils;
import csip.utils.Services;
import java.io.File;
@Name("regionalfdc")
@Description("regionalfdc")
@VersionInfo("1.0")
@Path("m/cfa/regionalfdc/1.0")
public class RegionalFlowDurationCurve_V1_0 extends AbstractModelService {
guiRegionalFDC_Model model = new guiRegionalFDC_Model();
@Override
protected Callable<String> createCallable() throws Exception {
return new Callable<String>() {
@Override
public String call() throws Exception {
Map<String, JSONObject> m = getParamMap();
model.setMainFolder(getWorkspaceDir().toString());
model.setDatabase(m.get("databases").getString(VALUE));
model.setStationID(m.get("station_ids").getString(VALUE));
model.setStationName(m.get("station_names").getString(VALUE));
model.setNormalizingMetricName(m.get("normalizing_metric_name").getString(VALUE));
model.setNormalizingMetrics(m.get("normalizing_metrics").getString(VALUE));
model.setFlowDurationCurves(m.get("flow_duration_curves").getString(VALUE));
model.run();
return EXEC_OK;
}
};
}
@Override
public File[] postprocess() throws Exception {
return Services.toFiles(model.getGraph(),
//Below are the result graph files for use by JHighCharts on eRAMS for duplicating the above graphs
model.getRegionalFDCgraphOutput().getName());
}
@Override
protected JSONArray createResults() throws Exception {
JSONArray result = new JSONArray();
result.put(JSONUtils.data("summary_table", model.getSummaryTable()));
result.put(JSONUtils.data("regional_flow_duration_curve", model.getRegionalFDC()));
result.put(JSONUtils.data("units", model.getUnits()));
result.put(JSONUtils.data("graph", model.getGraph()));
//Get result files for JSHighCharts
String graphDataFiles = model.getRegionalFDCgraphOutput().getName();
result.put(JSONUtils.data("graph_data_files", graphDataFiles));
return result;
}
}