ToPRMS_V1.java [src/java/m/prms/conv] Revision: default Date:
package m.prms.conv;
import csip.ModelDataService;
import csip.api.server.ServiceException;
import csip.annotations.*;
import java.io.File;
import javax.ws.rs.Path;
import m.prms.model.Utils;
/**
* PRMS/OMS Resource conversion.
*
* @author od
*/
@Name("PRMS")
@Description("Parameter Converter OMS -> MMS")
@State(State.UNSTABLE)
@Author(org = "USGS")
@Author(org = "CSU")
@Category("Hydrology")
@Path("m/oms_to_mms/params/convert/1.0")
public class ToPRMS_V1 extends ModelDataService {
static final String FILE = "file";
@Override
protected void doProcess() throws Exception {
File f = formdata().getFile(FILE);
String name = f.getName();
if (name.endsWith(".csv")) {
File result = Utils.convertToPRMSParam(f);
results().put(result);
} else {
throw new ServiceException("Error: cannot convert: " + f);
}
}
// public static void main(String[] args) throws IOException, ParseException {
//
// String b = "/od/oms/oms_examples/oms3.prj.prms/data/mixed_params.csv";
// String b1 = "/tmp/mixed_params.param";
//
// CSProperties p = readParameter(new File(b));
// writeParamFile(p, new File(b1));
// }
}