*/
private void createTypesViaAPI(HelperContext scope) throws Exception {
List typeDeclarations = new ArrayList();
TypeHelper typeHelper = scope.getTypeHelper();
Type stringType = typeHelper.getType(sdoApiUri, "String");
Type dateType = typeHelper.getType(sdoApiUri, "Date");
Type booleanType = typeHelper.getType(sdoApiUri, "Boolean");
// <complexType name="Person">
// <sequence>
// <element name="dob" type="date"/>
// <element name="relative" maxOccurs="unbounded" type="tns:Relative"/>
// <any namespace="##other" processContents="lax" maxOccurs="unbounded"/>
// </sequence>
// <attribute name="id" type="ID"/>
// <attribute name="name" type="string"/>
// <attribute name="gender" type = "tns:Gender"/>
// </complexType>
DataObject personTypeDesc = createTypeDescription(scope, peopleURI,
"Person");
typeDeclarations.add(personTypeDesc);
addPropertyDescription(personTypeDesc, stringType, "name");
addPropertyDescription(personTypeDesc, dateType, "dob");
addPropertyDescription(personTypeDesc, stringType, "id"); // set to unique
// identifier?
addPropertyDescription(personTypeDesc, stringType, "gender"); // restrict?
DataObject relativeType = createTypeDescription(scope, peopleURI,
"Relative"); // forward declare the Relative type
typeDeclarations.add(relativeType);
DataObject rp = addPropertyDescription(personTypeDesc, relativeType,
"relative");
rp.setBoolean("many", true);
personTypeDesc.set("open", Boolean.TRUE);
// <complexType name="Relative">
// <attribute name="target" type="IDREF" sdoxml:propertyType="tns:Person"
// use="required"/>
// <attribute name="relationship" type="string" />
// <attribute name="genetic" use="optional" type="boolean"/>
// </complexType>
addPropertyDescription(relativeType, stringType, "relationship");
addPropertyDescription(relativeType, booleanType, "genetic");
DataObject targetPersonProp = addPropertyDescription(relativeType,
personTypeDesc, "target");
targetPersonProp.setBoolean("containment", false);
// <complexType name="PersonSet">
// <sequence>
// <element name="person" type="tns:Person" maxOccurs="unbounded"/>
// </sequence>
// </complexType>
DataObject pSet = createTypeDescription(scope, peopleURI, "PersonSet");
typeDeclarations.add(pSet);
DataObject pSetProperty = addPropertyDescription(pSet, personTypeDesc,
"person");
pSetProperty.setBoolean("many", true);
// <complexType name="Condition">
// <sequence>
// <element name="diagnosed" type="date" />
// </sequence>
// <attribute name="name" type="tns:ConditionName" />
// </complexType>
DataObject condition = createTypeDescription(scope, medicalURI, "Condition");
typeDeclarations.add(condition);
addPropertyDescription(condition, booleanType, "diagnosed");
addPropertyDescription(condition, stringType, "name"); // constrain?
// <complexType name="Test">
// <sequence>
// <element name="referrals" type="people:PersonSet" />
// <element name="patients" type="people:PersonSet" />
// <element name="relatives" type="people:PersonSet" />
// </sequence>
// </complexType>
DataObject testType = createTypeDescription(scope, medicalURI, "Test");
typeDeclarations.add(testType);
addPropertyDescription(testType, pSet, "referrals");
addPropertyDescription(testType, pSet, "patients");
addPropertyDescription(testType, pSet, "relatives");
List types = typeHelper.define(typeDeclarations);
DataObject p = scope.getDataFactory().create("commonj.sdo", "Property");
p.set("type", typeHelper.getType(medicalURI, "Condition"));
p.set("name", "condition");
p.setBoolean("many", true);
p.setBoolean("containment", true); // why is this not the default?
typeHelper.defineOpenContentProperty(medicalURI, p);
}