package com.test.client;
import com.smartgwt.client.data.RestDataSource;
import com.smartgwt.client.data.fields.DataSourceTextField;

public class TransactionNestedDS extends RestDataSource {

    private static TransactionNestedDS instance = null;

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

	private TransactionNestedDS() {
        setID("transactionNestedDS");
        setDataURL("Datasource2.xml");
        setRecordXPath("/sites/site"); //the XML path of the element we want to display, in the datasource file (.data.xml)
        setClientOnly(true);

        DataSourceTextField code = new DataSourceTextField("code");
        code.setValueXPath("transaction/code");
        code.setPrimaryKey(true);
        code.setMultiple(true);
        DataSourceTextField name = new DataSourceTextField("name", "Transaction Type", 128, true); // isRequired = true
        name.setValueXPath("transaction/name");
        name.setMultiple(true);
        DataSourceTextField tls = new DataSourceTextField("secure", "TLS Endpoint");
        tls.setValueXPath("transaction/secure");
        tls.setMultiple(true);
        DataSourceTextField notls = new DataSourceTextField("unsecure", "Non-TLS Endpoint");
        notls.setValueXPath("transaction/unsecure");
        notls.setMultiple(true);
        setFields(code);
	}
}