V1_0.java [src/java/m/cfa/flood] Revision: 742c042a43087670f1ec0196652cc79475404051  Date: Fri Feb 12 09:14:51 MST 2016
package m.cfa.flood;

import csip.ModelDataService;
import java.io.File;
import javax.ws.rs.Path;
import oms3.annotations.Description;
import oms3.annotations.Name;
import oms3.annotations.VersionInfo;
import org.apache.commons.io.FileUtils;

@Name("flood")
@Description("flood")
@VersionInfo("1.0")
@Path("m/cfa/flood/1.0")
public class V1_0 extends ModelDataService {

    guiFlood_Model model = new guiFlood_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.setAnalysisType(getStringParam("analysis_type"));
        model.setBeginDate(getStringParam("begin_date"));
        model.setEndDate(getStringParam("end_date"));
        model.setSkewness(getDoubleParam("skewness"));
        model.setMeanSquareError(getDoubleParam("mean_square_error"));
        model.setShowLargeFloods(getBooleanParam("show_large_floods"));
        model.setPlotType(getBooleanParam("plot_type"));
        model.setPlotReference(getBooleanParam("plot_ref"));
        model.setUseSTORETretrieval(getBooleanParam("useSTORETretrieval"));
        model.setSTORETdata(getStringParam("STORETdata"));
        model.setMergeDatasets(getBooleanParam("merge_datasets"));
        model.setMergeMethod(getStringParam("merge_method"));
        model.setUserData(getStringParam("user_data"));

        model.run();
        return EXEC_OK;
    }

    @Override
    protected void postProcess() throws Exception {
        // files
        File wd = getWorkspaceDir();
        putResult(new File(wd, model.getGraph()));

        // values
        putResult("len", model.getLen());
        putResult("start", model.getStart());
        putResult("end", model.getEnd());
        putResult("data_source", model.getDataSource());
        String output = FileUtils.readFileToString(model.getOutput());
        putResult("output", output);
        putResult("graph", model.getGraph());
    }
}