package com.sample.client;

import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceBooleanField;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;

/**
 * DataSource for ElevationLayout
 */
public class ElevationLayoutDS extends DataSource {

    private static ElevationLayoutDS instance = null;

    public static ElevationLayoutDS getInstance() {
        if (instance == null) {
            instance = new ElevationLayoutDS();
        }
        return instance;
    }

    /**
     * Default constructor for the custom datasource.
     */
    public ElevationLayoutDS() {
        setID("ElevationLayout");
        setRecordXPath("/List/Elevation");
        final DataSourceTextField elevationID = new DataSourceTextField("elevationID");
        elevationID.setPrimaryKey(true);

        final DataSourceBooleanField leftSidelite = new DataSourceBooleanField("leftSidelite");
        final DataSourceBooleanField leftHalfSidelite = new DataSourceBooleanField("leftHalfSidelite");
        final DataSourceIntegerField leftRows = new DataSourceIntegerField("leftRows");
        final DataSourceIntegerField leftColumns = new DataSourceIntegerField("leftColumns");

        setFields(elevationID, leftSidelite, leftHalfSidelite, leftRows, leftColumns);
        setDataURL("ds/data/Elevations.xml");
        setClientOnly(true);
    }
}
