@@ -1,9 +1,9 @@ |
- |
package m.wqm.nuttechscores; |
|
/** |
* |
* @author SrinivasReddy kontham |
+ * @ update Rumpal Sidhu |
*/ |
import csip.ModelDataService; |
import static csip.ModelDataService.EXEC_OK; |
@@ -18,185 +18,218 @@ |
import java.sql.*; |
import java.util.concurrent.*; |
|
-@Name("(NutTechScores)") |
+@Name("WQM-14:(NutTechScores)") |
@Description("Nutrient Technique Scores") |
@Path("m/nut_tech_scores/1.0") |
|
-public class V1_0 extends ModelDataService |
-{ |
- ArrayList<Input> components=new ArrayList<>(); // store the set of all input soilcomponents as objects |
- ArrayList<Result1> result1=new ArrayList<>(); // store the result as objects |
- int nleach_techn_score=0; |
- int nleach_avoid_techn_score=0; |
- int nleach_control_techn_score=0; |
- int nleach_trap_techn_score=0; |
- int nsurf_techn_score=0; |
- int nsurf_avoid_techn_score=0; |
- int nsurf_control_techn_score=0; |
- int nsurf_trap_techn_score=0; |
- int psurf_techn_score=0; |
- int psurf_avoid_techn_score=0; |
- int psurf_control_techn_score=0; |
- int psurf_trap_techn_score=0; |
- int AoAid; |
+public class V1_0 extends ModelDataService { |
+ |
+ //SQL params names here for quick modification |
+ private final String USER = "postgres"; |
+ private final String PASS = "admin"; |
+ private final String HOST = "localhost"; |
+ private final String PORT = "5432"; |
+ private final String DBNAME = "postgres"; |
+ private final String JDBC_TYPE = "jdbc:postgresql://"; |
+ private final String CONNECTION = JDBC_TYPE + HOST + ":" + PORT + "/" + DBNAME; |
+ private final String CLASS_NAME = "org.postgresql.Driver"; |
+ |
+ private ArrayList<Input> components; // store the set of all input soilcomponents as objects |
+ private ArrayList<Result1> result1; // store the result as objects |
+ private int aoaId; |
+ |
@Override |
- // reading the inputs from the json file into input object and placing it in the arraylist |
- protected void preProcess() throws Exception { |
+ // reading the inputs from the json file into input object and placing it in the arraylist |
+ protected void preProcess() throws Exception { |
+ components = new ArrayList<>(); |
JSONArray groups = getJSONArrayParam("pestcomponents"); |
- for(int i=0;i<groups.length();i++) |
- { |
- Map<String, JSONObject> group = JSONUtils.preprocess(groups.getJSONArray(i)); |
+ for (int i = 0; i < groups.length(); i++) { |
+ Map<String, JSONObject> group = JSONUtils.preprocess(groups.getJSONArray(i)); |
+ aoaId = JSONUtils.getIntParam(group, "AoAid", 0); |
+ int plan_techn_id = JSONUtils.getIntParam(group, "plan_techn_id", 0); |
+ String plan_techn_discrim_type = JSONUtils.getStringParam(group, "plan_techn_discrim_type", "err"); |
+ String plan_techn_discrim = JSONUtils.getStringParam(group, "plan_techn_discrim", "err"); |
+ Input input = new Input(aoaId, plan_techn_id, plan_techn_discrim_type, plan_techn_discrim); |
+ components.add(input); |
+ } |
+ } |
|
- |
- AoAid = JSONUtils.getIntParam(group, "AoAid", 0); |
- int plan_techn_id=JSONUtils.getIntParam(group,"plan_techn_id",0); |
- String plan_techn_discrim_type=JSONUtils.getStringParam(group,"plan_techn_discrim_type","err"); |
- String plan_techn_discrim=JSONUtils.getStringParam(group,"plan_techn_discrim","err"); |
- Input input=new Input(AoAid,plan_techn_id,plan_techn_discrim_type,plan_techn_discrim); |
- components.add(input); |
+ @Override |
+ protected String process() throws Exception { |
+ result1 = new ArrayList<>(); |
+ Connection conn = null; |
+ Statement statement = null; |
+ try { |
+ Class.forName(CLASS_NAME); |
+ conn = DriverManager.getConnection(CONNECTION, USER, PASS); |
+ conn.setAutoCommit(false); |
+ statement = conn.createStatement(); |
+ |
+ int nleach_techn_score = 0; |
+ int nleach_avoid_techn_score = 0; |
+ int nleach_control_techn_score = 0; |
+ int nleach_trap_techn_score = 0; |
+ int nsurf_techn_score = 0; |
+ int nsurf_avoid_techn_score = 0; |
+ int nsurf_control_techn_score = 0; |
+ int nsurf_trap_techn_score = 0; |
+ int psurf_techn_score = 0; |
+ int psurf_avoid_techn_score = 0; |
+ int psurf_control_techn_score = 0; |
+ int psurf_trap_techn_score = 0; |
+ |
+ for (Input ip : components) { |
+ String query = "SELECT nut_tech_score FROM wqm_nutrient_technique_scores " |
+ + "WHERE nutrient_technique_id = " + ip.plan_techn_id |
+ + " AND wqm_concern ='Nitrogen in Ground Water';"; |
+ ResultSet resultset = statement.executeQuery(query); |
+ while (resultset.next()) { |
+ int techn_score = resultset.getInt("nut_tech_score"); |
+ nleach_techn_score += techn_score; |
+ } |
+ |
+ query = "SELECT nut_tech_score FROM wqm_nutrient_technique_scores " |
+ + "WHERE nutrient_technique_id= " + ip.plan_techn_id |
+ + " AND wqm_concern = 'Nitrogen in Ground Water' AND mode_of_action = 'Avoid';"; |
+ resultset = statement.executeQuery(query); |
+ while (resultset.next()) { |
+ int avoid_techn_score = resultset.getInt("nut_tech_score"); |
+ nleach_avoid_techn_score += avoid_techn_score; |
+ } |
+ |
+ query = "SELECT nut_tech_score FROM wqm_nutrient_technique_scores " |
+ + "WHERE nutrient_technique_id = " + ip.plan_techn_id |
+ + " AND wqm_concern = 'Nitrogen in Ground Water' AND mode_of_action = 'Control';"; |
+ resultset = statement.executeQuery(query); |
+ while (resultset.next()) { |
+ int control_techn_score = resultset.getInt("nut_tech_score"); |
+ nleach_control_techn_score += control_techn_score; |
+ } |
+ |
+ query = "SELECT nut_tech_score FROM wqm_nutrient_technique_scores " |
+ + "WHERE nutrient_technique_id = " + ip.plan_techn_id |
+ + " AND wqm_concern = 'Nitrogen in Ground Water' AND mode_of_action = 'Trap';"; |
+ resultset = statement.executeQuery(query); |
+ while (resultset.next()) { |
+ int trap_techn_score = resultset.getInt("nut_tech_score"); |
+ nleach_trap_techn_score += trap_techn_score; |
+ } |
+ |
+ // #Compute nutrient technique mitigation scores for Nitrogen in Surface Water concern and increment total scores |
+ query = "SELECT nut_tech_score FROM wqm_nutrient_technique_scores " |
+ + "WHERE nutrient_technique_id = " + ip.plan_techn_id |
+ + " AND wqm_concern = 'Nitrogen in Surface Water';"; |
+ resultset = statement.executeQuery(query); |
+ while (resultset.next()) { |
+ int techn_score = resultset.getInt("nut_tech_score"); |
+ nsurf_techn_score += techn_score; |
+ } |
+ |
+ query = "SELECT nut_tech_score FROM wqm_nutrient_technique_scores " |
+ + "WHERE nutrient_technique_id = " + ip.plan_techn_id |
+ + " AND wqm_concern = 'Nitrogen in Surface Water' AND mode_of_action = 'Avoid';"; |
+ resultset = statement.executeQuery(query); |
+ while (resultset.next()) { |
+ int avoid_techn_score = resultset.getInt("nut_tech_score"); |
+ nsurf_avoid_techn_score += avoid_techn_score; |
+ } |
+ |
+ query = "SELECT nut_tech_score FROM wqm_nutrient_technique_scores " |
+ + "WHERE nutrient_technique_id = " + ip.plan_techn_id |
+ + " AND wqm_concern = 'Nitrogen in Surface Water' AND mode_of_action = 'Control';"; |
+ resultset = statement.executeQuery(query); |
+ while (resultset.next()) { |
+ int control_techn_score = resultset.getInt("nut_tech_score"); |
+ nsurf_control_techn_score += control_techn_score; |
+ } |
+ |
+ query = "SELECT nut_tech_score FROM wqm_nutrient_technique_scores " |
+ + "WHERE nutrient_technique_id = " + ip.plan_techn_id |
+ + " AND wqm_concern = 'Nitrogen in Surface Water' AND mode_of_action = 'Trap';"; |
+ resultset = statement.executeQuery(query); |
+ while (resultset.next()) { |
+ int trap_techn_score = resultset.getInt("nut_tech_score"); |
+ nsurf_trap_techn_score += trap_techn_score; |
+ } |
+ |
+ //#Compute nutrient technique mitigation scores for Phosphorus in Surface Water concern and increment total scores |
+ query = "SELECT nut_tech_score FROM wqm_nutrient_technique_scores " |
+ + "WHERE nutrient_technique_id = " + ip.plan_techn_id |
+ + " AND wqm_concern = 'Phosphorous in Surface Water'" |
+ + " AND tech_discrim_type ='" + ip.plan_techn_discrim_type |
+ + "' AND tech_discrim = '" + ip.plan_techn_discrim + "';"; |
+ resultset = statement.executeQuery(query); |
+ while (resultset.next()) { |
+ int techn_score = resultset.getInt("nut_tech_score"); |
+ psurf_techn_score += techn_score; |
+ } |
+ |
+ query = "SELECT nut_tech_score FROM wqm_nutrient_technique_scores " |
+ + "WHERE nutrient_technique_id = " + ip.plan_techn_id |
+ + " AND wqm_concern = 'Phosphorus in Surface Water' AND mode_of_action = 'Avoid';"; |
+ resultset = statement.executeQuery(query); |
+ while (resultset.next()) { |
+ int avoid_techn_score = resultset.getInt("nut_tech_score"); |
+ psurf_avoid_techn_score += avoid_techn_score; |
+ } |
+ |
+ query = "SELECT nut_tech_score FROM wqm_nutrient_technique_scores " |
+ + "WHERE nutrient_technique_id = " + ip.plan_techn_id |
+ + "AND wqm_concern = 'Phosphorus in Surface Water' AND mode_of_action = 'Control';"; |
+ resultset = statement.executeQuery(query); |
+ while (resultset.next()) { |
+ int control_techn_score = resultset.getInt("nut_tech_score"); |
+ psurf_control_techn_score += control_techn_score; |
+ } |
+ |
+ query = "SELECT nut_tech_score FROM wqm_nutrient_technique_scores " |
+ + "WHERE nutrient_technique_id = " + ip.plan_techn_id |
+ + " AND wqm_concern = 'Phosphorus in Surface Water' AND mode_of_action = 'Trap';"; |
+ resultset = statement.executeQuery(query); |
+ while (resultset.next()) { |
+ int trap_techn_score = resultset.getInt("nut_tech_score"); |
+ psurf_trap_techn_score += trap_techn_score; |
+ } |
+ } |
+ Result1 result = new Result1(aoaId, nleach_techn_score, nsurf_techn_score, psurf_techn_score, nleach_avoid_techn_score, nleach_control_techn_score, nleach_trap_techn_score, nsurf_avoid_techn_score, nsurf_control_techn_score, nsurf_trap_techn_score, psurf_avoid_techn_score, psurf_control_techn_score, psurf_trap_techn_score); |
+ result1.add(result); |
+ |
+ } catch (SQLException se) { |
+ LOG.info("Did not open database for WQM-4!"); |
+ LOG.info(se.getMessage()); |
+ } finally { |
+ if (statement != null) { |
+ statement.close(); |
+ } |
+ if (conn != null) { |
+ conn.close(); |
} |
} |
- @Override |
- protected String process() throws Exception |
- { |
- Connection conn = null; |
- Statement statement = null; |
- Class.forName("org.postgresql.Driver"); |
- conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/postgres", "postgres", "admin"); |
- conn.setAutoCommit(false); |
- statement = conn.createStatement(); |
- |
- for(Input ip:components) |
- { |
- String query="SELECT nut_tech_score FROM wqm_nutrient_technique_scores WHERE nutrient_technique_id="+ip.plan_techn_id+"AND wqm_concern="+"'"+"Nitrogen in Ground Water"+"'"; |
- ResultSet results = statement.executeQuery(query); |
- // #Compute nutrient technique mitigation scores for Nitrogen in Ground Water concern and increment total scores |
- while (results.next()) |
- { |
- int techn_score=results.getInt("nut_tech_score"); |
- nleach_techn_score=nleach_techn_score+techn_score; |
- } |
- query="SELECT nut_tech_score FROM wqm_nutrient_technique_scores WHERE nutrient_technique_id="+ip.plan_techn_id+"AND wqm_concern="+"'"+"Nitrogen in Ground Water"+"' AND mode_of_action='"+"Avoid"+"'"; |
- results = statement.executeQuery(query); |
- |
- while (results.next()) |
- { |
- int avoid_techn_score=results.getInt("nut_tech_score"); |
- nleach_avoid_techn_score=nleach_avoid_techn_score+avoid_techn_score; |
- } |
- query="SELECT nut_tech_score FROM wqm_nutrient_technique_scores WHERE nutrient_technique_id="+ip.plan_techn_id+"AND wqm_concern="+"'"+"Nitrogen in Ground Water"+"' AND mode_of_action='"+"Control"+"'"; |
- results = statement.executeQuery(query); |
- |
- while (results.next()) |
- { |
- int control_techn_score=results.getInt("nut_tech_score"); |
- nleach_control_techn_score=nleach_avoid_techn_score+control_techn_score; |
- } |
- query="SELECT nut_tech_score FROM wqm_nutrient_technique_scores WHERE nutrient_technique_id="+ip.plan_techn_id+"AND wqm_concern="+"'"+"Nitrogen in Ground Water"+"' AND mode_of_action='"+"Trap"+"'"; |
- results = statement.executeQuery(query); |
- |
- while (results.next()) |
- { |
- int trap_techn_score=results.getInt("nut_tech_score"); |
- nleach_trap_techn_score=nleach_avoid_techn_score+trap_techn_score; |
- } |
- |
- // #Compute nutrient technique mitigation scores for Nitrogen in Surface Water concern and increment total scores |
- query="SELECT nut_tech_score FROM wqm_nutrient_technique_scores WHERE nutrient_technique_id="+ip.plan_techn_id+"AND wqm_concern="+"'"+"Nitrogen in Surface Water"+"'"; |
- results = statement.executeQuery(query); |
- while (results.next()) |
- { |
- int techn_score=results.getInt("nut_tech_score"); |
- nsurf_techn_score=nsurf_techn_score+techn_score; |
- } |
- query="SELECT nut_tech_score FROM wqm_nutrient_technique_scores WHERE nutrient_technique_id="+ip.plan_techn_id+"AND wqm_concern="+"'"+"Nitrogen in Surface Water"+"' AND mode_of_action='"+"Avoid"+"'"; |
- results = statement.executeQuery(query); |
- |
- while (results.next()) |
- { |
- int avoid_techn_score=results.getInt("nut_tech_score"); |
- nsurf_avoid_techn_score=nsurf_avoid_techn_score+avoid_techn_score; |
- } |
- query="SELECT nut_tech_score FROM wqm_nutrient_technique_scores WHERE nutrient_technique_id="+ip.plan_techn_id+"AND wqm_concern="+"'"+"Nitrogen in Surface Water"+"' AND mode_of_action='"+"Control"+"'"; |
- results = statement.executeQuery(query); |
- |
- while (results.next()) |
- { |
- int control_techn_score=results.getInt("nut_tech_score"); |
- nsurf_control_techn_score=nsurf_avoid_techn_score+control_techn_score; |
- } |
- query="SELECT nut_tech_score FROM wqm_nutrient_technique_scores WHERE nutrient_technique_id="+ip.plan_techn_id+"AND wqm_concern="+"'"+"Nitrogen in Surface Water"+"' AND mode_of_action='"+"Trap"+"'"; |
- results = statement.executeQuery(query); |
- |
- while (results.next()) |
- { |
- int trap_techn_score=results.getInt("nut_tech_score"); |
- nsurf_trap_techn_score=nsurf_avoid_techn_score+trap_techn_score; |
- } |
- //#Compute nutrient technique mitigation scores for Phosphorus in Surface Water concern and increment total scores |
- query="SELECT nut_tech_score FROM wqm_nutrient_technique_scores WHERE nutrient_technique_id="+ip.plan_techn_id+"AND wqm_concern="+"'"+"Phosphorous in Surface Water"+"' AND tech_discrim_type='"+ip.plan_techn_discrim_type+"' AND tech_discrim='"+ip.plan_techn_discrim+"'"; |
- results = statement.executeQuery(query); |
- while (results.next()) |
- { |
- int techn_score=results.getInt("nut_tech_score"); |
- psurf_techn_score=psurf_techn_score+techn_score; |
- } |
- query="SELECT nut_tech_score FROM wqm_nutrient_technique_scores WHERE nutrient_technique_id="+ip.plan_techn_id+"AND wqm_concern="+"'"+"Phosphorus in Surface Water"+"' AND mode_of_action='"+"Avoid"+"'"; |
- results = statement.executeQuery(query); |
- |
- while (results.next()) |
- { |
- int avoid_techn_score=results.getInt("nut_tech_score"); |
- psurf_avoid_techn_score=psurf_avoid_techn_score+avoid_techn_score; |
- } |
- query="SELECT nut_tech_score FROM wqm_nutrient_technique_scores WHERE nutrient_technique_id="+ip.plan_techn_id+"AND wqm_concern="+"'"+"Phosphorus in Surface Water"+"' AND mode_of_action='"+"Control"+"'"; |
- results = statement.executeQuery(query); |
- |
- while (results.next()) |
- { |
- int control_techn_score=results.getInt("nut_tech_score"); |
- psurf_control_techn_score=psurf_avoid_techn_score+control_techn_score; |
- } |
- query="SELECT nut_tech_score FROM wqm_nutrient_technique_scores WHERE nutrient_technique_id="+ip.plan_techn_id+"AND wqm_concern="+"'"+"Phosphorus in Surface Water"+"' AND mode_of_action='"+"Trap"+"'"; |
- results = statement.executeQuery(query); |
- |
- while (results.next()) |
- { |
- int trap_techn_score=results.getInt("nut_tech_score"); |
- psurf_trap_techn_score=psurf_avoid_techn_score+trap_techn_score; |
- } |
- |
- } |
- Result1 result=new Result1(AoAid,nleach_techn_score,nsurf_techn_score,psurf_techn_score,nleach_avoid_techn_score,nleach_control_techn_score,nleach_trap_techn_score,nsurf_avoid_techn_score,nsurf_control_techn_score,nsurf_trap_techn_score,psurf_avoid_techn_score,psurf_control_techn_score,psurf_trap_techn_score); |
- result1.add(result); |
- return EXEC_OK; |
+ return EXEC_OK; |
+ } |
+ |
+ @Override |
+ //writing the results back to JSON |
+ protected void postProcess() throws Exception { |
+ JSONArray result1Arr = new JSONArray(); |
+ for (Result1 rs1 : result1) { |
+ JSONArray tmpArr = new JSONArray(); |
+ tmpArr.put(JSONUtils.dataDesc("AoAId", rs1.AoAid, "Area of Analysis Identifier")); |
+ tmpArr.put(JSONUtils.dataDesc("nleach_techn_score", rs1.nleach_techn_score, "nutrient management technique mitigation score for nitrogen in ground water concern")); |
+ tmpArr.put(JSONUtils.dataDesc("nsurf_techn_score", rs1.nsurf_techn_score, "nutrient management technique mitigation score for nitrogen in surface water concern")); |
+ tmpArr.put(JSONUtils.dataDesc("psurf_techn_score", rs1.psurf_techn_score, "nutrient management technique mitigation score for phosphorus in surface water concern")); |
+ tmpArr.put(JSONUtils.dataDesc("nleach_avoid_techn_score", rs1.nleach_avoid_techn_score, "integer, nutrient management technique mitigation score for avoiding excess nitrogen use or application and loss to groundwater")); |
+ tmpArr.put(JSONUtils.dataDesc("nleach_control_techn_score", rs1.nleach_control_techn_score, "nutrient management technique mitigation score for controlling in-field nitrogen losses to groundwater")); |
+ tmpArr.put(JSONUtils.dataDesc("nleach_trap_techn_score", rs1.nleach_trap_techn_score, "nutrient management technique mitigation score for trapping excess nitrogen and keeping it from groundwater")); |
+ tmpArr.put(JSONUtils.dataDesc("nsurf_avoid_techn_score", rs1.nsurf_avoid_techn_score, "nutrient management technique mitigation score for avoiding excess nitrogen use or application and loss to surface water")); |
+ tmpArr.put(JSONUtils.dataDesc("nsurf_control_techn_score", rs1.nsurf_control_techn_score, "nutrient management technique mitigation score for controlling in-field nitrogen losses to surface water runoff")); |
+ tmpArr.put(JSONUtils.dataDesc("nsurf_trap_techn_score", rs1.nsurf_trap_techn_score, "nutrient management technique mitigation score for trapping excess nitrogen and keeping it from surface water")); |
+ tmpArr.put(JSONUtils.dataDesc("psurf_avoid_techn_score", rs1.psurf_avoid_techn_score, "nutrient management technique mitigation score for avoiding excess phosphorus use or application and loss to surface water")); |
+ tmpArr.put(JSONUtils.dataDesc("psurf_control_techn_score", rs1.psurf_control_techn_score, "nutrient management technique mitigation score for controlling in-field phosphorus losses to surface water runoff")); |
+ tmpArr.put(JSONUtils.dataDesc("psurf_trap_techn_score", rs1.psurf_trap_techn_score, "nutrient management technique mitigation score for trapping excess phophorus and keeping it from surface water")); |
+ result1Arr.put(JSONUtils.dataDesc("Nutrient Technique Scores", tmpArr, "AoANutScores")); |
} |
- @Override |
- //writing the results back to JSON |
- protected void postProcess() throws Exception |
- { |
- JSONArray result1Arr = new JSONArray(); |
- for(Result1 rs1:result1) |
- { |
- JSONArray tmpArr = new JSONArray(); |
- tmpArr.put(JSONUtils.dataDesc("AoAId", AoAid, "Area of Analysis Identifier")); |
- tmpArr.put(JSONUtils.dataDesc("nleach_techn_score", rs1.nleach_techn_score, "nutrient management technique mitigation score for nitrogen in ground water concern")); |
- tmpArr.put(JSONUtils.dataDesc("nsurf_techn_score", rs1.nsurf_techn_score, "nutrient management technique mitigation score for nitrogen in surface water concern")); |
- tmpArr.put(JSONUtils.dataDesc("psurf_techn_score", rs1.psurf_techn_score, "nutrient management technique mitigation score for phosphorus in surface water concern")); |
- tmpArr.put(JSONUtils.dataDesc("nleach_avoid_techn_score", rs1.nleach_avoid_techn_score, "integer, nutrient management technique mitigation score for avoiding excess nitrogen use or application and loss to groundwater")); |
- tmpArr.put(JSONUtils.dataDesc("nleach_control_techn_score", rs1.nleach_control_techn_score, "nutrient management technique mitigation score for controlling in-field nitrogen losses to groundwater")); |
- tmpArr.put(JSONUtils.dataDesc("nleach_trap_techn_score", rs1.nleach_trap_techn_score, "nutrient management technique mitigation score for trapping excess nitrogen and keeping it from groundwater")); |
- tmpArr.put(JSONUtils.dataDesc("nsurf_avoid_techn_score", rs1.nsurf_avoid_techn_score, "nutrient management technique mitigation score for avoiding excess nitrogen use or application and loss to surface water")); |
- tmpArr.put(JSONUtils.dataDesc("nsurf_control_techn_score", rs1.nsurf_control_techn_score, "nutrient management technique mitigation score for controlling in-field nitrogen losses to surface water runoff")); |
- tmpArr.put(JSONUtils.dataDesc("nsurf_trap_techn_score", rs1.nsurf_trap_techn_score, "nutrient management technique mitigation score for trapping excess nitrogen and keeping it from surface water")); |
- tmpArr.put(JSONUtils.dataDesc("psurf_avoid_techn_score", rs1.psurf_avoid_techn_score, "nutrient management technique mitigation score for avoiding excess phosphorus use or application and loss to surface water")); |
- tmpArr.put(JSONUtils.dataDesc("psurf_control_techn_score", rs1.psurf_control_techn_score, "nutrient management technique mitigation score for controlling in-field phosphorus losses to surface water runoff")); |
- tmpArr.put(JSONUtils.dataDesc("psurf_trap_techn_score", rs1.psurf_trap_techn_score, "nutrient management technique mitigation score for trapping excess phophorus and keeping it from surface water")); |
- result1Arr.put(JSONUtils.dataDesc("Nutrient Technique Scores", tmpArr, "AoANutScores")); |
- } |
- |
- putResult("operation", result1Arr); |
+ putResult("operation", result1Arr); |
} |
- |
|
} |
@@ -1,151 +1,143 @@ |
{ |
- "metainfo": { |
- }, |
- "parameter": [ |
- { |
- "name": "pestcomponents", |
- "value": [ |
- [ |
- { |
- "name": "AoAid", |
- "value": 1, |
- "Description":"Area of Analysis Identifier" |
- |
- }, |
- { |
- "name": "plan_techn_id", |
- "value": 1, |
- "Description":"nutrient management technique identifier corresponding to nutrient_technique_score_id value in WQM data mart" |
- }, |
- { |
- "name": "plan_techn_discrim_type", |
- "value": "", |
- "Description":"type of discriminator for varying nutrient management technique scores; value is “soil test result” otherwise NULL" |
- }, |
- { |
- "name": "plan_techn_discrim", |
- "value": "", |
- "Description":"value of the discriminator: HIGH,MEDIUM, LOW, NO SOIL TEST" |
- } |
- |
- ], |
- |
- [ |
- { |
- "name": "AoAid", |
- "value": 1, |
- "Description":"Area of Analysis Identifier" |
- |
- }, |
- { |
- "name": "plan_techn_id", |
- "value": 5, |
- "Description":"nutrient management technique identifier corresponding to nutrient_technique_score_id value in WQM data mart" |
- }, |
- { |
- "name": "plan_techn_discrim_type", |
- "value": "", |
- "Description":"type of discriminator for varying nutrient management technique scores; value is “soil test result” otherwise NULL" |
- }, |
- { |
- "name": "plan_techn_discrim", |
- "value": "", |
- "Description":"value of the discriminator: HIGH,MEDIUM, LOW, NO SOIL TEST" |
- } |
- ], |
- [ |
+ "metainfo": { |
+ }, |
+ "parameter": [ |
{ |
- "name": "AoAid", |
- "value": 1, |
- "Description":"Area of Analysis Identifier" |
- |
- }, |
- { |
- "name": "plan_techn_id", |
- "value": 8, |
- "Description":"nutrient management technique identifier corresponding to nutrient_technique_score_id value in WQM data mart" |
- }, |
- { |
- "name": "plan_techn_discrim_type", |
- "value": "Soil test result", |
- "Description":"type of discriminator for varying nutrient management technique scores; value is “soil test result” otherwise NULL" |
- }, |
- { |
- "name": "plan_techn_discrim", |
- "value": "Medium", |
- "Description":"value of the discriminator: HIGH,MEDIUM, LOW, NO SOIL TEST" |
- } |
- ], |
- [ |
- { |
- "name": "AoAid", |
- "value": 1, |
- "Description":"Area of Analysis Identifier" |
- |
- }, |
- { |
- "name": "plan_techn_id", |
- "value": 14, |
- "Description":"nutrient management technique identifier corresponding to nutrient_technique_score_id value in WQM data mart" |
- }, |
- { |
- "name": "plan_techn_discrim_type", |
- "value": "", |
- "Description":"type of discriminator for varying nutrient management technique scores; value is “soil test result” otherwise NULL" |
- }, |
- { |
- "name": "plan_techn_discrim", |
- "value": "", |
- "Description":"value of the discriminator: HIGH,MEDIUM, LOW, NO SOIL TEST" |
- } |
- ], |
- [ |
- { |
- "name": "AoAid", |
- "value": 1, |
- "Description":"Area of Analysis Identifier" |
- |
- }, |
- { |
- "name": "plan_techn_id", |
- "value": 2, |
- "Description":"nutrient management technique identifier corresponding to nutrient_technique_score_id value in WQM data mart" |
- }, |
- { |
- "name": "plan_techn_discrim_type", |
- "value": "", |
- "Description":"type of discriminator for varying nutrient management technique scores; value is “soil test result” otherwise NULL" |
- }, |
- { |
- "name": "plan_techn_discrim", |
- "value": "", |
- "Description":"value of the discriminator: HIGH,MEDIUM, LOW, NO SOIL TEST" |
- } |
- ], |
- [ |
- { |
- "name": "AoAid", |
- "value": 1, |
- "Description":"Area of Analysis Identifier" |
- |
- }, |
- { |
- "name": "plan_techn_id", |
- "value": 9, |
- "Description":"nutrient management technique identifier corresponding to nutrient_technique_score_id value in WQM data mart" |
- }, |
- { |
- "name": "plan_techn_discrim_type", |
- "value": "", |
- "Description":"type of discriminator for varying nutrient management technique scores; value is “soil test result” otherwise NULL" |
- }, |
- { |
- "name": "plan_techn_discrim", |
- "value": "", |
- "Description":"value of the discriminator: HIGH,MEDIUM, LOW, NO SOIL TEST" |
- } |
+ "name": "pestcomponents", |
+ "value": [ |
+ [ |
+ { |
+ "name": "AoAid", |
+ "value": 1, |
+ "Description": "Area of Analysis Identifier" |
+ }, |
+ { |
+ "name": "plan_techn_id", |
+ "value": 1, |
+ "Description": "nutrient management technique identifier corresponding to nutrient_technique_score_id value in WQM data mart" |
+ }, |
+ { |
+ "name": "plan_techn_discrim_type", |
+ "value": "", |
+ "Description": "type of discriminator for varying nutrient management technique scores; value is “soil test result” otherwise NULL" |
+ }, |
+ { |
+ "name": "plan_techn_discrim", |
+ "value": "", |
+ "Description": "value of the discriminator: HIGH,MEDIUM, LOW, NO SOIL TEST" |
+ } |
+ ], |
+ [ |
+ { |
+ "name": "AoAid", |
+ "value": 1, |
+ "Description": "Area of Analysis Identifier" |
+ }, |
+ { |
+ "name": "plan_techn_id", |
+ "value": 5, |
+ "Description": "nutrient management technique identifier corresponding to nutrient_technique_score_id value in WQM data mart" |
+ }, |
+ { |
+ "name": "plan_techn_discrim_type", |
+ "value": "", |
+ "Description": "type of discriminator for varying nutrient management technique scores; value is “soil test result” otherwise NULL" |
+ }, |
+ { |
+ "name": "plan_techn_discrim", |
+ "value": "", |
+ "Description": "value of the discriminator: HIGH,MEDIUM, LOW, NO SOIL TEST" |
+ } |
+ ], |
+ [ |
+ { |
+ "name": "AoAid", |
+ "value": 1, |
+ "Description": "Area of Analysis Identifier" |
+ }, |
+ { |
+ "name": "plan_techn_id", |
+ "value": 8, |
+ "Description": "nutrient management technique identifier corresponding to nutrient_technique_score_id value in WQM data mart" |
+ }, |
+ { |
+ "name": "plan_techn_discrim_type", |
+ "value": "Soil test result", |
+ "Description": "type of discriminator for varying nutrient management technique scores; value is “soil test result” otherwise NULL" |
+ }, |
+ { |
+ "name": "plan_techn_discrim", |
+ "value": "Medium", |
+ "Description": "value of the discriminator: HIGH,MEDIUM, LOW, NO SOIL TEST" |
+ } |
+ ], |
+ [ |
+ { |
+ "name": "AoAid", |
+ "value": 1, |
+ "Description": "Area of Analysis Identifier" |
+ }, |
+ { |
+ "name": "plan_techn_id", |
+ "value": 14, |
+ "Description": "nutrient management technique identifier corresponding to nutrient_technique_score_id value in WQM data mart" |
+ }, |
+ { |
+ "name": "plan_techn_discrim_type", |
+ "value": "", |
+ "Description": "type of discriminator for varying nutrient management technique scores; value is “soil test result” otherwise NULL" |
+ }, |
+ { |
+ "name": "plan_techn_discrim", |
+ "value": "", |
+ "Description": "value of the discriminator: HIGH,MEDIUM, LOW, NO SOIL TEST" |
+ } |
+ ], |
+ [ |
+ { |
+ "name": "AoAid", |
+ "value": 1, |
+ "Description": "Area of Analysis Identifier" |
+ }, |
+ { |
+ "name": "plan_techn_id", |
+ "value": 2, |
+ "Description": "nutrient management technique identifier corresponding to nutrient_technique_score_id value in WQM data mart" |
+ }, |
+ { |
+ "name": "plan_techn_discrim_type", |
+ "value": "", |
+ "Description": "type of discriminator for varying nutrient management technique scores; value is “soil test result” otherwise NULL" |
+ }, |
+ { |
+ "name": "plan_techn_discrim", |
+ "value": "", |
+ "Description": "value of the discriminator: HIGH,MEDIUM, LOW, NO SOIL TEST" |
+ } |
+ ], |
+ [ |
+ { |
+ "name": "AoAid", |
+ "value": 1, |
+ "Description": "Area of Analysis Identifier" |
+ }, |
+ { |
+ "name": "plan_techn_id", |
+ "value": 9, |
+ "Description": "nutrient management technique identifier corresponding to nutrient_technique_score_id value in WQM data mart" |
+ }, |
+ { |
+ "name": "plan_techn_discrim_type", |
+ "value": "", |
+ "Description": "type of discriminator for varying nutrient management technique scores; value is “soil test result” otherwise NULL" |
+ }, |
+ { |
+ "name": "plan_techn_discrim", |
+ "value": "", |
+ "Description": "value of the discriminator: HIGH,MEDIUM, LOW, NO SOIL TEST" |
+ } |
+ ] |
+ ] |
+ } |
] |
- ] |
- } |
- ] |
} |
@@ -1,5 +1,5 @@ |
+package m.wqm.pestlosspot; |
|
-package m.wqm.pestlosspot; |
import csip.ModelDataService; |
import java.util.ArrayList; |
import javax.ws.rs.Path; |
@@ -11,235 +11,256 @@ |
import java.sql.Connection; |
import java.sql.DriverManager; |
import java.sql.ResultSet; |
+import java.sql.SQLException; |
import java.sql.Statement; |
import java.util.Map; |
+ |
/** |
* |
* @ Srinivas |
+ * @ Update Rumpal Sidhu |
*/ |
@Name("WQM-4") |
@Description("Pesticide Attributes (WQMPestAttr)") |
@Path("m/pestlosspot/1.0") |
|
-public class V1_0 extends ModelDataService{ |
- |
- |
+public class V1_0 extends ModelDataService { |
+ |
+ //SQL params names here for quick modification |
+ private final String USER = "postgres"; |
+ private final String PASS = "admin"; |
+ private final String HOST = "localhost"; |
+ private final String PORT = "5432"; |
+ private final String DBNAME = "postgres"; |
+ private final String JDBC_TYPE = "jdbc:postgresql://"; |
+ private final String CONNECTION = JDBC_TYPE + HOST + ":" + PORT + "/" + DBNAME; |
+ private final String CLASS_NAME = "org.postgresql.Driver"; |
+ |
//JSONArray getArray |
- ArrayList<Input> components=new ArrayList<>(); // store the set of all input soilcomponents as objects |
- ArrayList<Result1> result1=new ArrayList<>(); // store the result as objects |
+ private ArrayList<Input> components; // store the set of all input soilcomponents as objects |
+ private ArrayList<Result1> result1; // store the result as objects |
+ |
@Override |
- // reading the inputs from the json file into input object and placing it in the arraylist |
- protected void preProcess() throws Exception { |
+ // reading the inputs from the json file into input object and placing it in the arraylist |
+ protected void preProcess() throws Exception { |
+ components = new ArrayList<>(); |
JSONArray groups = getJSONArrayParam("pestcomponents"); |
- for(int i=0;i<groups.length();i++) |
- { |
- Map<String, JSONObject> group = JSONUtils.preprocess(groups.getJSONArray(i)); |
- int AoAId = JSONUtils.getIntParam(group, "AoAId", 0); |
- int operation_id=JSONUtils.getIntParam(group,"operation_id",0); |
- String op_pest_id=JSONUtils.getStringParam(group,"op_pest_id","err"); |
- String app_rate=JSONUtils.getStringParam(group,"app_rate","err"); |
- String app_area=JSONUtils.getStringParam(group,"app_area","err"); |
- String app_method=JSONUtils.getStringParam(group,"app_method","err"); |
- Input input=new Input(AoAId,operation_id,op_pest_id,app_rate,app_area,app_method); |
- components.add(input); |
+ for (int i = 0; i < groups.length(); i++) { |
+ Map<String, JSONObject> group = JSONUtils.preprocess(groups.getJSONArray(i)); |
+ int AoAId = JSONUtils.getIntParam(group, "AoAId", 0); |
+ int operation_id = JSONUtils.getIntParam(group, "operation_id", 0); |
+ String op_pest_id = JSONUtils.getStringParam(group, "op_pest_id", "err"); |
+ String app_rate = JSONUtils.getStringParam(group, "app_rate", "err"); |
+ String app_area = JSONUtils.getStringParam(group, "app_area", "err"); |
+ String app_method = JSONUtils.getStringParam(group, "app_method", "err"); |
+ Input input = new Input(AoAId, operation_id, op_pest_id, app_rate, app_area, app_method); |
+ components.add(input); |
+ } |
+ } |
+ |
+ @Override |
+ protected String process() throws Exception { |
+ result1 = new ArrayList<>(); |
+ Connection conn = null; |
+ Statement statement = null; |
+ try { |
+ Class.forName(CLASS_NAME); |
+ conn = DriverManager.getConnection(CONNECTION, USER, PASS); |
+ conn.setAutoCommit(false); |
+ statement = conn.createStatement(); |
+ |
+ for (Input ip : components) { |
+ String ai_name = ""; |
+ double ai_ph = 0.0; |
+ double ai_sol = 0.0; |
+ double ai_koc = 0.0; |
+ double ai_hl = 0.0; |
+ double ai_fishtox = 0.0; |
+ String ai_fishtoxtype = ""; |
+ double ai_humtox = 0.0; |
+ String ai_humtoxtype = ""; |
+ |
+ String query = "SELECT * FROM wqm_pesticides WHERE \"PC_CODE\"='" + ip.op_pest_id + "';"; |
+ ResultSet results = statement.executeQuery(query); |
+ while (results.next()) { |
+ ai_name = results.getString("AI_NAME"); |
+ ai_ph = results.getDouble("PH"); |
+ ai_hl = results.getDouble("SOIL_HL_RV"); |
+ ai_koc = results.getDouble("KOC_RV"); |
+ ai_sol = results.getDouble("SOL_RV"); |
+ ai_humtox = results.getDouble("HUMAN_TOX_PPB"); |
+ ai_humtoxtype = results.getString("HUMAN_TOX_TYPE"); |
+ ai_fishtox = results.getDouble("FISH_TOX_PPB"); |
+ ai_fishtoxtype = results.getString("FISH_TOX_TYPE"); |
+ } |
+ |
+ // #Compute pesticide leaching potential fore each operation pesticide |
+ double log_val = Math.log10(ai_hl) * (4 - Math.log10(ai_koc)); |
+ String ai_plp; |
+ if (log_val >= 2.8) { |
+ if (ip.app_area.equals("Banded") |
+ || ip.app_method.equals("Foliar Application") |
+ || ip.app_rate.equals("LOW")) { |
+ ai_plp = "INTERMEDIATE"; |
+ } else if (ip.app_area.equals("Spot Treatment") |
+ || ip.app_rate.equals("ULTRA LOW")) { |
+ ai_plp = "LOW"; |
+ } else { |
+ ai_plp = "HIGH"; |
+ } |
+ } else if (log_val < 0.0 || (ai_sol < 1 && ai_hl <= 1)) { |
+ ai_plp = "VERY LOW"; |
+ } else if (log_val <= 1.8) { |
+ if (ip.app_area.equals("Banded") |
+ || ip.app_area.equals("Spot Treatment") |
+ || ip.app_method.equals("Foliar Application") |
+ || ip.app_rate.equals("LOW") |
+ || ip.app_rate.equals("ULTRA LOW")) { |
+ ai_plp = "VERY LOW"; |
+ } else { |
+ ai_plp = "LOW"; |
+ } |
+ } else { |
+ if (ip.app_area.equals("Banded") |
+ || ip.app_method.equals("Foliar Application") |
+ || ip.app_rate.equals("LOW")) { |
+ ai_plp = "LOW"; |
+ } else if (ip.app_area.equals("Spot Treatment") |
+ || ip.app_rate.equals("ULTRA LOW")) { |
+ ai_plp = "VERY LOW"; |
+ } else { |
+ ai_plp = "INTERMEDIATE"; |
+ } |
+ } |
+ |
+ String ai_psrp; |
+ // #Compute pesticide solution runoff potential for each operation pesticide |
+ if ((ai_sol >= 1 && ai_hl > 35 && ai_koc < 100000) |
+ || (ai_sol >= 10 && ai_sol < 100 && ai_koc <= 700)) { |
+ if (ip.app_area.equals("Banded") |
+ || ip.app_method.equals("Foliar Application") |
+ || ip.app_method.equals("Soil Incorporated") |
+ || ip.app_rate.equals("LOW")) { |
+ ai_psrp = "INTERMEDIATE"; |
+ } else if (ip.app_area.equals("Spot Treatment") |
+ || ip.app_rate.equals("ULTRA LOW")) { |
+ ai_psrp = "LOW"; |
+ } else { |
+ ai_psrp = "HIGH"; |
+ } |
+ } else if ((ai_koc >= 100000) |
+ || (ai_koc >= 1000 && ai_hl <= 1) |
+ || (ai_sol < 0.5 && ai_hl < 35)) { |
+ if (ip.app_area.equals("Banded") |
+ || ip.app_area.equals("Spot Treatment") |
+ || ip.app_method.equals("Foliar Application") |
+ || ip.app_method.equals("Soil Incorporated") |
+ || ip.app_rate.equals("LOW") |
+ || ip.app_rate.equals("ULTRA LOW")) { |
+ ai_psrp = "VERY LOW"; |
+ } else { |
+ ai_psrp = "LOW"; |
+ } |
+ } else { |
+ if (ip.app_area.equals("Banded") |
+ || ip.app_method.equals("Foliar Application") |
+ || ip.app_method.equals("Soil Incorporated") |
+ || ip.app_rate.equals("LOW")) { |
+ ai_psrp = "LOW"; |
+ } else if (ip.app_area.equals("Spot Treatment") |
+ || ip.app_rate.equals("ULTRA LOW")) { |
+ ai_psrp = "VERY LOW"; |
+ } else { |
+ ai_psrp = "INTERMEDIATE"; |
+ } |
+ } |
+ |
+ // #Compute pesticide adsorbed runoff potential for each operation pesticide |
+ String ai_parp; |
+ if ((ai_hl >= 40 && ai_koc >= 1000) |
+ || (ai_hl >= 40 && ai_koc >= 500 && ai_sol <= 0.5)) { |
+ if (ip.app_area.equals("Banded") |
+ || ip.app_method.equals("Foliar Application") |
+ || ip.app_method.equals("Soil Incorporate") |
+ || ip.app_rate.equals("LOW")) { |
+ ai_parp = "INTERMEDIATE"; |
+ } else if (ip.app_area.equals("Spot Treatment") |
+ || ip.app_rate.equals("ULTRA LOW")) { |
+ ai_parp = "LOW"; |
+ } else { |
+ ai_parp = "HIGH"; |
+ } |
+ } else if ((ai_hl <= 1) || (ai_hl <= 2 && ai_koc <= 500) |
+ || (ai_hl <= 4 && ai_koc <= 900 && ai_sol >= 0.5) |
+ || (ai_hl <= 40 && ai_koc <= 500 && ai_sol >= 0.5) |
+ || (ai_hl <= 50 && ai_koc <= 900 && ai_sol >= 2)) { |
+ if (ip.app_area.equals("Banded") |
+ || ip.app_area.equals("Spot Treatment") |
+ || ip.app_method.equals("Foliar Application") |
+ || ip.app_method.equals("Soil Incorporated") |
+ || ip.app_rate.equals("LOW") |
+ || ip.app_rate.equals("ULTRA LOW")) { |
+ ai_parp = "VERY LOW"; |
+ } else { |
+ ai_parp = "LOW"; |
+ } |
+ } else { |
+ if (ip.app_area.equals("Banded") |
+ || ip.app_method.equals("Foliar Application") |
+ || ip.app_method.equals("Soil Incorporated") |
+ || ip.app_rate.equals("LOW")) { |
+ ai_parp = "VERY LOW"; |
+ } else { |
+ ai_parp = "INTERMEDIATE"; |
+ } |
+ } |
+ Result1 result = new Result1(ip.AoAId, ip.operation_id, |
+ ip.op_pest_id, ip.app_rate, ai_name, ai_ph, ai_hl, |
+ ai_koc, ai_sol, ai_humtox, ai_humtoxtype, ai_fishtox, |
+ ai_fishtoxtype, ai_plp, ai_psrp, ai_parp, |
+ ip.app_area, ip.app_method); |
+ result1.add(result); |
+ } |
+ } catch (SQLException se) { |
+ LOG.info("Did not open database for WQM-4!"); |
+ LOG.info(se.getMessage()); |
+ } finally { |
+ if (statement != null) { |
+ statement.close(); |
+ } |
+ if (conn != null) { |
+ conn.close(); |
} |
} |
- @Override |
- protected String process() throws Exception |
- { |
- Connection conn = null; |
- Statement statement = null; |
- Class.forName("org.postgresql.Driver"); |
- conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432/wqm", "postgres", "admin"); |
- conn.setAutoCommit(false); |
- statement = conn.createStatement(); |
- |
- for(Input ip:components) |
- { |
- String pc_code=""; |
- String ai_name=""; |
- Double ai_ph=0.0; |
- Double ai_sol=0.0; |
- Double ai_koc=0.0; |
- Double ai_hl=0.0; |
- Double ai_fishtox=0.0; |
- String ai_fishtoxtype=""; |
- Double ai_humtox=0.0; |
- String ai_humtoxtype=""; |
- |
- String query="SELECT * FROM wqm_pesticides WHERE \"PC_CODE\"='"+ip.op_pest_id+"';"; |
- ResultSet results = statement.executeQuery(query); |
- while (results.next()) |
- { |
- pc_code=results.getString("PC_CODE"); |
- ai_name=results.getString("AI_NAME"); |
- ai_ph=results.getDouble("PH"); |
- ai_sol=results.getDouble("SOL_RV"); |
- ai_koc=results.getDouble("KOC_RV"); |
- ai_hl=results.getDouble("SOIL_HL_RV"); |
- ai_fishtox=results.getDouble("FISH_TOX_PPB"); |
- ai_fishtoxtype=results.getString("FISH_TOX_TYPE"); |
- ai_humtox=results.getDouble("HUMAN_TOX_PPB"); |
- ai_humtoxtype=results.getString("HUMAN_TOX_TYPE"); |
- } |
- // #Compute pesticide leaching potential fore each operation pesticide |
- double log_val=Math.log(ai_hl)*(4-Math.log(ai_koc)); |
- String ai_plp=""; |
- if(log_val>=2.8) |
- { |
- if(ip.app_area.equals("Banded")||ip.app_method.equals("Foliar Application")||ip.app_rate.equals("LOW")) |
- { |
- ai_plp="INTERMEDIATE"; |
- } |
- else if(ip.app_area.equals("Spot Treatment")||ip.app_rate.equals("ULTRA LOW")) |
- { |
- ai_plp="LOW"; |
- } |
- else |
- { |
- ai_plp="HIGH"; |
- } |
- |
- } |
- else if(log_val<0.0 || (ai_sol<1 && ai_hl<=1)) |
- { |
- ai_plp="VERY LOW"; |
- } |
- else if(log_val<=1.8) |
- { |
- if(ip.app_area.equals("Banded")||ip.app_area.equals("Spot Treatment")||ip.app_method.equals("Foliar Application")||ip.app_rate.equals("LOW")||ip.app_rate.equals("ULTRA LOW")) |
- { |
- ai_plp="VERY LOW"; |
- |
- } |
- else |
- { |
- ai_plp="LOW"; |
- } |
- } |
- else |
- { |
- if(ip.app_area.equals("Banded")||ip.app_method.equals("Foliar Application")||ip.app_rate.equals("LOW")) |
- { |
- ai_plp="LOW"; |
- } |
- else if(ip.app_area.equals("Spot Treatment")||ip.app_rate.equals("ULTRA LOW")) |
- { |
- ai_plp="VERY LOW"; |
- } |
- else |
- { |
- ai_plp="INTERMEDIATE"; |
- } |
- |
- }String ai_psrp=""; |
- // #Compute pesticide solution runoff potential for each operation pesticide |
- if((ai_sol>=1 && ai_hl>35 && ai_koc <100000) ||(ai_sol >=10 && ai_hl <100 &&ai_koc <=700 )) |
- { |
- if(ip.app_area.equals("Banded")||ip.app_method.equals("Foliar Application")||ip.app_method.equals("Soil Incorporated") || ip.app_rate.equals("LOW")) |
- { |
- ai_psrp="INTERMEDIATE"; |
- } |
- else if(ip.app_area.equals("Spot Treatment")||ip.app_rate.equals("ULTRA LOW")) |
- { |
- ai_plp="LOW"; |
- } |
- else |
- { |
- ai_psrp="HIGH"; |
- } |
- } |
- else if((ai_koc>=100000)||(ai_koc>=1000 && ai_hl<=1)|| (ai_sol<0.5 && ai_hl<35)) |
- { |
- if(ip.app_area.equals("Banded")||ip.app_area.equals("Spot Treatment")||ip.app_method.equals("Foliar Application")||ip.app_method.equals("Soil Incorporated")||ip.app_rate.equals("LOW")||ip.app_rate.equals("ULTRA LOW")) |
- { |
- ai_psrp="VERY LOW"; |
- } |
- else |
- { |
- ai_psrp="LOW"; |
- } |
- } |
- else |
- { |
- if(ip.app_area.equals("Banded")||ip.app_method.equals("Foliar Application")||ip.app_method.equals("Soil Incorporated")||ip.app_rate.equals("LOW")) |
- { |
- ai_psrp="LOW"; |
- } |
- else if(ip.app_area.equals("Spot Treatment")||ip.app_rate.equals("ULTRA LOW")) |
- { |
- ai_psrp="VERY LOW"; |
- } |
- else |
- { |
- ai_psrp="INTERMEDIATE"; |
- } |
- } |
- // #Compute pesticide adsorbed runoff potential for each operation pesticide |
- String ai_parp=""; |
- if((ai_hl>=40&&ai_koc>=1000)||(ai_hl>=40 &&ai_koc>=500 &&ai_sol<=0.5)) |
- { |
- if(ip.app_area.equals("Banded")||ip.app_method.equals("Foliar Application")||ip.app_method.equals("Soil Incorporate")||ip.app_rate.equals("LOW")) |
- { |
- ai_parp="INTERMEDIATE"; |
- } |
- else if(ip.app_area.equals("Spot Treatment")||ip.app_rate.equals("ULTRA LOW")) |
- { |
- ai_parp="LOW"; |
- } |
- else |
- { |
- ai_parp="HIGH"; |
- } |
- |
- } |
- else if((ai_hl<=1)||(ai_hl<=2 &&ai_koc<=500)||(ai_koc<=900 && ai_sol>=0.5)||(ai_hl<=40&&ai_koc<=500 && ai_sol>=0.5)||(ai_hl<=50 && ai_koc<=900 && ai_sol>=2)) |
- { |
- if(ip.app_area.equals("Banded")||ip.app_area.equals("Spot Treatment")||ip.app_method.equals("Foliar Application")||ip.app_method.equals("Soil Incorporated")||ip.app_rate.equals("LOW")||ip.app_rate.equals("ULTRA LOW")) |
- { |
- ai_parp="VERY LOW"; |
- } |
- else |
- { |
- ai_parp="LOW"; |
- } |
- } |
- Result1 result=new Result1(ip.AoAId,ip.operation_id,ip.op_pest_id,ip.app_rate,ai_name,ai_ph,ai_hl,ai_koc,ai_sol,ai_humtox,ai_humtoxtype,ai_fishtox,ai_fishtoxtype,ai_plp,ai_psrp,ai_parp,ip.app_area,ip.app_method); |
- result1.add(result); |
- } |
- return EXEC_OK; |
- } |
- @Override |
- //writing the results back to JSON |
+ return EXEC_OK; |
+ } |
+ |
+ @Override |
+ //writing the results back to JSON |
protected void postProcess() throws Exception { |
- JSONArray result1Arr = new JSONArray(); |
- for(Result1 rs1:result1) |
- { |
- JSONArray tmpArr = new JSONArray(); |
- tmpArr.put(JSONUtils.dataDesc("AoAId", rs1.AoAId, "Area of Analysis Identifier")); |
- tmpArr.put(JSONUtils.dataDesc("operation_id", rs1.operation_id, "Operation ID")); |
- |
- tmpArr.put(JSONUtils.dataDesc("op_pest_id", rs1.op_pest_id, "Pesticide Identifier (PC_CODE)")); |
- tmpArr.put(JSONUtils.dataDesc("app_rate", rs1.app_rate, "Pesticide Application Rating")); |
- tmpArr.put(JSONUtils.dataDesc("ai_name", rs1.ai_name, "Active Ingredient Name (AI_NAME)")); |
- tmpArr.put(JSONUtils.dataDesc("ai_ph", rs1.ai_ph, "Active ingredient pH of associate properties (PH)")); |
- tmpArr.put(JSONUtils.dataDesc("ai_hl", rs1.ai_hl, "Active ingredient field half life (HL)")); |
- tmpArr.put(JSONUtils.dataDesc("ai_koc", rs1.ai_koc, "Active ingredient soil organic carbon sorption coefficient (KOC)")); |
- tmpArr.put(JSONUtils.dataDesc("ai_sol", rs1.ai_sol, "Active ingredient solubility in water (SOL)")); |
- tmpArr.put(JSONUtils.dataDesc("ai_humtox", rs1.ai_humtox, "Active ingredient human toxicity value – long term")); |
- tmpArr.put(JSONUtils.dataDesc("ai_humtoxtype", rs1.ai_humtoxtype, "Active ingredient human toxicity type")); |
- tmpArr.put(JSONUtils.dataDesc("ai_fistox", rs1.ai_fishtox, "Active ingredient maximum acceptable toxicant concentration-fish")); |
- tmpArr.put(JSONUtils.dataDesc("ai_fishtoxtype", rs1.ai_fishtoxtype, "Active ingredient fish toxicity type")); |
- tmpArr.put(JSONUtils.dataDesc("ai_plp", rs1.ai_plp, "Active ingredient pesticide leaching potential")); |
- tmpArr.put(JSONUtils.dataDesc("ai_psrp", rs1.ai_psrp, "Active ingredient pesticide soil leaching potential")); |
- tmpArr.put(JSONUtils.dataDesc("ai_parp", rs1.ai_parp, "Active ingredient pesticide adsorbed runoff potential")); |
- tmpArr.put(JSONUtils.dataDesc("op_app_area", rs1.app_area, "Pesticide application operation area")); |
- tmpArr.put(JSONUtils.dataDesc("op_app_method", rs1.app_method, "Pesticide application operation method")); |
- result1Arr.put(JSONUtils.dataDesc("pesticide summary", tmpArr, "Pest")); |
- } |
- |
- putResult("operation", result1Arr); |
+ JSONArray result1Arr = new JSONArray(); |
+ for (Result1 rs1 : result1) { |
+ JSONArray tmpArr = new JSONArray(); |
+ tmpArr.put(JSONUtils.dataDesc("AoAId", rs1.AoAId, "Area of Analysis Identifier")); |
+ tmpArr.put(JSONUtils.dataDesc("operation_id", rs1.operation_id, "Operation ID")); |
+ tmpArr.put(JSONUtils.dataDesc("op_pest_id", rs1.op_pest_id, "Pesticide Identifier (PC_CODE)")); |
+ tmpArr.put(JSONUtils.dataDesc("app_rate", rs1.app_rate, "Pesticide Application Rating")); |
+ tmpArr.put(JSONUtils.dataDesc("ai_name", rs1.ai_name, "Active Ingredient Name (AI_NAME)")); |
+ tmpArr.put(JSONUtils.dataDesc("ai_ph", rs1.ai_ph, "Active ingredient pH of associate properties (PH)")); |
+ tmpArr.put(JSONUtils.dataDesc("ai_hl", rs1.ai_hl, "Active ingredient field half life (HL)")); |
+ tmpArr.put(JSONUtils.dataDesc("ai_koc", rs1.ai_koc, "Active ingredient soil organic carbon sorption coefficient (KOC)")); |
+ tmpArr.put(JSONUtils.dataDesc("ai_sol", rs1.ai_sol, "Active ingredient solubility in water (SOL)")); |
+ tmpArr.put(JSONUtils.dataDesc("ai_humtox", rs1.ai_humtox, "Active ingredient human toxicity value – long term")); |
+ tmpArr.put(JSONUtils.dataDesc("ai_humtoxtype", rs1.ai_humtoxtype, "Active ingredient human toxicity type")); |
+ tmpArr.put(JSONUtils.dataDesc("ai_fistox", rs1.ai_fishtox, "Active ingredient maximum acceptable toxicant concentration-fish")); |
+ tmpArr.put(JSONUtils.dataDesc("ai_fishtoxtype", rs1.ai_fishtoxtype, "Active ingredient fish toxicity type")); |
+ tmpArr.put(JSONUtils.dataDesc("ai_plp", rs1.ai_plp, "Active ingredient pesticide leaching potential")); |
+ tmpArr.put(JSONUtils.dataDesc("ai_psrp", rs1.ai_psrp, "Active ingredient pesticide soil leaching potential")); |
+ tmpArr.put(JSONUtils.dataDesc("ai_parp", rs1.ai_parp, "Active ingredient pesticide adsorbed runoff potential")); |
+ tmpArr.put(JSONUtils.dataDesc("op_app_area", rs1.app_area, "Pesticide application operation area")); |
+ tmpArr.put(JSONUtils.dataDesc("op_app_method", rs1.app_method, "Pesticide application operation method")); |
+ result1Arr.put(JSONUtils.dataDesc("pesticide summary", tmpArr, "Pest")); |
+ } |
+ putResult("operation", result1Arr); |
} |
- } |
- |
- |
+} |
@@ -1,80 +1,215 @@ |
{ |
- "metainfo": { |
- }, |
- "parameter": [ |
- { |
- "name": "pestcomponents", |
- "value": [ |
- [ |
- { |
- "name": "AoAId", |
- "value": 1, |
- "Description":"Area of Analysis Identifier" |
- |
- }, |
- { |
- "name": "operation_id", |
- "value": 1, |
- "Description":"Pesticide application operation identifier" |
- |
- }, |
- { |
- "name": "op_pest_id", |
- "value": "101101", |
- "Description":"Pesticide identifier, EPA Pesticide Chemical Code (PC_CODE)" |
- }, |
- { |
- "name": "app_rate", |
- "value": "STANDARD", |
- "Description":"Pesticide application rate" |
- }, |
- { |
- "name": "app_area", |
- "value": "Broadcast", |
- "Description":"Pesticide application operation area" |
- }, |
- { |
- "name": "app_method", |
- "value": "Surface Applied", |
- "Description":"Pesticide application operation method" |
- } |
- ], |
- [ |
- { |
- "name": "AoAId", |
- "value": 1, |
- "Description":"AoA Identifier" |
- |
- }, |
- { |
- "name": "operation_id", |
- "value": 1, |
- "Description":"Pesticide application operation identifier" |
- |
- }, |
- { |
- "name": "op_pest_id", |
- "value": "101702", |
- "Description":"Pesticide identifier, EPA Pesticide Chemical Code (PC_CODE)" |
- }, |
- { |
- "name": "app_rate", |
- "value": "LOW", |
- "Description":"Pesticide application rate" |
- }, |
- { |
- "name": "app_area", |
- "value": "Broadcast", |
- "Description":"Pesticide application operation area" |
- }, |
- { |
- "name": "app_method", |
- "value": "Surface Applied", |
- "Description":"Pesticide application operation method" |
- } |
+ "metainfo": { |
+ }, |
+ "parameter": [ |
+ { |
+ "name": "pestcomponents", |
+ "value": [ |
+ [ |
+ { |
+ "name": "AoAId", |
+ "value": 1, |
+ "Description": "Area of Analysis Identifier" |
+ |
+ }, |
+ { |
+ "name": "operation_id", |
+ "value": 1, |
+ "Description": "Pesticide application operation identifier" |
+ |
+ }, |
+ { |
+ "name": "op_pest_id", |
+ "value": "53501", |
+ "Description": "Pesticide identifier, EPA Pesticide Chemical Code (PC_CODE)" |
+ }, |
+ { |
+ "name": "app_rate", |
+ "value": "Starndard Rate", |
+ "Description": "Pesticide application rate" |
+ }, |
+ { |
+ "name": "app_area", |
+ "value": "Broadcast", |
+ "Description": "Pesticide application operation area" |
+ }, |
+ { |
+ "name": "app_method", |
+ "value": "Surface Applied", |
+ "Description": "Pesticide application operation method" |
+ } |
+ ], |
+ [ |
+ { |
+ "name": "AoAId", |
+ "value": 1, |
+ "Description": "Area of Analysis Identifier" |
+ |
+ }, |
+ { |
+ "name": "operation_id", |
+ "value": 2, |
+ "Description": "Pesticide application operation identifier" |
+ |
+ }, |
+ { |
+ "name": "op_pest_id", |
+ "value": "108801", |
+ "Description": "Pesticide identifier, EPA Pesticide Chemical Code (PC_CODE)" |
+ }, |
+ { |
+ "name": "app_rate", |
+ "value": "Starndard Rate", |
+ "Description": "Pesticide application rate" |
+ }, |
+ { |
+ "name": "app_area", |
+ "value": "Broadcast", |
+ "Description": "Pesticide application operation area" |
+ }, |
+ { |
+ "name": "app_method", |
+ "value": "Surface Applied", |
+ "Description": "Pesticide application operation method" |
+ } |
+ ], |
+ [ |
+ { |
+ "name": "AoAId", |
+ "value": 1, |
+ "Description": "Area of Analysis Identifier" |
+ |
+ }, |
+ { |
+ "name": "operation_id", |
+ "value": 3, |
+ "Description": "Pesticide application operation identifier" |
+ |
+ }, |
+ { |
+ "name": "op_pest_id", |
+ "value": "98301", |
+ "Description": "Pesticide identifier, EPA Pesticide Chemical Code (PC_CODE)" |
+ }, |
+ { |
+ "name": "app_rate", |
+ "value": "Starndard Rate", |
+ "Description": "Pesticide application rate" |
+ }, |
+ { |
+ "name": "app_area", |
+ "value": "Broadcast", |
+ "Description": "Pesticide application operation area" |
+ }, |
+ { |
+ "name": "app_method", |
+ "value": "Surface Applied", |
+ "Description": "Pesticide application operation method" |
+ } |
+ ], [ |
+ { |
+ "name": "AoAId", |
+ "value": 1, |
+ "Description": "Area of Analysis Identifier" |
+ |
+ }, |
+ { |
+ "name": "operation_id", |
+ "value": 4, |
+ "Description": "Pesticide application operation identifier" |
+ |
+ }, |
+ { |
+ "name": "op_pest_id", |
+ "value": "105001", |
+ "Description": "Pesticide identifier, EPA Pesticide Chemical Code (PC_CODE)" |
+ }, |
+ { |
+ "name": "app_rate", |
+ "value": "Starndard Rate", |
+ "Description": "Pesticide application rate" |
+ }, |
+ { |
+ "name": "app_area", |
+ "value": "Broadcast", |
+ "Description": "Pesticide application operation area" |
+ }, |
+ { |
+ "name": "app_method", |
+ "value": "Surface Applied", |
+ "Description": "Pesticide application operation method" |
+ } |
+ ], |
+ [ |
+ { |
+ "name": "AoAId", |
+ "value": 1, |
+ "Description": "Area of Analysis Identifier" |
+ |
+ }, |
+ { |
+ "name": "operation_id", |
+ "value": 5, |
+ "Description": "Pesticide application operation identifier" |
+ |
+ }, |
+ { |
+ "name": "op_pest_id", |
+ "value": "128008", |
+ "Description": "Pesticide identifier, EPA Pesticide Chemical Code (PC_CODE)" |
+ }, |
+ { |
+ "name": "app_rate", |
+ "value": "Starndard Rate", |
+ "Description": "Pesticide application rate" |
+ }, |
+ { |
+ "name": "app_area", |
+ "value": "Broadcast", |
+ "Description": "Pesticide application operation area" |
+ }, |
+ { |
+ "name": "app_method", |
+ "value": "Surface Applied", |
+ "Description": "Pesticide application operation method" |
+ } |
+ ], |
+ [ |
+ { |
+ "name": "AoAId", |
+ "value": 1, |
+ "Description": "Area of Analysis Identifier" |
+ |
+ }, |
+ { |
+ "name": "operation_id", |
+ "value": 6, |
+ "Description": "Pesticide application operation identifier" |
+ |
+ }, |
+ { |
+ "name": "op_pest_id", |
+ "value": "81901", |
+ "Description": "Pesticide identifier, EPA Pesticide Chemical Code (PC_CODE)" |
+ }, |
+ { |
+ "name": "app_rate", |
+ "value": "Starndard Rate", |
+ "Description": "Pesticide application rate" |
+ }, |
+ { |
+ "name": "app_area", |
+ "value": "Broadcast", |
+ "Description": "Pesticide application operation area" |
+ }, |
+ { |
+ "name": "app_method", |
+ "value": "Surface Applied", |
+ "Description": "Pesticide application operation method" |
+ } |
+ ] |
+ ] |
+ } |
] |
- ] |
- } |
- ] |
} |
|
@@ -78,13 +78,13 @@ |
|
for (Input ip : components) { |
|
- query = "SELECT wqm_ilp FROM wqm_soil_pest_interaction_leaching WHERE wqm_plp='" + ip.ai_plp + "'AND wqm_slp='" + ip.aoa_pslp + "';"; |
+ query = "SELECT wqm_ilp FROM wqm_soil_pest_interaction_leaching WHERE wqm_plp='" + ip.getAi_plp() + "' AND wqm_slp='" + ip.getAoa_pslp() + "';"; |
resultSet = statement.executeQuery(query); |
String op_pest_ilp = "err"; |
while (resultSet.next()) { |
op_pest_ilp = resultSet.getString("wqm_ilp"); |
} |
- if (ip.aoa_rain_prob.equals("LOW")) { |
+ if (ip.getAoa_rain_prob().equals("LOW")) { |
switch (op_pest_ilp) { |
case "HIGH": |
op_pest_ilp = "INTERMEDIATE"; |
@@ -98,13 +98,13 @@ |
} |
} |
|
- query = "SELECT wqm_isrp FROM wqm_soil_pest_interaction_solution_runoff WHERE wqm_psrp='" + ip.ai_psrp + "'AND wqm_ssrp ='" + ip.aoa_ssrp + "';"; |
+ query = "SELECT wqm_isrp FROM wqm_soil_pest_interaction_solution_runoff WHERE wqm_psrp='" + ip.getAi_psrp() + "' AND wqm_ssrp ='" + ip.getAoa_ssrp() + "';"; |
resultSet = statement.executeQuery(query); |
String op_pest_isrp = "err"; |
while (resultSet.next()) { |
op_pest_isrp = resultSet.getString("wqm_isrp"); |
} |
- if (ip.aoa_rain_prob.equals("LOW")) { |
+ if (ip.getAoa_rain_prob().equals("LOW")) { |
switch (op_pest_isrp) { |
case "HIGH": |
op_pest_isrp = "INTERMEDIATE"; |
@@ -112,19 +112,16 @@ |
case "INTERMEDIATE": |
op_pest_isrp = "LOW"; |
break; |
- case "LOW": |
- op_pest_isrp = "VERY LOW"; |
- break; |
} |
} |
|
- query = "SELECT wqm_iarp FROM wqm_soil_pest_interaction_adsorbed_runoff WHERE wqm_parp='" + ip.ai_parp + "'AND wqm_sarp='" + ip.aoa_sarp + "';"; |
+ query = "SELECT wqm_iarp FROM wqm_soil_pest_interaction_adsorbed_runoff WHERE wqm_parp='" + ip.getAi_parp() + "' AND wqm_sarp='" + ip.getAoa_sarp() + "';"; |
resultSet = statement.executeQuery(query); |
String op_pest_iarp = "err"; |
while (resultSet.next()) { |
op_pest_iarp = resultSet.getString("wqm_iarp"); |
} |
- if (ip.aoa_rain_prob.equals("LOW")) { |
+ if (ip.getAoa_rain_prob().equals("LOW")) { |
switch (op_pest_iarp) { |
case "HIGH": |
op_pest_iarp = "INTERMEDIATE"; |
@@ -132,13 +129,10 @@ |
case "INTERMEDIATE": |
op_pest_iarp = "LOW"; |
break; |
- case "LOW": |
- op_pest_iarp = "VERY LOW"; |
- break; |
} |
} |
|
- Result result1 = new Result(ip.AoAId, ip.operation_id, ip.op_pesticide_id, op_pest_ilp, op_pest_isrp, op_pest_iarp); |
+ Result result1 = new Result(ip.getAoaId(), ip.getOperationId(), ip.getPesticideId(), op_pest_ilp, op_pest_isrp, op_pest_iarp); |
result.add(result1); |
} |
} catch (SQLException se) { |
@@ -161,12 +155,12 @@ |
JSONArray resultArr = new JSONArray(); |
for (Result rs1 : result) { |
JSONArray tmpArr = new JSONArray(); |
- tmpArr.put(JSONUtils.dataDesc("AoAId", rs1.AoAId, "Area of Analysis Identifier")); |
- tmpArr.put(JSONUtils.dataDesc("operation_id", rs1.operation_id, "Pesticide Application Operation Identifier")); |
- tmpArr.put(JSONUtils.dataDesc("op_pesticide_id", rs1.op_pesticide_id, "Pesticide identifier, EPA Pesticide Chemical Code (PC_CODE)")); |
- tmpArr.put(JSONUtils.dataDesc("op_pest_ilp", rs1.op_pest_ilp, "Operation Soil Pesticide Interaction Leaching Potential")); |
- tmpArr.put(JSONUtils.dataDesc("op_pest_isrp", rs1.op_pest_isrp, "Operation Soil Pesticide Interaction Solution Runoff Potential")); |
- tmpArr.put(JSONUtils.dataDesc("op_pest_iarp", rs1.op_pest_iarp, "Operation Soil Pesticide Interaction Adsorbed Runoff Potential")); |
+ tmpArr.put(JSONUtils.dataDesc("AoAId", rs1.getAoaId(), "Area of Analysis Identifier")); |
+ tmpArr.put(JSONUtils.dataDesc("operation_id", rs1.getOperationId(), "Pesticide Application Operation Identifier")); |
+ tmpArr.put(JSONUtils.dataDesc("op_pesticide_id", rs1.getOpPesticideId(), "Pesticide identifier, EPA Pesticide Chemical Code (PC_CODE)")); |
+ tmpArr.put(JSONUtils.dataDesc("op_pest_ilp", rs1.getOpPestIlp(), "Operation Soil Pesticide Interaction Leaching Potential")); |
+ tmpArr.put(JSONUtils.dataDesc("op_pest_isrp", rs1.getOpPestIsrp(), "Operation Soil Pesticide Interaction Solution Runoff Potential")); |
+ tmpArr.put(JSONUtils.dataDesc("op_pest_iarp", rs1.getOpPestIarp(), "Operation Soil Pesticide Interaction Adsorbed Runoff Potential")); |
resultArr.put(JSONUtils.dataDesc("pesticide summary", tmpArr, "Pest")); |
} |
putResult("operation", resultArr); |