Cocropyld.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.TableCocropyld;

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

    protected static ArrayList<String> cocropyldRequiredInputs = new ArrayList<>();
    protected static ArrayList<String> cocropyldUsedColumns = new ArrayList<>();

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

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

    private final TableCocropyld tableCocropyld = new TableCocropyld();

    public Cocropyld() {
        tableCocropyld.setUsedColumns(cocropyldUsedColumns);
        tableCocropyld.setRequiredColumns(cocropyldRequiredInputs);
    }

    public Cocropyld(JSONArray dataJSON) throws ServiceException, JSONException {
        tableCocropyld.setUsedColumns(cocropyldUsedColumns);
        tableCocropyld.setRequiredColumns(cocropyldRequiredInputs);

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

            tableCocropyld.readValuesFromJSON(cocropyldDataArray);

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

    public Cocropyld(ResultSet results) throws ServiceException {
        tableCocropyld.setUsedColumns(cocropyldUsedColumns);
        tableCocropyld.setRequiredColumns(cocropyldRequiredInputs);

        tableCocropyld.readValuesFromSQL(results);

    }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    public final void cropprodindex(int value) {
        tableCocropyld.cropprodindex(value);
    }

    public final int cropprodindex() {
        return tableCocropyld.cropprodindex();
    }

    public final void vasoiprdgrp(String value) {
        tableCocropyld.vasoiprdgrp(value);
    }

    public final String vasoiprdgrp() {
        return tableCocropyld.vasoiprdgrp();
    }

    public final void cokey(int value) {
        Validation.checkCokey(value);
        tableCocropyld.cokey(value);
    }

    public final void cokey(String value) {
        Validation.checkCokey(value);
        tableCocropyld.cokey(Integer.parseInt(value));
    }

    public final String cokey() {
        return Integer.toString(tableCocropyld.cokey());
    }

    public final void cocropyldkey(int value) {
        tableCocropyld.cocropyldkey(value);
    }

    public final void cocropyldkey(String value) {
        tableCocropyld.cocropyldkey(Integer.parseInt(value));
    }

    public final String cocropyldkey() {
        return Integer.toString(tableCocropyld.cocropyldkey());
    }

    public boolean isEqual( Cocropyld tcropYld) throws ServiceException{
      return tableCocropyld.isEqual(tcropYld.tableCocropyld);
    }
}