Displaying differences for changeset
 
display as  

nbproject/build-impl.xml

@@ -1010,6 +1010,7 @@
         <copyfiles files="${libs.csip-geotools-15.1-2.classpath}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${libs.CSIP-Jersey-2.16.classpath}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <copyfiles files="${file.reference.csip-gis-objects-2.0.17.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${file.reference.SDMDriver-Beta.20.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
         <mkdir dir="${build.web.dir}/META-INF"/>
         <manifest file="${build.web.dir}/META-INF/MANIFEST.MF" mode="update"/>
     </target>
@@ -1018,6 +1019,7 @@
         <copyfiles files="${libs.csip-geotools-15.1-2.classpath}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${libs.CSIP-Jersey-2.16.classpath}" todir="${build.web.dir}/WEB-INF/lib"/>
         <copyfiles files="${file.reference.csip-gis-objects-2.0.17.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+        <copyfiles files="${file.reference.SDMDriver-Beta.20.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
     </target>
     <target depends="init" if="dist.ear.dir" name="-clean-webinf-lib">
         <delete dir="${build.web.dir}/WEB-INF/lib"/>

nbproject/project.properties

@@ -1,4 +1,5 @@
 file.reference.csip-gis-objects-2.0.17.jar=lib/csip-gis-objects-2.0.17.jar
+file.reference.SDMDriver-Beta.20.jar=lib/SDMDriver-Beta.20.jar
 j2ee.platform.classpath=${j2ee.server.home}/lib/annotations-api.jar:${j2ee.server.home}/lib/catalina-ant.jar:${j2ee.server.home}/lib/catalina-ha.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/ecj-4.4.2.jar:${j2ee.server.home}/lib/el-api.jar:${j2ee.server.home}/lib/jasper-el.jar:${j2ee.server.home}/lib/jasper.jar:${j2ee.server.home}/lib/jsp-api.jar:${j2ee.server.home}/lib/servlet-api.jar:${j2ee.server.home}/lib/sqljdbc42.jar:${j2ee.server.home}/lib/tomcat-api.jar:${j2ee.server.home}/lib/tomcat-coyote.jar:${j2ee.server.home}/lib/tomcat-dbcp.jar:${j2ee.server.home}/lib/tomcat-i18n-es.jar:${j2ee.server.home}/lib/tomcat-i18n-fr.jar:${j2ee.server.home}/lib/tomcat-i18n-ja.jar:${j2ee.server.home}/lib/tomcat-jdbc.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat7-websocket.jar:${j2ee.server.home}/lib/websocket-api.jar
 #Thu Dec 17 13:44:22 MST 2015
 javadoc.splitindex=true
@@ -54,7 +55,8 @@
     ${reference.csip-core.jar}:\
     ${libs.csip-geotools-15.1-2.classpath}:\
     ${libs.CSIP-Jersey-2.16.classpath}:\
-    ${file.reference.csip-gis-objects-2.0.17.jar}
+    ${file.reference.csip-gis-objects-2.0.17.jar}:\
+    ${file.reference.SDMDriver-Beta.20.jar}
 javadoc.noindex=false
 webinf.dir=web/WEB-INF
 annotation.processing.enabled.in.editor=true

nbproject/project.xml

@@ -27,6 +27,10 @@
                     <file>${file.reference.csip-gis-objects-2.0.17.jar}</file>
                     <path-in-war>WEB-INF/lib</path-in-war>
                 </library>
+                <library dirs="200">
+                    <file>${file.reference.SDMDriver-Beta.20.jar}</file>
+                    <path-in-war>WEB-INF/lib</path-in-war>
+                </library>
             </web-module-libraries>
             <web-module-additional-libraries/>
             <source-roots>

src/java/m/rhem/rhem01_runmodel/V1_0.java

@@ -1,7 +1,13 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
+ * $Id$
+ *
+ * This file is part of the Cloud Services Integration Platform (CSIP),
+ * a Model-as-a-Service framework, API, and application suite.
+ *
+ * 2012-2017, OMSLab, Colorado State University.
+ *
+ * OMSLab licenses this file to you under the MIT license.
+ * See the LICENSE file in the project root for more information.
  */
 package m.rhem.rhem01_runmodel;
 
@@ -11,7 +17,6 @@
 import csip.ServiceException;
 import csip.annotations.Polling;
 import csip.annotations.Resource;
-import static csip.annotations.ResourceType.EXECUTABLE;
 import java.io.File;
 import java.io.IOException;
 import java.sql.Connection;
@@ -28,10 +33,12 @@
 import oms3.annotations.Description;
 import oms3.annotations.Name;
 import rhem.utils.DBQueries;
-import static rhem.utils.RHEMResources.RHEM_EXE;
-import rhem.utils.RHEMResources;
+import static rhem.utils.DBResources.RHEM_EXE;
+import rhem.utils.DBResources;
 
 /**
+ * RHEM-01:Run RHEM Model
+ *
  * @version 1.0
  * @author Rumpal Sidhu
  */
@@ -43,8 +50,8 @@
         + "cryptogam cover.")
 @Path("m/rhem/runrhem/1.0")
 @Polling(first = 10000, next = 2000)
-@Resource(from = RHEMResources.class)
-//@Resource(file = "*.par *.pre *.sum *.out *.run", type = OUTPUT)
+@Resource(from = DBResources.class)
+
 public class V1_0 extends ModelDataService {
 
     private AoA aoa;
@@ -59,53 +66,48 @@
 
     @Override
     public void preProcess() throws ServiceException {
-        try {
-            int aoaId = getIntParam("AoAID", 0);
-            int rhemSiteId = getIntParam("rhem_site_id", 0);
-            String scenarioName = getStringParam("scenarioname");
-            String scenarioDescription = getStringParam("scenariodescription");
-            int unit = getIntParam("units", 0);
-            String stateId = getStringParam("stateid");
-            String climatestationId = getStringParam("climatestationid");
-            String soilTexture = getStringParam("soiltexture");
-            String slopeShape = getStringParam("slopeshape");
-            double slopeSteepness = getDoubleParam("slopesteepness", 0.0);
-            double bunchGgrassCanopyCover = getDoubleParam("bunchgrasscanopycover", 0.0);
-            double forbsCanopyCover = getDoubleParam("forbscanopycover", 0.0);
-            double shrubsCanopyCover = getDoubleParam("shrubscanopycover", 0.0);
-            double sodGrassCanopyCover = getDoubleParam("sodgrasscanopycover", 0.0);
-            double basalCover = getDoubleParam("basalcover", 0.0);
-            double rockCover = getDoubleParam("rockcover", 0.0);
-            double litterCover = getDoubleParam("littercover", 0.0);
-            double cryptogamsCover = getDoubleParam("cryptogamscover", 0.0);
+        int aoaId = getIntParam("AoAID", 0);
+        int rhemSiteId = getIntParam("rhem_site_id", 0);
+        String scenarioName = getStringParam("scenarioname");
+        String scenarioDescription = getStringParam("scenariodescription");
+        int unit = getIntParam("units", 0);
+        String stateId = getStringParam("stateid");
+        String climatestationId = getStringParam("climatestationid");
+        String soilTexture = getStringParam("soiltexture");
+        String slopeShape = getStringParam("slopeshape");
+        double slopeSteepness = getDoubleParam("slopesteepness", 0.0);
+        double bunchGgrassCanopyCover = getDoubleParam("bunchgrasscanopycover", 0.0);
+        double forbsCanopyCover = getDoubleParam("forbscanopycover", 0.0);
+        double shrubsCanopyCover = getDoubleParam("shrubscanopycover", 0.0);
+        double sodGrassCanopyCover = getDoubleParam("sodgrasscanopycover", 0.0);
+        double basalCover = getDoubleParam("basalcover", 0.0);
+        double rockCover = getDoubleParam("rockcover", 0.0);
+        double litterCover = getDoubleParam("littercover", 0.0);
+        double cryptogamsCover = getDoubleParam("cryptogamscover", 0.0);
 
-            //Validations
-            //The values allowed for the field unit in the request are 1 and 2. 1 is for metric units and 2 is for English units
-            if (unit != 1 && unit != 2) {
-                LOG.log(Level.SEVERE, "RHEM-01: Invalid unit");
-                throw new ServiceException("Unit should be 1-metric or 2 - English. Digit " + unit + " is not valid.");
-            }
-            double slopeLength;
-            if (unit == 1) {
-                slopeLength = 50;
-            } else {
-                slopeLength = 164.04;
-            }
+        //Validations
+        //The values allowed for the field unit in the request are 1 and 2. 1 is for metric units and 2 is for English units
+        if (unit != 1 && unit != 2) {
+            LOG.log(Level.SEVERE, "RHEM-01: Invalid unit");
+            throw new ServiceException("Unit should be 1-metric or 2 - English. Digit " + unit + " is not valid.");
+        }
+        double slopeLength;
+        if (unit == 1) {
+            slopeLength = 50;
+        } else {
+            slopeLength = 164.04;
+        }
 
-            aoa = new AoA(aoaId, rhemSiteId, scenarioName,
-                    scenarioDescription, unit, stateId, climatestationId,
-                    soilTexture, slopeLength, slopeShape, slopeSteepness,
-                    bunchGgrassCanopyCover, forbsCanopyCover, shrubsCanopyCover,
-                    sodGrassCanopyCover, basalCover, rockCover, litterCover,
-                    cryptogamsCover, 25);
-        } catch (ServiceException ex) {
-            LOG.log(Level.SEVERE, "RHEM-01: Error in processing the request JSON.", ex);
-            throw new ServiceException("Error in processing the request JSON.", ex);
-        }
+        aoa = new AoA(aoaId, rhemSiteId, scenarioName,
+                scenarioDescription, unit, stateId, climatestationId,
+                soilTexture, slopeLength, slopeShape, slopeSteepness,
+                bunchGgrassCanopyCover, forbsCanopyCover, shrubsCanopyCover,
+                sodGrassCanopyCover, basalCover, rockCover, litterCover,
+                cryptogamsCover, 25);
     }
 
     @Override
-    public void doProcess() throws ServiceException, IOException {
+    public void doProcess() throws ServiceException {
         SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd, YYYY, hh:mm a");
         Date now = new Date();
         String today = sdf.format(now);
@@ -122,7 +124,7 @@
 
         parameter = new Parameter(aoa);
 
-        try (Connection connection = getResourceJDBC(RHEMResources.RHEM_DB);) {
+        try (Connection connection = getResourceJDBC(DBResources.CRDB);) {
             parameter.computeParameters(connection);
         } catch (ServiceException | SQLException se) {
             throw new ServiceException(se);
@@ -135,12 +137,15 @@
         rhemModel.generateParamFile(parameter);
         rhemModel.generateStormFile(cligen_db, Double.parseDouble(parameter.getKe()));
         rhemModel.generateRunFile();
-
-        runModel();
+        try {
+            runModel();
+        } catch (IOException ex) {
+            throw new ServiceException(ex);
+        }
 
         //If the run is successful then edit the summary file.
         double avgYearlyPrecip = 0;
-        try (Connection connection = getResourceJDBC(RHEMResources.RHEM_DB);
+        try (Connection connection = getResourceJDBC(DBResources.CRDB);
                 Statement statement = connection.createStatement();) {
             try (ResultSet rs = statement.executeQuery(DBQueries.RHEM01Query02(aoa.getClimateStationId()))) {
                 while (rs.next()) {

src/java/m/rhem/rhem02_getclimatestations/V1_0.java

@@ -1,7 +1,13 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
+ * $Id$
+ *
+ * This file is part of the Cloud Services Integration Platform (CSIP),
+ * a Model-as-a-Service framework, API, and application suite.
+ *
+ * 2012-2017, OMSLab, Colorado State University.
+ *
+ * OMSLab licenses this file to you under the MIT license.
+ * See the LICENSE file in the project root for more information.
  */
 package m.rhem.rhem02_getclimatestations;
 
@@ -15,7 +21,6 @@
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
-import java.util.logging.Level;
 import javax.ws.rs.Path;
 import oms3.annotations.Description;
 import oms3.annotations.Name;
@@ -23,13 +28,16 @@
 import org.codehaus.jettison.json.JSONException;
 import rhem.utils.DBQueries;
 import rhem.utils.RHEMUtils;
-import rhem.utils.RHEMResources;
+import rhem.utils.DBResources;
+import static rhem.utils.RHEMUtils.MONTH_NAMES_LIST;
 
 /**
+ * RHEM-02:Get Climate Stations
+ *
  * @version 1.0
  * @author Rumpal Sidhu
  */
-@Name("RHEM-02:Get Climate Stations")
+@Name("RHEM-02: Get Climate Stations")
 @Description("Returns a list of climate stations associated with the state "
         + "selected by the user. Information associated with each climate "
         + "station will be station name, latitude, longitude, number of "
@@ -37,26 +45,20 @@
         + "and monthly precipitation amounts (millimeters).")
 @Path("m/rhem/getclimatestations/1.0")
 @Polling(first = 10000, next = 2000)
-@Resource(from = RHEMResources.class)
+@Resource(from = DBResources.class)
 public class V1_0 extends ModelDataService {
 
     private String stateId;
     private ClimateStationStates climateStationStates;
 
-
     @Override
     public void preProcess() throws ServiceException {
-        try {
-            stateId = getStringParam("stateid");
-        } catch (ServiceException ex) {
-            throw new ServiceException("Error in processing the request JSON.", ex);
-        }
+        stateId = getStringParam("stateid");
     }
 
-
     @Override
     public void doProcess() throws ServiceException {
-        try (Connection connection = getResourceJDBC(RHEMResources.RHEM_DB);
+        try (Connection connection = getResourceJDBC(DBResources.CRDB);
                 Statement statement = connection.createStatement()) {
 
             try (ResultSet resultSet = statement.executeQuery(DBQueries.RHEM02Query01(stateId))) {
@@ -73,18 +75,9 @@
                 ArrayList<ClimateStation> climateStationsList = new ArrayList();
                 while (resultSet.next()) {
                     double[] monthlyPrecip = new double[12];
-                    monthlyPrecip[0] = resultSet.getDouble("jan_precip_mm");
-                    monthlyPrecip[1] = resultSet.getDouble("feb_precip_mm");
-                    monthlyPrecip[2] = resultSet.getDouble("mar_precip_mm");
-                    monthlyPrecip[3] = resultSet.getDouble("apr_precip_mm");
-                    monthlyPrecip[4] = resultSet.getDouble("may_precip_mm");
-                    monthlyPrecip[5] = resultSet.getDouble("jun_precip_mm");
-                    monthlyPrecip[6] = resultSet.getDouble("jul_precip_mm");
-                    monthlyPrecip[7] = resultSet.getDouble("aug_precip_mm");
-                    monthlyPrecip[8] = resultSet.getDouble("sep_precip_mm");
-                    monthlyPrecip[9] = resultSet.getDouble("oct_precip_mm");
-                    monthlyPrecip[10] = resultSet.getDouble("nov_precip_mm");
-                    monthlyPrecip[11] = resultSet.getDouble("dec_precip_mm");
+                    for (int i = 0; i< 12; i++) {
+                        monthlyPrecip[i] = resultSet.getDouble(MONTH_NAMES_LIST[i].toLowerCase().substring(0,3) + "_precip_mm");
+                    }
 
                     climateStationsList.add(new ClimateStation(
                             resultSet.getString("station_id"),
@@ -98,17 +91,13 @@
                 }
                 climateStationStates.addClimateStationsList(climateStationsList);
             }
-        } catch (ServiceException | SQLException se) {
-            LOG.log(Level.SEVERE, "RHEM-02: SQLException.", se);
-            throw new ServiceException("SQL problem.", se);
+        } catch (SQLException se) {
+            throw new ServiceException(se);
         }
     }
 
-
     @Override
-    public void postProcess() throws Exception {
-        String[] listOfMonths = {"January", "February", "March", "April", "May",
-            "June", "July", "August", "September", "October", "November", "December"};
+    public void postProcess() throws ServiceException {
         try {
             putResult("stateid", climateStationStates.getStateId(), "State abbreviation of climate station location");
             putResult("state_name", climateStationStates.getStateName(), "State name");
@@ -127,15 +116,14 @@
                 innerArray.put(JSONUtils.dataDesc("elevation_ft", climateStation.getElevation(), "Climate station elevation"));
                 innerArray.put(JSONUtils.dataDesc("avg_yearly_precip_mm", RHEMUtils.roundValues(climateStation.getAvgYearlyPrecip(), 2), "300 year average annual precipitation (mm)"));
                 for (int i = 0; i < 12; i++) {
-                    innerArray.put(JSONUtils.dataDesc(listOfMonths[i].substring(0, 3).toLowerCase() + "_precip_mm",
-                            RHEMUtils.roundValues(climateStation.getMonthlyPrecip()[i], 2), listOfMonths[i] + " estimated monthly average precipitation (mm)"));
+                    innerArray.put(JSONUtils.dataDesc(MONTH_NAMES_LIST[i].substring(0, 3).toLowerCase() + "_precip_mm",
+                            RHEMUtils.roundValues(climateStation.getMonthlyPrecip()[i], 2), MONTH_NAMES_LIST[i] + " estimated monthly average precipitation (mm)"));
                 }
                 climateStationArray.put(JSONUtils.dataDesc("climate_stations", innerArray, "Climate station attributes"));
             }
             putResult("climate_station_list", climateStationArray, "Climate Station List");
         } catch (JSONException ex) {
-            LOG.log(Level.SEVERE, "RHEM-02: Error in processing the reponse JSON.", ex);
-            throw new ServiceException("Error in processing the reponse JSON.", ex);
+            throw new ServiceException(ex);
         }
     }
 
@@ -148,7 +136,6 @@
         protected int zoom;
         protected ArrayList<ClimateStation> climateStationsList;
 
-
         public ClimateStationStates(String stateId, String stateName, double latitude,
                 double longitude, int zoom) {
             this.stateId = stateId;
@@ -158,37 +145,30 @@
             this.zoom = zoom;
         }
 
-
         public String getStateId() {
             return this.stateId;
         }
 
-
         public String getStateName() {
             return this.stateName;
         }
 
-
         public double getStateLatitude() {
             return this.latitude;
         }
 
-
         public double getStateLongitude() {
             return this.longitude;
         }
 
-
         public int getZoom() {
             return this.zoom;
         }
 
-
         public ArrayList<ClimateStation> getClimateStationsList() {
             return this.climateStationsList;
         }
 
-
         public void addClimateStationsList(ArrayList<ClimateStation> list) {
             this.climateStationsList = list;
         }
@@ -206,7 +186,6 @@
         protected double avgYearlyPrecip_mm;
         protected double[] monthlyPrecip_mm;
 
-
         public ClimateStation(String stationId, String stationName, double latitude,
                 double longitude, int yearRecorded, int elevation,
                 double avg_yearly_precip_mm, double[] monthlyPrecip_mm) {
@@ -221,42 +200,34 @@
             this.monthlyPrecip_mm = monthlyPrecip_mm;
         }
 
-
         public String getStationId() {
             return this.stationId;
         }
 
-
         public String getStationName() {
             return this.stationName;
         }
 
-
         public double getStationLatitude() {
             return this.latitude;
         }
 
-
         public double getStationLongitude() {
             return this.longitude;
         }
 
-
         public int getYearRecorded() {
             return this.yearRecorded;
         }
 
-
         public int getElevation() {
             return this.elevation_ft;
         }
 
-
         public double getAvgYearlyPrecip() {
             return this.avgYearlyPrecip_mm;
         }
 
-
         public double[] getMonthlyPrecip() {
             return this.monthlyPrecip_mm;
         }

src/java/m/rhem/rhem03_compEsd/V1_0.java

@@ -1,3 +1,14 @@
+/*
+ * $Id$
+ *
+ * This file is part of the Cloud Services Integration Platform (CSIP),
+ * a Model-as-a-Service framework, API, and application suite.
+ *
+ * 2012-2017, OMSLab, Colorado State University.
+ *
+ * OMSLab licenses this file to you under the MIT license.
+ * See the LICENSE file in the project root for more information.
+ */
 package m.rhem.rhem03_compEsd;
 
 import gisobjects.db.GISEngine;
@@ -16,7 +27,6 @@
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
-import java.util.logging.Level;
 import javax.ws.rs.Path;
 import oms3.annotations.Description;
 import oms3.annotations.Name;
@@ -24,14 +34,17 @@
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
 import rhem.utils.DBQueries;
-import rhem.utils.RHEMResources;
+import rhem.utils.DBResources;
+import static rhem.utils.DBResources.SDM_REST;
 
 /**
+ * RHEM-03: Get Soil Component, Ecological Site, Soil Component Surface Texture
+ * Class, Soil Component Slope Length and Steepness for RHEM Evaluation Area
+ *
  * @version 1.0
  * @author Rumpal Sidhu
  */
-@Name("RHEM-03: Get Soil Component, Ecological Site, "
-        + "Soil Component Surface Texture Class, "
+@Name("RHEM-03: Get Soil Component, Ecological Site, Soil Component Surface Texture Class, "
         + "Soil Component Slope Length and Steepness for RHEM Evaluation Area.")
 @Description("Get map unit, soil component and ecological site information for "
         + "RHEM evaluation site. Get surface soil texture class relevant to "
@@ -40,48 +53,40 @@
         + "component associated with a RHEM evaluation site within an AoA.")
 @Path("m/rhem/getrhemsoilcomponent/1.0")
 @Polling(first = 10000, next = 2000)
-@Resource(from = RHEMResources.class)
+@Resource(from = DBResources.class)
 public class V1_0 extends ModelDataService {
 
-    private int aoaId;
-    private int rhemSiteId;
+    private int aoaId, rhemSiteId;
     private JSONObject rhemSiteGeometryPoint;
-
-    //Result Payload
-    private ArrayList<Mapunit> mapunitList;
+    private ArrayList<Mapunit> mapunitList = new ArrayList<>();
 
     @Override
     public void preProcess() throws ServiceException {
-        mapunitList = new ArrayList<>();
-        try {
-            aoaId = getIntParam("AoAID");
-            rhemSiteId = getIntParam("rhem_site_id");
-            rhemSiteGeometryPoint = getParam("rhem_site_geometry");
-        } catch (ServiceException ex) {
-            throw new ServiceException("Error in processing the request JSON.", ex);
-        }
+        aoaId = getIntParam("AoAID");
+        rhemSiteId = getIntParam("rhem_site_id");
+        rhemSiteGeometryPoint = getParam("rhem_site_geometry");
     }
 
     @Override
     public void doProcess() throws ServiceException {
-        try (Connection sdmConnection = getResourceJDBC(RHEMResources.SDM_DB);
-                Connection esdConnection = getResourceJDBC(RHEMResources.ESD_DB);
-                Connection rhemConnection = getResourceJDBC(RHEMResources.RHEM_DB);) {
-            getMapunitValues(sdmConnection);
-            getComponentValues(sdmConnection, esdConnection);
-            getSurfaceTextureClass(sdmConnection, rhemConnection);
-        } catch (ServiceException | SQLException se) {
-            throw new ServiceException("SQL problem.", se);
+        try (Connection sdmConnection = getResourceJDBC(SDM_REST);
+                Connection crdbConnection = getResourceJDBC(DBResources.CRDB);) {
+            GISEngine gisEngine = createGISEngine(sdmConnection);
+            GISObject geometry = GISObjectFactory.createGISObject(rhemSiteGeometryPoint, gisEngine);
+            getMapunitValues(sdmConnection, geometry);
+            try (Connection esdConnection = getResourceJDBC(DBResources.ESD);) {
+                getComponentValues(sdmConnection, esdConnection);
+            }
+            getSurfaceTextureClass(sdmConnection, crdbConnection);
+            getSurfaceTextureClass(sdmConnection, crdbConnection);
+        } catch (ServiceException | SQLException | GISObjectException | IOException | JSONException se) {
+            throw new ServiceException(se);
         }
     }
 
-    private void getMapunitValues(Connection sdmConnection) throws ServiceException {
+    private void getMapunitValues(Connection sdmConnection, GISObject geometry) throws SQLException {
         try (Statement statement = sdmConnection.createStatement();) {
-            GISEngine gisEngine = createGISEngine(sdmConnection);
-            GISObject geometry = GISObjectFactory.createGISObject(rhemSiteGeometryPoint, gisEngine);
-            String mukey = null;
-            String musym = null;
-            String muname = null;
+            String mukey = null, musym = null, muname = null;
 
             try (ResultSet resultSet = statement.executeQuery(DBQueries.RHEM03Query01(geometry))) {
                 while (resultSet.next()) {
@@ -104,13 +109,10 @@
                 }
                 mapunitList.add(new Mapunit(musym, muname, componentList));
             }
-        } catch (SQLException | GISObjectException | JSONException | IOException ex) {
-            LOG.log(Level.SEVERE, "RHEM-03: SQLException.", ex);
-            throw new ServiceException("SQL problem.", ex);
         }
     }
 
-    private void getComponentValues(Connection connection, Connection esdConnection) throws ServiceException {
+    private void getComponentValues(Connection connection, Connection esdConnection) throws SQLException {
         try (Statement statement = connection.createStatement();) {
             for (Mapunit mapunit : mapunitList) {
                 for (Component component : mapunit.getComponentList()) {
@@ -134,13 +136,10 @@
                     component.setEcoSiteList(ecoList);
                 }
             }
-        } catch (SQLException ex) {
-            LOG.log(Level.SEVERE, "RHEM-03: SQLException.", ex);
-            throw new ServiceException("SQL problem.", ex);
         }
     }
 
-    private void getSurfaceTextureClass(Connection connection, Connection rhemConnection) throws ServiceException {
+    private void getSurfaceTextureClass(Connection connection, Connection rhemConnection) throws SQLException {
         try (Statement statement = connection.createStatement();) {
             for (Mapunit mapunit : this.mapunitList) {
                 for (Component component : mapunit.getComponentList()) {
@@ -163,14 +162,11 @@
                     component.setSurfaceTextureList(surfaceTextureList);
                 }
             }
-        } catch (SQLException ex) {
-            LOG.log(Level.SEVERE, "RHEM-03: SQLException.", ex);
-            throw new ServiceException("SQL problem.", ex);
         }
     }
 
     @Override
-    public void postProcess() throws Exception {
+    public void postProcess() throws ServiceException {
         try {
             putResult("AoAID", this.aoaId, "Area of Analysis Identifier");
             putResult("rhem_site_id", this.rhemSiteId, "RHEM Evaluation Site Identifier");
@@ -217,8 +213,7 @@
             }
             putResult("mapunit_list", mapUnitArray, "Mapunit List");
         } catch (JSONException ex) {
-            LOG.log(Level.SEVERE, "RHEM-03: Error in processing the reponse JSON.", ex);
-            throw new ServiceException("Error in processing the reponse JSON.", ex);
+            throw new ServiceException(ex);
         }
     }
 

src/java/m/rhem/rhem04_surfacetextureclasses/V1_0.java

@@ -1,7 +1,13 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
+ * $Id$
+ *
+ * This file is part of the Cloud Services Integration Platform (CSIP),
+ * a Model-as-a-Service framework, API, and application suite.
+ *
+ * 2012-2017, OMSLab, Colorado State University.
+ *
+ * OMSLab licenses this file to you under the MIT license.
+ * See the LICENSE file in the project root for more information.
  */
 package m.rhem.rhem04_surfacetextureclasses;
 
@@ -16,17 +22,18 @@
 import java.sql.Statement;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.logging.Level;
 import javax.ws.rs.Path;
 import oms3.annotations.Description;
 import oms3.annotations.Name;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import rhem.utils.DBQueries;
-import static rhem.utils.RHEMResources.RHEM_DB;
-import rhem.utils.RHEMResources;
+import rhem.utils.DBResources;
+import static rhem.utils.DBResources.CRDB;
 
 /**
+ * RHEM-04: Get RHEM Surface Texture Classes Choice List
+ *
  * @version 1.0
  * @author rumpal
  */
@@ -34,14 +41,14 @@
 @Description("Get and return a list of RHEM surface soil texture classes.")
 @Path("m/rhem/getsurftexclasses/1.0")
 @Polling(first = 10000, next = 2000)
-@Resource(from = RHEMResources.class)
+@Resource(from = DBResources.class)
 public class V1_0 extends ModelDataService {
 
     private List<ChoiceList> choiceList = new ArrayList<>();
 
     @Override
     public void doProcess() throws ServiceException, ClassNotFoundException {
-        try (Connection connection = getResourceJDBC(RHEM_DB);
+        try (Connection connection = getResourceJDBC(CRDB);
                 Statement statement = connection.createStatement();) {
             try (ResultSet resultSet = statement.executeQuery(DBQueries.RHEM04Query01())) {
                 while (resultSet.next()) {
@@ -50,18 +57,16 @@
                     int sequence = id;
                     String dataTextEntry = resultSet.getString("text_abreviation");
                     String label = resultSet.getString("text_label");
-                    choiceList.add(new ChoiceList(id, kind, sequence,
-                            dataTextEntry, label));
+                    choiceList.add(new ChoiceList(id, kind, sequence, dataTextEntry, label));
                 }
             }
         } catch (SQLException se) {
-            LOG.log(Level.SEVERE, "RHEM-04: SQLException.", se);
-            throw new ServiceException("SQL problem.", se);
+            throw new ServiceException(se);
         }
     }
 
     @Override
-    public void postProcess() throws Exception {
+    public void postProcess() throws ServiceException {
         try {
             JSONArray resultArr = new JSONArray();
             for (ChoiceList list : choiceList) {
@@ -75,8 +80,7 @@
             }
             putResult("choice_lists", resultArr, "List");
         } catch (JSONException ex) {
-            LOG.log(Level.SEVERE, "RHEM-04: Error in processing the response JSON.", ex);
-            throw new ServiceException("Error in processing the response JSON.", ex);
+            throw new ServiceException(ex);
         }
     }
 

src/java/m/rhem/rhem05_slopeShapes/V1_0.java

@@ -1,7 +1,13 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
+ * $Id$
+ *
+ * This file is part of the Cloud Services Integration Platform (CSIP),
+ * a Model-as-a-Service framework, API, and application suite.
+ *
+ * 2012-2017, OMSLab, Colorado State University.
+ *
+ * OMSLab licenses this file to you under the MIT license.
+ * See the LICENSE file in the project root for more information.
  */
 package m.rhem.rhem05_slopeShapes;
 
@@ -15,17 +21,18 @@
 import java.sql.SQLException;
 import java.sql.Statement;
 import java.util.ArrayList;
-import java.util.logging.Level;
 import javax.ws.rs.Path;
 import oms3.annotations.Description;
 import oms3.annotations.Name;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import rhem.utils.DBQueries;
-import static rhem.utils.RHEMResources.RHEM_DB;
-import rhem.utils.RHEMResources;
+import rhem.utils.DBResources;
+import static rhem.utils.DBResources.CRDB;
 
 /**
+ * RHEM-05: Get RHEM Slope Shape Choice List
+ *
  * @version 1.0
  * @author rumpal
  */
@@ -33,15 +40,15 @@
 @Description("Get and return a list of RHEM slope shapes.")
 @Path("m/rhem/getslopeshapes/1.0")
 @Polling(first = 10000, next = 2000)
-@Resource(from = RHEMResources.class)
+@Resource(from = DBResources.class)
 public class V1_0 extends ModelDataService {
 
-    private ArrayList<ChoiceList> choiceList;
+    private ArrayList<ChoiceList> choiceList = new ArrayList<>();
 
     @Override
     public void doProcess() throws ServiceException {
         choiceList = new ArrayList<>();
-        try (Connection conn = getResourceJDBC(RHEM_DB);
+        try (Connection conn = getResourceJDBC(CRDB);
                 Statement statement = conn.createStatement();) {
             try (ResultSet resultSet = statement.executeQuery(DBQueries.RHEM05Query01())) {
                 while (resultSet.next()) {
@@ -53,12 +60,12 @@
                 }
             }
         } catch (SQLException se) {
-            throw new ServiceException("SQL Problem.", se);
+            throw new ServiceException(se);
         }
     }
 
     @Override
-    public void postProcess() throws Exception {
+    public void postProcess() throws ServiceException {
         try {
             JSONArray resultArr = new JSONArray();
             for (ChoiceList list : choiceList) {
@@ -71,8 +78,7 @@
             }
             putResult("choice_lists", resultArr, "Slope Shape Choice List");
         } catch (JSONException ex) {
-            LOG.log(Level.SEVERE, "RHEM-05: Error in processing the reponse JSON.", ex);
-            throw new ServiceException("Error in processing the reponse JSON.", ex);
+            throw new ServiceException(ex);
         }
     }
 

src/java/m/rhem/rhem06_riskassessment/V1_0.java

@@ -1,7 +1,13 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
+ * $Id$
+ *
+ * This file is part of the Cloud Services Integration Platform (CSIP),
+ * a Model-as-a-Service framework, API, and application suite.
+ *
+ * 2012-2017, OMSLab, Colorado State University.
+ *
+ * OMSLab licenses this file to you under the MIT license.
+ * See the LICENSE file in the project root for more information.
  */
 package m.rhem.rhem06_riskassessment;
 
@@ -19,29 +25,30 @@
 import java.io.PrintWriter;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.logging.Level;
 import javax.ws.rs.Path;
 import oms3.annotations.Description;
 import oms3.annotations.Name;
 import rhem.utils.LinearInterpolate;
-import rhem.utils.RHEMResources;
-import static rhem.utils.RHEMResources.RHEM_RA_EXE;
+import static rhem.utils.DBResources.RHEM_RA_EXE;
+import rhem.utils.DBResources;
 
 /**
+ * RHEM-06: Risk Assessment
  *
  * @author rumpal
+ * @version 1.0
  */
 @Name("RHEM-06: Risk Assessment")
 @Description("This service runs risk assessment with a maximum of five detailed output files.")
 @Path("m/rhem/riskassessment/1.0")
 @Polling(first = 10000, next = 2000)
 @Resource(file = "*.out *.run", type = OUTPUT)
-@Resource(from = RHEMResources.class)
+@Resource(from = DBResources.class)
 public class V1_0 extends ModelDataService {
 
     private String baseLineScenarioFileName;
-    private List<String> raScenarioFilenameList;
-    private ArrayList<String> scenarioNames;
+    private List<String> raScenarioFilenameList = new ArrayList<>();
+    private ArrayList<String> scenarioNames = new ArrayList<>();
 
     @Override
     public void preProcess() throws ServiceException {
@@ -49,7 +56,6 @@
         if (numberOfFiles > 5) {
             throw new ServiceException("The risk assessment can be performed with a maximum of five scenarios.");
         }
-        raScenarioFilenameList = new ArrayList();
         for (int i = 1; i < numberOfFiles; i++) {
             raScenarioFilenameList.add(getStringParam("scenario_" + i + "_filename"));
         }
@@ -57,10 +63,14 @@
     }
 
     @Override
-    public void doProcess() throws ServiceException, IOException {
+    public void doProcess() throws ServiceException {
         writeOutFilesToWorkspace();
         generateRARunFile();
-        runRiskAssessment();
+        try {
+            runRiskAssessment();
+        } catch (IOException ex) {
+            throw new ServiceException(ex);
+        }
 
         double[][] outRAarray = readRiskAssessmentOutFile();
         ArrayList<ArrayList> interpolatedResultsArray = calculateReturnPeriods(outRAarray);
@@ -82,8 +92,7 @@
             }
             writer.close();
         } catch (FileNotFoundException ex) {
-            LOG.log(Level.SEVERE, "RHEM-06: Problem in generating run file.", ex);
-            throw new ServiceException("Problem in generating run file.", ex);
+            throw new ServiceException(ex);
         }
     }
 
@@ -97,7 +106,6 @@
     }
 
     private double[][] readRiskAssessmentOutFile() throws ServiceException {
-        scenarioNames = new ArrayList<>();
         double outputRAArray[][] = new double[12][raScenarioFilenameList.size() + 2];
         int count = -1;
         boolean check = false;
@@ -132,7 +140,7 @@
 
             }
         } catch (IOException exception) {
-            throw new ServiceException("Problem in reading the risk assessment out file.", exception);
+            throw new ServiceException(exception);
         }
         return outputRAArray;
     }
@@ -233,7 +241,7 @@
             }
             writer.close();
         } catch (FileNotFoundException ex) {
-            throw new ServiceException("Problem in generating the parameter file.", ex);
+            throw new ServiceException(ex);
         }
 
     }

src/java/m/rhem/rhem07_editparfile/V1_0.java

@@ -1,7 +1,13 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
+ * $Id$
+ *
+ * This file is part of the Cloud Services Integration Platform (CSIP),
+ * a Model-as-a-Service framework, API, and application suite.
+ *
+ * 2012-2017, OMSLab, Colorado State University.
+ *
+ * OMSLab licenses this file to you under the MIT license.
+ * See the LICENSE file in the project root for more information.
  */
 package m.rhem.rhem07_editparfile;
 
@@ -11,7 +17,6 @@
 import csip.ServiceException;
 import csip.annotations.Polling;
 import csip.annotations.Resource;
-import static csip.annotations.ResourceType.EXECUTABLE;
 import java.io.File;
 import java.io.IOException;
 import java.sql.Connection;
@@ -26,19 +31,21 @@
 import oms3.annotations.Description;
 import oms3.annotations.Name;
 import rhem.utils.DBQueries;
-import rhem.utils.RHEMResources;
-import static rhem.utils.RHEMResources.RHEM_EXE;
+import static rhem.utils.DBResources.RHEM_EXE;
+import rhem.utils.DBResources;
 
 /**
+ * RHEM-07: Run model with edited parameter file
+ *
  * @version 1.0
  * @author Rumpal Sidhu
  */
-@Name("RHEM-07: Run model with edited paramater file")
+@Name("RHEM-07: Run model with edited parameter file")
 @Description("Run the RHEM model with parameter file as input.")
 @Path("m/rhem/editparfile/1.0")
 @Polling(first = 5000, next = 2000)
-@Resource(from = RHEMResources.class)
-//@Resource(file = "*.par *.pre *.sum *.out *.run", type = OUTPUT)
+@Resource(from = DBResources.class)
+
 public class V1_0 extends ModelDataService {
 
     private String cligen_db = Config.getString("rhem.cligen_db", "file:/Users/rumpal/Documents/Work/csipDocuments/RHEM/cligen");
@@ -58,46 +65,42 @@
 
     @Override
     public void preProcess() throws ServiceException {
-        try {
-            aoaId = getIntParam("AoAID", 0);
-            rhemSiteId = getIntParam("rhem_site_id", 0);
-            scenarioName = getStringParam("scenarioname");
-            stateId = getStringParam("stateid");
-            climatestationId = getStringParam("climatestationid");
+        aoaId = getIntParam("AoAID", 0);
+        rhemSiteId = getIntParam("rhem_site_id", 0);
+        scenarioName = getStringParam("scenarioname");
+        stateId = getStringParam("stateid");
+        climatestationId = getStringParam("climatestationid");
 
-            String diams = getStringParam("DIAMS");
-            String density = getStringParam("DENSITY");
+        String diams = getStringParam("DIAMS");
+        String density = getStringParam("DENSITY");
 
-            String len = getStringParam("LEN");
-            String chezy = getStringParam("CHEZY");
-            String rchezy = getStringParam("RCHEZY");
-            String sl = getStringParam("SL");
-            String sx = getStringParam("SX");
-            String cv = getStringParam("CV");
-            String sat = getStringParam("SAT");
-            String kss = getStringParam("KSS");
-            String komega = getStringParam("KOMEGA");
-            String kcm = getStringParam("KCM");
-            String ke = getStringParam("KE");
-            String adf = getStringParam("ADF");
-            String alf = getStringParam("ALF");
-            String bare = getStringParam("BARE");
+        String len = getStringParam("LEN");
+        String chezy = getStringParam("CHEZY");
+        String rchezy = getStringParam("RCHEZY");
+        String sl = getStringParam("SL");
+        String sx = getStringParam("SX");
+        String cv = getStringParam("CV");
+        String sat = getStringParam("SAT");
+        String kss = getStringParam("KSS");
+        String komega = getStringParam("KOMEGA");
+        String kcm = getStringParam("KCM");
+        String ke = getStringParam("KE");
+        String adf = getStringParam("ADF");
+        String alf = getStringParam("ALF");
+        String bare = getStringParam("BARE");
 
-            String g = getStringParam("G");
-            String dist = getStringParam("DIST");
-            String por = getStringParam("POR");
-            String fract = getStringParam("FRACT");
+        String g = getStringParam("G");
+        String dist = getStringParam("DIST");
+        String por = getStringParam("POR");
+        String fract = getStringParam("FRACT");
 
-            parameter = new Parameter(diams, density, len, chezy, rchezy,
-                    sl, sx, cv, sat, kss, komega, kcm, ke, adf, alf, bare, g,
-                    dist, por, fract);
-        } catch (ServiceException ex) {
-            throw new ServiceException("Error in processing the request JSON.", ex);
-        }
+        parameter = new Parameter(diams, density, len, chezy, rchezy,
+                sl, sx, cv, sat, kss, komega, kcm, ke, adf, alf, bare, g,
+                dist, por, fract);
     }
 
     @Override
-    public void doProcess() throws ServiceException, IOException {
+    public void doProcess() throws ServiceException {
 
         SimpleDateFormat sdf = new SimpleDateFormat("MMMM dd, YYYY, hh:mm a");
         Date now = new Date();
@@ -120,11 +123,15 @@
         rhemModel.generateParamFile(parameter);
         rhemModel.generateStormFile(cligen_db, Double.parseDouble(parameter.getKe()));
         rhemModel.generateRunFile();
-        runModel();
+        try {
+            runModel();
+        } catch (IOException ex) {
+            throw new ServiceException(ex);
+        }
 
         //If the run is successful then edit the summary file.
         double avgYearlyPrecip = 0;
-        try (Connection connection = getResourceJDBC(RHEMResources.RHEM_DB);
+        try (Connection connection = getResourceJDBC(DBResources.CRDB);
                 Statement statement = connection.createStatement();) {
             try (ResultSet rs = statement.executeQuery(DBQueries.RHEM07Query01(climatestationId))) {
                 while (rs.next()) {

src/java/rhem/utils/DBQueries.java

@@ -1,7 +1,13 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
+ * $Id$
+ *
+ * This file is part of the Cloud Services Integration Platform (CSIP),
+ * a Model-as-a-Service framework, API, and application suite.
+ *
+ * 2012-2017, OMSLab, Colorado State University.
+ *
+ * OMSLab licenses this file to you under the MIT license.
+ * See the LICENSE file in the project root for more information.
  */
 package rhem.utils;
 

src/java/rhem/utils/LinearInterpolate.java

@@ -1,7 +1,13 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
+ * $Id$
+ *
+ * This file is part of the Cloud Services Integration Platform (CSIP),
+ * a Model-as-a-Service framework, API, and application suite.
+ *
+ * 2012-2017, OMSLab, Colorado State University.
+ *
+ * OMSLab licenses this file to you under the MIT license.
+ * See the LICENSE file in the project root for more information.
  */
 package rhem.utils;
 

src/java/rhem/utils/RHEMUtils.java

@@ -1,7 +1,13 @@
 /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
+ * $Id$
+ *
+ * This file is part of the Cloud Services Integration Platform (CSIP),
+ * a Model-as-a-Service framework, API, and application suite.
+ *
+ * 2012-2017, OMSLab, Colorado State University.
+ *
+ * OMSLab licenses this file to you under the MIT license.
+ * See the LICENSE file in the project root for more information.
  */
 package rhem.utils;
 
@@ -10,6 +16,9 @@
  * @author rumpal
  */
 public class RHEMUtils {
+    
+    public static final String[] MONTH_NAMES_LIST = {"January", "February", "March", "April", "May",
+            "June", "July", "August", "September", "October", "November", "December"};
 
     //Round the value of a float or double
     public static double roundValues(double value, int places) {