Search in sources :

Example 6 with SDOXMLHelper

use of org.eclipse.persistence.sdo.helper.SDOXMLHelper 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 SDOXMLHelper

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

the class LoadAndSaveBase64AttachmentTestCases method setUp.

@Override
public void setUp() {
    super.setUp();
    XMLMarshaller aMarshaller = ((SDOXMLHelper) xmlHelper).getXmlMarshaller();
    XMLUnmarshaller anUnmarshaller = ((SDOXMLHelper) xmlHelper).getXmlUnmarshaller();
    XMLAttachmentMarshaller anAttachmentMarshaller = new AttachmentMarshallerImpl("c_id0");
    XMLAttachmentUnmarshaller anAttachmentUnmarshaller = new AttachmentUnmarshallerImpl("Testing".getBytes());
    aMarshaller.setAttachmentMarshaller(anAttachmentMarshaller);
    anUnmarshaller.setAttachmentUnmarshaller(anAttachmentUnmarshaller);
}
Also used : XMLMarshaller(org.eclipse.persistence.oxm.XMLMarshaller) XMLAttachmentMarshaller(org.eclipse.persistence.oxm.attachment.XMLAttachmentMarshaller) XMLUnmarshaller(org.eclipse.persistence.oxm.XMLUnmarshaller) SDOXMLHelper(org.eclipse.persistence.sdo.helper.SDOXMLHelper) XMLAttachmentUnmarshaller(org.eclipse.persistence.oxm.attachment.XMLAttachmentUnmarshaller)

Example 8 with SDOXMLHelper

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

the class SDODataObjectGetPathTest method testGetXPathFromAncestorDeletedFromChildToAncestorInsideListWrapperLoggingOn.

public void testGetXPathFromAncestorDeletedFromChildToAncestorInsideListWrapperLoggingOn() {
    SDODataObject anItem = (SDODataObject) aRoot5.get("billTo/phone[1]");
    // start logging
    SDOChangeSummary aCS = aRoot5.getChangeSummary();
    aCS.beginLogging();
    assertTrue(aCS.isLogging());
    // delete source object
    SDODataObject deletedObjectParent = ((SDODataObject) aRoot5.get("billTo"));
    // detach();
    deletedObjectParent.delete();
    String aPath = ((SDOMarshalListener) ((SDOXMLHelper) xmlHelper).getXmlMarshaller().getMarshalListener()).getPathFromAncestor(anItem, aRoot5, aRoot5.getChangeSummary());
    // SDODataObject anItemFromPath = (SDODataObject)aRoot5.get(aPath);
    // System.out.println("testGetPathFromAncestorDeletedFromChildToRootLoggingOn: " + aPath);
    assertNotNull(aPath);
    // TODO: no storage of deleted indexed postition - defaults to size() = start of list for now
    // see SDODataObject: index = ((SDODataObject)parent).getList(aChild).size();
    assertEquals("ns0:billTo/ns0:phone[1]", aPath);
}
Also used : SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDOMarshalListener(org.eclipse.persistence.sdo.helper.SDOMarshalListener) SDOXMLHelper(org.eclipse.persistence.sdo.helper.SDOXMLHelper) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 9 with SDOXMLHelper

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

the class SDODataObjectGetPathTest method testGetPathFromAncestorDetachedFromChildToAncestorInsideListWrapperLoggingOn.

// TODO: This case fails to find a path because the oldSettings map is not populated during detach()
public void testGetPathFromAncestorDetachedFromChildToAncestorInsideListWrapperLoggingOn() {
    SDODataObject anItem = (SDODataObject) aRoot5.get("items/item[2]");
    // start logging
    SDOChangeSummary aCS = aRoot5.getChangeSummary();
    aCS.beginLogging();
    assertTrue(aCS.isLogging());
    // delete source object
    // SDODataObject deletedObject = ((SDODataObject)aRoot5.get("items"));
    anItem.detach();
    // String aPath = anItem.getPathFromAncestor(aCS, aRoot5, useXPathFormat);
    String aPath = ((SDOMarshalListener) ((SDOXMLHelper) xmlHelper).getXmlMarshaller().getMarshalListener()).getPathFromAncestor(anItem, aRoot5, aRoot5.getChangeSummary());
    // SDODataObject anItemFromPath = (SDODataObject)aRoot5.get(aPath);
    assertNotNull(aPath);
    // TODO: no storage of deleted indexed postition - defaults to size() = start of list for now
    // see SDODataObject: index = ((SDODataObject)parent).getList(aChild).size();
    assertEquals("ns0:items/ns0:item[2]", aPath);
}
Also used : SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDOMarshalListener(org.eclipse.persistence.sdo.helper.SDOMarshalListener) SDOXMLHelper(org.eclipse.persistence.sdo.helper.SDOXMLHelper) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Example 10 with SDOXMLHelper

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

the class SDODataObjectGetPathTest method testGetXPathFromAncestorDeletedFromChildToRootInsideListWrapperLoggingOn.

public void testGetXPathFromAncestorDeletedFromChildToRootInsideListWrapperLoggingOn() {
    SDODataObject anItem = (SDODataObject) aRoot5.get("items/item[2]");
    // start logging
    SDOChangeSummary aCS = aRoot5.getChangeSummary();
    aCS.beginLogging();
    assertTrue(aCS.isLogging());
    // delete source object
    // SDODataObject deletedObject = ((SDODataObject)aRoot5.get("items"));
    // detach();
    anItem.delete();
    String aPath = ((SDOMarshalListener) ((SDOXMLHelper) xmlHelper).getXmlMarshaller().getMarshalListener()).getPathFromAncestor(anItem, aRoot5, aRoot5.getChangeSummary());
    // SDODataObject anItemFromPath = (SDODataObject)aRoot5.get(aPath);
    // System.out.println("testGetPathFromAncestorDeletedFromChildToRootLoggingOn: " + aPath);
    assertNotNull(aPath);
    // TODO: no storage of deleted indexed postition - defaults to size() = start of list for now
    // see SDODataObject: index = ((SDODataObject)parent).getList(aChild).size();
    assertEquals("ns0:items/ns0:item[2]", aPath);
}
Also used : SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) SDOMarshalListener(org.eclipse.persistence.sdo.helper.SDOMarshalListener) SDOXMLHelper(org.eclipse.persistence.sdo.helper.SDOXMLHelper) SDODataObject(org.eclipse.persistence.sdo.SDODataObject)

Aggregations

SDOXMLHelper (org.eclipse.persistence.sdo.helper.SDOXMLHelper)40 SDOMarshalListener (org.eclipse.persistence.sdo.helper.SDOMarshalListener)22 SDODataObject (org.eclipse.persistence.sdo.SDODataObject)21 SDOChangeSummary (org.eclipse.persistence.sdo.SDOChangeSummary)16 XMLDocument (commonj.sdo.helper.XMLDocument)6 XMLMarshaller (org.eclipse.persistence.oxm.XMLMarshaller)6 XMLUnmarshaller (org.eclipse.persistence.oxm.XMLUnmarshaller)5 XMLAttachmentMarshaller (org.eclipse.persistence.oxm.attachment.XMLAttachmentMarshaller)5 XMLAttachmentUnmarshaller (org.eclipse.persistence.oxm.attachment.XMLAttachmentUnmarshaller)5 ArrayList (java.util.ArrayList)4 List (java.util.List)3 SDOType (org.eclipse.persistence.sdo.SDOType)3 SDOClassLoader (org.eclipse.persistence.sdo.helper.SDOClassLoader)3 SDOTypeHelper (org.eclipse.persistence.sdo.helper.SDOTypeHelper)3 DataObject (commonj.sdo.DataObject)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 FileInputStream (java.io.FileInputStream)2 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)2 SDOXSDHelper (org.eclipse.persistence.sdo.helper.SDOXSDHelper)2 Type (commonj.sdo.Type)1