Search in sources :

Example 6 with SDOTypeHelper

use of org.eclipse.persistence.sdo.helper.SDOTypeHelper in project eclipselink by eclipse-ee4j.

the class SDOResolvableTest method setUp.

@Override
public void setUp() {
    try {
        xmlComparer = new SDOXMLComparer();
        aHelperContext = SDOHelperContext.getHelperContext();
        typeHelper = aHelperContext.getTypeHelper();
        xmlHelper = aHelperContext.getXMLHelper();
        xsdHelper = aHelperContext.getXSDHelper();
        equalityHelper = aHelperContext.getEqualityHelper();
        copyHelper = aHelperContext.getCopyHelper();
        dataFactory = aHelperContext.getDataFactory();
        // TODO: we should be using the DataHelper interface
        dataHelper = (SDODataHelper) aHelperContext.getDataHelper();
        DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
        builderFactory.setNamespaceAware(true);
        builderFactory.setIgnoringElementContentWhitespace(true);
        try {
            parser = builderFactory.newDocumentBuilder();
        } catch (Exception e) {
            fail("Could not create parser.");
            e.printStackTrace();
        }
        ((SDOTypeHelper) typeHelper).reset();
        ((SDOXMLHelper) xmlHelper).reset();
        ((SDOXSDHelper) xsdHelper).reset();
        // load in the schema
        String xsdString = getXSDString("org/eclipse/persistence/testing/sdo/helper/xmlhelper/PurchaseOrderDeep.xsd");
        // Define Types so that processing attributes completes
        List types = xsdHelper.define(xsdString);
        // first we set up root data object
        FileInputStream inStream = new FileInputStream("org/eclipse/persistence/testing/sdo/helper/xmlhelper/PurchaseOrderNSDeep.xml");
        XMLDocument document = xmlHelper.load(inStream);
        root = document.getRootObject();
        inStream.close();
    } catch (Exception e) {
        e.printStackTrace();
        fail("SDOResolvableTestCases.setup() failed to load DataObject");
    }
}
Also used : SDOTypeHelper(org.eclipse.persistence.sdo.helper.SDOTypeHelper) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) SDOXSDHelper(org.eclipse.persistence.sdo.helper.SDOXSDHelper) ArrayList(java.util.ArrayList) List(java.util.List) SDOXMLHelper(org.eclipse.persistence.sdo.helper.SDOXMLHelper) SDOXMLComparer(org.eclipse.persistence.testing.sdo.SDOXMLComparer) InvalidClassException(java.io.InvalidClassException) FileInputStream(java.io.FileInputStream) XMLDocument(commonj.sdo.helper.XMLDocument)

Example 7 with SDOTypeHelper

use of org.eclipse.persistence.sdo.helper.SDOTypeHelper in project eclipselink by eclipse-ee4j.

the class DefineAndGenerateWrapperTypeTestCases method getControlTypes.

// public List getTypesToGenerateFrom() {
@Override
public List getControlTypes() {
    // return getControlTypes();
    List types = new ArrayList();
    ((SDOTypeHelper) typeHelper).reset();
    SDOType dataObjectType = (SDOType) typeHelper.getType(SDOConstants.SDO_URL, SDOConstants.DATAOBJECT);
    SDOProperty xmlDataTypeProperty = (SDOProperty) typeHelper.getOpenContentProperty(SDOConstants.SDOXML_URL, SDOConstants.SDOXML_DATATYPE);
    SDOProperty xmlSchemaTypeProperty = (SDOProperty) typeHelper.getOpenContentProperty(SDOConstants.ORACLE_SDO_URL, SDOConstants.XML_SCHEMA_TYPE_NAME);
    DataObject myChildTypeDO = dataFactory.create("commonj.sdo", "Type");
    myChildTypeDO.set("uri", "http://www.example.org");
    myChildTypeDO.set("name", "childType");
    addProperty(myChildTypeDO, "name", SDOConstants.SDO_STRING, false, false, true);
    Type childType = typeHelper.define(myChildTypeDO);
    ((SDOProperty) childType.getProperty("name")).setXsd(true);
    ((SDOProperty) childType.getProperty("name")).setXsdLocalName("name");
    DataObject myRootTypeDO = dataFactory.create("commonj.sdo", "Type");
    myRootTypeDO.set("uri", "http://www.example.org");
    myRootTypeDO.set("name", "rootType");
    DataObject test1Prop = addProperty(myRootTypeDO, "test1", SDOConstants.SDO_INTOBJECT, false, false, true);
    test1Prop.set(xmlDataTypeProperty, SDOConstants.SDO_INTOBJECT);
    DataObject test2Prop = addProperty(myRootTypeDO, "test2", SDOConstants.SDO_BOOLEANOBJECT, false, false, true);
    test2Prop.set(xmlDataTypeProperty, SDOConstants.SDO_BOOLEANOBJECT);
    DataObject test3Prop = addProperty(myRootTypeDO, "test3", SDOConstants.SDO_DATE, false, false, true);
    test3Prop.set(xmlDataTypeProperty, SDOConstants.SDO_DATE);
    DataObject test4Prop = addProperty(myRootTypeDO, "test4", SDOConstants.SDO_DATETIME, false, false, true);
    test4Prop.set(xmlDataTypeProperty, SDOConstants.SDO_DATETIME);
    DataObject test5Prop = addProperty(myRootTypeDO, "test5", SDOConstants.SDO_SHORTOBJECT, false, false, true);
    test5Prop.set(xmlDataTypeProperty, SDOConstants.SDO_SHORTOBJECT);
    DataObject test6Prop = addProperty(myRootTypeDO, "test6", dataObjectType, true, false, true);
    test6Prop.set(xmlDataTypeProperty, dataObjectType);
    DataObject test7Prop = addProperty(myRootTypeDO, "test7", dataObjectType, true, false, true);
    test7Prop.set(xmlSchemaTypeProperty, childType);
    test7Prop.set(xmlDataTypeProperty, dataObjectType);
    Type myRootType = typeHelper.define(myRootTypeDO);
    ((SDOType) myRootType).setXsd(true);
    ((SDOType) myRootType).setXsdLocalName("rootType");
    ((SDOProperty) myRootType.getProperty("test1")).setXsd(true);
    ((SDOProperty) myRootType.getProperty("test1")).setXsdLocalName("test1");
    ((SDOProperty) myRootType.getProperty("test2")).setXsd(true);
    ((SDOProperty) myRootType.getProperty("test2")).setXsdLocalName("test2");
    ((SDOProperty) myRootType.getProperty("test3")).setXsd(true);
    ((SDOProperty) myRootType.getProperty("test3")).setXsdLocalName("test3");
    ((SDOProperty) myRootType.getProperty("test4")).setXsd(true);
    ((SDOProperty) myRootType.getProperty("test4")).setXsdLocalName("test4");
    ((SDOProperty) myRootType.getProperty("test5")).setXsd(true);
    ((SDOProperty) myRootType.getProperty("test5")).setXsdLocalName("test5");
    ((SDOProperty) myRootType.getProperty("test6")).setXsd(true);
    ((SDOProperty) myRootType.getProperty("test6")).setXsdLocalName("test6");
    ((SDOProperty) myRootType.getProperty("test7")).setXsd(true);
    ((SDOProperty) myRootType.getProperty("test7")).setXsdLocalName("test7");
    types.add(childType);
    types.add(myRootType);
    return types;
}
Also used : SDOTypeHelper(org.eclipse.persistence.sdo.helper.SDOTypeHelper) Type(commonj.sdo.Type) SDOType(org.eclipse.persistence.sdo.SDOType) DataObject(commonj.sdo.DataObject) ArrayList(java.util.ArrayList) SDOType(org.eclipse.persistence.sdo.SDOType) ArrayList(java.util.ArrayList) List(java.util.List) SDOProperty(org.eclipse.persistence.sdo.SDOProperty)

Example 8 with SDOTypeHelper

use of org.eclipse.persistence.sdo.helper.SDOTypeHelper in project eclipselink by eclipse-ee4j.

the class DefineFailsDontRegisterTypesTestCases method testDefine.

@Override
public void testDefine() {
    InputStream is = getSchemaInputStream(getSchemaToDefine());
    int sizeBefore = ((SDOTypeHelper) typeHelper).getTypesHashMap().size();
    boolean exceptionCase = false;
    List types = null;
    try {
        types = xsdHelper.define(is, getSchemaLocation());
    } catch (SDOException e) {
        exceptionCase = true;
    // do nothing
    }
    assertTrue(exceptionCase);
    assertEquals(sizeBefore, ((SDOTypeHelper) typeHelper).getTypesHashMap().size());
    assertNull(types);
    assertNull(typeHelper.getType("http://www.example.org", "address-type"));
    assertNull(typeHelper.getType("http://www.example.org", "customer-type"));
    assertNull(typeHelper.getType("http://www.example.org", "bad-type"));
    assertNull(xsdHelper.getGlobalProperty("http://www.example.org", "customer", true));
}
Also used : SDOTypeHelper(org.eclipse.persistence.sdo.helper.SDOTypeHelper) SDOException(org.eclipse.persistence.exceptions.SDOException) InputStream(java.io.InputStream) List(java.util.List) ArrayList(java.util.ArrayList)

Example 9 with SDOTypeHelper

use of org.eclipse.persistence.sdo.helper.SDOTypeHelper in project eclipselink by eclipse-ee4j.

the class ContainmentManyTestCases method getRootSDOType.

@Override
public SDOType getRootSDOType() {
    SDOType type = new SDOType("http://testing", "myRoot");
    type.setOpen(true);
    type.setAbstract(false);
    SDOProperty prop = new SDOProperty(aHelperContext);
    prop.setName("name");
    prop.setType(SDOConstants.SDO_STRING);
    prop.setContainingType(type);
    type.addDeclaredProperty(prop);
    SDOProperty prop2 = new SDOProperty(aHelperContext);
    prop2.setName("child");
    prop2.setMany(true);
    prop2.setType(typeHelper.getType("http://testing", "firstChildType"));
    prop2.setContainment(true);
    prop2.setContainingType(type);
    type.addDeclaredProperty(prop2);
    SDOProperty prop3 = new SDOProperty(aHelperContext);
    prop3.setName("child2");
    prop3.setMany(true);
    prop3.setType(typeHelper.getType("http://testing", "firstChildType"));
    prop3.setContainment(true);
    prop3.setContainingType(type);
    type.addDeclaredProperty(prop3);
    SDOProperty prop4 = new SDOProperty(aHelperContext);
    prop4.setName("nullTypeProp");
    prop4.setContainingType(type);
    type.addDeclaredProperty(prop4);
    ((SDOTypeHelper) typeHelper).addType(type);
    return type;
}
Also used : SDOTypeHelper(org.eclipse.persistence.sdo.helper.SDOTypeHelper) SDOType(org.eclipse.persistence.sdo.SDOType) SDOProperty(org.eclipse.persistence.sdo.SDOProperty)

Example 10 with SDOTypeHelper

use of org.eclipse.persistence.sdo.helper.SDOTypeHelper in project eclipselink by eclipse-ee4j.

the class ContainmentTestCases method getFirstChildType.

public SDOType getFirstChildType() {
    SDOType type = new SDOType("http://testing", "firstChildType");
    type.setOpen(true);
    type.setAbstract(false);
    SDOProperty prop = new SDOProperty(aHelperContext);
    prop.setName("name");
    prop.setType(SDOConstants.SDO_STRING);
    prop.setContainingType(type);
    type.addDeclaredProperty(prop);
    SDOProperty prop2 = new SDOProperty(aHelperContext);
    prop2.setName("child");
    prop2.setType(typeHelper.getType("http://testing", "secondChildType"));
    prop2.setContainment(true);
    prop2.setContainingType(type);
    type.addDeclaredProperty(prop2);
    ((SDOTypeHelper) typeHelper).addType(type);
    return type;
}
Also used : SDOTypeHelper(org.eclipse.persistence.sdo.helper.SDOTypeHelper) SDOType(org.eclipse.persistence.sdo.SDOType) SDOProperty(org.eclipse.persistence.sdo.SDOProperty)

Aggregations

SDOTypeHelper (org.eclipse.persistence.sdo.helper.SDOTypeHelper)31 SDOProperty (org.eclipse.persistence.sdo.SDOProperty)17 SDOType (org.eclipse.persistence.sdo.SDOType)17 DataObject (commonj.sdo.DataObject)13 Type (commonj.sdo.Type)9 ArrayList (java.util.ArrayList)9 List (java.util.List)7 QName (javax.xml.namespace.QName)3 SequencedObject (org.eclipse.persistence.oxm.sequenced.SequencedObject)3 SDOXMLHelper (org.eclipse.persistence.sdo.helper.SDOXMLHelper)3 SDOXSDHelper (org.eclipse.persistence.sdo.helper.SDOXSDHelper)3 Collection (java.util.Collection)2 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)2 NamespaceResolver (org.eclipse.persistence.oxm.NamespaceResolver)2 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)2 XMLField (org.eclipse.persistence.oxm.XMLField)2 XMLMarshaller (org.eclipse.persistence.oxm.XMLMarshaller)2 XMLRoot (org.eclipse.persistence.oxm.XMLRoot)2 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)2 SDODataObject (org.eclipse.persistence.sdo.SDODataObject)2