}
public void testDefineDataType() throws Exception
{
TypeHelper types = SDOUtil.createTypeHelper();
DataFactory factory = SDOUtil.createDataFactory(types);
XSDHelper xsdHelper = SDOUtil.createXSDHelper(types);
XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
Property javaClassProperty = xsdHelper.getGlobalProperty("commonj.sdo/java", "javaClass", false);
// create a data types
DataObject intType = factory.create("commonj.sdo", "Type");
intType.set("uri", "http://example.com/customer");
intType.set("name", "MyIntType");
intType.setBoolean("dataType", true);
intType.set(javaClassProperty, "int");
DataObject stringType = factory.create("commonj.sdo", "Type");
stringType.set("uri", "http://example.com/customer");
stringType.set("name", "MyStringType");
stringType.setBoolean("dataType", true);
stringType.set(javaClassProperty, "java.lang.String");
// create a new Type for Customers
DataObject customerType = factory.create("commonj.sdo",
"Type");
customerType.set("uri", "http://example.com/customer");
customerType.set("name", "Customer");
// create a customer number property
DataObject custNumProperty = customerType.createDataObject("property");
custNumProperty.set("name", "custNum");
custNumProperty.set("type", intType);
// create a first name property
DataObject firstNameProperty =
customerType.createDataObject("property");
firstNameProperty.set("name", "firstName");
firstNameProperty.set("type", stringType);
// create a last name property
DataObject lastNameProperty = customerType.createDataObject("property");
lastNameProperty.set("name", "lastName");
lastNameProperty.set("type", stringType);
// now define the Customer type so that customers can be made
types.define(customerType);
DataObject customer1 = factory.create("http://example.com/customer",
"Customer");
customer1.setInt("custNum", 1);
customer1.set("firstName", "John");
customer1.set("lastName", "Adams");
DataObject customer2 = factory.create("http://example.com/customer",
"Customer");
customer2.setInt("custNum", 2);
customer2.set("firstName", "Jeremy");
customer2.set("lastName", "Pavick");