Displaying differences for changeset
 
display as  

src/java/m/wqm/nuttechscores/Input.java

@@ -1,9 +1,9 @@
-
 package m.wqm.nuttechscores;
 
 /**
  *
  * @author Kontham Srinivas Reddy
+ * @update Rumpal Sidhu
  */
 public class Input {
 
@@ -11,13 +11,14 @@
     int plan_techn_id;
     String plan_techn_discrim_type;
     String plan_techn_discrim;
-    public Input(int AoAid,int plan_techn_id,String plan_techn_discrim_type,String plan_techn_discrim)
-    {
-        this.AoAid=AoAid;
-        this.plan_techn_id=plan_techn_id;
-        this.plan_techn_discrim_type=plan_techn_discrim_type;
-        this.plan_techn_discrim=plan_techn_discrim;
-        
+
+    public Input(int AoAid, int plan_techn_id, String plan_techn_discrim_type,
+            String plan_techn_discrim) {
+        this.AoAid = AoAid;
+        this.plan_techn_id = plan_techn_id;
+        this.plan_techn_discrim_type = plan_techn_discrim_type;
+        this.plan_techn_discrim = plan_techn_discrim;
+
     }
-    
+
 }

src/java/m/wqm/nuttechscores/Result1.java

@@ -3,37 +3,42 @@
 /**
  *
  * @author Srinivas Reddy Kontham
+ * @ Update Rumpal Sidhu
  */
+public class Result1 {
 
-public class Result1 
-{
-            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 Result1(int AoAid,int nleach_techn_score,int nsurf_techn_score,int psurf_techn_score,int nleach_avoid_techn_score,int nleach_control_techn_score,int nleach_trap_techn_score,int nsurf_avoid_techn_score,int nsurf_control_techn_score,int nsurf_trap_techn_score,int psurf_avoid_techn_score,int psurf_control_techn_score,int psurf_trap_techn_score)
-    {
-         this.nleach_techn_score=nleach_techn_score;
-         this.nleach_avoid_techn_score=nleach_avoid_techn_score;
-         this.nleach_control_techn_score=nleach_control_techn_score;
-         this.nleach_trap_techn_score=nleach_trap_techn_score;
-         this.nsurf_techn_score=nsurf_techn_score;
-         this.nsurf_avoid_techn_score=nsurf_avoid_techn_score;
-         this.nsurf_control_techn_score=nsurf_control_techn_score;
-         this.nsurf_trap_techn_score=nsurf_trap_techn_score;
-         this.psurf_techn_score=psurf_techn_score;
-         this.psurf_avoid_techn_score=psurf_avoid_techn_score;
-         this.psurf_control_techn_score=psurf_control_techn_score;
-         this.psurf_trap_techn_score=psurf_trap_techn_score;
-         this.AoAid=AoAid;
+    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 Result1(int AoAid, int nleach_techn_score, int nsurf_techn_score, 
+            int psurf_techn_score, int nleach_avoid_techn_score, 
+            int nleach_control_techn_score, int nleach_trap_techn_score, 
+            int nsurf_avoid_techn_score, int nsurf_control_techn_score, 
+            int nsurf_trap_techn_score, int psurf_avoid_techn_score, 
+            int psurf_control_techn_score, int psurf_trap_techn_score) {
+        this.nleach_techn_score = nleach_techn_score;
+        this.nleach_avoid_techn_score = nleach_avoid_techn_score;
+        this.nleach_control_techn_score = nleach_control_techn_score;
+        this.nleach_trap_techn_score = nleach_trap_techn_score;
+        this.nsurf_techn_score = nsurf_techn_score;
+        this.nsurf_avoid_techn_score = nsurf_avoid_techn_score;
+        this.nsurf_control_techn_score = nsurf_control_techn_score;
+        this.nsurf_trap_techn_score = nsurf_trap_techn_score;
+        this.psurf_techn_score = psurf_techn_score;
+        this.psurf_avoid_techn_score = psurf_avoid_techn_score;
+        this.psurf_control_techn_score = psurf_control_techn_score;
+        this.psurf_trap_techn_score = psurf_trap_techn_score;
+        this.AoAid = AoAid;
     }
 }

src/java/m/wqm/nuttechscores/V1_0.java

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

src/java/m/wqm/nuttechscores/V1_0.json

@@ -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"
+                    }
+                ]
+            ]
+        }
     ]
-   ]
-  }
- ]
 }

src/java/m/wqm/pesthazrating/V1_0.java

@@ -181,8 +181,8 @@
                 while(results.next())
                 {
                     op_phr_leach_matcfish=results.getString("wqm_phr");
-                }
-                query="SELECT wqm_phr FROM wqm_pesticide_hazard_potential WHERE wqm_ilr="+op_pest_isrp_temp+"AND wqm_eat="+ eat_rating_stvfish_temp;
+                }             
+                query="SELECT wqm_phr FROM wqm_pesticide_hazard_potential WHERE wqm_ilr="+op_pest_isrp_temp+"AND wqm_eat="+ eat_rating_matcfish_temp;
                 results = statement.executeQuery(query);
                 String op_phr_sorun_matcfish="";
                 while(results.next())

src/java/m/wqm/pesticidesarp/Input.java

@@ -1,13 +1,9 @@
-/*
- * 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.
- */
 package m.wqm.pesticidesarp;
 
 /**
- * 
+ *
  * @author Srinivasredy10392
+ * @update Rumpal Sidhu
  */
 // this class is mainly used to store the input soil components
 public class Input {
@@ -19,16 +15,17 @@
     double aoa_comp_kfact;
     boolean aoa_comp_slopegr15;
     boolean aoa_comp_drained;
-    public Input(int AoAId,String cokey,double aoa_comp_area,String aoa_comp_hsg,double aoa_comp_kfact,boolean aoa_comp_slopegr15,boolean aoa_comp_drained)
-    {
-        this.AoAId=AoAId;
-        this.cokey=cokey;
-        this.aoa_comp_area=aoa_comp_area;
-        this.aoa_comp_hsg=aoa_comp_hsg;
-        this.aoa_comp_kfact=aoa_comp_kfact;
-        this.aoa_comp_slopegr15=aoa_comp_slopegr15;
-        this.aoa_comp_drained=aoa_comp_drained;
+
+    public Input(int AoAId, String cokey, double aoa_comp_area,
+            String aoa_comp_hsg, double aoa_comp_kfact,
+            boolean aoa_comp_slopegr15, boolean aoa_comp_drained) {
+        this.AoAId = AoAId;
+        this.cokey = cokey;
+        this.aoa_comp_area = aoa_comp_area;
+        this.aoa_comp_hsg = aoa_comp_hsg;
+        this.aoa_comp_kfact = aoa_comp_kfact;
+        this.aoa_comp_slopegr15 = aoa_comp_slopegr15;
+        this.aoa_comp_drained = aoa_comp_drained;
     }
-    
+
 }
-

src/java/m/wqm/pesticidesarp/Result1.java

@@ -1,8 +1,3 @@
-/*
- * 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.
- */
 package m.wqm.pesticidesarp;
 
 /**
@@ -11,18 +6,18 @@
  */
 // this class is used to store the results of each soil component
 public class Result1 {
+
     int AoAId;
     String cokey;
     double aoa_comp_area;
     String comp_sarp;
     int comp_sarp_number;
-    public Result1(int AoAId,String cokey,double aoa_comp_area,String comp_sarp,int comp_sarp_number)
-    {
-        this.AoAId=AoAId;
-        this.cokey=cokey;
-        this.aoa_comp_area=aoa_comp_area;
-        this.comp_sarp=comp_sarp;
-        this.comp_sarp_number=comp_sarp_number;
+
+    public Result1(int AoAId, String cokey, double aoa_comp_area, String comp_sarp, int comp_sarp_number) {
+        this.AoAId = AoAId;
+        this.cokey = cokey;
+        this.aoa_comp_area = aoa_comp_area;
+        this.comp_sarp = comp_sarp;
+        this.comp_sarp_number = comp_sarp_number;
     }
 }
-

src/java/m/wqm/pesticidesarp/V1_0.java

@@ -1,9 +1,5 @@
-/*
- * 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.
- */
 package m.wqm.pesticidesarp;
+
 import csip.ModelDataService;
 import static csip.ModelDataService.EXEC_OK;
 import java.util.ArrayList;
@@ -18,116 +14,106 @@
 /**
  *
  * @ Srinivas
+ * @ update Rumpal Sidhu
  */
-@Name("Pesticide Soil Adsorbed Runoff Potential (PesticideSARP)")
-@Description("Clculating Pesticide Soil Adsorbed Runoff Potential")
+@Name("WQM-9:Pesticide Soil Adsorbed Runoff Potential (PesticideSARP)")
+@Description("Calculating Pesticide Soil Adsorbed Runoff Potential")
 @Path("m/pesticide_sarp/1.0")
 
-public class V1_0 extends ModelDataService{
-    String comp_sarp[]=new String[]{"","LOW","INTERMEDIATE","HIGH"};
+public class V1_0 extends ModelDataService {
+
+    String comp_sarp[] = new String[]{"", "LOW", "INTERMEDIATE", "HIGH"};
     int comp_sarp_number;
     String aoa_sarp;
 
     //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
-    @Override
-        // reading the inputs from the json file into input object and placing it in the arraylist
-        protected void preProcess() throws Exception {
-        JSONArray groups = getJSONArrayParam("soilcomponents");
-            for(int i=0;i<groups.length();i++)
-            {
-                Map<String, JSONObject> group = JSONUtils.preprocess(groups.getJSONArray(i));
-
-                
-                int AoAId = JSONUtils.getIntParam(group, "AoAId", 0);
-                String cokey=JSONUtils.getStringParam(group,"cokey","err");
-                double aoa_comp_area=JSONUtils.getDoubleParam(group,"aoa_comp_area",0);
-                String aoa_comp_hsg=JSONUtils.getStringParam(group,"aoa_comp_hsg","err");
-                double aoa_comp_kfact=JSONUtils.getDoubleParam(group,"aoa_comp_kfact",0);
-                boolean aoa_comp_slopegr15=JSONUtils.getBooleanParam(group,"aoa_comp_slopegr15",false);
-                boolean aoa_comp_drained=JSONUtils.getBooleanParam(group,"aoa_comp_drained",false);
-                Input input=new Input(AoAId,cokey,aoa_comp_area,aoa_comp_hsg,aoa_comp_kfact,aoa_comp_slopegr15,aoa_comp_drained);
-        components.add(input);
-            }
-        }
+    ArrayList<Input> components;// store the set of all input soilcomponents as objects
+    ArrayList<Result1> result1;  // store the result as objects
 
     @Override
-        protected String process() 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("soilcomponents");
+        for (int i = 0; i < groups.length(); i++) {
+            Map<String, JSONObject> group = JSONUtils.preprocess(groups.getJSONArray(i));
+            int AoAId = JSONUtils.getIntParam(group, "AoAId", 0);
+            String cokey = JSONUtils.getStringParam(group, "cokey", "err");
+            double aoa_comp_area = JSONUtils.getDoubleParam(group, "aoa_comp_area", 0);
+            String aoa_comp_hsg = JSONUtils.getStringParam(group, "aoa_comp_hsg", "err");
+            double aoa_comp_kfact = JSONUtils.getDoubleParam(group, "aoa_comp_kfact", 0);
+            boolean aoa_comp_slopegr15 = JSONUtils.getBooleanParam(group, "aoa_comp_slopegr15", false);
+            boolean aoa_comp_drained = JSONUtils.getBooleanParam(group, "aoa_comp_drained", false);
+            Input input = new Input(AoAId, cokey, aoa_comp_area, aoa_comp_hsg, aoa_comp_kfact, aoa_comp_slopegr15, aoa_comp_drained);
+            components.add(input);
+        }
+    }
+
+    @Override
+    protected String process() throws Exception {
+        result1 = new ArrayList<>();
         for (Input ip : components) {
-          if(((ip.aoa_comp_hsg.equals("C"))&&(ip.aoa_comp_kfact>=0.21))||((ip.aoa_comp_hsg.equals("D"))&&(ip.aoa_comp_kfact>=0.10)))
-          {
-                
-                comp_sarp_number=3;
-          }
-          else if(((ip.aoa_comp_hsg.equals("A")||ip.aoa_comp_hsg.equals("B"))&&(ip.aoa_comp_kfact<=0.10))||(ip.aoa_comp_hsg.equals("C")&&(ip.aoa_comp_kfact<=0.07))||(ip.aoa_comp_hsg.equals("D")&&(ip.aoa_comp_kfact<=0.02))||((ip.aoa_comp_hsg.equals("A/D")||ip.aoa_comp_hsg.equals("B/D"))&&(ip.aoa_comp_kfact<=0.10)&&ip.aoa_comp_drained==true)||((ip.aoa_comp_hsg.equals("C/D"))&&(ip.aoa_comp_kfact<=0.07)&&ip.aoa_comp_drained==true)||((ip.aoa_comp_hsg.equals("A/D")||ip.aoa_comp_hsg.equals("B/D")||ip.aoa_comp_hsg.equals("C/D"))&&(ip.aoa_comp_kfact<=0.02)&&ip.aoa_comp_drained==false))
-          {
-               if(!ip.aoa_comp_slopegr15)
-               {
-                   comp_sarp_number=1;
-               }
-               else
-               {
-                   comp_sarp_number=2;
-               }
-          }
-          else
-          {
-              if(!ip.aoa_comp_slopegr15)
-              {
-                  comp_sarp_number=2;
-              }
-              else
-              {
-                  comp_sarp_number=3;
-              }
-          }
-            Result1 result=new Result1(ip.AoAId,ip.cokey,ip.aoa_comp_area,comp_sarp[comp_sarp_number],comp_sarp_number);
+            if ((ip.aoa_comp_hsg.equals("C") && ip.aoa_comp_kfact >= 0.21)
+                    || (ip.aoa_comp_hsg.equals("D") && ip.aoa_comp_kfact >= 0.10)
+                    || (ip.aoa_comp_hsg.equals("C\\/D") && ip.aoa_comp_drained && ip.aoa_comp_kfact >= 0.21)) {
+                comp_sarp_number = 3;
+            } else if (ip.aoa_comp_hsg.equals("A")
+                    || (ip.aoa_comp_hsg.equals("B") && ip.aoa_comp_kfact <= 0.10)
+                    || (ip.aoa_comp_hsg.equals("C") && ip.aoa_comp_kfact <= 0.07)
+                    || (ip.aoa_comp_hsg.equals("D") && ip.aoa_comp_kfact <= 0.02)
+                    || (ip.aoa_comp_hsg.equals("A\\/D") && ip.aoa_comp_drained)
+                    || (ip.aoa_comp_hsg.equals("B\\/D") && ip.aoa_comp_kfact <= 0.10 && ip.aoa_comp_drained)
+                    || (ip.aoa_comp_hsg.equals("C\\/D") && ip.aoa_comp_kfact <= 0.07 && ip.aoa_comp_drained)
+                    || ((ip.aoa_comp_hsg.equals("A\\/D") || ip.aoa_comp_hsg.equals("B\\/D") || ip.aoa_comp_hsg.equals("C\\/D")) && ip.aoa_comp_kfact <= 0.02 && !ip.aoa_comp_drained)) {
+                if (!ip.aoa_comp_slopegr15) {
+                    comp_sarp_number = 1;
+                } else {
+                    comp_sarp_number = 2;
+                }
+            } else {
+                if (!ip.aoa_comp_slopegr15) {
+                    comp_sarp_number = 2;
+                } else {
+                    comp_sarp_number = 3;
+                }
+            }
+            Result1 result = new Result1(ip.AoAId, ip.cokey, ip.aoa_comp_area, comp_sarp[comp_sarp_number], comp_sarp_number);
             result1.add(result);
         }
         calAoANutSLP(result1);
-        return EXEC_OK;       
+        return EXEC_OK;
     }
-        @Override
-        //writing the results back to JSON
+
+    @Override
+    //writing the results back to JSON
     protected void postProcess() throws Exception {
-        for(int i=0;i<result1.size();i++)
-        {
-            
-            Result1 temp=result1.get(i);
-            putResult("AoAId",temp.AoAId,"Area of Analysis ID");
-            putResult("cokey",temp.cokey,"cokey");
-            putResult("aoa_comp_area",temp.aoa_comp_area,"Area of the soil component in the AoA");
-            putResult("comp_sarp",temp.comp_sarp,"Pesticide Soil Adsorbed Runoff Potential");
-            putResult("comp_sarp_number",temp.comp_sarp_number,"Integer Representinf Pesticide Soil Adsorbed Runoff Potential");
-        }    
-        putResult("aoa_sarp",aoa_sarp,"Pesticide Soil Adsorbed Runoff Potential of AoA");
+        for (int i = 0; i < result1.size(); i++) {
+            Result1 temp = result1.get(i);
+            putResult("AoAId", temp.AoAId, "Area of Analysis ID");
+            putResult("cokey", temp.cokey, "cokey");
+            putResult("aoa_comp_area", temp.aoa_comp_area, "Area of the soil component in the AoA");
+            putResult("comp_sarp", temp.comp_sarp, "Pesticide Soil Adsorbed Runoff Potential");
+            putResult("comp_sarp_number", temp.comp_sarp_number, "Integer Representinf Pesticide Soil Adsorbed Runoff Potential");
+        }
+        putResult("aoa_sarp", aoa_sarp, "Pesticide Soil Adsorbed Runoff Potential of AoA");
     }
-   // calculate the aoa_nslp 
-    void calAoANutSLP(ArrayList<Result1> source)
-    {
-        double cum_pslp_product=0;
-        double aoa_area=0;
-        
-        for(Result1 tmp:source)
-        {
-             cum_pslp_product+=(tmp.comp_sarp_number*tmp.aoa_comp_area);
-             aoa_area+=tmp.aoa_comp_area;
+
+    //#Compute weighted average pesticide soil adsorbed runoff potential for the AoA
+    void calAoANutSLP(ArrayList<Result1> source) {
+        double cum_sarp_product = 0;
+        double aoa_area = 0;
+
+        for (Result1 tmp : source) {
+            cum_sarp_product += (tmp.comp_sarp_number * tmp.aoa_comp_area);
+            aoa_area += tmp.aoa_comp_area;
         }
-        double aoa_pslp_fract=cum_pslp_product/aoa_area;
-        if(aoa_pslp_fract<=1.50)
-        {
-               aoa_sarp="LOW"; 
-        }
-        else if(aoa_pslp_fract>1.50&&aoa_pslp_fract<=2.50)
-        {
-            aoa_sarp="INTERMEDIATE";
-        }
-        
-        else
-        {
-            aoa_sarp="HIGH";
+        double aoa_sarp_fract = cum_sarp_product / aoa_area;
+        if (aoa_sarp_fract <= 1.50) {
+            aoa_sarp = "LOW";
+        } else if (aoa_sarp_fract > 1.50 && aoa_sarp_fract <= 2.50) {
+            aoa_sarp = "INTERMEDIATE";
+        } else {
+            aoa_sarp = "HIGH";
         }
     }
 }

src/java/m/wqm/pesticidesarp/V1_0.json

@@ -1,201 +1,197 @@
 {
- "metainfo": {
- },
- "parameter": [
-  {
-   "name": "soilcomponents",
-   "value": [
-    [
-     {
-      "name": "AoAId",
-      "value": 1
-     },
-     {
-      "name": "cokey",
-      "value": "11510284"
-     },
-     {
-      "name": "aoa_comp_area",
-      "value": 45.84,
-      "description":"Area of the soil component in the AoA"
-      
-     },
-     {
-      "name": "aoa_comp_hsg",
-      "value": "A",
-      "description":"Hydrologic soil group of the soil component"
-      
-     },
-     {
-      "name": "aoa_comp_kfact",
-      "value": 0.24,
-      "description":"#K factor of the horizon representing the soil component; usually the surface horizon"
-     },
-     {
-         "name":"aoa_comp_slopegr15",
-         "value":true,
-         "description":"#Whether soil component representative slope is greater than 15% (true, false)"
-     },
-     {
-         "name":"aoa_comp_drained",
-         "value":false,
-         "description":"#Whether this soil component instance is drained"
-     }
-    ],
-    [
-     {
-      "name": "AoAId",
-      "value": 1
-     },
-     {
-      "name": "cokey",
-      "value": "11510284"
-     },
-     {
-      "name": "aoa_comp_area",
-      "value": 25.84,
-      "description":"Area of the soil component in the AoA"
-      
-     },
-     {
-      "name": "aoa_comp_hsg",
-      "value": "B",
-      "description":"Hydrologic soil group of the soil component"
-      
-     },
-     {
-      "name": "aoa_comp_kfact",
-      "value": 0.34,
-      "description":"#K factor of the horizon representing the soil component; usually the surface horizon"
-     },
-    
-     {
-         "name":"aoa_comp_slopegr15",
-         "value":false,
-         "description":"#Whether soil component representative slope is greater than 15% (true, false)"
-     },
-     {
-         "name":"aoa_comp_drained",
-         "value":true,
-         "description":"#Whether this soil component instance is drained"
-     }
-    ],
-    [
-     {
-      "name": "AoAId",
-      "value": 1
-     },
-     {
-      "name": "cokey",
-      "value": "11510284"
-     },
-     {
-      "name": "aoa_comp_area",
-      "value": 15.84,
-      "description":"Area of the soil component in the AoA"
-      
-     },
-     {
-      "name": "aoa_comp_hsg",
-      "value": "A/D",
-      "description":"Hydrologic soil group of the soil component"
-      
-     },
-     {
-      "name": "aoa_comp_kfact",
-      "value": 0.34,
-      "description":"#K factor of the horizon representing the soil component; usually the surface horizon"
-     },
-     
-     {
-         "name":"aoa_comp_slopegr15",
-         "value":true,
-         "description":"#Whether soil component representative slope is greater than 15% (true, false)"
-     },
-     {
-         "name":"aoa_comp_drained",
-         "value":false,
-         "description":"#Whether this soil component instance is drained"
-     }
-    ],
-    [
-     {
-      "name": "AoAId",
-      "value": 1
-     },
-     {
-      "name": "cokey",
-      "value": "11510284"
-     },
-     {
-      "name": "aoa_comp_area",
-      "value": 55.84,
-      "description":"Area of the soil component in the AoA"
-      
-     },
-     {
-      "name": "aoa_comp_hsg",
-      "value": "B/D",
-      "description":"Hydrologic soil group of the soil component"
-      
-     },
-     {
-      "name": "aoa_comp_kfact",
-      "value": 0.34,
-      "description":"#K factor of the horizon representing the soil component; usually the surface horizon"
-     },
-     
-     {
-         "name":"aoa_comp_slopegr15",
-         "value":false,
-         "description":"#Whether soil component representative slope is greater than 15% (true, false)"
-     },
-     {
-         "name":"aoa_comp_drained",
-         "value":false,
-         "description":"#Whether this soil component instance is drained"
-     }
-    ],
-    [
-     {
-      "name": "AoAId",
-      "value": 1
-     },
-     {
-      "name": "cokey",
-      "value": "11510284"
-     },
-     {
-      "name": "aoa_comp_area",
-      "value": 45.84,
-      "description":"Area of the soil component in the AoA"
-      
-     },
-     {
-      "name": "aoa_comp_hsg",
-      "value": "C/D",
-      "description":"Hydrologic soil group of the soil component"
-      
-     },
-     {
-      "name": "aoa_comp_kfact",
-      "value": 0.24,
-      "description":"#K factor of the horizon representing the soil component; usually the surface horizon"
-     },
-     
-     {
-         "name":"aoa_comp_slopegr15",
-         "value":false,
-         "description":"#Whether soil component representative slope is greater than 15% (true, false)"
-     },
-     {
-         "name":"aoa_comp_drained",
-         "value":true,
-         "description":"#Whether this soil component instance is drained"
-     }
+    "metainfo": {
+    },
+    "parameter": [
+        {
+            "name": "soilcomponents",
+            "value": [
+                [
+                    {
+                        "name": "AoAId",
+                        "value": 1
+                    },
+                    {
+                        "name": "cokey",
+                        "value": "11510284"
+                    },
+                    {
+                        "name": "aoa_comp_area",
+                        "value": 45.84,
+                        "description": "Area of the soil component in the AoA"
+
+                    },
+                    {
+                        "name": "aoa_comp_hsg",
+                        "value": "A",
+                        "description": "Hydrologic soil group of the soil component"
+
+                    },
+                    {
+                        "name": "aoa_comp_kfact",
+                        "value": 0.24,
+                        "description": "#K factor of the horizon representing the soil component; usually the surface horizon"
+                    },
+                    {
+                        "name": "aoa_comp_slopegr15",
+                        "value": true,
+                        "description": "#Whether soil component representative slope is greater than 15% (true, false)"
+                    },
+                    {
+                        "name": "aoa_comp_drained",
+                        "value": false,
+                        "description": "#Whether this soil component instance is drained"
+                    }
+                ],
+                [
+                    {
+                        "name": "AoAId",
+                        "value": 1
+                    },
+                    {
+                        "name": "cokey",
+                        "value": "11510284"
+                    },
+                    {
+                        "name": "aoa_comp_area",
+                        "value": 25.84,
+                        "description": "Area of the soil component in the AoA"
+
+                    },
+                    {
+                        "name": "aoa_comp_hsg",
+                        "value": "B",
+                        "description": "Hydrologic soil group of the soil component"
+
+                    },
+                    {
+                        "name": "aoa_comp_kfact",
+                        "value": 0.34,
+                        "description": "#K factor of the horizon representing the soil component; usually the surface horizon"
+                    },
+                    {
+                        "name": "aoa_comp_slopegr15",
+                        "value": false,
+                        "description": "#Whether soil component representative slope is greater than 15% (true, false)"
+                    },
+                    {
+                        "name": "aoa_comp_drained",
+                        "value": true,
+                        "description": "#Whether this soil component instance is drained"
+                    }
+                ],
+                [
+                    {
+                        "name": "AoAId",
+                        "value": 1
+                    },
+                    {
+                        "name": "cokey",
+                        "value": "11510284"
+                    },
+                    {
+                        "name": "aoa_comp_area",
+                        "value": 15.84,
+                        "description": "Area of the soil component in the AoA"
+
+                    },
+                    {
+                        "name": "aoa_comp_hsg",
+                        "value": "A/D",
+                        "description": "Hydrologic soil group of the soil component"
+
+                    },
+                    {
+                        "name": "aoa_comp_kfact",
+                        "value": 0.34,
+                        "description": "#K factor of the horizon representing the soil component; usually the surface horizon"
+                    },
+                    {
+                        "name": "aoa_comp_slopegr15",
+                        "value": true,
+                        "description": "#Whether soil component representative slope is greater than 15% (true, false)"
+                    },
+                    {
+                        "name": "aoa_comp_drained",
+                        "value": false,
+                        "description": "#Whether this soil component instance is drained"
+                    }
+                ],
+                [
+                    {
+                        "name": "AoAId",
+                        "value": 1
+                    },
+                    {
+                        "name": "cokey",
+                        "value": "11510284"
+                    },
+                    {
+                        "name": "aoa_comp_area",
+                        "value": 55.84,
+                        "description": "Area of the soil component in the AoA"
+
+                    },
+                    {
+                        "name": "aoa_comp_hsg",
+                        "value": "B/D",
+                        "description": "Hydrologic soil group of the soil component"
+
+                    },
+                    {
+                        "name": "aoa_comp_kfact",
+                        "value": 0.34,
+                        "description": "#K factor of the horizon representing the soil component; usually the surface horizon"
+                    },
+                    {
+                        "name": "aoa_comp_slopegr15",
+                        "value": false,
+                        "description": "#Whether soil component representative slope is greater than 15% (true, false)"
+                    },
+                    {
+                        "name": "aoa_comp_drained",
+                        "value": false,
+                        "description": "#Whether this soil component instance is drained"
+                    }
+                ],
+                [
+                    {
+                        "name": "AoAId",
+                        "value": 1
+                    },
+                    {
+                        "name": "cokey",
+                        "value": "11510284"
+                    },
+                    {
+                        "name": "aoa_comp_area",
+                        "value": 45.84,
+                        "description": "Area of the soil component in the AoA"
+
+                    },
+                    {
+                        "name": "aoa_comp_hsg",
+                        "value": "C/D",
+                        "description": "Hydrologic soil group of the soil component"
+
+                    },
+                    {
+                        "name": "aoa_comp_kfact",
+                        "value": 0.24,
+                        "description": "#K factor of the horizon representing the soil component; usually the surface horizon"
+                    },
+                    {
+                        "name": "aoa_comp_slopegr15",
+                        "value": false,
+                        "description": "#Whether soil component representative slope is greater than 15% (true, false)"
+                    },
+                    {
+                        "name": "aoa_comp_drained",
+                        "value": true,
+                        "description": "#Whether this soil component instance is drained"
+                    }
+                ]
+
+            ]
+        }
     ]
-    
-   ]
-  }
- ]
 }

src/java/m/wqm/pestlosspot/Input.java

@@ -1,27 +1,26 @@
-
 package m.wqm.pestlosspot;
 
 /**
  *
  * @author Srinivas Reddy Kontham
+ * @update Rumpal Sidhu
  */
-public class Input
-{
+public class Input {
+
     int operation_id;
     int AoAId;
     String op_pest_id;
     String app_rate;
     String app_area;
     String app_method;
-    
-    public Input(int AoAId,int operation_id,String op_pest_id,String app_rate,String app_area,String app_method)
-    {
-        this.AoAId=AoAId;
-        this.operation_id=operation_id;
-        this.op_pest_id=op_pest_id;
-        this.app_rate=app_rate;
-        this.app_area=app_area;
-        this.app_method=app_method;
-       
+
+    public Input(int AoAId, int operation_id, String op_pest_id, String app_rate, String app_area, String app_method) {
+        this.AoAId = AoAId;
+        this.operation_id = operation_id;
+        this.op_pest_id = op_pest_id;
+        this.app_rate = app_rate;
+        this.app_area = app_area;
+        this.app_method = app_method;
+
     }
 }

src/java/m/wqm/pestlosspot/Result1.java

@@ -3,46 +3,52 @@
 /**
  *
  * @author Kontham Srinivas Reddy
+ * @ Update Rumpal Sidhu
  */
-public class Result1 
-{
-                    int operation_id;
-                    int AoAId;
-                    String op_pest_id;
-                    String app_rate;
-                    String app_area;
-                    String app_method; 
-                    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 ai_plp;
-                    String ai_psrp;
-                    String ai_parp;
-                public Result1(int AoAId,int operation_id,String op_pest_id,String app_rate,String ai_name,Double ai_ph, Double ai_hl, Double ai_koc,Double ai_sol,Double humtox,String humtoxtype,Double fishtox,String fishtoxtype,String ai_plp,String ai_psrp,String ai_parp,String op_app_area,String op_app_method)
-                {
-                    this.AoAId=AoAId;
-                    this.operation_id=operation_id;
-                    this.op_pest_id=op_pest_id;
-                    this.app_rate=app_rate;
-                    this.ai_name=ai_name;
-                    this.ai_ph=ai_ph;
-                    this.ai_hl=ai_hl;
-                    this.ai_koc=ai_koc;
-                    this.ai_sol=ai_sol;
-                    this.ai_humtox=humtox;
-                    this.ai_humtoxtype=humtoxtype;
-                    this.ai_fishtox=fishtox;
-                    this.ai_fishtoxtype=fishtoxtype;
-                    this.ai_plp=ai_plp;
-                    this.ai_psrp=ai_psrp;
-                    this.ai_parp=ai_parp;
-                    this.app_area=op_app_area;
-                    this.app_method=op_app_method;
-                }
+public class Result1 {
+
+    int operation_id;
+    int AoAId;
+    String op_pest_id;
+    String app_rate;
+    String app_area;
+    String app_method;
+    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 ai_plp;
+    String ai_psrp;
+    String ai_parp;
+
+    public Result1(int AoAId, int operation_id, String op_pest_id, 
+            String app_rate, String ai_name, Double ai_ph, 
+            Double ai_hl, Double ai_koc, Double ai_sol, Double humtox, 
+            String humtoxtype, Double fishtox, String fishtoxtype, 
+            String ai_plp, String ai_psrp, String ai_parp, 
+            String op_app_area, String op_app_method) {
+        this.AoAId = AoAId;
+        this.operation_id = operation_id;
+        this.op_pest_id = op_pest_id;
+        this.app_rate = app_rate;
+        this.ai_name = ai_name;
+        this.ai_ph = ai_ph;
+        this.ai_hl = ai_hl;
+        this.ai_koc = ai_koc;
+        this.ai_sol = ai_sol;
+        this.ai_humtox = humtox;
+        this.ai_humtoxtype = humtoxtype;
+        this.ai_fishtox = fishtox;
+        this.ai_fishtoxtype = fishtoxtype;
+        this.ai_plp = ai_plp;
+        this.ai_psrp = ai_psrp;
+        this.ai_parp = ai_parp;
+        this.app_area = op_app_area;
+        this.app_method = op_app_method;
+    }
 }

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

@@ -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);
     }
-    }   
-    
-
+}

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

@@ -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"
+                    }
+                ]
+            ]
+        }
     ]
-   ]
-  }
- ]
 }
 

src/java/m/wqm/scpestslp/Input.java

@@ -1,13 +1,9 @@
-/*
- * 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.
- */
 package m.wqm.scpestslp;
 
 /**
- * 
+ *
  * @author Lenovo
+ * @update by Rumpal Sidhu
  */
 // this class is mainly used to store the input soil components
 public class Input {
@@ -21,18 +17,20 @@
     int aoa_comp_hzdepth;
     boolean aoa_comp_cracksgr24;
     boolean aoa_comp_hwt_lt_24;
-    public Input(int AoAId,String cokey,double aoa_comp_area,String aoa_comp_hsg,double aoa_comp_kfact,double aoa_comp_om, int aoa_comp_hzdepth, boolean aoa_comp_cracksgr24,boolean aoa_comp_hwt_lt_24)
-    {
-        this.AoAId=AoAId;
-        this.cokey=cokey;
-        this.aoa_comp_area=aoa_comp_area;
-        this.aoa_comp_hsg=aoa_comp_hsg;
-        this.aoa_comp_kfact=aoa_comp_kfact;
-        this.aoa_comp_om=aoa_comp_om;
-        this.aoa_comp_hzdepth=aoa_comp_hzdepth;
-        this.aoa_comp_cracksgr24=aoa_comp_cracksgr24;
-        this.aoa_comp_hwt_lt_24=aoa_comp_hwt_lt_24;
+
+    public Input(int AoAId, String cokey, double aoa_comp_area,
+            String aoa_comp_hsg, double aoa_comp_kfact, double aoa_comp_om,
+            int aoa_comp_hzdepth, boolean aoa_comp_cracksgr24,
+            boolean aoa_comp_hwt_lt_24) {
+        this.AoAId = AoAId;
+        this.cokey = cokey;
+        this.aoa_comp_area = aoa_comp_area;
+        this.aoa_comp_hsg = aoa_comp_hsg;
+        this.aoa_comp_kfact = aoa_comp_kfact;
+        this.aoa_comp_om = aoa_comp_om;
+        this.aoa_comp_hzdepth = aoa_comp_hzdepth;
+        this.aoa_comp_cracksgr24 = aoa_comp_cracksgr24;
+        this.aoa_comp_hwt_lt_24 = aoa_comp_hwt_lt_24;
     }
-    
+
 }
-

src/java/m/wqm/scpestslp/Result1.java

@@ -1,28 +1,25 @@
-/*
- * 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.
- */
 package m.wqm.scpestslp;
 
 /**
  *
  * @author Lenovo
+ * @update Rumpal Sidhu
  */
 // this class is used to store the results of each soil component
 public class Result1 {
+
     int AoAId;
     String cokey;
     double aoa_comp_area;
     String comp_pslp;
     int comp_pslp_number;
-    public Result1(int AoAId,String cokey,double aoa_comp_area,String comp_nslp,int comp_nslp_number)
-    {
-        this.AoAId=AoAId;
-        this.cokey=cokey;
-        this.aoa_comp_area=aoa_comp_area;
-        this.comp_pslp=comp_nslp;
-        this.comp_pslp_number=comp_nslp_number;
+
+    public Result1(int AoAId, String cokey, double aoa_comp_area, 
+            String comp_pslp, int comp_pslp_number) {
+        this.AoAId = AoAId;
+        this.cokey = cokey;
+        this.aoa_comp_area = aoa_comp_area;
+        this.comp_pslp = comp_pslp;
+        this.comp_pslp_number = comp_pslp_number;
     }
 }
-

src/java/m/wqm/scpestslp/V1_0.java

@@ -1,11 +1,6 @@
-/*
- * 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.
- */
 package m.wqm.scpestslp;
+
 import csip.ModelDataService;
-import static csip.ModelDataService.EXEC_OK;
 import java.util.ArrayList;
 import javax.ws.rs.Path;
 import oms3.annotations.Description;
@@ -18,143 +13,115 @@
 /**
  *
  * @ Srinivas
+ * @ Update Rumpal Sidhu
  */
-@Name("Pesticide Soil Leaching Potential (PesticideSLP)")
-@Description("Clculating Pesticide Soil Leaching Potential")
+@Name("WQM-7:Pesticide Soil Leaching Potential (PesticideSLP)")
+@Description("Calculating Pesticide Soil Leaching Potential")
 @Path("m/pesticide_slp/1.0")
 
-public class V1_0 extends ModelDataService{
-    String comp_pslp[]=new String[]{"","VERY LOW","LOW","INTERMEDIATE","HIGH"};
+public class V1_0 extends ModelDataService {
+
+    String comp_pslp[] = new String[]{"", "VERY LOW", "LOW", "INTERMEDIATE", "HIGH"};
     int comp_pslp_number;
     String aoa_pslp;
 
-    //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
-    @Override
-        // reading the inputs from the json file into input object and placing it in the arraylist
-        protected void preProcess() throws Exception {
-        JSONArray groups = getJSONArrayParam("soilcomponents");
-            for(int i=0;i<groups.length();i++)
-            {
-                Map<String, JSONObject> group = JSONUtils.preprocess(groups.getJSONArray(i));
-
-                
-                int AoAId = JSONUtils.getIntParam(group, "AoAId", 0);
-                String cokey=JSONUtils.getStringParam(group,"cokey","err");
-                double aoa_comp_area=JSONUtils.getDoubleParam(group,"aoa_comp_area",0);
-                String aoa_comp_hsg=JSONUtils.getStringParam(group,"aoa_comp_hsg","err");
-                double aoa_comp_kfact=JSONUtils.getDoubleParam(group,"aoa_comp_kfact",0);
-                double aoa_comp_om=JSONUtils.getDoubleParam(group, "aoa_comp_om", 0);
-                int aoa_comp_hzdepth=JSONUtils.getIntParam(group, "aoa_comp_hzdepth", 0);
-                boolean aoa_comp_cracksgr24=JSONUtils.getBooleanParam(group,"aoa_comp_cracksgr24",false);
-                boolean aoa_comp_hwt_lt_24=JSONUtils.getBooleanParam(group,"aoa_comp_hwt_lt_24",false);
-                Input input=new Input(AoAId,cokey,aoa_comp_area,aoa_comp_hsg,aoa_comp_kfact,aoa_comp_om,aoa_comp_hzdepth,aoa_comp_cracksgr24,aoa_comp_hwt_lt_24);
-        components.add(input);
-            }
-        }
+    //request
+    ArrayList<Input> components; // store the set of all input soilcomponents as objects
+    //response
+    ArrayList<Result1> result1;  // store the result as objects
 
     @Override
-        protected String process() 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("soilcomponents");
+        for (int i = 0; i < groups.length(); i++) {
+            Map<String, JSONObject> group = JSONUtils.preprocess(groups.getJSONArray(i));
+            int AoAId = JSONUtils.getIntParam(group, "AoAId", 0);
+            String cokey = JSONUtils.getStringParam(group, "cokey", "err");
+            double aoa_comp_area = JSONUtils.getDoubleParam(group, "aoa_comp_area", 0);
+            String aoa_comp_hsg = JSONUtils.getStringParam(group, "aoa_comp_hsg", "err");
+            double aoa_comp_kfact = JSONUtils.getDoubleParam(group, "aoa_comp_kfact", 0);
+            double aoa_comp_om = JSONUtils.getDoubleParam(group, "aoa_comp_om", 0);
+            int aoa_comp_hzdepth = JSONUtils.getIntParam(group, "aoa_comp_hzdepth", 0);
+            boolean aoa_comp_cracksgr24 = JSONUtils.getBooleanParam(group, "aoa_comp_cracksgr24", false);
+            boolean aoa_comp_hwt_lt_24 = JSONUtils.getBooleanParam(group, "aoa_comp_hwt_lt_24", false);
+            Input input = new Input(AoAId, cokey, aoa_comp_area, aoa_comp_hsg, aoa_comp_kfact, aoa_comp_om, aoa_comp_hzdepth, aoa_comp_cracksgr24, aoa_comp_hwt_lt_24);
+            components.add(input);
+        }
+    }
+
+    @Override
+    protected String process() throws Exception {
+        result1 = new ArrayList<>();
         for (Input ip : components) {
-           if(ip.aoa_comp_hwt_lt_24)
-           {
-               
-               comp_pslp_number=4;
-           }
-           else if(((ip.aoa_comp_hsg.equals("A")||ip.aoa_comp_hsg.equals("A/D"))&& (ip.aoa_comp_hzdepth*ip.aoa_comp_om<=30))||((ip.aoa_comp_hsg.equals("B")||ip.aoa_comp_hsg.equals("B/D"))&& (ip.aoa_comp_hzdepth*ip.aoa_comp_om<=9)&&ip.aoa_comp_kfact<=0.48)||((ip.aoa_comp_hsg.equals("B")||ip.aoa_comp_hsg.equals("B/D"))&& (ip.aoa_comp_hzdepth*ip.aoa_comp_om<=15)&&ip.aoa_comp_kfact<=0.26))
-           {
-               
-               comp_pslp_number=4;
-           }
-           else if(((ip.aoa_comp_hsg.equals("B")||ip.aoa_comp_hsg.equals("B/D"))&& (ip.aoa_comp_hzdepth*ip.aoa_comp_om>=35)&&ip.aoa_comp_kfact<=0.48)||((ip.aoa_comp_hsg.equals("B")||ip.aoa_comp_hsg.equals("B/D"))&& (ip.aoa_comp_hzdepth*ip.aoa_comp_om>=35)&&ip.aoa_comp_kfact>=0.20)||((ip.aoa_comp_hsg.equals("C")||ip.aoa_comp_hsg.equals("C/D"))&& (ip.aoa_comp_hzdepth*ip.aoa_comp_om<=10)&&ip.aoa_comp_kfact<=0.28)||((ip.aoa_comp_hsg.equals("C")||ip.aoa_comp_hsg.equals("C/D"))&& (ip.aoa_comp_hzdepth*ip.aoa_comp_om>=10)))
-           {
-               if(!ip.aoa_comp_cracksgr24)
-               {
-                   
-                   comp_pslp_number=2;
-               }
-               else
-               {
-                   
-                   comp_pslp_number=3;
-               }
-               
-           }    
-           else if(ip.aoa_comp_hsg.equals("D"))
-           {
-               if(!ip.aoa_comp_cracksgr24)
-               {
-                   
-                   comp_pslp_number=1;
-               }
-               else
-               {
-                   
-                   comp_pslp_number=2;
-               }
-           }
-           else
-           {
-               if(!ip.aoa_comp_cracksgr24)
-               {
-                   
-                   comp_pslp_number=3;
-               }
-               else
-               {
-                   
-                   comp_pslp_number=4;
-               }
-           }
-            Result1 result=new Result1(ip.AoAId,ip.cokey,ip.aoa_comp_area,comp_pslp[comp_pslp_number],comp_pslp_number);
+            if (ip.aoa_comp_hwt_lt_24) {
+                comp_pslp_number = 4;
+            } else if (((ip.aoa_comp_hsg.equals("A") || ip.aoa_comp_hsg.equals("A\\/D")) && (ip.aoa_comp_hzdepth * ip.aoa_comp_om <= 30))
+                    || ((ip.aoa_comp_hsg.equals("B") || ip.aoa_comp_hsg.equals("B\\/D")) && (ip.aoa_comp_hzdepth * ip.aoa_comp_om <= 9) && ip.aoa_comp_kfact <= 0.48)
+                    || ((ip.aoa_comp_hsg.equals("B") || ip.aoa_comp_hsg.equals("B\\/D")) && (ip.aoa_comp_hzdepth * ip.aoa_comp_om <= 15) && ip.aoa_comp_kfact <= 0.26)) {
+                comp_pslp_number = 4;
+            } else if (((ip.aoa_comp_hsg.equals("B") || ip.aoa_comp_hsg.equals("B\\/D")) && (ip.aoa_comp_hzdepth * ip.aoa_comp_om >= 35) && ip.aoa_comp_kfact >= 0.40)
+                    || ((ip.aoa_comp_hsg.equals("B") || ip.aoa_comp_hsg.equals("B\\/D")) && (ip.aoa_comp_hzdepth * ip.aoa_comp_om >= 45) && ip.aoa_comp_kfact >= 0.20)
+                    || ((ip.aoa_comp_hsg.equals("C") || ip.aoa_comp_hsg.equals("C\\/D")) && (ip.aoa_comp_hzdepth * ip.aoa_comp_om <= 10) && ip.aoa_comp_kfact <= 0.28)
+                    || ((ip.aoa_comp_hsg.equals("C") || ip.aoa_comp_hsg.equals("C\\/D")) && (ip.aoa_comp_hzdepth * ip.aoa_comp_om >= 10))) {
+                if (!ip.aoa_comp_cracksgr24) {
+                    comp_pslp_number = 2;
+                } else {
+                    comp_pslp_number = 3;
+                }
+            } else if (ip.aoa_comp_hsg.equals("D")) {
+                if (!ip.aoa_comp_cracksgr24) {
+                    comp_pslp_number = 1;
+                } else {
+                    comp_pslp_number = 2;
+                }
+            } else {
+                if (!ip.aoa_comp_cracksgr24) {
+                    comp_pslp_number = 3;
+                } else {
+                    comp_pslp_number = 4;
+                }
+            }
+            Result1 result = new Result1(ip.AoAId, ip.cokey, ip.aoa_comp_area, comp_pslp[comp_pslp_number], comp_pslp_number);
             result1.add(result);
         }
         calAoANutSLP(result1);
-        return EXEC_OK;       
+        return EXEC_OK;
     }
-        @Override
-        //writing the results back to JSON
+
+    @Override
+    //writing the results back to JSON
     protected void postProcess() throws Exception {
-        for(int i=0;i<result1.size();i++)
-        {
-            Result1 temp=result1.get(i);
-            putResult("AoAId",temp.AoAId,"Area of Analysis ID");
-            putResult("cokey",temp.cokey,"cokey");
-            putResult("aoa_comp_area",temp.aoa_comp_area,"Area of the soil component in the AoA");
-            putResult("comp_nslp",temp.comp_pslp,"Pesticide soil leaching potential representing the soil component");
-            putResult("comp_nslp_number",temp.comp_pslp_number,"Integer Representinf Pesticide Soil Leaching Potential");
-        }    
-        putResult("aoa_nslp",aoa_pslp,"Pesticide soil leaching potential representing the AoA");
+        for (int i = 0; i < result1.size(); i++) {
+            Result1 temp = result1.get(i);
+            putResult("AoAId", temp.AoAId, "Area of Analysis ID");
+            putResult("cokey", temp.cokey, "cokey");
+            putResult("aoa_comp_area", temp.aoa_comp_area, "Area of the soil component in the AoA");
+            putResult("comp_pslp", temp.comp_pslp, "Pesticide soil leaching potential representing the soil component");
+            putResult("comp_pslp_number", temp.comp_pslp_number, "Integer Representinf Pesticide Soil Leaching Potential");
+        }
+        putResult("aoa_pslp", aoa_pslp, "Pesticide soil leaching potential representing the AoA");
     }
-   // calculate the aoa_nslp 
-    void calAoANutSLP(ArrayList<Result1> source)
-    {
-        double cum_pslp_product=0;
-        double aoa_area=0;
-        
-        for(Result1 tmp:source)
-        {
-             cum_pslp_product+=(tmp.comp_pslp_number*tmp.aoa_comp_area);
-             aoa_area+=tmp.aoa_comp_area;
+
+    // calculate the aoa_nslp
+    void calAoANutSLP(ArrayList<Result1> source) {
+        double cum_pslp_product = 0;
+        double aoa_area = 0;
+
+        for (Result1 tmp : source) {
+            cum_pslp_product += (tmp.comp_pslp_number * tmp.aoa_comp_area);
+            aoa_area += tmp.aoa_comp_area;
         }
-        double aoa_pslp_fract=cum_pslp_product/aoa_area;
-        if(aoa_pslp_fract<=1.50)
-        {
-               aoa_pslp="VERY LOW"; 
-        }
-        else if(aoa_pslp_fract>1.50&&aoa_pslp_fract<=2.50)
-        {
-            aoa_pslp="LOW";
-        }
-        else if(aoa_pslp_fract>2.50&&aoa_pslp_fract<=3.50)
-        {
-            aoa_pslp="INTERMEDIATE";
-        }
-        else
-        {
-            aoa_pslp="HIGH";
+        double aoa_pslp_fract = cum_pslp_product / aoa_area;
+        if (aoa_pslp_fract <= 1.50) {
+            aoa_pslp = "VERY LOW";
+        } else if (aoa_pslp_fract > 1.50 && aoa_pslp_fract <= 2.50) {
+            aoa_pslp = "LOW";
+        } else if (aoa_pslp_fract > 2.50 && aoa_pslp_fract <= 3.50) {
+            aoa_pslp = "INTERMEDIATE";
+        } else {
+            aoa_pslp = "HIGH";
         }
     }
 }

src/java/m/wqm/scpestslp/V1_0.json

@@ -1,252 +1,252 @@
 {
- "metainfo": {
- },
- "parameter": [
-  {
-   "name": "soilcomponents",
-   "value": [
-    [
-     {
-      "name": "AoAId",
-      "value": 1
-     },
-     {
-      "name": "cokey",
-      "value": "11510284"
-     },
-     {
-      "name": "aoa_comp_area",
-      "value": 45.84,
-      "description":"Area of the soil component in the AoA"
-      
-     },
-     {
-      "name": "aoa_comp_hsg",
-      "value": "A",
-      "description":"Hydrologic soil group of the soil component"
-      
-     },
-     {
-      "name": "aoa_comp_kfact",
-      "value": 0.24,
-      "description":"#K factor of the horizon representing the soil component; usually the surface horizon"
-     },
-     {
-         "name":" aoa_comp_om",
-         "value":2.30,
-         "description":"#Organic matter content of the horizon representing the soil component"
-     },
-     {
-         "name":"aoa_comp_hzdepth",
-         "value":14,
-         "unit":"inches",
-         "description":"#Thickness of horizon representing the soil component"
-     },
-     {
-         "name":"aoa_comp_cracksgr24",
-         "value":true,
-         "description":"#Whether the soil has surface connected macropores to 24 inches"
-     },
-     {
-         "name":"aoa_comp_hwt_lt_24",
-         "value":false,
-         "description":"#Whether the soil has a water table less than 24 inches from the surface"
-     }
-    ],
-    [
-     {
-      "name": "AoAId",
-      "value": 1
-     },
-     {
-      "name": "cokey",
-      "value": "11510284"
-     },
-     {
-      "name": "aoa_comp_area",
-      "value": 25.84,
-      "description":"Area of the soil component in the AoA"
-      
-     },
-     {
-      "name": "aoa_comp_hsg",
-      "value": "B",
-      "description":"Hydrologic soil group of the soil component"
-      
-     },
-     {
-      "name": "aoa_comp_kfact",
-      "value": 0.34,
-      "description":"#K factor of the horizon representing the soil component; usually the surface horizon"
-     },
-     {
-         "name":" aoa_comp_om",
-         "value":2.30,
-         "description":"#Organic matter content of the horizon representing the soil component"
-     },
-     {
-         "name":"aoa_comp_hzdepth",
-         "value":20,
-         "unit":"inches",
-         "description":"#Thickness of horizon representing the soil component"
-     },
-     {
-         "name":"aoa_comp_cracksgr24",
-         "value":true,
-         "description":"#Whether the soil has surface connected macropores to 24 inches"
-     },
-     {
-         "name":"aoa_comp_hwt_lt_24",
-         "value":false,
-         "description":"#Whether the soil has a water table less than 24 inches from the surface"
-     }
-    ],
-    [
-     {
-      "name": "AoAId",
-      "value": 1
-     },
-     {
-      "name": "cokey",
-      "value": "11510284"
-     },
-     {
-      "name": "aoa_comp_area",
-      "value": 15.84,
-      "description":"Area of the soil component in the AoA"
-      
-     },
-     {
-      "name": "aoa_comp_hsg",
-      "value": "A/D",
-      "description":"Hydrologic soil group of the soil component"
-      
-     },
-     {
-      "name": "aoa_comp_kfact",
-      "value": 0.34,
-      "description":"#K factor of the horizon representing the soil component; usually the surface horizon"
-     },
-     {
-         "name":" aoa_comp_om",
-         "value":1.30,
-         "description":"#Organic matter content of the horizon representing the soil component"
-     },
-     {
-         "name":"aoa_comp_hzdepth",
-         "value":45,
-         "unit":"inches",
-         "description":"#Thickness of horizon representing the soil component"
-     },
-     {
-         "name":"aoa_comp_cracksgr24",
-         "value":true,
-         "description":"#Whether the soil has surface connected macropores to 24 inches"
-     },
-     {
-         "name":"aoa_comp_hwt_lt_24",
-         "value":false,
-         "description":"#Whether the soil has a water table less than 24 inches from the surface"
-     }
-    ],
-    [
-     {
-      "name": "AoAId",
-      "value": 1
-     },
-     {
-      "name": "cokey",
-      "value": "11510284"
-     },
-     {
-      "name": "aoa_comp_area",
-      "value": 55.84,
-      "description":"Area of the soil component in the AoA"
-      
-     },
-     {
-      "name": "aoa_comp_hsg",
-      "value": "B/D",
-      "description":"Hydrologic soil group of the soil component"
-      
-     },
-     {
-      "name": "aoa_comp_kfact",
-      "value": 0.34,
-      "description":"#K factor of the horizon representing the soil component; usually the surface horizon"
-     },
-     {
-         "name":" aoa_comp_om",
-         "value":3.30,
-         "description":"#Organic matter content of the horizon representing the soil component"
-     },
-     {
-         "name":"aoa_comp_hzdepth",
-         "value":64,
-         "unit":"inches",
-         "description":"#Thickness of horizon representing the soil component"
-     },
-     {
-         "name":"aoa_comp_cracksgr24",
-         "value":false,
-         "description":"#Whether the soil has surface connected macropores to 24 inches"
-     },
-     {
-         "name":"aoa_comp_hwt_lt_24",
-         "value":false,
-         "description":"#Whether the soil has a water table less than 24 inches from the surface"
-     }
-    ],
-    [
-     {
-      "name": "AoAId",
-      "value": 1
-     },
-     {
-      "name": "cokey",
-      "value": "11510284"
-     },
-     {
-      "name": "aoa_comp_area",
-      "value": 45.84,
-      "description":"Area of the soil component in the AoA"
-      
-     },
-     {
-      "name": "aoa_comp_hsg",
-      "value": "C/D",
-      "description":"Hydrologic soil group of the soil component"
-      
-     },
-     {
-      "name": "aoa_comp_kfact",
-      "value": 0.24,
-      "description":"#K factor of the horizon representing the soil component; usually the surface horizon"
-     },
-     {
-         "name":" aoa_comp_om",
-         "value":4.00,
-         "description":"#Organic matter content of the horizon representing the soil component"
-     },
-     {
-         "name":"aoa_comp_hzdepth",
-         "value":14,
-         "unit":"inches",
-         "description":"#Thickness of horizon representing the soil component"
-     },
-     {
-         "name":"aoa_comp_cracksgr24",
-         "value":false,
-         "description":"#Whether the soil has surface connected macropores to 24 inches"
-     },
-     {
-         "name":"aoa_comp_hwt_lt_24",
-         "value":true,
-         "description":"#Whether the soil has a water table less than 24 inches from the surface"
-     }
+    "metainfo": {
+    },
+    "parameter": [
+        {
+            "name": "soilcomponents",
+            "value": [
+                [
+                    {
+                        "name": "AoAId",
+                        "value": 1
+                    },
+                    {
+                        "name": "cokey",
+                        "value": "11510284"
+                    },
+                    {
+                        "name": "aoa_comp_area",
+                        "value": 45.84,
+                        "description": "Area of the soil component in the AoA"
+
+                    },
+                    {
+                        "name": "aoa_comp_hsg",
+                        "value": "A",
+                        "description": "Hydrologic soil group of the soil component"
+
+                    },
+                    {
+                        "name": "aoa_comp_kfact",
+                        "value": 0.24,
+                        "description": "#K factor of the horizon representing the soil component; usually the surface horizon"
+                    },
+                    {
+                        "name": "aoa_comp_om",
+                        "value": 2.30,
+                        "description": "#Organic matter content of the horizon representing the soil component"
+                    },
+                    {
+                        "name": "aoa_comp_hzdepth",
+                        "value": 14,
+                        "unit": "inches",
+                        "description": "#Thickness of horizon representing the soil component"
+                    },
+                    {
+                        "name": "aoa_comp_cracksgr24",
+                        "value": true,
+                        "description": "#Whether the soil has surface connected macropores to 24 inches"
+                    },
+                    {
+                        "name": "aoa_comp_hwt_lt_24",
+                        "value": false,
+                        "description": "#Whether the soil has a water table less than 24 inches from the surface"
+                    }
+                ],
+                [
+                    {
+                        "name": "AoAId",
+                        "value": 1
+                    },
+                    {
+                        "name": "cokey",
+                        "value": "11510284"
+                    },
+                    {
+                        "name": "aoa_comp_area",
+                        "value": 25.84,
+                        "description": "Area of the soil component in the AoA"
+
+                    },
+                    {
+                        "name": "aoa_comp_hsg",
+                        "value": "B",
+                        "description": "Hydrologic soil group of the soil component"
+
+                    },
+                    {
+                        "name": "aoa_comp_kfact",
+                        "value": 0.34,
+                        "description": "#K factor of the horizon representing the soil component; usually the surface horizon"
+                    },
+                    {
+                        "name": "aoa_comp_om",
+                        "value": 2.30,
+                        "description": "#Organic matter content of the horizon representing the soil component"
+                    },
+                    {
+                        "name": "aoa_comp_hzdepth",
+                        "value": 20,
+                        "unit": "inches",
+                        "description": "#Thickness of horizon representing the soil component"
+                    },
+                    {
+                        "name": "aoa_comp_cracksgr24",
+                        "value": true,
+                        "description": "#Whether the soil has surface connected macropores to 24 inches"
+                    },
+                    {
+                        "name": "aoa_comp_hwt_lt_24",
+                        "value": false,
+                        "description": "#Whether the soil has a water table less than 24 inches from the surface"
+                    }
+                ],
+                [
+                    {
+                        "name": "AoAId",
+                        "value": 1
+                    },
+                    {
+                        "name": "cokey",
+                        "value": "11510284"
+                    },
+                    {
+                        "name": "aoa_comp_area",
+                        "value": 15.84,
+                        "description": "Area of the soil component in the AoA"
+
+                    },
+                    {
+                        "name": "aoa_comp_hsg",
+                        "value": "A/D",
+                        "description": "Hydrologic soil group of the soil component"
+
+                    },
+                    {
+                        "name": "aoa_comp_kfact",
+                        "value": 0.34,
+                        "description": "#K factor of the horizon representing the soil component; usually the surface horizon"
+                    },
+                    {
+                        "name": "aoa_comp_om",
+                        "value": 1.30,
+                        "description": "#Organic matter content of the horizon representing the soil component"
+                    },
+                    {
+                        "name": "aoa_comp_hzdepth",
+                        "value": 45,
+                        "unit": "inches",
+                        "description": "#Thickness of horizon representing the soil component"
+                    },
+                    {
+                        "name": "aoa_comp_cracksgr24",
+                        "value": true,
+                        "description": "#Whether the soil has surface connected macropores to 24 inches"
+                    },
+                    {
+                        "name": "aoa_comp_hwt_lt_24",
+                        "value": false,
+                        "description": "#Whether the soil has a water table less than 24 inches from the surface"
+                    }
+                ],
+                [
+                    {
+                        "name": "AoAId",
+                        "value": 1
+                    },
+                    {
+                        "name": "cokey",
+                        "value": "11510284"
+                    },
+                    {
+                        "name": "aoa_comp_area",
+                        "value": 55.84,
+                        "description": "Area of the soil component in the AoA"
+
+                    },
+                    {
+                        "name": "aoa_comp_hsg",
+                        "value": "B/D",
+                        "description": "Hydrologic soil group of the soil component"
+
+                    },
+                    {
+                        "name": "aoa_comp_kfact",
+                        "value": 0.34,
+                        "description": "#K factor of the horizon representing the soil component; usually the surface horizon"
+                    },
+                    {
+                        "name": "aoa_comp_om",
+                        "value": 3.30,
+                        "description": "#Organic matter content of the horizon representing the soil component"
+                    },
+                    {
+                        "name": "aoa_comp_hzdepth",
+                        "value": 64,
+                        "unit": "inches",
+                        "description": "#Thickness of horizon representing the soil component"
+                    },
+                    {
+                        "name": "aoa_comp_cracksgr24",
+                        "value": false,
+                        "description": "#Whether the soil has surface connected macropores to 24 inches"
+                    },
+                    {
+                        "name": "aoa_comp_hwt_lt_24",
+                        "value": false,
+                        "description": "#Whether the soil has a water table less than 24 inches from the surface"
+                    }
+                ],
+                [
+                    {
+                        "name": "AoAId",
+                        "value": 1
+                    },
+                    {
+                        "name": "cokey",
+                        "value": "11510284"
+                    },
+                    {
+                        "name": "aoa_comp_area",
+                        "value": 45.84,
+                        "description": "Area of the soil component in the AoA"
+
+                    },
+                    {
+                        "name": "aoa_comp_hsg",
+                        "value": "C/D",
+                        "description": "Hydrologic soil group of the soil component"
+
+                    },
+                    {
+                        "name": "aoa_comp_kfact",
+                        "value": 0.24,
+                        "description": "#K factor of the horizon representing the soil component; usually the surface horizon"
+                    },
+                    {
+                        "name": "aoa_comp_om",
+                        "value": 4.00,
+                        "description": "#Organic matter content of the horizon representing the soil component"
+                    },
+                    {
+                        "name": "aoa_comp_hzdepth",
+                        "value": 14,
+                        "unit": "inches",
+                        "description": "#Thickness of horizon representing the soil component"
+                    },
+                    {
+                        "name": "aoa_comp_cracksgr24",
+                        "value": false,
+                        "description": "#Whether the soil has surface connected macropores to 24 inches"
+                    },
+                    {
+                        "name": "aoa_comp_hwt_lt_24",
+                        "value": true,
+                        "description": "#Whether the soil has a water table less than 24 inches from the surface"
+                    }
+                ]
+
+            ]
+        }
     ]
-    
-   ]
-  }
- ]
 }

src/java/m/wqm/soilpestlosspot/Input.java

@@ -4,19 +4,18 @@
  *
  * @author RUMPAL SIDHU
  */
-
 public class Input {
 
-    int AoAId;
-    int operation_id;
-    String op_pesticide_id;
-    String ai_plp;
-    String ai_psrp;
-    String ai_parp;
-    String aoa_pslp;
-    String aoa_ssrp;
-    String aoa_sarp;
-    String aoa_rain_prob;
+    private int AoAId;
+    private int operation_id;
+    private String op_pesticide_id;
+    private String ai_plp;
+    private String ai_psrp;
+    private String ai_parp;
+    private String aoa_pslp;
+    private String aoa_ssrp;
+    private String aoa_sarp;
+    private String aoa_rain_prob;
 
     public Input(int AoAId, int operation_id, String op_pesticide_id, String ai_plp, String ai_psrp, String ai_parp, String aoa_pslp, String aoa_ssrp, String aoa_sarp, String aoa_rain_prob) {
         this.AoAId = AoAId;
@@ -30,4 +29,45 @@
         this.aoa_sarp = aoa_sarp;
         this.aoa_rain_prob = aoa_rain_prob;
     }
+
+    //Getter Methods
+    public int getAoaId() {
+        return this.AoAId;
+    }
+
+    public int getOperationId() {
+        return this.operation_id;
+    }
+
+    public String getPesticideId() {
+        return this.op_pesticide_id;
+    }
+
+    public String getAi_plp() {
+        return this.ai_plp;
+    }
+
+    public String getAi_psrp() {
+        return this.ai_psrp;
+    }
+
+    public String getAi_parp() {
+        return this.ai_parp;
+    }
+
+    public String getAoa_pslp() {
+        return this.aoa_pslp;
+    }
+
+    public String getAoa_ssrp() {
+        return this.aoa_ssrp;
+    }
+
+    public String getAoa_sarp() {
+        return this.aoa_sarp;
+    }
+
+    public String getAoa_rain_prob() {
+        return this.aoa_rain_prob;
+    }
 }

src/java/m/wqm/soilpestlosspot/Result.java

@@ -4,15 +4,14 @@
  *
  * @author RUMPAL SIDHU
  */
-
 public class Result {
 
-    int AoAId;
-    int operation_id;
-    String op_pesticide_id;
-    String op_pest_ilp;
-    String op_pest_isrp;
-    String op_pest_iarp;
+    private int AoAId;
+    private int operation_id;
+    private String op_pesticide_id;
+    private String op_pest_ilp;
+    private String op_pest_isrp;
+    private String op_pest_iarp;
 
     public Result(int AoAId, int operation_id, String op_pesticide_id, String op_pest_ilp, String op_pest_isrp, String op_pest_iarp) {
         this.AoAId = AoAId;
@@ -22,4 +21,28 @@
         this.op_pest_isrp = op_pest_isrp;
         this.op_pest_iarp = op_pest_iarp;
     }
-}
\ No newline at end of file
+
+    public int getAoaId() {
+        return this.AoAId;
+    }
+
+    public int getOperationId() {
+        return this.operation_id;
+    }
+
+    public String getOpPesticideId() {
+        return this.op_pesticide_id;
+    }
+
+    public String getOpPestIlp() {
+        return this.op_pest_ilp;
+    }
+
+    public String getOpPestIsrp() {
+        return this.op_pest_isrp;
+    }
+
+    public String getOpPestIarp() {
+        return this.op_pest_iarp;
+    }
+}

src/java/m/wqm/soilpestlosspot/V1_0.java

@@ -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);

src/java/m/wqm/soilpestlosspot/V1_0.json

@@ -48,7 +48,7 @@
                     },
                     {
                         "name": "aoa_sarp",
-                        "value": "VERY LOW",
+                        "value": "LOW",
                         "Description": "Soil Pesticide Adsorbed Runoff Potential for the Area of Analysis"
                     },
                     {
@@ -100,7 +100,7 @@
                     },
                     {
                         "name": "aoa_sarp",
-                        "value": "VERY LOW",
+                        "value": "LOW",
                         "Description": "Soil Pesticide Adsorbed Runoff Potential for the Area of Analysis"
                     },
                     {
@@ -152,7 +152,7 @@
                     },
                     {
                         "name": "aoa_sarp",
-                        "value": "VERY LOW",
+                        "value": "LOW",
                         "Description": "Soil Pesticide Adsorbed Runoff Potential for the Area of Analysis"
                     },
                     {
@@ -204,7 +204,7 @@
                     },
                     {
                         "name": "aoa_sarp",
-                        "value": "VERY LOW",
+                        "value": "LOW",
                         "Description": "Soil Pesticide Adsorbed Runoff Potential for the Area of Analysis"
                     },
                     {
@@ -256,7 +256,7 @@
                     },
                     {
                         "name": "aoa_sarp",
-                        "value": "VERY LOW",
+                        "value": "LOW",
                         "Description": "Soil Pesticide Adsorbed Runoff Potential for the Area of Analysis"
                     },
                     {
@@ -308,7 +308,7 @@
                     },
                     {
                         "name": "aoa_sarp",
-                        "value": "VERY LOW",
+                        "value": "LOW",
                         "Description": "Soil Pesticide Adsorbed Runoff Potential for the Area of Analysis"
                     },
                     {