package com.sample.client;  
  
import com.smartgwt.client.data.DataSource;
import com.smartgwt.client.data.fields.DataSourceIntegerField;
import com.smartgwt.client.data.fields.DataSourceTextField;  
  
public class ItemSupplyXmlDS extends DataSource {  
  
    private static ItemSupplyXmlDS instance = null;  
  
    public static ItemSupplyXmlDS getInstance() {  
        if (instance == null) {  
            instance = new ItemSupplyXmlDS("supplyItemDS");  
        }  
        return instance;  
    }  
  
    public ItemSupplyXmlDS(String id) {
        setID(id);
        setTitleField("Name");
        setRecordXPath("/List/employee");
        DataSourceTextField nameField = new DataSourceTextField("Name", "Name", 128);

        DataSourceIntegerField employeeIdField = new DataSourceIntegerField("EmployeeId", "Employee ID");
        employeeIdField.setPrimaryKey(true);
        employeeIdField.setRequired(true);

        DataSourceIntegerField reportsToField = new DataSourceIntegerField("ReportsTo", "Manager");
        reportsToField.setRequired(true);
        reportsToField.setForeignKey(id + ".EmployeeId");
        reportsToField.setRootValue("1");

        DataSourceTextField jobField = new DataSourceTextField("Job", "Title", 128);  
        jobField.setCanFilter(true);
        jobField.setCanEdit(true);

        setFields(nameField,employeeIdField,reportsToField,jobField);

        setDataURL("sample/countryData.xml");
        setClientOnly(true);
    }  
}  