Search in sources :

Example 21 with SDOType

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);
}
Also used : Type(commonj.sdo.Type) SDOType(org.eclipse.persistence.sdo.SDOType) DataObject(commonj.sdo.DataObject) SDOType(org.eclipse.persistence.sdo.SDOType)

Example 22 with SDOType

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);
}
Also used : Type(commonj.sdo.Type) SDOType(org.eclipse.persistence.sdo.SDOType) DataObject(commonj.sdo.DataObject) SDOType(org.eclipse.persistence.sdo.SDOType)

Example 23 with SDOType

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;
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) Element(org.w3c.dom.Element) SDOType(org.eclipse.persistence.sdo.SDOType) ArrayList(java.util.ArrayList) SDOXSDHelper(org.eclipse.persistence.sdo.helper.SDOXSDHelper) XMLDocument(commonj.sdo.helper.XMLDocument) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) DataObject(commonj.sdo.DataObject) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File)

Example 24 with SDOType

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;
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) Element(org.w3c.dom.Element) SDOType(org.eclipse.persistence.sdo.SDOType) SDOXSDHelper(org.eclipse.persistence.sdo.helper.SDOXSDHelper) XMLDocument(commonj.sdo.helper.XMLDocument) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) DataObject(commonj.sdo.DataObject) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File)

Example 25 with SDOType

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;
    }
}
Also used : DOMSource(javax.xml.transform.dom.DOMSource) Element(org.w3c.dom.Element) SDOType(org.eclipse.persistence.sdo.SDOType) ArrayList(java.util.ArrayList) SDOXSDHelper(org.eclipse.persistence.sdo.helper.SDOXSDHelper) XMLDocument(commonj.sdo.helper.XMLDocument) FileInputStream(java.io.FileInputStream) IOException(java.io.IOException) SAXException(org.xml.sax.SAXException) DataObject(commonj.sdo.DataObject) Collection(java.util.Collection) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File)

Aggregations

SDOType (org.eclipse.persistence.sdo.SDOType)318 SDOProperty (org.eclipse.persistence.sdo.SDOProperty)158 DataObject (commonj.sdo.DataObject)139 Type (commonj.sdo.Type)132 SDODataObject (org.eclipse.persistence.sdo.SDODataObject)102 ArrayList (java.util.ArrayList)89 List (java.util.List)83 QName (javax.xml.namespace.QName)31 Property (commonj.sdo.Property)30 SDOTypeHelper (org.eclipse.persistence.sdo.helper.SDOTypeHelper)17 SDOChangeSummary (org.eclipse.persistence.sdo.SDOChangeSummary)13 ChangeSummary (commonj.sdo.ChangeSummary)11 SDOWrapperType (org.eclipse.persistence.sdo.types.SDOWrapperType)10 ComplexType (org.eclipse.persistence.internal.oxm.schema.model.ComplexType)9 SimpleType (org.eclipse.persistence.internal.oxm.schema.model.SimpleType)9 XMLDocument (commonj.sdo.helper.XMLDocument)8 SDOXSDHelper (org.eclipse.persistence.sdo.helper.SDOXSDHelper)8 SDODataType (org.eclipse.persistence.sdo.types.SDODataType)7 IOException (java.io.IOException)6 FileInputStream (java.io.FileInputStream)5