V1_0.java [src/java/m/cfa/regionalfdc] Revision: fae2c38c5ab71042ad506de8b970cded23828934  Date: Tue Nov 20 11:38:25 MST 2018
package m.cfa.regionalfdc;

import csip.ModelDataService;
import csip.annotations.Description;
import csip.annotations.Name;
import csip.annotations.VersionInfo;
import java.io.File;
import javax.ws.rs.Path;

@Name("regionalfdc")
@Description("Time Series: Regional Flow Duration Curve Calculation")
@VersionInfo("1.0")
@Path("m/cfa/regionalfdc/1.0")
public class V1_0 extends ModelDataService {

    guiRegionalFDC_Model model = new guiRegionalFDC_Model();

    @Override
    protected void doProcess() throws Exception {
        model.setDirectory(getWorkspaceDir().toString());
        model.setDatabases(getStringParam("databases"));
        model.setStationIds(getStringParam("station_ids"));
        model.setStationNames(getStringParam("station_names"));
        model.setNormalizingMetricName(getStringParam("normalizing_metric_name"));
        model.setNormalizingMetrics(getStringParam("normalizing_metrics"));
        model.setFlowDurationCurves(getStringParam("flow_duration_curves"));
        
        model.run();
    }
    
    @Override
    protected void postProcess() throws Exception {
        // files
        File wd = getWorkspaceDir();
        putResult(new File(wd, model.getGraph()),
                  model.getRegionalFDC_results(),
                  //Below are the result graph files for use by JHighCharts on eRAMS for duplicating the above graphs
                  model.getRegionalFDCgraphOutput());

        // values
        putResult("summary_table", model.getSummaryTable());
        putResult("regional_flow_duration_curve", model.getRegionalFDC());
        putResult("units", model.getUnits());
        putResult("graph", model.getGraph());
        putResult("result_file", model.getRegionalFDC_results().getName());
        
        //Get result files for JSHighCharts
        String graphDataFiles = model.getRegionalFDCgraphOutput().getName();
        putResult("graph_data_files", graphDataFiles);
    }
}