IpatInput.java [src/java/m/ipat] 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 m.ipat;

import csip.ServiceException;
import csip.utils.JSONUtils;
import static csip.utils.JSONUtils.preprocess;
import data.table.Table;
import data.table.column.ColumnBoolean;
import data.table.column.ColumnDouble;
import data.table.column.ColumnGeometry;
import data.table.column.ColumnInteger;
import data.table.column.ColumnString;
import database.ipat.IPAT_Db;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.codehaus.jettison.json.JSONArray;
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
import utils.EvalResult;

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

    public static final String LOCATION = "location";
    public static final String IRRIGATION_SYSTEM = "irrigation_system";
    public static final String POWER_SOURCE = "power_source";
    public static final String WELL_LIFT = "well_lift";
    public static final String SYSTEM_PRESSURE = "system_pressure";
    public static final String ENERGY_COST_RATE = "energy_cost_rate";
    public static final String FLOW_METER = "flow_meter";
    public static final String IRRIGATION_SCHEDULING = "irrigation_scheduling";
    public static final String MAINTENANCE_UPGRADES = "maintenance_upgrades";
    public static final String POWER_PLANT_EVAL = "power_plant_evaluation";
    public static final String IRRIGATION_LAND_UNITS = "irrigation_land_units";    

    //Looked up from location data.
    public static final String STATE_NUMBER = "state_number";



    public IpatInput() throws ServiceException {
        addDataColumn(LOCATION, new ColumnGeometry(LOCATION, "Location is a geoJSON object representing a location for the land units under study.  The prefered shape is a POINT location.  Multi-point shapes will have their centroid used for the location value."));
        addDataColumn(IRRIGATION_SYSTEM, new ColumnInteger(IRRIGATION_SYSTEM, "This is the id (primary key) value associated with the correct irrigation system found in the database."));
        addDataColumn(POWER_SOURCE, new ColumnInteger(POWER_SOURCE, "This is the id (primary key) value associated with the correct power source found in the database."));
        addDataColumn(WELL_LIFT, new ColumnInteger(WELL_LIFT, "This is an optional parameter specifying the height in feet of the depth of the well being used to supply the water.  If not provided the service will use the average well_lift for the State, in which the location specified lies."));
        addDataColumn(SYSTEM_PRESSURE, new ColumnInteger(SYSTEM_PRESSURE, "This is the PSI pressure expected within the irrigation system."));
        addDataColumn(ENERGY_COST_RATE, new ColumnDouble(ENERGY_COST_RATE, "This is the dollar cost per unit of measure for the power source specified in " + POWER_SOURCE + "."));
        addDataColumn(FLOW_METER, new ColumnBoolean(FLOW_METER, "This is a boolean value specifying whether or not a flow meter is installed and in use for this system."));
        addDataColumn(IRRIGATION_SCHEDULING, new ColumnBoolean(IRRIGATION_SCHEDULING, "This is a boolean value specifying whether or not this system is utilizing an irrigation schedule."));
        addDataColumn(MAINTENANCE_UPGRADES, new ColumnBoolean(MAINTENANCE_UPGRADES, "This is a boolean value specifying whether or not this system is subject to maintenance upgrades."));
        addDataColumn(POWER_PLANT_EVAL, new ColumnBoolean(POWER_PLANT_EVAL, "Optional results concerning power plant evaluations.  Specify True or False.  Default: false"));
        addDataColumn(IRRIGATION_LAND_UNITS, new ColumnLandUnitTable(IRRIGATION_LAND_UNITS));
        
        addDataColumn(STATE_NUMBER, new ColumnString(STATE_NUMBER, "USDA NRT Database state_number code for the location specified."));
        
        setRequiredColumns(new ArrayList<>(Arrays.asList(
                LOCATION, POWER_SOURCE, SYSTEM_PRESSURE,
                ENERGY_COST_RATE, IRRIGATION_LAND_UNITS)));

    }
}