Mucropyld.java [src/soils] Revision: default  Date:
package soils;

import csip.api.server.ServiceException;
import csip.utils.JSONUtils;
import csip.utils.Validation;
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.TableMucropyld;

/**
 *
 * @author <a href="mailto:shaun.case@colostate.edu">Shaun Case</a>
 */
public class Mucropyld {

    protected static ArrayList<String> mucropyldRequiredInputs = new ArrayList<>();
    protected static ArrayList<String> mucropyldUsedColumns = new ArrayList<>();

    public synchronized static void setRequiredInputs(List<String> requiredInputs) {
        mucropyldRequiredInputs.clear();
        if (null != requiredInputs) {
            mucropyldRequiredInputs.addAll(requiredInputs);
            mucropyldUsedColumns.addAll(requiredInputs);
        }
    }

    public synchronized static void setDefaultUsedColumns(List<String> usedColumns) {
        mucropyldUsedColumns.clear();
        if (null != usedColumns) {
            mucropyldUsedColumns.addAll(usedColumns);
        }
    }

    private final TableMucropyld tableMucropyld = new TableMucropyld();

    public Mucropyld() {
        tableMucropyld.setUsedColumns(mucropyldUsedColumns);
        tableMucropyld.setRequiredColumns(mucropyldRequiredInputs);
    }

    public Mucropyld(JSONArray dataJSON) throws ServiceException, JSONException {
        tableMucropyld.setUsedColumns(mucropyldUsedColumns);
        tableMucropyld.setRequiredColumns(mucropyldRequiredInputs);

        if ((null != dataJSON) && (dataJSON.length() > 0)) {
            Map<String, JSONObject> mucropyldDataArray = JSONUtils.preprocess(dataJSON);

            tableMucropyld.readValuesFromJSON(mucropyldDataArray);

        } else {
            throw new ServiceException("No mapunit JSON specified.  A NULL or empty value was passed to Mucropyld()");
        }
    }

    public Mucropyld(ResultSet results) throws ServiceException {
        tableMucropyld.setUsedColumns(mucropyldUsedColumns);
        tableMucropyld.setRequiredColumns(mucropyldRequiredInputs);

        tableMucropyld.readValuesFromSQL(results);

    }

    public void readFromSQL(ResultSet results) throws ServiceException {
        tableMucropyld.readValuesFromSQL(results);
    }

    public final void cropname(String value) {
        tableMucropyld.cropname(value);
    }

    public final String cropname() {
        return tableMucropyld.cropname();
    }

    public final void yldunits(String value) {
        tableMucropyld.yldunits(value);
    }

    public final String yldunits() {
        return tableMucropyld.yldunits();
    }

    public final void nonirryield_l(double value) {
        tableMucropyld.nonirryield_l(value);
    }

    public final double nonirryield_l() {
        return tableMucropyld.nonirryield_l();
    }

    public final void nonirryield_r(double value) {
        tableMucropyld.nonirryield_r(value);
    }

    public final double nonirryield_r() {
        return tableMucropyld.nonirryield_r();
    }

    public final void nonirryield_h(double value) {
        tableMucropyld.nonirryield_h(value);
    }

    public final double nonirryield_h() {
        return tableMucropyld.nonirryield_h();
    }

    public final void irryield_l(double value) {
        tableMucropyld.irryield_l(value);
    }

    public final double irryield_l() {
        return tableMucropyld.irryield_l();
    }

    public final void irryield_r(double value) {
        tableMucropyld.irryield_r(value);
    }

    public final double irryield_r() {
        return tableMucropyld.irryield_r();
    }

    public final void irryield_h(double value) {
        tableMucropyld.irryield_h(value);
    }

    public final double irryield_h() {
        return tableMucropyld.irryield_h();
    }

    public final void mukey(int value) {
        Validation.checkMukey(value);
        tableMucropyld.mukey(value);
    }

    public final void mukey(String value) {
        Validation.checkMukey(value);
        tableMucropyld.mukey(Integer.parseInt(value));
    }

    public final String mukey() {
        return Integer.toString(tableMucropyld.mukey());
    }

    public final void mucrpyldkey(int value) {
        tableMucropyld.mucrpyldkey(value);
    }

    public final void mucrpyldkey(String value) {
        tableMucropyld.mucrpyldkey(Integer.parseInt(value));
    }

    public final String mucrpyldkey() {
        return Integer.toString(tableMucropyld.mucrpyldkey());
    }

}