public void testDefineSequencedOpenType() throws Exception
{
TypeHelper types = SDOUtil.createTypeHelper();
DataFactory factory = SDOUtil.createDataFactory(types);
XMLHelper xmlHelper = SDOUtil.createXMLHelper(types);
Type stringType = types.getType("commonj.sdo", "String");
Type decimalType = types.getType("commonj.sdo", "Decimal");
// Define a new mixed type - MixedQuote
DataObject mixedQuoteType = factory.create("commonj.sdo", "Type");
mixedQuoteType.set("uri", "http://www.example.com/mixed");
mixedQuoteType.set("name", "MixedOpenQuote");
mixedQuoteType.set("sequenced", Boolean.TRUE);
mixedQuoteType.set("open", Boolean.TRUE);
// DataObject symbolProperty = mixedQuoteType.createDataObject("property");
// symbolProperty.set("name", "symbol");
// symbolProperty.set("type", stringType);
DataObject companyNameProperty = mixedQuoteType.createDataObject("property");
companyNameProperty.set("name", "companyName");
companyNameProperty.set("type", stringType);
DataObject priceProperty = mixedQuoteType.createDataObject("property");
priceProperty.set("name", "price");
priceProperty.set("type", decimalType);
DataObject quotesProperty = mixedQuoteType.createDataObject("property");
quotesProperty.set("name", "quotes");
quotesProperty.set("type", mixedQuoteType);
quotesProperty.set("many", Boolean.TRUE);
quotesProperty.set("containment", Boolean.TRUE);
types.define(mixedQuoteType);
// Define a global type
DataObject globalType = factory.create("commonj.sdo", "Type");
globalType.set("uri", "http://www.example.com/open");
// Don't set the type's name - null is used for types containing global properties.
DataObject symbolProperty = globalType.createDataObject("property");
symbolProperty.set("name", "symbol");
symbolProperty.set("type", stringType);
symbolProperty.set("containment", Boolean.TRUE);
types.define(globalType);
DataObject quote = factory.create("http://www.example.com/mixed", "MixedOpenQuote");
assertTrue(quote.getType().isSequenced());
Sequence sequence = quote.getSequence();