Displaying differences for changeset
 
display as  

nbproject/build-impl.xml

@@ -1008,14 +1008,12 @@
     <target depends="init" if="dist.ear.dir" name="library-inclusion-in-manifest">
         <copyfiles files="${reference.csip-core-1.jar}" 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.sqljdbc42.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>
     <target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir">
         <copyfiles files="${reference.csip-core-1.jar}" 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.sqljdbc42.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/build-impl.xml~

@@ -1008,16 +1008,14 @@
     <target depends="init" if="dist.ear.dir" name="library-inclusion-in-manifest">
         <copyfiles files="${reference.csip-core-1.jar}" 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.sqljdbc4.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
-        <copyfiles files="${file.reference.postgresql-9.0-801.jdbc4.jar}" iftldtodir="${build.web.dir}/WEB-INF" todir="${dist.ear.dir}/lib"/>
+        <copyfiles files="${file.reference.sqljdbc42.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>
     <target depends="init" name="library-inclusion-in-archive" unless="dist.ear.dir">
         <copyfiles files="${reference.csip-core-1.jar}" 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.sqljdbc4.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
-        <copyfiles files="${file.reference.postgresql-9.0-801.jdbc4.jar}" todir="${build.web.dir}/WEB-INF/lib"/>
+        <copyfiles files="${file.reference.sqljdbc42.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/genfiles.properties

@@ -1,25 +1,25 @@
-<<<<<<< local
-build.xml.data.CRC32=b029a393
-build.xml.script.CRC32=388e9258
-build.xml.stylesheet.CRC32=651128d4@1.65.1.1
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=a8f467a9
-nbproject/build-impl.xml.script.CRC32=fe296715
-nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.68.1.1
-nbproject/rest-build.xml.data.CRC32=bff4a8fe
-nbproject/rest-build.xml.script.CRC32=4734534b
-nbproject/rest-build.xml.stylesheet.CRC32=5f13befe@1.21
-=======
-build.xml.data.CRC32=b029a393
-build.xml.script.CRC32=388e9258
-build.xml.stylesheet.CRC32=651128d4@1.65.1.1
-# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
-# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=441bc854
-nbproject/build-impl.xml.script.CRC32=0c811e84
-nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.75.1.1
-nbproject/rest-build.xml.data.CRC32=bff4a8fe
-nbproject/rest-build.xml.script.CRC32=4734534b
-nbproject/rest-build.xml.stylesheet.CRC32=5f13befe@1.21
->>>>>>> other
+<<<<<<< local
+build.xml.data.CRC32=b029a393
+build.xml.script.CRC32=388e9258
+build.xml.stylesheet.CRC32=651128d4@1.65.1.1
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=a8f467a9
+nbproject/build-impl.xml.script.CRC32=fe296715
+nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.68.1.1
+nbproject/rest-build.xml.data.CRC32=bff4a8fe
+nbproject/rest-build.xml.script.CRC32=4734534b
+nbproject/rest-build.xml.stylesheet.CRC32=5f13befe@1.21
+=======
+build.xml.data.CRC32=b029a393
+build.xml.script.CRC32=388e9258
+build.xml.stylesheet.CRC32=651128d4@1.65.1.1
+# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
+# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
+nbproject/build-impl.xml.data.CRC32=177632b5
+nbproject/build-impl.xml.script.CRC32=06e47a7d
+nbproject/build-impl.xml.stylesheet.CRC32=99ea4b56@1.75.1.1
+nbproject/rest-build.xml.data.CRC32=bff4a8fe
+nbproject/rest-build.xml.script.CRC32=4734534b
+nbproject/rest-build.xml.stylesheet.CRC32=5f13befe@1.21
+>>>>>>> other

nbproject/project.properties

@@ -1,5 +1,3 @@
-#Wed Mar 30 10:27:03 MDT 2016
-file.reference.sqljdbc42.jar=../csip-core/lib/csip-jersey-2.16/sqljdbc42.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-storeconfig.jar:${j2ee.server.home}/lib/catalina-tribes.jar:${j2ee.server.home}/lib/catalina.jar:${j2ee.server.home}/lib/ecj-4.4.1.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/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-jni.jar:${j2ee.server.home}/lib/tomcat-spdy.jar:${j2ee.server.home}/lib/tomcat-util-scan.jar:${j2ee.server.home}/lib/tomcat-util.jar:${j2ee.server.home}/lib/tomcat-websocket.jar:${j2ee.server.home}/lib/websocket-api.jar
 javadoc.splitindex=true
 lib.dir=${web.docbase.dir}/WEB-INF/lib
@@ -53,8 +51,7 @@
 javadoc.additionalparam=
 javac.classpath=\
     ${reference.csip-core-1.jar}:\
-    ${libs.CSIP-Jersey-2.16.classpath}:\
-    ${file.reference.sqljdbc42.jar}
+    ${libs.CSIP-Jersey-2.16.classpath}
 javadoc.noindex=false
 webinf.dir=web/WEB-INF
 annotation.processing.enabled.in.editor=true

nbproject/project.xml

@@ -19,10 +19,6 @@
                     <file>${libs.CSIP-Jersey-2.16.classpath}</file>
                     <path-in-war>WEB-INF/lib</path-in-war>
                 </library>
-                <library dirs="200">
-                    <file>${file.reference.sqljdbc42.jar}</file>
-                    <path-in-war>WEB-INF/lib</path-in-war>
-                </library>
             </web-module-libraries>
             <web-module-additional-libraries/>
             <source-roots>

src/java/m/wqm/ApplicationConfig.java

@@ -69,7 +69,6 @@
         resources.add(m.wqm.ipmscoresfull.V1_0.class);
         resources.add(m.wqm.ipmscoresfull.V1_0_1.class);
         resources.add(m.wqm.nutappmgtscores.V1_0.class);
-        resources.add(m.wqm.nutmitigationtech.V1_0.class);
         resources.add(m.wqm.nutrientslpsrp.V1_0.class);
         resources.add(m.wqm.nuttechscores.V1_0.class);
         resources.add(m.wqm.pesthazrating.V1_0.class);
@@ -87,7 +86,6 @@
         resources.add(m.wqm.scpestslp.V1_0.class);
         resources.add(m.wqm.scsednutsrp.V1_0.class);
         resources.add(m.wqm.sednutpractscores.V1_0.class);
-        resources.add(m.wqm.sednutpractscoresfull.V1_0.class);
         resources.add(m.wqm.soilpestlosspot.V1_0.class);
         resources.add(m.wqm.thresholdscores.V1_0.class);
         resources.add(m.wqm.wqmsoilattributes.V1_0.class);

src/java/m/wqm/pestipmscoresfull/V1_0.java

@@ -1,4 +1,3 @@
-
 /**
  * @author anvesh
  */
@@ -7,6 +6,7 @@
 import csip.ModelDataService;
 import static csip.ModelDataService.EXEC_OK;
 import csip.ServiceException;
+import csip.annotations.Resource;
 import java.util.ArrayList;
 import javax.ws.rs.Path;
 import oms3.annotations.Description;
@@ -17,11 +17,15 @@
 import java.util.Map;
 import java.sql.*;
 import java.util.concurrent.*;
+import java.util.logging.Level;
 import org.codehaus.jettison.json.JSONException;
+import wqm.utils.DBResources;
+import static wqm.utils.DBResources.WQM_ID;
 
 @Name("WQM-26: Pesticide Practice Scores ")
 @Description("This service returns all rows and columns from the wqm_ipm_practice_scores table.")
 @Path("m/pestipmscoresfull/1.0")
+@Resource(from = DBResources.class)
 
 public class V1_0 extends ModelDataService {
 
@@ -33,51 +37,32 @@
     String practice_variant;
     String wqm_concern;
 
- 
-    ArrayList<V1_0.Result1> result1;
-    String errorMessage = "";
+    ArrayList<Result1> result1 = new ArrayList<>();
 
     @Override
-    // reading the inputs from the json file into input object and placing it in the arraylist
-    protected void preProcess() throws ServiceException, JSONException {
+    protected void doProcess() throws Exception {
+        try (Connection conn = getResourceJDBC(WQM_ID);
+                Statement statement = conn.createStatement()) {
 
-        // No pre-processing required, as we don't expect to find anything useful in the Json   
-    }
+            String query = "SELECT * FROM wqm_ipm_practice_scores"; // We need to return the entire table, so we use the not standard SELECT * 
+            try (ResultSet results = statement.executeQuery(query)) {
+                while (results.next()) {
+                    ipm_practice_score_id = results.getInt("ipm_practice_score_id");
+                    practice_id = results.getInt("practice_id");
+                    ipm_practice_score = results.getInt("ipm_practice_score");
+                    practice_code = results.getString("practice_code");
+                    ipm_practice_name = results.getString("ipm_practice_name");
+                    practice_variant = results.getString("practice_variant");
+                    wqm_concern = results.getString("wqm_concern");
 
-    @Override
-    protected String process() throws Exception {
-        try {
-            Connection conn = wqm.utils.WQMTools.getConnection("wqm", LOG);
-            Statement statement = conn.createStatement();
-            result1 = new ArrayList<>();  // store the result as objects
+                    result1.add(new Result1(ipm_practice_score_id, practice_id, ipm_practice_score, practice_code, ipm_practice_name, practice_variant, wqm_concern));
 
-            conn.setAutoCommit(false);
-            String query = "SELECT * FROM wqm_ipm_practice_scores"; // We need to return the entire table, so we use the not standard SELECT * 
-            ResultSet results = statement.executeQuery(query);
-            while (results.next()) {
-                ipm_practice_score_id = results.getInt("ipm_practice_score_id");
-                practice_id = results.getInt("practice_id");
-                ipm_practice_score = results.getInt("ipm_practice_score");
-                practice_code = results.getString("practice_code");
-                ipm_practice_name = results.getString("ipm_practice_name");
-                practice_variant = results.getString("practice_variant");
-                wqm_concern = results.getString("wqm_concern");
-
-
-                result1.add(new Result1(ipm_practice_score_id, practice_id, ipm_practice_score, practice_code,ipm_practice_name,practice_variant, wqm_concern));
-
+                }
             }
 
         } catch (SQLException se) {
-            errorMessage = "Did not open database for WQM-26!";
-            LOG.info(errorMessage);
-            LOG.info(se.getMessage());
-        }
-
-        if (errorMessage.isEmpty()) {
-            return EXEC_OK;
-        } else {
-            return errorMessage;
+            LOG.log(Level.SEVERE, "Did not open database for WQM-24!", se);
+            throw new ServiceException("SQL problem", se);
         }
 
     }
@@ -110,24 +95,21 @@
         String practice_variant;
         String wqm_concern;
 
-
-
         public Result1(
-            int ipm_practice_score_id,
-            int practice_id,
-            int ipm_practice_score,
-            String practice_code,
-            String ipm_practice_name,
-            String practice_variant,
-            String wqm_concern) {
-                this.ipm_practice_score_id = ipm_practice_score_id;
-                this.practice_id = practice_id;
-                this.ipm_practice_score = ipm_practice_score;
-                this.practice_code = practice_code;
-                this.ipm_practice_name = ipm_practice_name;
-                this.practice_variant = practice_variant;
-                this.wqm_concern = wqm_concern;
-
+                int ipm_practice_score_id,
+                int practice_id,
+                int ipm_practice_score,
+                String practice_code,
+                String ipm_practice_name,
+                String practice_variant,
+                String wqm_concern) {
+            this.ipm_practice_score_id = ipm_practice_score_id;
+            this.practice_id = practice_id;
+            this.ipm_practice_score = ipm_practice_score;
+            this.practice_code = practice_code;
+            this.ipm_practice_name = ipm_practice_name;
+            this.practice_variant = practice_variant;
+            this.wqm_concern = wqm_concern;
 
         }
     }

src/java/m/wqm/pestlosspot/V1_0.java

@@ -1,6 +1,7 @@
 package m.wqm.pestlosspot;
 
 import csip.ModelDataService;
+import csip.annotations.Resource;
 import csip.utils.JSONUtils;
 import java.sql.Connection;
 import java.sql.ResultSet;
@@ -14,6 +15,7 @@
 import oms3.annotations.Name;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONObject;
+import wqm.utils.DBResources;
 import static wqm.utils.DBResources.WQM_ID;
 
 /**
@@ -25,6 +27,8 @@
 @Name("WQM-04: Pesticide Attributes and Loss Potentials (WQMPestLossPot)")
 @Description("The service consumes a request payload of one or more pesticide application operations from a farm crop rotation for an area of analysis, get attributes from the WQM pesticide table for each instance of pesticide active ingredient applied. The pesticide active ingredient attributes will be used later in WQM to compute hazard ratings. The service computes loss potentials for pesticide leaching, solution runoff, and adsorbed runoff also to be used later for computing soil/pesticide interaction ratings.")
 @Path("m/pestlosspot/1.0")
+@Resource(from = DBResources.class)
+
 
 public class V1_0 extends ModelDataService {
 

src/java/m/wqm/pestmitgntechsfull/V1_0.java

@@ -1,27 +1,26 @@
-
 /**
  * @author anvesh
  */
 package m.wqm.pestmitgntechsfull;
 
 import csip.ModelDataService;
-import static csip.ModelDataService.EXEC_OK;
 import csip.ServiceException;
+import csip.annotations.Resource;
 import java.util.ArrayList;
 import javax.ws.rs.Path;
 import oms3.annotations.Description;
 import oms3.annotations.Name;
 import org.codehaus.jettison.json.JSONArray;
-import org.codehaus.jettison.json.JSONObject;
 import csip.utils.JSONUtils;
-import java.util.Map;
 import java.sql.*;
-import java.util.concurrent.*;
-import org.codehaus.jettison.json.JSONException;
+import java.util.logging.Level;
+import wqm.utils.DBResources;
+import static wqm.utils.DBResources.WQM_ID;
 
 @Name("WQM-25: Pesticide Migration Techniques")
 @Description("This service returns all rows and columns from the wqm_ipm_technique_scores table.")
 @Path("m/pestmigtechsfull/1.0")
+@Resource(from = DBResources.class)
 
 public class V1_0 extends ModelDataService {
 
@@ -31,49 +30,27 @@
     String ipm_technique_name;
     String wqm_concern;
 
- 
-    ArrayList<V1_0.Result1> result1;
-    String errorMessage = "";
+    ArrayList<Result1> result1 = new ArrayList<>();
 
     @Override
-    // reading the inputs from the json file into input object and placing it in the arraylist
-    protected void preProcess() throws ServiceException, JSONException {
+    protected void doProcess() throws Exception {
+        try (Connection conn = getResourceJDBC(WQM_ID);
+                Statement statement = conn.createStatement()) {
+            String query = "SELECT * FROM wqm_ipm_technique_scores"; // We need to return the entire table, so we use the not standard SELECT * 
+            try (ResultSet results = statement.executeQuery(query)) {
+                while (results.next()) {
+                    ipm_technique_score_id = results.getInt("ipm_technique_score_id");
+                    ipm_technique_id = results.getInt("ipm_technique_id");
+                    ipm_technique_score = results.getInt("ipm_technique_score");
+                    ipm_technique_name = results.getString("ipm_technique_name");
+                    wqm_concern = results.getString("wqm_concern");
 
-        // No pre-processing required, as we don't expect to find anything useful in the Json   
-    }
-
-    @Override
-    protected String process() throws Exception {
-        try {
-            Connection conn = wqm.utils.WQMTools.getConnection("wqm", LOG);
-            Statement statement = conn.createStatement();
-            result1 = new ArrayList<>();  // store the result as objects
-
-            conn.setAutoCommit(false);
-            String query = "SELECT * FROM wqm_ipm_technique_scores"; // We need to return the entire table, so we use the not standard SELECT * 
-            ResultSet results = statement.executeQuery(query);
-            while (results.next()) {
-                ipm_technique_score_id = results.getInt("ipm_technique_score_id");
-                ipm_technique_id = results.getInt("ipm_technique_id");
-                ipm_technique_score = results.getInt("ipm_technique_score");
-                ipm_technique_name = results.getString("ipm_technique_name");
-                wqm_concern = results.getString("wqm_concern");
-
-
-                result1.add(new Result1(ipm_technique_score_id, ipm_technique_id, ipm_technique_score, ipm_technique_name, wqm_concern));
-
+                    result1.add(new Result1(ipm_technique_score_id, ipm_technique_id, ipm_technique_score, ipm_technique_name, wqm_concern));
+                }
             }
-
         } catch (SQLException se) {
-            errorMessage = "Did not open database for WQM-25!";
-            LOG.info(errorMessage);
-            LOG.info(se.getMessage());
-        }
-
-        if (errorMessage.isEmpty()) {
-            return EXEC_OK;
-        } else {
-            return errorMessage;
+            LOG.log(Level.SEVERE, "Did not open database for WQM-25!", se);
+            throw new ServiceException("SQL problem", se);
         }
 
     }
@@ -102,20 +79,17 @@
         String ipm_technique_name;
         String wqm_concern;
 
-
-
         public Result1(
-            int ipm_technique_score_id,
-            int ipm_technique_id,
-            int ipm_technique_score,
-            String ipm_technique_name,
-            String wqm_concern) {
-                this.ipm_technique_score_id = ipm_technique_score_id;
-                this.ipm_technique_id = ipm_technique_id;
-                this.ipm_technique_score = ipm_technique_score;
-                this.ipm_technique_name = ipm_technique_name;
-                this.wqm_concern = wqm_concern;
-
+                int ipm_technique_score_id,
+                int ipm_technique_id,
+                int ipm_technique_score,
+                String ipm_technique_name,
+                String wqm_concern) {
+            this.ipm_technique_score_id = ipm_technique_score_id;
+            this.ipm_technique_id = ipm_technique_id;
+            this.ipm_technique_score = ipm_technique_score;
+            this.ipm_technique_name = ipm_technique_name;
+            this.wqm_concern = wqm_concern;
 
         }
     }

src/java/m/wqm/pestpractscores/V1_0.java

@@ -1,13 +1,14 @@
 package m.wqm.pestpractscores;
+
 /*
  * 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.
  */
-
 import csip.ModelDataService;
 import static csip.ModelDataService.EXEC_OK;
 import csip.ServiceException;
+import csip.annotations.Resource;
 import csip.utils.JSONUtils;
 import java.sql.Connection;
 import java.sql.ResultSet;
@@ -23,67 +24,57 @@
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONException;
 import org.codehaus.jettison.json.JSONObject;
+import wqm.utils.DBResources;
+import static wqm.utils.DBResources.WQM_ID;
 
 /**
  *
  * @author dhawal
  * @author Shaun Case
+ * @author anvesh
  */
 @Name("WQM-19: Pesticide Mitigation Practice Scores (PestPractScores)")
 @Description("This service computes scores for conservation practices applied to mitigate pesticide leaching, solution runoff, adsorbed runoff, and drift.")
 @Path("m/pesticide_practice_score/1.0")
+@Resource(from = DBResources.class)
 
 public class V1_0 extends ModelDataService {
 
-    private String error_msg = "";
+//    private String error_msg = "";
     private PestPractScores pestPractScores;
 
     @Override
     protected void preProcess() throws Exception {
         // reading the inputs from the json file into input object and placing it in the arraylist
-        int AoAId;
-        this.pestPractScores = null;
+        int AoAId = getIntParam("AoAId");
+        JSONArray pestComponents = getJSONArrayParam("pestcomponents");
+        pestPractScores = new V1_0.PestPractScores(AoAId, pestComponents);
 
-        JSONArray pestComponents;
+    }
 
+    @Override
+    protected void doProcess() throws Exception {
         try {
-            AoAId = getIntParam("AoAId");
-            pestComponents = getJSONArrayParam("pestcomponents");
-            pestPractScores = new V1_0.PestPractScores(AoAId, pestComponents);
-        } catch (ServiceException ex) {
-            this.error_msg = ex.getMessage();
+            pestPractScores.computeScores();
+
+        } catch (Exception ex) {
+            LOG.log(Level.SEVERE, "Error computing Pest Pract Scores", ex);
+            throw new Exception("Error computing Scores", ex);
+
         }
     }
 
     @Override
-    protected String process() throws Exception {
-        try {
-            if ((this.error_msg.isEmpty()) && (pestPractScores != null)) {
-                if (!pestPractScores.computeScores()) {
-                    this.error_msg += pestPractScores.getErrorMsg();
-                }
-            }
-        } catch (Exception ex) {
-            this.error_msg += pestPractScores.getErrorMsg() + " " + ex.getMessage();
-            LOG.log(Level.SEVERE, this.error_msg);
+    protected void postProcess() throws Exception {
+        V1_0.Result result = pestPractScores.getResults();
+        if (result != null) {
+            result.putResults();
         }
 
-        return (this.error_msg.isEmpty() ? EXEC_OK : this.error_msg);
-    }
-
-    @Override
-    protected void postProcess() throws Exception {
-        if (pestPractScores.getErrorMsg().isEmpty() && this.error_msg.isEmpty()) {
-            V1_0.Result result = pestPractScores.getResults();
-            if (result != null) {
-                result.putResults();
-            }
-        }
     }
 
     class PestPractScores {
 
-        private String error_msg = "";
         private int AoAId;
         private int pleach_practice_score;
         private int psolsurf_practice_score;
@@ -92,91 +83,75 @@
         private ArrayList<ipmData> ipmList;
         private V1_0.Result results = null;
 
-        PestPractScores(int AoAId, JSONArray ipms) {
-            this.pleach_practice_score = this.psolsurf_practice_score = this.padsurf_practice_score = this.pdrift_practice_score = 0;
-            this.error_msg = "";
-            this.ipmList = new ArrayList<>();
-            this.results = null;
+        PestPractScores(int AoAId, JSONArray ipms) throws Exception {
+            pleach_practice_score = psolsurf_practice_score = padsurf_practice_score = pdrift_practice_score = 0;
+            ipmList = new ArrayList<>();
 
             this.AoAId = AoAId;
 
             if (null != ipms) {
-                try {
-                    for (int i = 0; i < ipms.length(); i++) {
-                        Map<String, JSONObject> ipmsData = JSONUtils.preprocess(ipms.getJSONArray(i));
 
-                        ipmList.add(new ipmData(JSONUtils.getIntParam(ipmsData, "plan_ipm_practice", -1),
-                                JSONUtils.getStringParam(ipmsData, "plan_pract_variant", "err")));
-                    }
-                } catch (JSONException ex) {
-                    this.error_msg = " Cannot read IPM input variables:  " + ex.getMessage() + "  ";
+                for (int i = 0; i < ipms.length(); i++) {
+                    Map<String, JSONObject> ipmsData = JSONUtils.preprocess(ipms.getJSONArray(i));
+
+                    ipmList.add(new ipmData(JSONUtils.getIntParam(ipmsData, "plan_ipm_practice", -1),
+                            JSONUtils.getStringParam(ipmsData, "plan_pract_variant", "err")));
                 }
+
             } else {
-                this.error_msg = "No input variables:  Missing plan_ipm_practice list. ";
+                LOG.log(Level.SEVERE, "No input variables:  Missing plan_ipm_practice list. ");
+                throw new ServiceException("No input variables:  Missing plan_ipm_practice list. ");
+
             }
         }
 
-        String getErrorMsg() {
-            return this.error_msg;
+        Result getResults() {
+            return results;
         }
 
-        Result getResults() {
-            return this.results;
-        }
+        void computeScores() throws Exception {
 
-        boolean computeScores() throws Exception {
-            boolean ret_val = false;
-
-            if ((this.error_msg.isEmpty()) && ((null != this.ipmList) && (!this.ipmList.isEmpty()))) {
+            if (((null != ipmList) && (!ipmList.isEmpty()))) {
                 //Compute values here.
 
-                if (this.error_msg.isEmpty()) {
-                    this.pleach_practice_score = this.psolsurf_practice_score = this.padsurf_practice_score = this.pdrift_practice_score = 0;
-                    for (ipmData ipm : this.ipmList) {
-                        this.pleach_practice_score += getPlPractScore(ipm);
-                        this.psolsurf_practice_score += getPsPractScore(ipm);
-                        this.padsurf_practice_score += getPaPractScore(ipm);
-                        this.pdrift_practice_score += getPdPractScore(ipm);
-                        if (!this.error_msg.isEmpty()) {
-                            break;
-                        }
-                    }
+                pleach_practice_score = psolsurf_practice_score = padsurf_practice_score = pdrift_practice_score = 0;
+                for (ipmData ipm : this.ipmList) {
+                    pleach_practice_score += getPlPractScore(ipm);
+                    psolsurf_practice_score += getPsPractScore(ipm);
+                    padsurf_practice_score += getPaPractScore(ipm);
+                    pdrift_practice_score += getPdPractScore(ipm);
+                    //Create Results here...
+                    results = new V1_0.Result(this.AoAId, pleach_practice_score, psolsurf_practice_score, padsurf_practice_score, pdrift_practice_score);
 
-                    //Create Results here...
-                    if (this.error_msg.isEmpty()) {
-                        results = new V1_0.Result(this.AoAId, this.pleach_practice_score, this.psolsurf_practice_score, this.padsurf_practice_score, this.pdrift_practice_score);
-                    }
                 }
 
             }
 
-            return ret_val;
         }
 
         private int getPlPractScore(ipmData ipm) throws ServiceException {
             int ret_val = 0;
             String query;
 
-            if (this.error_msg.isEmpty()) {
-                try (
-                        Connection conn = wqm.utils.WQMTools.getConnection("wqm", LOG);
-                        Statement statement = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);) {
-                    String variant = ipm.getVariant();
-                    query = "SELECT ipm_practice_score FROM wqm_ipm_practice_scores WHERE practice_id='" + ipm.getIpm() + "' AND wqm_concern='Pesticide Leaching'";
+            try (Connection conn = getResourceJDBC(WQM_ID);
+                    Statement statement = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);) {
+                String variant = ipm.getVariant();
+                query = "SELECT ipm_practice_score FROM wqm_ipm_practice_scores WHERE practice_id='" + ipm.getIpm() + "' AND wqm_concern='Pesticide Leaching'";
 
-                    if (variant != null && !variant.isEmpty()) {
-                        query += " AND practice_variant='" + variant + "'";
-                    }
+                if (variant != null && !variant.isEmpty()) {
+                    query += " AND practice_variant='" + variant + "'";
+                }
 
-                    ResultSet result = statement.executeQuery(query);
+                try (ResultSet result = statement.executeQuery(query);) {
 
                     if (result.first()) {
                         ret_val = result.getInt("ipm_practice_score");
                     }
+                }
 
-                } catch (SQLException ex) {
-                    this.error_msg += " Cannot compute pl_pract_score:  " + ex.getMessage() + " ";
-                }
+            } catch (SQLException ex) {
+                LOG.log(Level.SEVERE, "Did not open database for WQM-19!", ex);
+                throw new ServiceException(" Cannot compute pl_pract_score:  ", ex);
             }
 
             return ret_val;
@@ -186,86 +161,81 @@
             int ret_val = 0;
             String query;
 
-            if (this.error_msg.isEmpty()) {
-                try (
-                        Connection conn = wqm.utils.WQMTools.getConnection("wqm", LOG);
-                        Statement statement = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);) {
-                    String variant = ipm.getVariant();
-                    query = "SELECT ipm_practice_score FROM wqm_ipm_practice_scores WHERE practice_id='" + ipm.getIpm() + "' AND wqm_concern='Pesticide Solution Runoff'";
+            try (Connection conn = getResourceJDBC(WQM_ID);
+                    Statement statement = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) {
+                String variant = ipm.getVariant();
+                query = "SELECT ipm_practice_score FROM wqm_ipm_practice_scores WHERE practice_id='" + ipm.getIpm() + "' AND wqm_concern='Pesticide Solution Runoff'";
 
-                    if (variant != null && !variant.isEmpty()) {
-                        query += " AND practice_variant='" + variant + "'";
-                    }
+                if (variant != null && !variant.isEmpty()) {
+                    query += " AND practice_variant='" + variant + "'";
+                }
 
-                    ResultSet result = statement.executeQuery(query);
+                try (ResultSet result = statement.executeQuery(query);) {
 
                     if (result.first()) {
                         ret_val = result.getInt("ipm_practice_score");
                     }
-
-                } catch (SQLException ex) {
-                    this.error_msg += " Cannot compute ps_pract_score:  " + ex.getMessage() + " ";
                 }
+            } catch (SQLException ex) {
+                LOG.log(Level.SEVERE, "Did not open database for WQM-19!", ex);
+                throw new ServiceException(" Cannot compute ps_pract_score:  ", ex);
             }
 
             return ret_val;
         }
 
-        private int getPaPractScore(ipmData ipm) {
+        private int getPaPractScore(ipmData ipm) throws ServiceException {
             int ret_val = 0;
             String query;
 
-            if (this.error_msg.isEmpty()) {
-                try (
-                        Connection conn = wqm.utils.WQMTools.getConnection("wqm", LOG);
-                        Statement statement = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);) {
-                    String variant = ipm.getVariant();
-                    query = "SELECT ipm_practice_score FROM wqm_ipm_practice_scores WHERE practice_id='" + ipm.getIpm() + "' AND wqm_concern='Pesticide Adsorbed Runoff'";
+            try (Connection conn = getResourceJDBC(WQM_ID);
+                    Statement statement = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) {
+                String variant = ipm.getVariant();
+                query = "SELECT ipm_practice_score FROM wqm_ipm_practice_scores WHERE practice_id='" + ipm.getIpm() + "' AND wqm_concern='Pesticide Adsorbed Runoff'";
 
-                    if (variant != null && !variant.isEmpty()) {
-                        query += " AND practice_variant='" + variant + "'";
-                    }
+                if (variant != null && !variant.isEmpty()) {
+                    query += " AND practice_variant='" + variant + "'";
+                }
 
-                    ResultSet result = statement.executeQuery(query);
+                try (ResultSet result = statement.executeQuery(query)) {
 
                     if (result.first()) {
                         ret_val = result.getInt("ipm_practice_score");
                     }
+                }
+            } catch (SQLException ex) {
+                LOG.log(Level.SEVERE, "Did not open database for WQM-19!", ex);
+                throw new ServiceException(" Cannot compute pa_pract_score:  ", ex);
 
-                } catch (SQLException ex) {
-                    this.error_msg += " Cannot compute pa_pract_score:  " + ex.getMessage() + " ";
-                } catch (ServiceException ex) {
-                    Logger.getLogger(V1_0.class.getName()).log(Level.SEVERE, null, ex);
-                }
             }
 
             return ret_val;
+
         }
 
         private int getPdPractScore(ipmData ipm) throws ServiceException {
             int ret_val = 0;
             String query;
 
-            if (this.error_msg.isEmpty()) {
-                try (
-                        Connection conn = wqm.utils.WQMTools.getConnection("wqm", LOG);
-                        Statement statement = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);) {
-                    String variant = ipm.getVariant();
-                    query = "SELECT ipm_practice_score FROM wqm_ipm_practice_scores WHERE practice_id='" + ipm.getIpm() + "' AND wqm_concern='Pesticide Drift'";
+            try (Connection conn = wqm.utils.WQMTools.getConnection("wqm", LOG);
+                    Statement statement = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)) {
+                String variant = ipm.getVariant();
+                query = "SELECT ipm_practice_score FROM wqm_ipm_practice_scores WHERE practice_id='" + ipm.getIpm() + "' AND wqm_concern='Pesticide Drift'";
 
-                    if (variant != null && !variant.isEmpty()) {
-                        query += " AND practice_variant='" + variant + "'";
-                    }
+                if (variant != null && !variant.isEmpty()) {
+                    query += " AND practice_variant='" + variant + "'";
+                }
 
-                    ResultSet result = statement.executeQuery(query);
+                ResultSet result = statement.executeQuery(query);
 
-                    if (result.first()) {
-                        ret_val = result.getInt("ipm_practice_score");
-                    }
+                if (result.first()) {
+                    ret_val = result.getInt("ipm_practice_score");
+                }
 
-                } catch (SQLException ex) {
-                    this.error_msg += " Cannot compute pd_pract_score:  " + ex.getMessage() + " ";
-                }
+            } catch (SQLException ex) {
+                LOG.log(Level.SEVERE, "Did not open database for WQM-19!", ex);
+                throw new ServiceException(" Cannot compute pd_pract_score:  ", ex);
+
             }
 
             return ret_val;
@@ -277,18 +247,19 @@
             String variant = "";
 
             ipmData(int plan_ipm_practice, String plan_pract_variant) {
-                this.ipm = plan_ipm_practice;
-                this.variant = plan_pract_variant;
+                ipm = plan_ipm_practice;
+                variant = plan_pract_variant;
             }
 
             public int getIpm() {
-                return this.ipm;
+                return ipm;
             }
 
             public String getVariant() {
-                return this.variant;
+                return variant;
             }
         }
+
     }
 
     class Result {

web/META-INF/csip-conf-CSU.json

@@ -2,6 +2,6 @@
  "csip.archive.enabled": false,
  "csip.logging.enabled": false,
  "wqm.db": "jdbc:postgresql://csip.engr.colostate.edu:5435/wqm?user=postgres&password=admin",
- "ssurgo.db": "jdbc:postgresql://csip.engr.colostate.edu:5435/ssurgo?user=postgres&password=admin",
+ "ssurgo.db": "jdbc:postgresql://csip.engr.colostate.edu:5435/ssurgo?user=postgres&password=admin"
 }
 

web/META-INF/csip-conf.json

@@ -9,6 +9,7 @@
   "mssql-ssurgo.db": "jdbc:sqlserver:\/\/129.82.20.241:1433;databaseName=conservation_resources;user=rset-r;password=cs1prs3t",
   "mssql-ssurgo.db.driver":"com.microsoft.sqlserver.jdbc.SQLServerDriver",
   "rse-sql.db.driver":"com.microsoft.sqlserver.jdbc.SQLServerDriver",
-  "csip-wqm.version" : "$version: 0.2.22 8a55a90166a4 2016-03-30 od, built at 2016-04-07 10:40 by od$"
+  "wqm.db": "jdbc:postgresql://csip.engr.colostate.edu:5435/wqm?user=postgres&password=admin",
+  "csip-wqm.version" : "$version: 0.2.32 db5221589af1 2016-04-20 anvesh<anvesh@cs.colostate.edu>, built at 2016-04-20 14:14 by od$"
 }
 

web/WEB-INF/csip-defaults.json

@@ -1,4 +1,4 @@
 { 
-    "csip-wqm.version": "$version: 0.2.28a55a90166a4 2016-03-30 od, built at 2016-04-07 10:40 by od$"
+    "csip-wqm.version": "$version: 0.2.3db5221589af1 2016-04-20 anvesh<anvesh@cs.colostate.edu>, built at 2016-04-20 14:14 by od$"
 }