Displaying differences for changeset
 
display as  

src/java/m/sci/V1_3.java

@@ -20,10 +20,6 @@
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import csip.ModelDataService;
-import static csip.ModelDataService.KEY_METAINFO;
-import static csip.ModelDataService.KEY_MODE;
-import static csip.ModelDataService.KEY_REQUEST_RESULTS;
-import static csip.ModelDataService.SYNC;
 import static util.ErosionConst.CONV_KGM2_TONACRE;
 import static util.ErosionConst.KEY_LENGTH;
 import static util.ErosionConst.KEY_MGMTS;
@@ -105,7 +101,6 @@
                 double r2sci_fo = 0.0;
                 double r2sci_er = 0.0;
 
-                JSONObject syncRequest = JSONUtils.clone(getRequest());
                 File[] dummy = new File[0]; // the client function should check for null array.
                 if (JSONUtils.checkKeyExistsB(getParamMap(), KEY_LENGTH)
                         && JSONUtils.checkKeyExistsB(getParamMap(), KEY_STEEPNESS)) {
@@ -118,18 +113,14 @@
                     req_results.put(RES_SLOPE_DELIVERY);
                     req_results.put(RES_SLOPE_T_VALUE);
                     req_results.put(RES_SLOPE_DEGRAD);
-                    
-                    
-                    syncRequest.getJSONObject(KEY_METAINFO).put(KEY_MODE, SYNC);
-                    syncRequest.getJSONObject(KEY_METAINFO).put(KEY_REQUEST_RESULTS, req_results);
+                    getRequest().getJSONObject(KEY_METAINFO).put(KEY_REQUEST_RESULTS, req_results);
+                    getRequest().getJSONObject(KEY_METAINFO).put(KEY_MODE, SYNC);
                     //LOG.info("This is the request =) : "+getRequest().toString());
                     //String url = Config.getString("codebase.url", "bad")+"/csip-erosion/m/rusle2/1.2";
                     //LOG.info(url);
                     LOG.info("STARTING RUSLE2");
-                    LOG.info("R2 Request" + syncRequest);
                     //JSONObject r2Response = new Client(LOG).doPOST("http://localhost:8080/csip-erosion/m/rusle2/1.2", getRequest(), dummy);
-                    JSONObject r2Response = new Client(LOG).doPOST("http://localhost:8080/csip-erosion/m/rusle2/1.3", syncRequest);
-                    LOG.info("R2 Response "+ syncRequest);
+                    JSONObject r2Response = new Client(LOG).doPOST("http://localhost:8080/csip-erosion/m/rusle2/1.3", getRequest());
 
                     Map<String, JSONObject> r2Results = JSONUtils.preprocess(r2Response.getJSONArray(KEY_RESULT));
 
@@ -157,20 +148,20 @@
 
                     LOG.info("The soil is: " + wepsSoil.toString());
                     //getParamMap().put(WEPS_KEY_SOIL, wepsSoil);
-                    syncRequest.getJSONArray(KEY_PARAMETER).put(wepsSoil);
+                    getRequest().getJSONArray(KEY_PARAMETER).put(wepsSoil);
                 }
                 if (!JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_MANAGEMENT)) {
 
                     JSONObject lmodweps = (JSONObject) JSONUtils.getJSONArrayParam(getParamMap(), KEY_MGMTS).get(0);
                     JSONObject lmodwepsobj = JSONUtils.data(WEPS_KEY_MANAGEMENT, lmodweps);
                     //getParamMap().put(WEPS_KEY_MANAGEMENT, lmodwepsobj);
-                    syncRequest.getJSONArray(KEY_PARAMETER).put(lmodwepsobj);
+                    getRequest().getJSONArray(KEY_PARAMETER).put(lmodwepsobj);
                 }
 
                 LOG.info("Trying to invoke WEPS for SCI");
 
                 //JSONObject wepsResponse = new Client(LOG).doPOST("http://localhost:8080/csip-erosion/m/weps/1.2", getRequest(), dummy);
-                JSONObject wepsResponse = new Client(LOG).doPOST("http://localhost:8080/csip-erosion/m/weps/1.3", syncRequest);
+                JSONObject wepsResponse = new Client(LOG).doPOST("http://localhost:8080/csip-erosion/m/weps/1.3", getRequest());
                 
 
                 Map<String, JSONObject> wepsResults = JSONUtils.preprocess(wepsResponse.getJSONArray(KEY_RESULT));

src/java/m/weps/V1_2.java.orig

@@ -4,9 +4,8 @@
  */
 package m.weps;
 
+import c.CSIPConfig;
 import c.PostGIS;
-import csip.Config;
-import csip.ServiceException;
 import java.io.*;
 import java.util.ArrayList;
 import java.util.Collection;
@@ -15,6 +14,7 @@
 import java.util.concurrent.Callable;
 import java.util.logging.Level;
 import javax.ws.rs.Path;
+import m.AbstractModelService;
 import man2weps.WepsTranslator;
 import man2weps.mcrew.ManageData;
 import oms3.annotations.Description;
@@ -31,18 +31,11 @@
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
-import csip.ModelDataService;
-import static csip.ModelDataService.EXEC_FAILED;
-import static csip.ModelDataService.EXEC_OK;
-import static csip.ModelDataService.KEY_METAINFO;
-import static csip.ModelDataService.KEY_PARAMETER;
-import static csip.ModelDataService.REPORT_NAME;
-import static csip.ModelDataService.REPORT_TYPE;
-import static csip.ModelDataService.REPORT_VALUE;
+import services.BinUtils;
+import static services.ServiceConst.*;
 import static util.ErosionConst.*;
-import csip.utils.Binaries;
-import csip.utils.JSONUtils;
-import static m.weps.SciEnergyParser.LOG;
+import services.JSONUtils;
+import services.ServiceException;
 import usda.weru.weps.reports.query.WepsConnection;
 import wepsreportdata.WepsReportData;
 
@@ -55,23 +48,20 @@
 @Description("WEPS")
 @VersionInfo("1.2")
 @Path("m/weps/1.2")
-public class V1_2 extends ModelDataService {
+public class V1_2 extends AbstractModelService {
 
     String sessionWorkDir = "";
     static final String SOIL_FILE_EXT = ".ifc";
-    static final String WIND_STATIONS_DIR = "windstations";
-    static final String WIND_STATION_FILE_EXT = ".wdb";
-    static final String DEFAULT_WIND_STATION_DB = "wind_gen_his_upper_US.wdb";
     static final String DUMMY_MGMT = "dummy.man";
     static final String REPORT_JSON_FILENAME = "weps_report.json";
     static final String WEPS_MGMT = "wepsmgmt.man";
-    static final int NRCS_CYCLE_COUNT = 50;
+    static final int NRCS_CYCLE_COUNT = 50;    
     public WepsOutput wo = new WepsOutput();
-
+    
     // Variables for WEPS model run
     private String soilkey = "";
     private WepsModelRun wmr = new WepsModelRun();
-    private int simulationYears = 3 * NRCS_CYCLE_COUNT;
+    private int simulationYears = 3 * NRCS_CYCLE_COUNT;    
     private JSONObject fieldGeometry = null;
     private JsonRegion field_region = null;
     private JsonRegion barrier_region = null;
@@ -81,61 +71,66 @@
     private String soilFilename = "";
     private String windDbPath = "";
     private String sWindgenStation = "";
-
+    
     @Override
     public void preprocess() throws Exception {
         JSONUtils.checkKeyExists(getParamMap(), WEPS_KEY_SOIL);
         JSONUtils.checkKeyExists(getParamMap(), WEPS_KEY_ELEVATION);
-        JSONUtils.checkKeyExists(getParamMap(), WEPS_KEY_MANAGEMENT);
-
-        if ((!JSONUtils.checkKeyExistsB(getParamMap(), WEPS_FIELD_BOUNDARY))
-                && !((JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_LATITUDE))
-                && (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_LONGITUDE))
-                && (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_FIELD_WIDTH))
-                && (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_FIELD_LENGTH)))) {
+        JSONUtils.checkKeyExists(getParamMap(), WEPS_KEY_MANAGEMENT);    
+        
+        if ((!JSONUtils.checkKeyExistsB(getParamMap(), WEPS_FIELD_BOUNDARY)) &&
+            !((JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_LATITUDE)) &&
+             (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_LONGITUDE)) &&
+             (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_FIELD_WIDTH)) &&
+             (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_FIELD_LENGTH))))
+        {
             throw new ServiceException("No WEPS Field specification available: geometry or paramters: latitude, longitude, field_width, field_length ");
         }
     }
 
     @Override
-    public Callable<String> createCallable() throws Exception {
-        return new Callable<String>() {
+    public Callable<Integer> createCallable() throws Exception {
+        return new Callable<Integer>() {
 
             // to do
             // refactor & make smaller
             @Override
-            public String call() throws Exception {
+            public Integer call() throws Exception 
+            {
                 ProcessComponent pc = new ProcessComponent();
-                try {
+                try
+                {
                     db = PostGIS.singleton();
-                } catch (Exception e) {
+                }
+                catch (Exception e)
+                {
                     LOG.severe("Error obtaining DB connection in WEPS run!");
                     throw new ServiceException("WEPS error: Cannot obtain geospatial db connection");
                 }
-
+                
                 LOG.info("The default CISP WEPS user dir is=" + System.getProperty("user.dir"));
-
-                try {
-                    File workDir = getWorkspaceDir();
-                    sessionWorkDir = workDir.toString();
-                    binDir = Config.getString("m.bin.dir", "/tmp/csip/bin");
-
+                
+                try
+                {
+                    File workDir = getWorkspace();
+                    sessionWorkDir = workDir.toString();  
+                    
                     // Unpack the dummy mgmt
-                    String dummyMgmt = Binaries.unpackResourceAbsolute("/bin/" + Binaries.getArch() + "/" + DUMMY_MGMT, sessionWorkDir + "/" + DUMMY_MGMT).toString();
-                    wmr.setMgmtFile(DUMMY_MGMT);      // the default mgmt, if none provided
-
+                    String dummyMgmt = BinUtils.unpackResourceAbsolute("/bin/" + BinUtils.getArch() + "/" + DUMMY_MGMT, sessionWorkDir + "/" + DUMMY_MGMT).toString();
+                    wmr.mgmtFile = DUMMY_MGMT;      // the default mgmt, if none provided
+                    
                     // check that required parameters exist. populate them in wmr data object
                     loadRequiredParameters();
-
+                    
                     // get the mgmt as a json obj and create a WEPS man file using Jim's parser
                     loadWepsMgmt();
-
+                    
                     // Get field geometry
                     getFieldGeometry();
-
+                    
                     // get wind barriers
                     getWindBarriers();
-
+                    
                     // Get climate info
                     getClimate();
 
@@ -146,7 +141,8 @@
                     getSoilIfc();
 
                     // run WEPS model
-                    try {
+                    try
+                    {
                         // Always generate Weps Run file from JSON parameters (it is never provided in the model srvc signature)
                         LOG.log(Level.INFO, "wepsrun file does not exist, creating it.");
                         String wepsrunFile = "weps.run";
@@ -155,7 +151,8 @@
                         // Our WEPS model call uses the following cmd line args
                         // /weps -W1 -u0 -I2 -t1 -P./ >stdout.txt 2>stderr.txt
                         pc = new ProcessComponent();
-                        pc.exe = Binaries.unpackResource("/bin/" + Binaries.getArch() + "/weps", new File(binDir)).toString();
+                        binDir = CSIPConfig.getString("m.bin.dir", "/tmp/csip/bin");
+                        pc.exe = BinUtils.unpackResource("/bin/" + BinUtils.getArch() + "/weps", new File(binDir)).toString();
                         pc.args = new String[]{"-W1", "-u0", "-I2", "-t1", "-P./"};
                         pc.working_dir = sessionWorkDir;
                         pc.execute();
@@ -164,117 +161,114 @@
                         FileUtils.write(new File(workDir, "stderr.txt"), pc.stderr);
 
                         // Generate report output
-                        String reportJSON = Binaries.unpackResourceAbsolute("/bin/" + Binaries.getArch() + "/" + REPORT_JSON_FILENAME, sessionWorkDir + "/" + REPORT_JSON_FILENAME).toString();
-                    } catch (Exception e) {
+                        String reportJSON = BinUtils.unpackResourceAbsolute("/bin/" + BinUtils.getArch() + "/" + REPORT_JSON_FILENAME, sessionWorkDir + "/" + REPORT_JSON_FILENAME).toString();
+                    }
+                    catch (Exception e)
+                    {
                         throw new ServiceException("WEPS error: error running WEPS model binary");
                     }
 
-                    return pc.exitValue == 0 ? EXEC_OK : EXEC_FAILED;
-                } catch (Exception e) {
-                    LOG.log(Level.SEVERE, "ERROR EXECUTING WEPS!!!");
-//                    LOG.log(Level.SEVERE, e.getStackTrace().toString());
-                    for (StackTraceElement ste : e.getStackTrace()) {
-                        LOG.log(Level.SEVERE, "class=" + ste.getClassName() + " method=" + ste.getMethodName() + " |" + ste.toString());
-                    }
+                    return pc.exitValue;
+                }
+                catch (Exception e)
+                {
+                    LOG.log(Level.SEVERE, e.toString());
+                    LOG.log(Level.SEVERE, e.getStackTrace().toString());
                     throw new ServiceException("WEPS error: unknown error executing WEPS model>" + e.toString());
                 }
             }
         };
     }
-
+    
     /*
      * Checks for the existence of required WEPS parameters.
      * Loads them into proper variables for running the model.
      */
-    private void loadRequiredParameters() throws ServiceException {
-        try {
-            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_SOIL)) {
+    private void loadRequiredParameters() throws ServiceException
+    {
+        try
+        {
+            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_SOIL))
                 soilkey = JSONUtils.getValue(getParamMap().get(WEPS_KEY_SOIL));
+            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_LATITUDE))
+                wmr.lat = JSONUtils.getValue(getParamMap().get(WEPS_KEY_LATITUDE));
+            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_LONGITUDE))
+                wmr.longitude = JSONUtils.getValue(getParamMap().get(WEPS_KEY_LONGITUDE));
+            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_ELEVATION))
+            {
+                double elevationInM = Double.parseDouble(JSONUtils.getValue(getParamMap().get(WEPS_KEY_ELEVATION))) * CONV_FT_TO_M;
+                wmr.elevation = String.valueOf(elevationInM);
             }
-            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_LATITUDE)) {
-                wmr.setLat(JSONUtils.getValue(getParamMap().get(WEPS_KEY_LATITUDE)));
+            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_FIELD_LENGTH))
+            {
+                double fieldLengthInM = Double.parseDouble(JSONUtils.getValue(getParamMap().get(WEPS_KEY_FIELD_LENGTH))) * CONV_FT_TO_M;
+                wmr.simYLen = String.valueOf(fieldLengthInM);
             }
-            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_LONGITUDE)) {
-                wmr.setLongitude(JSONUtils.getValue(getParamMap().get(WEPS_KEY_LONGITUDE)));
+            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_FIELD_WIDTH))
+            {
+                double fieldWidthInM = Double.parseDouble(JSONUtils.getValue(getParamMap().get(WEPS_KEY_FIELD_WIDTH))) * CONV_FT_TO_M;
+                wmr.simXLen = String.valueOf(fieldWidthInM);
             }
-            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_ELEVATION)) {
-                double elevationInM = Double.parseDouble(JSONUtils.getValue(getParamMap().get(WEPS_KEY_ELEVATION))) * CONV_FT_TO_M;
-                wmr.setElevation(String.valueOf(elevationInM));
+            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_WATER_EROSION_LOSS))
+            {
+                double waterErosionLoss = Double.parseDouble(JSONUtils.getValue(getParamMap().get(WEPS_KEY_WATER_EROSION_LOSS))) * CONV_TONACREYR_TO_KGM2YR;
+                wmr.waterErosionLoss = String.valueOf(waterErosionLoss);
             }
-            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_FIELD_LENGTH)) {
-                double fieldLengthInM = Double.parseDouble(JSONUtils.getValue(getParamMap().get(WEPS_KEY_FIELD_LENGTH))) * CONV_FT_TO_M;
-                wmr.setSimYLen(String.valueOf(fieldLengthInM));
-            }
-            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_FIELD_WIDTH)) {
-                double fieldWidthInM = Double.parseDouble(JSONUtils.getValue(getParamMap().get(WEPS_KEY_FIELD_WIDTH))) * CONV_FT_TO_M;
-                wmr.setSimXLen(String.valueOf(fieldWidthInM));
-            }
-            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_WATER_EROSION_LOSS)) {
-                double waterErosionLoss = Double.parseDouble(JSONUtils.getValue(getParamMap().get(WEPS_KEY_WATER_EROSION_LOSS))) * CONV_TONACRE_TO_KGM2;
-                wmr.setWaterErosionLoss(String.valueOf(waterErosionLoss));
-            }
-        } catch (Exception e) {
+        }
+        catch (Exception e)
+        {
             throw new ServiceException("WEPS error: error processing model run parameters.");
-        }
+        }        
     }
-
+    
     /*
      * Uses's Jim Lyon's LMOD to WEPS mgmt translator to create a WEPS mgmt file
      */
-    private void loadWepsMgmt() throws ServiceException {
-        try {
+    private void loadWepsMgmt() throws ServiceException
+    {
+        try
+        {
             LOG.info("WEPS MGMT exisitence check=" + JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_MANAGEMENT));
-            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_MANAGEMENT)) {
+            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_MANAGEMENT))
+            {
                 LOG.info("Attempting to translate WEPS management JSON from LMOD to MAN file");
                 JSONObject mgmt = JSONUtils.getJSONObjectParam(getParamMap(), WEPS_KEY_MANAGEMENT);
-                //LOG.info("The WEPS mgmt is");
-                //LOG.info(mgmt.toString());
+                LOG.info("The WEPS mgmt is");
+                LOG.info(mgmt.toString());
                 WepsTranslator translator = new WepsTranslator();
                 translator.setConfigFilename("config/mcrew_start.xml");
-                translator.setInputManType(ManageData.InputManType.READ_LMOD_MAN_JSON);
-                translator.setOutputMan(true);
+                translator.setInputManType(ManageData.InputManType.READ_LMOD);
+                translator.setOutputMan(true);                
                 org.json.JSONObject mgmtObj = new org.json.JSONObject(mgmt.toString());
                 translator.setInputJSONObject(mgmtObj);
-                translator.setOutputFilename(getWorkspaceDir().toString() + "/" + WEPS_MGMT);
-                if (translator != null) {
-                    LOG.log(Level.INFO, "input filename =" + translator.getInputFilename());
-                    LOG.log(Level.INFO, "output filename =" + translator.getOutputFilename());
-                    LOG.log(Level.INFO, "rotation years =" + translator.getRotationYears());
-                    LOG.log(Level.INFO, "JSON to translate=" + translator.getInputJSONObject());
+                translator.setOutputFilename(getWorkspace().toString() + "/" + WEPS_MGMT);
+                try
+                {
+                    translator.Translate();
                 }
-                try {
-                    translator.Translate();
-                } catch (Exception e) {
-                    LOG.log(Level.SEVERE, "FLAT UP EXPLOSION FROM THE WEPS TRANSLATOR:" + e.toString());
-                    if (translator != null) {
-                        //LOG.log(Level.INFO, translator.)
-                    } else {
-                        LOG.log(Level.INFO, "TRANSLATOR IS NULL!");
-                    }
-                    for (StackTraceElement ste : e.getStackTrace()) {
-                        LOG.log(Level.SEVERE, "class=" + ste.getClassName() + " method=" + ste.getMethodName() + " |" + ste.toString());
-                    }
-
+                catch (Exception e)
+                {
                     throw new ServiceException("LMOD management translation error executing WEPS");
                     //return WEPS_ERROR_LMOD_TRANSLATION_ERROR;
                 }
-                wmr.setRunCycle(Integer.toString(translator.getRotationYears()));
-                simulationYears = Integer.parseInt(wmr.getRunCycle()) * NRCS_CYCLE_COUNT;
-                wmr.setNumYears(Integer.toString(simulationYears));
-                wmr.setMgmtFile(WEPS_MGMT);
+                wmr.runCycle = Integer.toString(translator.getRotationYears());
+                simulationYears = Integer.parseInt(wmr.runCycle) * NRCS_CYCLE_COUNT;
+                wmr.numYears = Integer.toString(simulationYears);
+                wmr.mgmtFile = WEPS_MGMT;
             }
-        } catch (Exception e) {
-            LOG.log(Level.SEVERE, "STACK TRACE FROM LMOD TRANSLATOR ERROR:");
-            for (StackTraceElement ste : e.getStackTrace()) {
-                LOG.log(Level.SEVERE, "class=" + ste.getClassName() + " method=" + ste.getMethodName() + " |" + ste.toString());
-            }
+        }
+        catch (Exception e)
+        {
             throw new ServiceException("WEPS error: error translating WEPS mgmt from LMOD.");
         }
     }
 
-    private void getFieldGeometry() throws ServiceException {
-        try {
-            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_FIELD_BOUNDARY)) {
+    private void getFieldGeometry() throws ServiceException
+    {
+        try
+        {
+            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_FIELD_BOUNDARY))
+            {
                 fieldGeometry = JSONUtils.getJSONObjectGeometry(getParamMap(), WEPS_FIELD_BOUNDARY);
                 LOG.info("field boundary geometry json obj=" + fieldGeometry);
                 String field_json_in = fieldGeometry.toString();
@@ -283,35 +277,44 @@
                 field_region = new JsonRegion(field_json_object);
                 // override provided lat long with centroid of field if available
                 // which is then used for wind and climate queries
-                wmr.setLat(String.valueOf(field_region.center_y));
-                wmr.setLongitude(String.valueOf(field_region.center_x));
-                wmr.setSimRegionAngle(String.valueOf(field_region.region_angle));
+                wmr.lat = String.valueOf(field_region.center_y);
+                wmr.longitude = String.valueOf(field_region.center_x);
+                wmr.simRegionAngle = String.valueOf(field_region.region_angle);
             }
-        } catch (Exception e) {
+        }
+        catch (Exception e)
+        {
             throw new ServiceException("WEPS error: error processing field geometry");
         }
     }
 
-    private void getWindBarriers() throws ServiceException {
-        try {
+    private void getWindBarriers() throws ServiceException
+    {
+        try
+        {
             String barrierdir = "";
-            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_BARRIERS)) {
+            if (JSONUtils.checkKeyExistsB(getParamMap(), WEPS_KEY_BARRIERS))
+            {
                 JSONArray barriers = JSONUtils.getJSONArrayParam(getParamMap(), WEPS_KEY_BARRIERS);
-                if ((barriers != null) && (barriers.length() > 0)) {
+                if ((barriers != null) && (barriers.length() > 0))
+                {
                     LinkedList<Barrier> lstBarriers = new LinkedList<Barrier>();
-                    for (int i = 0; i < barriers.length(); i++) {
+                    for (int i=0; i<barriers.length();i++)
+                    {
                         Barrier b = new Barrier();
                         JSONObject barrier = barriers.getJSONObject(i);
                         LOG.info("barrier obj " + i + "=" + barrier.toString());
-                        JSONObject barriervalue = barrier.optJSONObject("value");
-                        if (barriervalue != null) {
+                        JSONObject barriervalue =  barrier.optJSONObject("value");
+                        if (barriervalue != null)
+                        {
                             JSONObject lmodfile = barriervalue.optJSONObject("lmod_file");
-                            JSONObject properties = barrier.optJSONObject("properties");
+                            JSONObject properties =  barrier.optJSONObject("properties");
                             JSONObject barrierGeometry = barrier.optJSONObject(WEPS_GEOMETRY);  // pass to Jim's code
-                            if (barrierGeometry != null) {
+                            if (barrierGeometry != null)  
+                            {
                                 LOG.info("barrier geometry=" + barrierGeometry.toString());
                                 String barrier_json_in = barrierGeometry.toString();
-                                org.json.JSONTokener barrier_json_tok = new org.json.JSONTokener(barrier_json_in);
+                                org.json.JSONTokener barrier_json_tok= new org.json.JSONTokener(barrier_json_in);
                                 org.json.JSONObject barrier_json_object = new org.json.JSONObject(barrier_json_tok);
                                 barrier_region = new JsonRegion(barrier_json_object);
                             }
@@ -323,131 +326,144 @@
                             LOG.info("barrierParamObj=" + barrierParamObj.toString());
                             JSONArray barrierParams = barrierParamObj.optJSONArray("param");
                             LOG.info("barrierParams array=" + barrierParams.toString());
-                            for (int j = 0; j < barrierParams.length(); j++) {
+                            for (int j=0;j<barrierParams.length(); j++)
+                            {
                                 JSONObject barrierp = barrierParams.getJSONObject(j);
                                 LOG.info("barrierparam[" + j + "]=" + barrierp.toString());
                                 String thisparam = barrierp.getString("name");
-                                if (thisparam.equals(WEPS_BARRIERPARAM_WIDTH)) {
-                                    b.width = trimBrackets(barrierp.getString("data"));
-                                }
-                                if (thisparam.equals(WEPS_BARRIERPARAM_HEIGHT)) {
+                                if (thisparam.equals(WEPS_BARRIERPARAM_WIDTH))
+                                    b.width = trimBrackets(barrierp.getString("data")); 
+                                if (thisparam.equals(WEPS_BARRIERPARAM_HEIGHT))
                                     b.height = trimBrackets(barrierp.getString("data"));
-                                }
-                                if (thisparam.equals(WEPS_BARRIERPARAM_NUM_ROWS)) {
+                                if (thisparam.equals(WEPS_BARRIERPARAM_NUM_ROWS))
                                     b.number = trimBrackets(barrierp.getString("data"));
-                                }
-                                if (thisparam.equals(WEPS_BARRIERPARAM_POROSITY)) {
+                                if (thisparam.equals(WEPS_BARRIERPARAM_POROSITY))
                                     b.porosity = trimBrackets(barrierp.getString("data"));
-                                }
                             }
 
                             // check if barrier geometry is available and if so prefer these values instead
                             //if (field_region != null)
-                            if (barrier_region != null) {
+                            if (barrier_region != null)                                
+                            {
                                 LOG.info("barrier_region obj=" + barrier_region.toString());
                                 barrierdir = barrier_region.getCompassDir(field_region);
                                 b.height = String.valueOf(barrier_region.getHeight());
                                 b.width = String.valueOf(barrier_region.getWidth());
-                            } else {
+                            }
+                            else
+                            {
                                 // The weps barrier location (n s e w) is described based on how coordinates are specified
                                 barrierdir = properties.getString("placement");
                             }
-                            if (barrierdir.equals(WEPS_BARRIER_NORTH)) {
+                            if (barrierdir.equals(WEPS_BARRIER_NORTH))
+                            {
                                 b.x1 = "0";
-                                b.y1 = wmr.getSimYLen();
-                                b.x2 = wmr.getSimXLen();
-                                b.y2 = Double.toString(Double.parseDouble(wmr.getSimYLen()) + Double.parseDouble(b.width));
+                                b.y1 = wmr.simYLen;
+                                b.x2 = wmr.simXLen;
+                                b.y2 = Double.toString(Double.parseDouble(wmr.simYLen) + Double.parseDouble(b.width));
                             }
-                            if (barrierdir.equals(WEPS_BARRIER_SOUTH)) {
+                            if (barrierdir.equals(WEPS_BARRIER_SOUTH))
+                            {
                                 b.x1 = "0";
                                 b.y1 = Double.toString(-Double.parseDouble(b.width));
-                                b.x2 = wmr.getSimXLen();
+                                b.x2 = wmr.simXLen;
                                 b.y2 = "0";
                             }
-                            if (barrierdir.equals(WEPS_BARRIER_EAST)) {
-                                b.x1 = wmr.getSimXLen();
+                            if (barrierdir.equals(WEPS_BARRIER_EAST))
+                            {
+                                b.x1 = wmr.simXLen;
                                 b.y1 = "0";
-                                b.x2 = Double.toString(Double.parseDouble(wmr.getSimXLen()) + Double.parseDouble(b.width));
-                                b.y2 = wmr.getSimYLen();
+                                b.x2 = Double.toString(Double.parseDouble(wmr.simXLen) + Double.parseDouble(b.width));
+                                b.y2 = wmr.simYLen;
                             }
-                            if (barrierdir.equals(WEPS_BARRIER_WEST)) {
+                            if (barrierdir.equals(WEPS_BARRIER_WEST))
+                            {
                                 b.x1 = Double.toString(-Double.parseDouble(b.width));
                                 b.y1 = "0";
                                 b.x2 = "0";
-                                b.y2 = wmr.getSimYLen();
+                                b.y2 = wmr.simYLen;
                             }
                             lstBarriers.add(b);
                         }
                     }
-                    wmr.setNumBarriers(Integer.toString(lstBarriers.size()));
-                    for (int ij = 0; ij < Integer.parseInt(wmr.getNumBarriers()); ij++) {
+                    wmr.numBarriers = Integer.toString(lstBarriers.size());
+                    for (int ij=0;ij<Integer.parseInt(wmr.numBarriers);ij++)
+                    {
                         Barrier b = lstBarriers.get(ij);
                         LOG.info("Barrier #" + ij + " x1=" + b.x1 + " x2=" + b.x2 + " y1=" + b.y1 + " y2=" + b.y2 + " width=" + b.width + " height=" + b.height + " number=" + b.number + " type=" + b.type + " porosity=" + b.porosity);
                     }
                     // A blank dummy barrier is required in the weps.run file if there are none
-                    if (lstBarriers.size() == 0) {
+                    if (lstBarriers.size() == 0)
+                    {
                         LOG.info("THIS WEPS RUN HAS NO BARRIERS!");
                         Barrier b = new Barrier();
                         lstBarriers.add(b);
                     }
-                    wmr.setBarriers(lstBarriers); 
+                    wmr.barriers = lstBarriers;
                 }
             }
-        } catch (Exception e) {
+        }
+        catch (Exception e)
+        {
             // Handle error in processing barriers
             LOG.severe("Error with wind barriers: " + e.toString());
             String stackTrace = "";
-            for (StackTraceElement ste : e.getStackTrace()) {
+            for (StackTraceElement ste : e.getStackTrace())
                 stackTrace += ste.toString();
-            }
             LOG.severe("stack trace=" + stackTrace);
             throw new ServiceException("WEPS error: error processing wind barriers information: " + e.toString());
         }
     }
 
-    private void getClimate() throws ServiceException {
-        try {
-            if (db != null) {
+    private void getClimate() throws ServiceException
+    {
+        try
+        {
+            if (db != null)
+            {
                 // get climate station for this lat / long
-                PostGIS.StationResult cligenStation = db.findCligenStation(Double.parseDouble(wmr.getLat()), Double.parseDouble(wmr.getLongitude()));
+                PostGIS.StationResult cligenStation = db.findCligenStation(Double.parseDouble(wmr.lat), Double.parseDouble(wmr.longitude));
                 // generate cli file using this station
                 ProcessComponent pcCliGen = new ProcessComponent();
                 pcCliGen.working_dir = sessionWorkDir;
-                LOG.info("extract cligen to:/bin/" + Binaries.getArch());
-                LOG.info("binDir is=" + binDir);
-                pcCliGen.exe = Binaries.unpackResource("/bin/" + Binaries.getArch() + "/cligen", new File(binDir)).toString();
-                LOG.info("extract climate db");
-                String dbpath = Binaries.unpackResource("/bin/" + Binaries.getArch() + "/upd_US_cligen_stations.par", new File(binDir)).toString();
+                pcCliGen.exe = BinUtils.unpackResource("/bin/" + BinUtils.getArch() + "/cligen", new File(binDir)).toString();
+                String dbpath = BinUtils.unpackResource("/bin/" + BinUtils.getArch() + "/upd_US_cligen_stations.par", new File(binDir)).toString();
                 pcCliGen.args = new String[]{"-S" + cligenStation.state, "-s" + cligenStation.stationId, "-i" + dbpath, "-t5", "-I3", "-F", "-b01", "-y" + simulationYears, "-o" + sessionWorkDir + "/cligen.cli"};
-                LOG.log(Level.INFO, "cligen args=" + pcCliGen.args.toString());
+                LOG.log(Level.INFO, "cligen args=" + pcCliGen.args.toString());                            
                 pcCliGen.execute();
                 // prefer lat/long generated climates file for weps run
-                //wmr.cliFile = "cligen.cli";
+                wmr.cliFile = "cligen.cli";
             }
-        } catch (Exception e) {
-            throw new ServiceException("WEPS error: error generating climate data:" + e.toString());
+        }
+        catch (Exception e)
+        {
+            throw new ServiceException("WEPS error: error generating climate data");
         }
     }
 
-    private void generateWindData() throws ServiceException {
-        try {
+    private void generateWindData() throws ServiceException 
+    {
+        try
+        {
             // Always generate wind data for lat / long using wingen and possible interpolate program
-            if (db != null) {
-                double latitude = Double.parseDouble(wmr.getLat());
-                double longitude = Double.parseDouble(wmr.getLongitude());
+            if (db != null)
+            {
+                double latitude = Double.parseDouble(wmr.lat);
+                double longitude = Double.parseDouble(wmr.longitude);
 
                 // check if in the interpolation boundary shape, if so, interpolate 3 nearest wind stations
                 // to generate an interpolated station
                 LOG.log(Level.INFO, "Check if lat/long is in interpolation boundary");
-                if (db.IsInInterpolateBoundary(latitude, longitude)) {
+                if (db.IsInInterpolateBoundary(latitude, longitude))
+                {
                     LOG.log(Level.INFO, "YES! lat/long is in interpolation boundary");
                     // Generate wind station interpolation
 
                     // Generate weights file
                     ProcessComponent pcInterpolate = new ProcessComponent();
-                    String exepath = Binaries.unpackResource("/bin/" + Binaries.getArch() + "/interpolate", new File(binDir)).toString();
-                    String dbpath = Binaries.unpackResource("/bin/" + Binaries.getArch() + "/wind_gen_his_upper_US.idx", new File(binDir)).toString();
-                    String polygon = Binaries.unpackResource("/bin/" + Binaries.getArch() + "/WINDGEN_DEC_13_2011.pol", new File(binDir)).toString();
+                    String exepath = BinUtils.unpackResource("/bin/" + BinUtils.getArch() + "/interpolate", new File(binDir)).toString();
+                    String dbpath = BinUtils.unpackResource("/bin/" + BinUtils.getArch() + "/wind_gen_his_upper_US.idx", new File(binDir)).toString();
+                    String polygon = BinUtils.unpackResource("/bin/" + BinUtils.getArch() + "/WINDGEN_DEC_13_2011.pol", new File(binDir)).toString();
 
                     // Generate shell script to invoke interpolate
                     File interpolatesh = new File(sessionWorkDir + "/interpolate.sh");
@@ -468,29 +484,26 @@
                     // must process this monstrosity 
                     wp.parse();
 
-                    if ((wp.station1 > 0) & (wp.station2 > 0) && (wp.station3 > 0)) {
+                    if ((wp.station1 > 0) & (wp.station2 > 0) && (wp.station3 > 0))
+                    {
                         // If there are wind stations then, generate interpolate wind station wdb file
 
                         // Note the interp_wdb program is ancient Fortran and can not handle file paths of any length
                         // therefore everything has to be extracted to the workdir and done locally there.
                         // This is BAD (inefficient) because it is extra work to always extract wind station wdb's for every model run!
                         ProcessComponent pcInterpWdb = new ProcessComponent();
-                        exepath = Binaries.unpackResource("/bin/" + Binaries.getArch() + "/interp_wdb", new File(binDir)).toString();
-
-//                        String station1Db = BinUtils.unpackResourceAbsolute("/bin/" + BinUtils.getArch() + "/windstations/" + wp.station1 + ".wdb", sessionWorkDir + "/" + wp.station1 + ".wdb").toString();
-//                        String station2Db = BinUtils.unpackResourceAbsolute("/bin/" + BinUtils.getArch() + "/windstations/" + wp.station2 + ".wdb", sessionWorkDir + "/" + wp.station2 + ".wdb").toString();
-//                        String station3Db = BinUtils.unpackResourceAbsolute("/bin/" + BinUtils.getArch() + "/windstations/" + wp.station3 + ".wdb", sessionWorkDir + "/" + wp.station3 + ".wdb").toString();
-                        String station1Db = getWindStationFile(wp.station1);
-                        String station2Db = getWindStationFile(wp.station2);
-                        String station3Db = getWindStationFile(wp.station3);
+                        exepath = BinUtils.unpackResource("/bin/" + BinUtils.getArch() + "/interp_wdb", new File(binDir)).toString();
+                        String station1Db = BinUtils.unpackResourceAbsolute("/bin/" + BinUtils.getArch() + "/windstations/" + wp.station1 + ".wdb", sessionWorkDir + "/" + wp.station1 + ".wdb").toString();
+                        String station2Db = BinUtils.unpackResourceAbsolute("/bin/" + BinUtils.getArch() + "/windstations/" + wp.station2 + ".wdb", sessionWorkDir + "/" + wp.station2 + ".wdb").toString();
+                        String station3Db = BinUtils.unpackResourceAbsolute("/bin/" + BinUtils.getArch() + "/windstations/" + wp.station3 + ".wdb", sessionWorkDir + "/" + wp.station3 + ".wdb").toString();
 
                         // Generate shell script to invoke interpolate
                         File interpwdbsh = new File(sessionWorkDir + "/interpwdb.sh");
-                        String invokeInterpWdb = exepath + " test.wdb" + " " + station1Db + wp.weight1 + " " + station2Db + wp.weight2 + " " + station3Db + wp.weight3;
+                        String invokeInterpWdb = exepath + " test.wdb" + " " + wp.station1 + ".wdb " + wp.weight1 + " " + wp.station2 + ".wdb " + wp.weight2 + " " + wp.station3 + ".wdb " + wp.weight3;
                         FileUtils.writeStringToFile(interpwdbsh, invokeInterpWdb);
                         interpwdbsh.setExecutable(true);
 
-                        pcInterpWdb.working_dir = sessionWorkDir;
+                        pcInterpWdb.working_dir = sessionWorkDir;                                    
                         pcInterpWdb.exe = "./interpwdb.sh";
                         pcInterpWdb.args = new String[]{};
                         pcInterpWdb.execute();
@@ -500,18 +513,20 @@
                 }
 
                 // otherwise, just use data from nearest wind station:
+
                 // If this is not using an interpolated wind station, then use the default one...
-                if (windDbPath.length() == 0) {
+                if (windDbPath.length() == 0)
+                {
                     LOG.log(Level.INFO, "NO! lat/long is NOT in interpolation boundary");
                     // get wind generation station for this lat / long
-                    PostGIS.StationResult windgenStation = db.findWindgenStation(Double.parseDouble(wmr.getLat()), Double.parseDouble(wmr.getLongitude()));
+                    PostGIS.StationResult windgenStation = db.findWindgenStation(Double.parseDouble(wmr.lat), Double.parseDouble(wmr.longitude));
                     sWindgenStation = windgenStation.stationId.trim();
 
-                    windDbPath = Binaries.unpackResource("/bin/" + Binaries.getArch() + "/" + DEFAULT_WIND_STATION_DB, new File(binDir)).toString();
+                    windDbPath = BinUtils.unpackResource("/bin/" + BinUtils.getArch() + "/wind_gen_his_upper_US.wdb", new File(binDir)).toString();
                 }
                 // generate win file using this station (or interpolated one)
                 ProcessComponent pcWindGen = new ProcessComponent();
-                String exepath = Binaries.unpackResource("/bin/" + Binaries.getArch() + "/wind_gen4", new File(binDir)).toString();
+                String exepath = BinUtils.unpackResource("/bin/" + BinUtils.getArch() + "/wind_gen4", new File(binDir)).toString();
                 LOG.log(Level.INFO, "Using wind database:" + windDbPath);
 
                 // Generate shell script to invoke windgen
@@ -521,129 +536,121 @@
                 windgensh.setExecutable(true);
 
                 pcWindGen.working_dir = sessionWorkDir;
-                String cmd = "./windgen.sh";
+                String cmd="./windgen.sh";
                 pcWindGen.args = new String[]{};
                 pcWindGen.exe = cmd;
                 pcWindGen.execute();
 
-                //wmr.winFile = "thewind.win";
+                wmr.winFile = "thewind.win";
             }
-        } catch (Exception e) {
+        }
+        catch (Exception e)
+        {
             throw new ServiceException("WEPS error: error generating wind data");
         }
     }
 
-    private String getWindStationFile(int windStationId) throws ServiceException {
-        String wepsdb = Config.getString("weps.db", "http://oms-db.engr.colostate.edu/weps");
-        String windStation = WIND_STATIONS_DIR + "/" + windStationId + WIND_STATION_FILE_EXT;
+    private void getSoilIfc() throws ServiceException
+    {
+        String wepsdb = CSIPConfig.getString("weps.db", "http://oms-db.engr.colostate.edu/weps");
 
-        // Get wind station file and write to temp space
-        String fileToGet = wepsdb + "/" + windStation;
-        LOG.log(Level.INFO, "wind station file to get=" + fileToGet);
-        getFile(fileToGet, sessionWorkDir, windStationId + WIND_STATION_FILE_EXT);
+        try
+        {
+            // Use user provided soil key to look up and acquire soils file
+            if (db != null)                         
+            {
+                PostGIS.FileQryResult soil = ((soilkey != null) && (soilkey.length() > 0)) ? 
+                        db.findSoilsWepsByCokey(soilkey, Double.parseDouble(wmr.longitude)) :
+                        db.findSoilsWeps(Double.parseDouble(wmr.lat), Double.parseDouble(wmr.longitude));
 
-        // Return file name of retrieved wind station
-        // An extra space is appended for interp_wdb.exe use on command line
-        wmr.setSoilFile(windStationId + WIND_STATION_FILE_EXT + " ");
-        return wmr.getSoilFile();
-    }
-
-    private void getSoilIfc() throws ServiceException {
-        String wepsdb = Config.getString("weps.db", "http://oms-db.engr.colostate.edu/weps");
-
-        try {
-            // Use user provided soil key to look up and acquire soils file
-            if (db != null) {
-                PostGIS.FileQryResult soil = ((soilkey != null) && (soilkey.length() > 0))
-                        ? db.findSoilsWepsByCokey(soilkey, Double.parseDouble(wmr.getLongitude()))
-                        : db.findSoilsWeps(Double.parseDouble(wmr.getLat()), Double.parseDouble(wmr.getLongitude()));
-
-                if (soil == null) {
-                    LOG.log(Level.WARNING, "No soil for lat=" + wmr.getLat() + "\nfor long=" + wmr.getLongitude() + "\n");
+                if (soil == null) 
+                {
+                    LOG.log(Level.WARNING, "No soil for lat=" + wmr.lat + "\nfor long=" + wmr.longitude + "\n");
                     soilPtr = "";
-                    if ((soilkey != null) && (soilkey.length() > 0)) {
+                    if ((soilkey != null) && (soilkey.length() > 0))
                         throw new ServiceException("WEPS error: no soil available for cokey");
-                    } else {
+                    else
                         throw new ServiceException("WEPS error: no soil available for provided lat/long coordinates");
-                    }
-                } else {
+                } 
+                else 
+                {
                     soilPtr = soil.file_path + "/" + soil.file_name + SOIL_FILE_EXT;
                     // Get soil file and write to temp space
                     String fileToGet = wepsdb + "/" + soilPtr;
                     LOG.log(Level.INFO, "soils file to get=" + fileToGet);
-                    getFile(fileToGet, sessionWorkDir, soil.file_name + SOIL_FILE_EXT);
+                    getFile(fileToGet,sessionWorkDir, soil.file_name + SOIL_FILE_EXT);
                     // Prefer lat/long retrieved soils file 
-                    wmr.setSoilFile(soil.file_name + SOIL_FILE_EXT);
+                    wmr.soilFile = soil.file_name + SOIL_FILE_EXT;
                 }
             }
-        } catch (Exception e) {
+        }
+        catch (Exception e)
+        {
             throw new ServiceException("WEPS error: error retrieiving soil data");
         }
     }
-
+    
     private void getFile(String url, String destDir, String filename) {
 
         FileOutputStream fos = null;
         try {
 
             HttpClient client = new DefaultHttpClient();
-            HttpGet httpget = new HttpGet(url);
+            HttpGet httpget  = new HttpGet(url);
             HttpResponse response = client.execute((HttpUriRequest) httpget);
-
+            
+            
             byte[] soilData = IOUtils.toByteArray(response.getEntity().getContent());
             fos = new FileOutputStream(new File(destDir + "/" + filename));
             fos.write(soilData);
             fos.close();
-        } catch (IOException ie) {
+        }
+        catch (IOException ie) {
             LOG.log(Level.SEVERE, "ERROR GETTING SOILS IFC FILE!:" + ie.toString());
         } finally {
-            if (fos != null) {
-                try {
-                    fos.close();
-                } catch (Exception fe) {
-                }
-            }
+            if(fos != null) try { fos.close(); } catch (Exception fe) {}
         }
     }
-
-    private String trimBrackets(String sText) {
-        return sText.substring(1, sText.length() - 1);
+    
+    private String trimBrackets(String sText)
+    {
+        return sText.substring(1, sText.length()-1);
     }
 
     @Override
-    protected File[] postprocess() throws Exception {
-        File simDir = getWorkspaceDir();
-        return new File[] {
-            new File(simDir, "stir_energy.out"),
-            new File(simDir, "sci_energy.out"),
-            new File(simDir, "stdout.txt"),
-            new File(simDir, "stderr.txt")
-        };
+    protected String[] postprocess() throws Exception {
+        File simDir = getWorkspace();
+        File outDir = getResults();
+        FileUtils.copyFileToDirectory(new File(simDir, "stir_energy.out"), outDir);
+        FileUtils.copyFileToDirectory(new File(simDir, "sci_energy.out"), outDir);
+        FileUtils.copyFileToDirectory(new File(simDir, "stdout.txt"), outDir);
+        FileUtils.copyFileToDirectory(new File(simDir, "stderr.txt"), outDir);
+        
+        return null;
     }
 
     @Override
     public JSONArray createResults() throws Exception {
         LOG.info("Create the WEPS results...");
         JSONArray results = new JSONArray();
-        String outUrl = Config.getString("m.results.url", "http://localhost:8084/csip/q/");
+        String outUrl = CSIPConfig.getString("m.results.url", "http://localhost:8084/csip/q/");
         String baseUrl = outUrl + getSUID();
-
+        
         FileReader fr = new FileReader(sessionWorkDir + "/sci_energy.out");
         BufferedReader bfr = new BufferedReader(fr);
         String sciEnergyOut = "";
-        while (bfr.ready()) {
+        while (bfr.ready())
             sciEnergyOut += bfr.readLine();
-        }
         bfr.close();
         fr.close();
         wo = SciEnergyParser.parseSciEnergyFile(sciEnergyOut);
-
+        
         // Special unit conversions for Phacil
         double dieselEnergy_gallonsPerAcre = Double.parseDouble(wo.dieselEnergy) * CONV_LITERHECTATRE_TO_GALLONACRE;
         double averageBiomass_tonAcreYear = Double.parseDouble(wo.averageBiomass) * CONV_KGM2_TONACRE;
-        double windEros_tonAcreYear = Double.parseDouble(wo.windEros) * CONV_KGM2_TONACRE;
-        double waterEros_tonAcreYear = Double.parseDouble(wo.waterEros) * CONV_KGM2_TONACRE;
-
+        double windEros_tonAcreYear = Double.parseDouble(wo.windEros) * CONV_KGM2YR_TONACREYR;
+        double waterEros_tonAcreYear = Double.parseDouble(wo.waterEros) * CONV_KGM2YR_TONACREYR;
+        
         results.put(JSONUtils.dataDesc(WEPS_RES_SOIL_COND_INDEX, wo.soilConditioningIndex, "total SCI (soil conditioning index)"));
         results.put(JSONUtils.dataDesc(WEPS_RES_SCI_OM_FACTOR, wo.sciOmFactor, "SCI Organic Matter subfactor"));
         results.put(JSONUtils.dataDesc(WEPS_RES_SCI_ER_FACTOR, wo.sciErFactor, "SCI Erosion Rate subfactor"));
@@ -653,7 +660,7 @@
         results.put(JSONUtils.dataUnitDesc(WEPS_RES_WIND_EROS, windEros_tonAcreYear, "ton/acre/year", "Wind erosion (computed by WEPS)"));
         results.put(JSONUtils.dataUnitDesc(WEPS_RES_WATER_EROS, waterEros_tonAcreYear, "ton/acre/year", "Water erosion (external input)"));
         results.put(JSONUtils.dataDesc(WEPS_RES_AVG_ALL_STIR, wo.avgAllStir, "Average STIR"));
-
+        
 //        results.put(JSONUtils.data("sci", baseUrl + "/sci_energy.out"));
 //        results.put(JSONUtils.data("stir", baseUrl + "/strir_energy.out"));
 //        results.put(JSONUtils.data("stdout", baseUrl + "/stdout.txt"));
@@ -661,50 +668,52 @@
         return results;
     }
 
-//    @Override
-//    public String getModelName() {
-//        return "weps/1.2";
-//    }
     @Override
-    public long getNextPoll() {
+    public String getModelName() {
+        return "weps/1.2";
+    }
+
+      @Override
+    public long getPollingInterval() {
         return 2000;  // poll every 2 seconds after the first poll
     }
 
     @Override
-    protected long getFirstPoll() {
+    protected long getFirstPolling() {
         // to do
         // this should be based on the number of years of the weps run
         return 25000; // wait 25 seconds for the first poll.
     }
 
-//    @Override
-//    protected JSONObject describe() throws JSONException {
-//
-//        JSONArray p = new JSONArray();
-//
-//        JSONObject metainfo = new JSONObject();
-//////        metainfo.put(KEY_REQUEST_RESULTS, new JSONArray(potResults));
-//
-//        JSONObject model = new JSONObject();
-//        model.put(KEY_PARAMETER, p);
-//        model.put(KEY_METAINFO, metainfo);
-//        return model;
-//    }
+    @Override
+    protected JSONObject describe() throws JSONException {
+        
+        JSONArray p = new JSONArray();
 
+        JSONObject metainfo = new JSONObject();
+////        metainfo.put(KEY_REQUEST_RESULTS, new JSONArray(potResults));
+
+        JSONObject model = new JSONObject();
+        model.put(KEY_PARAMETER, p);
+        model.put(KEY_METAINFO, metainfo);
+        return model;
+    }
+    
     @Override
-    protected JSONArray createReport() throws Exception {
-        String workDir = getWorkspaceDir().toString();
+    protected JSONArray createReport() throws Exception 
+    {
+        String workDir = getWorkspace().toString();
         File reportTemplate = new File(workDir + "/" + REPORT_JSON_FILENAME);
         String sReportJSON = FileUtils.readFileToString(reportTemplate);
         //JSONObject reportObj = new JSONObject(sReportJSON);
         //JSONArray reportItems = reportObj.getJSONArray("WEPSreport");
         JSONArray reportItems = new JSONArray(sReportJSON);
-
+        
         WepsConnection con = new WepsConnection();
-
+        
         // Create an instance of this class to do the actual loading.
         WepsReportData reportdata = new WepsReportData(con);
-
+        
         // Set the location of the folder to translate files in.
         String sInputDirectory = workDir;
         if (!reportdata.setInputDirectory(sInputDirectory)) {
@@ -712,73 +721,63 @@
             LOG.severe("error: WEPS reports input directory doesn't exist.");
             throw new ServiceException("Error create WEPS reports.  Report directory does not exist.");
         }
-
+        
         // @todo set configuration options.
         reportdata.m_sUnits = "US";
-
+        
         // Load the file data.
-        reportdata.loadFiles(getWorkspaceDir().toString());
-
+        reportdata.loadFiles();
+        
 //        // Dump the loaded data as text for debugging purposes.
 //        LOG.info("hash map output=" + con.toString());
 //        
 //        LOG.info("Original Report JSON obj=" + reportObj.toString());
+        
         HashMap<String, ArrayList<Object>> m_reportdata = con.getParamValues();
-        for (int i = 0; i < reportItems.length(); i++) {
+        for (int i=0;i<reportItems.length();i++)
+        {
             JSONObject obj = (JSONObject) reportItems.get(i);
             String itemName = obj.getString(REPORT_NAME);
             //LOG.info("COMPARISON for scalars: itemname='" + itemName + "'");
             //if (itemName.length() >= 5)  LOG.info("COMPARISON for scalars: itemname 0,5='" + itemName.substring(0,5) + "'");
             //if (itemName.length() >= 11)  LOG.info("COMPARISON for scalars: itemname 0,11='" + itemName.substring(0,11) + "'");
-            if ((itemName != null) && ((((itemName.length()) >= 5) && (itemName.substring(0, 5).contentEquals("runs.")))
-                    || (((itemName.length()) >= 11) && (itemName.substring(0, 11).contentEquals("sci_energy."))))) {
+            if ((itemName != null) && ((((itemName.length()) >= 5) && (itemName.substring(0,5).contentEquals("runs."))) ||
+                (((itemName.length()) >= 11) && (itemName.substring(0,11).contentEquals("sci_energy.")))))
+            {
                 // Scalar values
                 //LOG.info("look up " + itemName + " in report hash table for scalar output.");
                 ArrayList<Object> scalar = m_reportdata.get(itemName);
-                if (scalar != null) {
+                if (scalar != null)
+                {
                     //LOG.info("putting to jsonobj=" + scalar.get(0));
                     obj.put(REPORT_VALUE, scalar.get(0));
                     reportItems.put(i, obj);
-                } else {
+                }
+                else
                     LOG.warning("WEPS report generatioin: Scalar parameter has no data in hashmap=" + itemName);
-                }
-            } else {
+            }
+            else
+            {
                 // Array values
                 //LOG.info("look up " + itemName + " in report hash table for array output.");
                 LinkedList coll = new LinkedList();
                 ArrayList<Object> array = m_reportdata.get(itemName);
-                if (array != null) {
-                    for (int j = 0; j < array.size(); j++) {
+                if (array != null)
+                {
+                    for (int j=0;j<array.size();j++)
                         coll.add(array.get(j));
-                    }
 
                     obj.put(REPORT_VALUE, (Collection) coll);
                     reportItems.put(i, obj);
-                } else {
+                }
+                else
                     LOG.warning("WEPS report generation: Array parameter has no data in hashmap=" + itemName);
-                }
             }
             obj.remove(REPORT_TYPE);
-
+            
         }
+        
         //LOG.info("Updated Report JSON obj=" + reportObj.toString());
         return reportItems;
     }
-    
-    // Added accessor methods to access attributes formerly public in AbstractModelService
-    // but now protected in ModelDataService...
-    public String getAMSSUID()
-    {
-        return getSUID();   
-    }
-    
-    public String getAMStz()
-    {
-        return tz;  
-    }
-    
-    public JSONObject getAMSMetainfo()
-    {
-        return getMetainfo();
-    }
-}
+}
\ No newline at end of file

tools/WepsReportData/src/wepsreportdata/WepsReportData.java

@@ -47,7 +47,6 @@
      */
     public boolean loadFiles(String path) {
         try {
-            
             // Try loading each of the output files in sequence.
             // Configuration is handled within each of these functions.
             // Failure will throw an exception.
@@ -100,7 +99,7 @@
     public void loadOutputResultSet(String path) {
         // @todo Check configuration options to see if we should load this file.
         try {
-            Binaries.unpackResourceAbsolute(DETAIL_SOURCE, path +"/"+ PATH_META);
+            Binaries.unpackResourceAbsolute(DETAIL_SOURCE, System.getProperty("user.dir") +"/"+ PATH_META);
             OutputResultSet resultset = new OutputResultSet(m_con, m_sInputDirectory, m_sUnits);
             resultset.setWorkingDir(path);
             resultset.fill();