Comonth.java [src/soils] 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 soils;
import csip.api.server.ServiceException;
import csip.utils.JSONUtils;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import soils.db.tables.TableComonth;
/**
*
* @author <a href="mailto:shaun.case@colostate.edu">Shaun Case</a>
*/
public class Comonth {
protected static ArrayList<String> requiredInputs = new ArrayList<>();
protected static ArrayList<String> usedColumns = new ArrayList<>();
public synchronized static void setDefaultUsedColumns(List<String> _usedColumns) {
usedColumns.clear();
if (null != _usedColumns) {
usedColumns.addAll(_usedColumns);
}
}
public synchronized static void setRequiredInputs(List<String> componentInputs) {
requiredInputs.clear();
if (null != componentInputs) {
requiredInputs.addAll(componentInputs);
usedColumns.addAll(componentInputs);
}
}
public synchronized static ArrayList<String> getDefaultUsedColumns() {
return ((null != usedColumns) ? ((ArrayList<String>) usedColumns.clone()) : null);
}
public synchronized static ArrayList<String> getRequiedInputs() {
return ((null != requiredInputs) ? ((ArrayList<String>) requiredInputs.clone()) : null);
}
private final TableComonth tableComonth = new TableComonth();
/**
*
* @throws ServiceException
*/
public Comonth() throws ServiceException {
tableComonth.setRequiredColumns(requiredInputs);
tableComonth.setUsedColumns(usedColumns);
}
/**
*
* @param dataJSON
* @throws ServiceException
* @throws JSONException
*/
public Comonth(JSONArray dataJSON) throws ServiceException, JSONException {
if ((null != dataJSON) && (dataJSON.length() > 0)) {
Map<String, JSONObject> dataArray = JSONUtils.preprocess(dataJSON);
tableComonth.setRequiredColumns(requiredInputs);
tableComonth.setUsedColumns(usedColumns);
tableComonth.readValuesFromJSON(dataArray);
} else {
throw new ServiceException("No comonth JSON specified. A NULL or empty value was passed to Comonth()");
}
}
public Comonth(ResultSet results) throws ServiceException {
tableComonth.setRequiredColumns(requiredInputs);
tableComonth.setUsedColumns(usedColumns);
tableComonth.readValuesFromSQL(results);
}
public int cokey() {
return tableComonth.cokey();
}
public void cokey(int value) {
tableComonth.cokey(value);
}
public String comonthkey() {
return tableComonth.comonthkey();
}
public void comonthkey(String value) {
tableComonth.comonthkey(value);
}
public String flodfreqcl() {
return tableComonth.flodfreqcl();
}
public void flodfreqcl(String value) {
tableComonth.flodfreqcl(value);
}
public String pondfreqcl() {
return tableComonth.pondfreqcl();
}
public void pondfreqcl(String value) {
tableComonth.pondfreqcl(value);
}
public int monthseq() {
return tableComonth.monthseq();
}
public void monthseq(int value) {
tableComonth.monthseq(value);
}
public String month() {
return tableComonth.month();
}
public void month(String value) {
tableComonth.month(value);
}
public void readFromSQL(ResultSet results) throws ServiceException {
tableComonth.readValuesFromSQL(results);
}
/**
*
*/
public JSONArray toJSON() throws JSONException {
JSONArray outArray = new JSONArray();
toJSON(outArray);
return outArray;
}
/**
*
*/
public void toJSON(JSONArray outArray) throws JSONException {
tableComonth.toJSON(outArray);
}
public boolean isEqual(Comonth tcoMonth) throws ServiceException{
return tableComonth.isEqual(tcoMonth.tableComonth);
}
}