Search in sources :

Example 1 with DataFactory

use of commonj.sdo.helper.DataFactory in project metro-jax-ws by eclipse-ee4j.

the class SDOBond method deserialize.

private T deserialize(Source src, jakarta.xml.bind.attachment.AttachmentUnmarshaller au) {
    try {
        if (!commonj.sdo.DataObject.class.isAssignableFrom(javaType) && !javaType.isInterface()) {
            return (T) deserializePrimitives(src);
        }
        HelperContext context = parent.getHelperContext();
        SDOAttachmentUnmarshaller unmarshaller = null;
        if (au != null) {
            unmarshaller = new SDOAttachmentUnmarshaller(au);
        }
        DataFactory dataFactory = context.getDataFactory();
        DataObject loadOptions = dataFactory.create(SDOConstants.ORACLE_SDO_URL, SDOConstants.XMLHELPER_LOAD_OPTIONS);
        // bug 8680450
        loadOptions.set(SDOConstants.TYPE_LOAD_OPTION, theType);
        if (unmarshaller != null) {
            loadOptions.set(SDOConstants.ATTACHMENT_UNMARSHALLER_OPTION, unmarshaller);
        }
        XMLDocument xdoc = context.getXMLHelper().load(src, null, loadOptions);
        DataObject obj = xdoc.getRootObject();
        Object o = SDOUtils.unwrapPrimitives(obj);
        // ClassCast possible without check
        return (T) o;
    } catch (Exception e) {
        throw new SDODatabindingException(e);
    }
}
Also used : HelperContext(commonj.sdo.helper.HelperContext) DataObject(commonj.sdo.DataObject) DataObject(commonj.sdo.DataObject) DataFactory(commonj.sdo.helper.DataFactory) XMLDocument(commonj.sdo.helper.XMLDocument) XMLStreamException(javax.xml.stream.XMLStreamException) JAXBException(jakarta.xml.bind.JAXBException)

Example 2 with DataFactory

use of commonj.sdo.helper.DataFactory in project metro-jax-ws by eclipse-ee4j.

the class SDOBond method serializeDataObject.

private void serializeDataObject(DataObject java, Result result, jakarta.xml.bind.attachment.AttachmentMarshaller am) {
    logger.entering(CLASSNAME, "serializeDataObject");
    try {
        HelperContext context = parent.getHelperContext();
        SDOAttachmentMarshaller marshaller = null;
        if (am != null) {
            marshaller = new SDOAttachmentMarshaller(am);
        }
        // check Primitives for T
        SDOXMLHelper sdoXMLHelper = (SDOXMLHelper) context.getXMLHelper();
        // Bug 8909750 - Toplink already sets this to "GMT".  ADF
        // resets it before we get here, so don't change it again.
        // sdoXMLHelper.setTimeZone(TimeZone.getTimeZone("GMT"));
        sdoXMLHelper.setTimeZoneQualified(true);
        XMLDocument xmlDoc = sdoXMLHelper.createDocument(java, xmlTag.getNamespaceURI(), xmlTag.getLocalPart());
        if (xmlDoc == null) {
            return;
        }
        xmlDoc.setXMLDeclaration(false);
        DataObject saveOptions = null;
        if (marshaller != null) {
            DataFactory dataFactory = parent.getHelperContext().getDataFactory();
            saveOptions = dataFactory.create(SDOConstants.ORACLE_SDO_URL, SDOConstants.XMLHELPER_LOAD_OPTIONS);
            saveOptions.set(SDOConstants.ATTACHMENT_MARSHALLER_OPTION, marshaller);
        }
        sdoXMLHelper.save(xmlDoc, result, saveOptions);
    } catch (Exception e) {
        throw new SDODatabindingException(e);
    }
}
Also used : HelperContext(commonj.sdo.helper.HelperContext) DataObject(commonj.sdo.DataObject) DataFactory(commonj.sdo.helper.DataFactory) SDOXMLHelper(org.eclipse.persistence.sdo.helper.SDOXMLHelper) XMLDocument(commonj.sdo.helper.XMLDocument) XMLStreamException(javax.xml.stream.XMLStreamException) JAXBException(jakarta.xml.bind.JAXBException)

Aggregations

DataObject (commonj.sdo.DataObject)2 DataFactory (commonj.sdo.helper.DataFactory)2 HelperContext (commonj.sdo.helper.HelperContext)2 XMLDocument (commonj.sdo.helper.XMLDocument)2 JAXBException (jakarta.xml.bind.JAXBException)2 XMLStreamException (javax.xml.stream.XMLStreamException)2 SDOXMLHelper (org.eclipse.persistence.sdo.helper.SDOXMLHelper)1