@@ -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; |
|
} |
} |
@@ -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; |
|
} |
} |
@@ -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 { |