V2_0.java [src/java/m/wqm/wqm11_pesthazrating] Revision:   Date:
/*
 * 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.wqm11_pesthazrating;

import csip.ModelDataService;
import csip.api.server.ServiceException;
import csip.annotations.Resource;
import java.sql.Connection;
import java.sql.SQLException;
import javax.ws.rs.Path;
import csip.annotations.Description;
import csip.annotations.Name;
import org.codehaus.jettison.json.JSONException;
import wqm.utils.DBResources;
import static wqm.utils.DBResources.WQM_ID;
import wqm.utils.Pesticides;

/**
 * WQM-11: Pesticide Hazard Ratings
 *
 * @author rumpal
 * @version 2.0
 */
@Name("WQM-11: Pesticide Hazard Ratings (PestHazRating)")
@Description("This service computes pesticide hazard ratings for leaching, "
        + "solution runoff, and adsorbed runoff for each pesticide applied in "
        + "an area of analysis, and then computes hazard ratings for each "
        + "concern representing the area of analysis (AoA). "
        + "The service consumes soil/pesticide interaction loss potentials "
        + "from the WQM-10 service to compute the hazard ratings, which are "
        + "used later by the WQM-13 service to compute mitigation threshold scores.")
@Path("m/pest_hazrating/2.0")
@Resource(from = DBResources.class)

public class V2_0 extends ModelDataService {

    @Override
    protected void doProcess() throws ServiceException, SQLException, JSONException {
        try (Connection conn = resources().getJDBC(WQM_ID)) {
            Pesticides pesticides = new Pesticides(conn);
            pesticides.readWQM11Input(getParamMap());

            pesticides.calculatePestHazRating();
            pesticides.setResults(results());
            pesticides.toWQM11JSON();
        }
    }

}