V2_0.java [src/java/m/wqm/wqm08_pesticidessrp] Revision:   Date:
/*
 * $Id$
 *
 * This file is part of the Cloud Services Integration Platform (CSIP),
 * a Model-as-a-Service framework, API, and application suite.
 *
 * 2012-2017, OMSLab, Colorado State University.
 *
 * OMSLab licenses this file to you under the MIT license.
 * See the LICENSE file in the project root for more information.
 */
package m.wqm.wqm08_pesticidessrp;

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

/**
 * WQM-08: Pesticide Soil Solution Runoff Potential
 *
 * @author Rumpal Sidhu
 * @version 2.0
 */
@Name("WQM-08: Pesticide Soil Solution Runoff Potential (PesticideSSRP)")
@Description("This service computes pesticide soil solution runoff potential "
        + "for soil components in an area of analysis, and computes soil "
        + "solution runoff potential representing the area of analysis (AoA). "
        + "The service primarily will consume data from the WQM-2 WQMSoilAttributes "
        + "service to compute soil solution runoff potential used later by the "
        + "WQM-13 service to compute WQM threshold treatment level scores.")
@Path("m/pesticide_ssrp/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.readAoAInput(getParamMap());

            pesticides.calculatePesticideSSRP();
            pesticides.setResults(results());
            pesticides.toWQM08Result();
        }
    }
}