use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.
the class LoadAndSaveBug6680769TestCases method registerTypes.
@Override
protected void registerTypes() {
SDOType changeSummaryType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.CHANGESUMMARY);
SDOType dataObjectType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.DATAOBJECT);
SDOType typeType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.TYPE);
SDOType propertyType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.PROPERTY);
// Data Type
DataObject dataTypeDO = dataFactory.create(typeType);
dataTypeDO.set("name", "Data");
dataTypeDO.set("uri", "http://www.example.org/data");
addProperty(dataTypeDO, "Value", dataObjectType, true, true, true);
addProperty(dataTypeDO, "ChangeSummary", changeSummaryType, true, false, true);
Type dataType = typeHelper.define(dataTypeDO);
// Emp Type
DataObject empTypeDO = dataFactory.create(typeType);
empTypeDO.set("name", "Emp");
empTypeDO.set("uri", "http://www.example.org/emp");
addProperty(empTypeDO, "Empno", SDOConstants.SDO_STRING, false, false, true);
addProperty(empTypeDO, "Ename", SDOConstants.SDO_STRING, false, false, true);
Type empType = typeHelper.define(empTypeDO);
// Root Type
DataObject rootTypeDO = dataFactory.create(typeType);
rootTypeDO.set("name", "Root");
rootTypeDO.set("uri", "http://www.example.org/root");
addProperty(rootTypeDO, "data", dataType, true, false, true);
Type rootType = typeHelper.define(rootTypeDO);
// root open content property
DataObject rootPropDO = dataFactory.create(propertyType);
rootPropDO.set("name", "root");
rootPropDO.set("type", rootType);
typeHelper.defineOpenContentProperty(getControlRootURI(), rootPropDO);
}
use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.
the class LoadAndSaveMixedContentTestCases method registerTypes.
@Override
public void registerTypes() {
Type intType = typeHelper.getType("commonj.sdo", "Int");
Type stringType = typeHelper.getType("commonj.sdo", "String");
Type decimalType = typeHelper.getType("commonj.sdo", "Decimal");
Type dateType = typeHelper.getType("commonj.sdo", "Date");
Type booleanType = typeHelper.getType("commonj.sdo", "Boolean");
SDOType propertyType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.PROPERTY);
DataObject empTypeDO = defineType("http://www.example.org", "EmployeeType");
addProperty(empTypeDO, "id", stringType, false, false, true);
addProperty(empTypeDO, "name", stringType, false, false, true);
empTypeDO.set("sequenced", true);
Type empType = typeHelper.define(empTypeDO);
DataObject empPropDO = dataFactory.create(propertyType);
empPropDO.set("name", getControlRootName());
empPropDO.set("type", empType);
typeHelper.defineOpenContentProperty("http://www.example.org", empPropDO);
}
use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.
the class ListPropertyNillableElementTestCases method testInvalidAddAllSetNullInList.
/**
* 'kid' property is not nillable, so a null entry in the collection to be
* added is not allowed.
*/
public void testInvalidAddAllSetNullInList() throws Exception {
try {
Element[] schemas = new Element[1];
schemas[0] = getDOM(getSchemaName());
SDOElementResolver resolver = new SDOElementResolver(schemas);
List<SDOType> types = ((SDOXSDHelper) aHelperContext.getXSDHelper()).define(new DOMSource(schemas[0], getSchemaName()), resolver);
assertEquals(3, types.size());
XMLDocument doc = aHelperContext.getXMLHelper().load(new FileInputStream(new File(getControlFileName())));
DataObject rootObj = doc.getRootObject();
DataObject childDo = rootObj.getDataObject("childContain");
List listTest = childDo.getList("kid");
Collection kids = new ArrayList();
kids.add(listTest.get(0));
kids.add(null);
kids.add(listTest.get(1));
boolean exceptionOccurred = false;
try {
listTest.addAll(kids);
} catch (UnsupportedOperationException uoe) {
exceptionOccurred = true;
}
assertTrue("An UnsupportedOperationException did not occur as expected (adding a collection with a null entry to non-nillable list property is not allowed)", exceptionOccurred);
aHelperContext.getXMLHelper().save(doc.getRootObject(), doc.getRootElementURI(), doc.getRootElementName());
} catch (Exception xxx) {
xxx.printStackTrace();
throw xxx;
}
}
use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.
the class ListPropertyNillableElementTestCases method testInvalidSetNullInList.
/**
* 'kid' property is not nillable, so null is not allowed
*/
public void testInvalidSetNullInList() throws Exception {
try {
Element[] schemas = new Element[1];
schemas[0] = getDOM(getSchemaName());
SDOElementResolver resolver = new SDOElementResolver(schemas);
List<SDOType> types = ((SDOXSDHelper) aHelperContext.getXSDHelper()).define(new DOMSource(schemas[0], getSchemaName()), resolver);
assertEquals(3, types.size());
XMLDocument doc = aHelperContext.getXMLHelper().load(new FileInputStream(new File(getControlFileName())));
DataObject rootObj = doc.getRootObject();
DataObject childDo = rootObj.getDataObject("childContain");
List listTest = childDo.getList("kid");
assertNotNull(listTest);
assertEquals(2, listTest.size());
boolean exceptionOccurred = false;
try {
listTest.add(null);
} catch (UnsupportedOperationException uoe) {
exceptionOccurred = true;
}
assertTrue("An UnsupportedOperationException did not occur as expected (adding null to non-nillable list is not allowed)", exceptionOccurred);
assertEquals(2, listTest.size());
aHelperContext.getXMLHelper().save(doc.getRootObject(), doc.getRootElementURI(), doc.getRootElementName());
} catch (Exception xxx) {
xxx.printStackTrace();
throw xxx;
}
}
use of org.eclipse.persistence.sdo.SDOType in project eclipselink by eclipse-ee4j.
the class ListPropertyNillableElementTestCases method testAddAllSetNullInList.
/**
* 'child' property is nillable, so a null entry in the collection to be
* added is allowed.
*/
public void testAddAllSetNullInList() throws Exception {
try {
Element[] schemas = new Element[1];
schemas[0] = getDOM(getSchemaName());
SDOElementResolver resolver = new SDOElementResolver(schemas);
List<SDOType> types = ((SDOXSDHelper) aHelperContext.getXSDHelper()).define(new DOMSource(schemas[0], getSchemaName()), resolver);
assertEquals(3, types.size());
XMLDocument doc = aHelperContext.getXMLHelper().load(new FileInputStream(new File(getControlFileName())));
DataObject rootObj = doc.getRootObject();
DataObject childDo = rootObj.getDataObject("childContain");
List listTest = childDo.getList("child");
Collection kids = new ArrayList();
kids.add(listTest.get(0));
kids.add(null);
kids.add(listTest.get(1));
boolean exceptionOccurred = false;
try {
listTest.addAll(kids);
} catch (UnsupportedOperationException uoe) {
exceptionOccurred = true;
}
assertFalse("An unexpected UnsupportedOperationException occurred", exceptionOccurred);
aHelperContext.getXMLHelper().save(doc.getRootObject(), doc.getRootElementURI(), doc.getRootElementName());
} catch (Exception xxx) {
xxx.printStackTrace();
throw xxx;
}
}
Aggregations