WEPPSoilParamsServiceCall.java [src/java/util] Revision: default 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 util;
import static csip.ModelDataService.KEY_METAINFO;
import static csip.ModelDataService.KEY_PARAMETER;
import csip.api.server.ServiceException;
import csip.utils.JSONUtils;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
/**
*
* @author <a href="mailto:shaun.case@colostate.edu">Shaun Case</a>
*/
public class WEPPSoilParamsServiceCall extends ServiceCall {
protected int _cokey;
protected boolean _stream;
protected String _callingMetaInfo;
public WEPPSoilParamsServiceCall(String URI, String callingMetaInfo, int cokey, boolean stream) {
super(URI);
_cokey = cokey;
_stream = stream;
_callingMetaInfo = callingMetaInfo;
}
@Override
protected void createRequest() throws ServiceException {
JSONArray dataArray;
requestMetainfoObject = new JSONObject();
request = new JSONObject();
dataArray = new JSONArray();
try {
requestMetainfoObject.put("MultipartRequest", "Bundled Service Request from WEPP");
requestMetainfoObject.put("WEPP_Metainfo", new JSONObject(_callingMetaInfo));
request.put(KEY_METAINFO, requestMetainfoObject);
dataArray.put(JSONUtils.dataDesc("cokey", _cokey, "Cokey of soil parameters needed"));
dataArray.put(JSONUtils.dataDesc("stream_file", _stream, "Stream sol file rather than force a GET request for it"));
request.put(KEY_PARAMETER, dataArray);
} catch (JSONException ex) {
throwServiceCallException("Cannot create the JSON request for WEPPSoilInput call.", ex);
}
}
}