commentary("We can look up existing types to use in the creation of Properties\n\n"+
"Type intType = types.getType(\"commonj.sdo\", \"Int\");\n"+
"Type stringType = types.getType(\"commonj.sdo\", \"String\");");
Type intType = typeHelper.getType("commonj.sdo", "Int");
Type stringType = typeHelper.getType("commonj.sdo", "String");
commentary("To begin modelling the type system we create a DataObject with\n"+
"Type \"commonj.sdo#Type\" and set the URI and name for that type\n\n"+
"DataObject customerType = scope.getDataFactory().create(\"commonj.sdo\", \"Type\");\n"+
"customerType.set(\"uri\", \"http://example.com/customer\");\n"+
"customerType.set(\"name\", \"Customer\");");
DataObject customerType = scope.getDataFactory().create("commonj.sdo", "Type");
customerType.set("uri", "http://example.com/customer");
customerType.set("name", "Customer");
commentary("Now we can create a model for the Properties for the Type\n"+
"and set the name and Types of those Properties\n\n"+
"DataObject custNumProperty = customerType.createDataObject(\"property\");\n"+
"custNumProperty.set(\"name\", \"custNum\");\n"+
"custNumProperty.set(\"type\", intType);"
);
DataObject custNumProperty = customerType.createDataObject("property");
custNumProperty.set("name", "custNum");
custNumProperty.set("type", intType);
commentary("We continue in this manner until all the Types and their Properties are modelled");
DataObject lastNameProperty = customerType.createDataObject("property");
lastNameProperty.set("name", "lastName");
lastNameProperty.set("type", stringType);
DataObject firstNameProperty = customerType.createDataObject("property");
firstNameProperty.set("name", "firstName");
firstNameProperty.set("type", stringType);
commentary("Now that our type is fully modelled we submit the model to the TypeHelper\n"+
"The new Type instance is retuend to us, but is also available for lookup within\n"+
"the scope associated with the TypeHelper\n\n"+
"Type t = typeHelper.define(customerType);");
Type t = typeHelper.define(customerType);
commentary("Here we see the newly created Type being accessed via the TypeHelper\n"+
"along with a printout of the Type's Properties\n\n"+
"Type testType = scope.getTypeHelper().getType(\"http://example.com/customer\", \"Customer\");");
Type testType = scope.getTypeHelper().getType("http://example.com/customer", "Customer");
List props = testType.getProperties();
for (int i = 0; i < props.size(); i++) {
System.out.println(props.get(i));
}
commentary("Now we can create an instance of the type using the DataFactory associated with the type scope\n\n"+