V2_0.java [src/java/m/wqm/wqm04_pestlosspot] Revision: default 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.wqm04_pestlosspot;
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-04: Pesticide Attributes and Loss Potentials (WQMPestLossPot)
*
* @author Rumpal Sidhu
* @version 2.0
*/
@Name("WQM-04: Pesticide Attributes and Loss Potentials (WQMPestLossPot)")
@Description("The service consumes a request payload of one or more pesticide "
+ "application operations from a farm crop rotation for an area of "
+ "analysis, get attributes from the WQM pesticide table for each "
+ "instance of pesticide active ingredient applied. The pesticide "
+ "active ingredient attributes will be used later in WQM to compute "
+ "hazard ratings. The service computes loss potentials for pesticide "
+ "leaching, solution runoff, and adsorbed runoff also to be used later "
+ "for computing soil/pesticide interaction ratings.")
@Path("m/pestlosspot/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.readPesticides(getParamMap());
pesticides.calculatePesticideLossPotentials();
pesticides.setResults(results());
pesticides.toWQM04Result();
}
}
}