import com.smartgwt.client.data.DataSourceField;
import com.smartgwt.client.data.RestDataSource;
import com.smartgwt.client.types.DSDataFormat;
import com.smartgwt.client.types.FieldType;

public class TypeDataSource extends RestDataSource
{
	public TypeDataSource()
	{
		DataSourceField idField = new DataSourceField("id", FieldType.TEXT, "Id");
		DataSourceField nameField = new DataSourceField("name", FieldType.TEXT, "Name");
		DataSourceField internalIdField = new DataSourceField("internal_id", FieldType.TEXT, "Internal id");
		DataSourceField parentField = new DataSourceField("parent_id", FieldType.TEXT, "Parent");
		DataSourceField cloneField = new DataSourceField("clone", FieldType.TEXT, "Clone");

		this.setChildrenField("children");
		parentField.setForeignKey("id");
		idField.setPrimaryKey(true);
		internalIdField.setHidden(true);
		idField.setHidden(true);
		cloneField.setHidden(true);

		this.setFields(nameField, idField, internalIdField, parentField, cloneField);
		this.setDataFormat(DSDataFormat.JSON);
		this.setDataURL("types.js");

		this.setClientOnly(false);
	}
}
