Search in sources :

Example 6 with XMLConversionManager

use of org.eclipse.persistence.internal.oxm.XMLConversionManager in project eclipselink by eclipse-ee4j.

the class SDOMarshalListener method beforeMarshal.

@Override
public void beforeMarshal(Object obj) {
    if (obj instanceof SDOChangeSummary) {
        SDOChangeSummary changeSummary = ((SDOChangeSummary) obj);
        // CREATED - build a list of xpaths to write to the created attribute
        // this must be done dynamically because the xpath is relative to the marshalledObject
        // so it can't be calculated until we know what object is being marshalled
        List createdSet = changeSummary.getCreated();
        List xpaths = new ArrayList(createdSet.size());
        String rootElementName = this.marshalledObjectRootQName.getLocalPart();
        String rootNamespaceUri = this.marshalledObjectRootQName.getNamespaceURI();
        if (rootNamespaceUri != null && !rootNamespaceUri.equals(XMLConstants.EMPTY_STRING)) {
            org.eclipse.persistence.internal.oxm.NamespaceResolver resolver = getRootMarshalRecord().getNamespaceResolver();
            if (resolver != null) {
                String prefix = resolver.resolveNamespaceURI(this.marshalledObjectRootQName.getNamespaceURI());
                if (prefix != null) {
                    rootElementName = prefix + XMLConstants.COLON + rootElementName;
                }
            }
        }
        if ((createdSet != null) && (createdSet.size() > 0)) {
            Iterator anIterator = createdSet.iterator();
            SDODataObject nextCreatedDO = null;
            while (anIterator.hasNext()) {
                // get path to the changeSummaryRoot (may not be the root marshalled object - may be internal)
                nextCreatedDO = ((SDODataObject) anIterator.next());
                String nextPath = getPathFromAncestor(nextCreatedDO, (SDODataObject) marshalledObject, changeSummary);
                // Add sdoRef attribute...all modified objects written should have this
                if (nextPath == SDOConstants.EMPTY_STRING) {
                    // if this is the root, just put the root element
                    xpaths.add(SDOConstants.SDO_CHANGESUMMARY_REF_PATH_PREFIX + // 
                    SDOConstants.SDO_XPATH_SEPARATOR_FRAGMENT + rootElementName);
                } else {
                    xpaths.add(SDOConstants.SDO_CHANGESUMMARY_REF_PATH_PREFIX + // 
                    SDOConstants.SDO_XPATH_SEPARATOR_FRAGMENT + rootElementName + SDOConstants.SDO_XPATH_SEPARATOR_FRAGMENT + nextPath);
                }
            }
        }
        changeSummary.setCreatedXPaths(xpaths);
        // Build xpathToCS
        String xpathMarshalledObjToCS = getPathFromAncestor(changeSummary.getRootObject(), (SDODataObject) marshalledObject, changeSummary);
        String xpathChangeSumProp = getXPathForProperty(changeSummary.getRootObject().getType().getChangeSummaryProperty());
        String xpathToCS = SDOConstants.SDO_CHANGESUMMARY_REF_PATH_PREFIX + SDOConstants.SDO_XPATH_SEPARATOR_FRAGMENT + rootElementName;
        // check if the CS is at the local-cs-root or is in a child property
        if ((xpathMarshalledObjToCS != null) && !xpathMarshalledObjToCS.equals(SDOConstants.EMPTY_STRING)) {
            // SDO_XPATH_TO_ROOT)) {
            // CS is not on the root
            xpathToCS = xpathToCS + SDOConstants.SDO_XPATH_SEPARATOR_FRAGMENT + xpathMarshalledObjToCS;
        }
        xpathToCS = // 
        xpathToCS + SDOConstants.SDO_XPATH_SEPARATOR_FRAGMENT + xpathChangeSumProp + SDOConstants.SDO_XPATH_SEPARATOR_FRAGMENT;
        // MODIFIED && DELETED
        List deletedXPaths = new ArrayList();
        Document document = XMLPlatformFactory.getInstance().getXMLPlatform().createDocument();
        Element csNode = null;
        List modifiedItems = changeSummary.getModified();
        int modifiedSize = modifiedItems.size();
        List newNodes = new ArrayList(modifiedSize);
        SDODataObject nextModifiedDO = null;
        // Iterate through CS modified items
        for (int i = 0; i < modifiedSize; i++) {
            nextModifiedDO = (SDODataObject) modifiedItems.get(i);
            String sdoPrefix = typeHelper.getPrefix(SDOConstants.SDO_URL);
            // List unsetPropNames = new ArrayList();
            String uri = getURI(nextModifiedDO);
            String qualifiedName = getQualifiedName(nextModifiedDO);
            String sdoRefPrefix = SDOConstants.SDO_CHANGESUMMARY_REF_PATH_PREFIX + SDOConstants.SDO_XPATH_SEPARATOR_FRAGMENT;
            if (uri == null) {
                csNode = document.createElement(qualifiedName);
            } else {
                csNode = document.createElementNS(uri, qualifiedName);
            }
            String nextPath = getPathFromAncestor(nextModifiedDO, (SDODataObject) marshalledObject, changeSummary);
            // Add sdoRef attribute...all modified objects written should have this
            if (nextPath == SDOConstants.EMPTY_STRING) {
                // if this is the root, just put the root element
                csNode.setAttributeNS(SDOConstants.SDO_URL, // 
                sdoPrefix + // 
                SDOConstants.SDO_XPATH_NS_SEPARATOR_FRAGMENT + // 
                SDOConstants.CHANGESUMMARY_REF, sdoRefPrefix + rootElementName);
            } else {
                csNode.setAttributeNS(SDOConstants.SDO_URL, // 
                sdoPrefix + // 
                SDOConstants.SDO_XPATH_NS_SEPARATOR_FRAGMENT + // 
                SDOConstants.CHANGESUMMARY_REF, sdoRefPrefix + rootElementName + "/" + nextPath);
            }
            // Bug6346754 Add all namespaces if they are not yet declared above.
            Vector namespaces = nextModifiedDO.getType().getXmlDescriptor().getNonNullNamespaceResolver().getNamespaces();
            for (int j = 0; j < namespaces.size(); j++) {
                Namespace next = (Namespace) namespaces.get(j);
                if (declareNamespace(next.getNamespaceURI(), next.getPrefix(), changeSummary.getRootObject())) {
                    csNode.setAttributeNS(javax.xml.XMLConstants.XMLNS_ATTRIBUTE_NS_URI, javax.xml.XMLConstants.XMLNS_ATTRIBUTE + XMLConstants.COLON + next.getPrefix(), next.getNamespaceURI());
                }
            }
            List nextDOSettings = changeSummary.getOldValues(nextModifiedDO);
            DOMRecord row = new DOMRecord(csNode);
            Session session = ((SDOXMLHelper) typeHelper.getHelperContext().getXMLHelper()).getXmlContext().getSession();
            row.setSession((AbstractSession) session);
            // Iterate through SDOSettings for the current modified Object
            SDOSetting nextSetting = null;
            for (int j = 0; j < nextDOSettings.size(); j++) {
                nextSetting = (SDOSetting) nextDOSettings.get(j);
                if (nextSetting.isSet()) {
                    if (!nextSetting.getProperty().getType().isDataType()) {
                        if (nextSetting.getProperty().isMany()) {
                            List values = (List) nextSetting.getValue();
                            for (int k = 0; k < values.size(); k++) {
                                doMarshal(// 
                                nextSetting.getProperty(), // 
                                (DataObject) values.get(k), changeSummary, csNode, nextModifiedDO, deletedXPaths, xpathToCS, sdoPrefix, rootElementName);
                            }
                        } else {
                            doMarshal(// 
                            nextSetting.getProperty(), // 
                            (DataObject) nextSetting.getValue(), changeSummary, csNode, nextModifiedDO, deletedXPaths, xpathToCS, sdoPrefix, rootElementName);
                        }
                    } else {
                        // This writes out simple values
                        Object value = nextSetting.getValue();
                        if (value == null) {
                            // Marshal out xsi:nil=true
                            marshalNilAttribute(nextSetting.getProperty(), row);
                        } else {
                            String xPath = getXPathForProperty(nextSetting.getProperty());
                            XMLField field = new XMLField(xPath);
                            field.setNamespaceResolver(typeHelper.getNamespaceResolver());
                            row.put(field, value);
                        }
                    }
                }
            }
            List unsetPropNames = changeSummary.getUnsetProps(nextModifiedDO);
            if (!unsetPropNames.isEmpty()) {
                XMLConversionManager xmlConversionManager = ((SDOXMLHelper) typeHelper.getHelperContext().getXMLHelper()).getXmlConversionManager();
                String unsetPropsString = xmlConversionManager.convertObject(unsetPropNames, String.class);
                csNode.setAttributeNS(SDOConstants.SDO_URL, // 
                sdoPrefix + // 
                SDOConstants.SDO_XPATH_NS_SEPARATOR_FRAGMENT + SDOConstants.CHANGESUMMARY_UNSET, unsetPropsString);
            }
            newNodes.add(csNode);
        }
        changeSummary.setDeletedXPaths(deletedXPaths);
        changeSummary.setModifiedDoms(newNodes);
    }
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) SDOSetting(org.eclipse.persistence.sdo.SDOSetting) DOMRecord(org.eclipse.persistence.oxm.record.DOMRecord) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) Document(org.w3c.dom.Document) Namespace(org.eclipse.persistence.internal.oxm.Namespace) SDOChangeSummary(org.eclipse.persistence.sdo.SDOChangeSummary) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) SDODataObject(org.eclipse.persistence.sdo.SDODataObject) DataObject(commonj.sdo.DataObject) Vector(java.util.Vector) SDODataObject(org.eclipse.persistence.sdo.SDODataObject) AbstractSession(org.eclipse.persistence.internal.sessions.AbstractSession) Session(org.eclipse.persistence.sessions.Session) XMLConversionManager(org.eclipse.persistence.internal.oxm.XMLConversionManager)

Example 7 with XMLConversionManager

use of org.eclipse.persistence.internal.oxm.XMLConversionManager in project eclipselink by eclipse-ee4j.

the class SDOTypesGenerator method processSimpleComponentAnnotations.

private SDOType processSimpleComponentAnnotations(SDOType owningType, SimpleComponent simpleComponent, SDOProperty p, String targetNamespace, String defaultNamespace, SDOType sdoPropertyType) {
    // aliasName annotation
    String aliasNamesValue = simpleComponent.getAttributesMap().get(SDOConstants.SDOXML_ALIASNAME_QNAME);
    if (aliasNamesValue != null) {
        XMLConversionManager xmlConversionManager = ((SDOXMLHelper) aHelperContext.getXMLHelper()).getXmlConversionManager();
        java.util.List names = xmlConversionManager.convertObject(aliasNamesValue, java.util.List.class);
        p.setAliasNames(names);
    }
    // readOnly annotation
    String readOnlyValue = simpleComponent.getAttributesMap().get(SDOConstants.SDOXML_READONLY_QNAME);
    if (readOnlyValue != null) {
        p.setReadOnly(Boolean.parseBoolean(readOnlyValue));
    }
    // dataType annotation
    String dataTypeValue = simpleComponent.getAttributesMap().get(SDOConstants.SDOXML_DATATYPE_QNAME);
    if (dataTypeValue != null) {
        QName xsdQName = ((SDOTypeHelper) aHelperContext.getTypeHelper()).getXSDTypeFromSDOType(sdoPropertyType);
        if ((xsdQName == null) && !sdoPropertyType.isDataType()) {
            xsdQName = new QName(sdoPropertyType.getURI(), sdoPropertyType.getName());
        }
        p.setXsdType(xsdQName);
        SDOType sdoType = getSDOTypeForName(targetNamespace, defaultNamespace, dataTypeValue);
        sdoPropertyType = sdoType;
        Property xmlDataTypeProperty = aHelperContext.getTypeHelper().getOpenContentProperty(SDOConstants.SDOXML_URL, SDOConstants.SDOXML_DATATYPE);
        p.setInstanceProperty(xmlDataTypeProperty, sdoType);
    }
    // string annotation
    String stringValue = simpleComponent.getAttributesMap().get(SDOConstants.SDOXML_STRING_QNAME);
    if (stringValue != null) {
        QName xsdTypeQName = getQNameForString(defaultNamespace, simpleComponent.getType());
        p.setXsdType(xsdTypeQName);
        sdoPropertyType = SDOConstants.SDO_STRING;
    }
    // name annotation
    String nameValue = simpleComponent.getAttributesMap().get(SDOConstants.SDOXML_NAME_QNAME);
    if (nameValue != null) {
        // itemNameToSDOName.put(sdoTypeName, nameValue);
        p.setName(nameValue);
        if (p.isGlobal() && targetNamespace != null) {
            QName propertyName = new QName(targetNamespace, nameValue);
            ((SDOTypeHelper) aHelperContext.getTypeHelper()).getOpenContentProperties().put(propertyName, p);
        }
    } else {
        if (p.isGlobal() && targetNamespace != null) {
            QName propertyName = new QName(targetNamespace, p.getName());
            ((SDOTypeHelper) aHelperContext.getTypeHelper()).getOpenContentProperties().put(propertyName, p);
        }
    }
    // propertyType annotation
    String propertyTypeValue = simpleComponent.getAttributesMap().get(SDOConstants.SDOXML_PROPERTYTYPE_QNAME);
    if (propertyTypeValue != null) {
        String uri = targetNamespace;
        int colonIndex = propertyTypeValue.indexOf(':');
        if (colonIndex > -1) {
            String prefix = propertyTypeValue.substring(0, colonIndex);
            uri = getURIForPrefix(prefix);
        }
        NonContainmentReference nonContainmentReference = new NonContainmentReference();
        nonContainmentReference.setPropertyTypeName(propertyTypeValue);
        nonContainmentReference.setPropertyTypeURI(uri);
        nonContainmentReference.setOwningType(owningType);
        nonContainmentReference.setOwningProp(p);
        String oppositePropValue = simpleComponent.getAttributesMap().get(SDOConstants.SDOXML_OPPOSITEPROPERTY_QNAME);
        nonContainmentReference.setOppositePropName(oppositePropValue);
        getNonContainmentReferences().add(nonContainmentReference);
    }
    return sdoPropertyType;
}
Also used : QName(javax.xml.namespace.QName) SDOType(org.eclipse.persistence.sdo.SDOType) SDOProperty(org.eclipse.persistence.sdo.SDOProperty) Property(commonj.sdo.Property) XMLConversionManager(org.eclipse.persistence.internal.oxm.XMLConversionManager)

Example 8 with XMLConversionManager

use of org.eclipse.persistence.internal.oxm.XMLConversionManager in project eclipselink by eclipse-ee4j.

the class SDOTypesGenerator method finishSimpleType.

private void finishSimpleType(String targetNamespace, String defaultNamespace, String sdoTypeName, SimpleType simpleType, SDOType currentType) {
    String value = simpleType.getAttributesMap().get(SDOConstants.SDOXML_ALIASNAME_QNAME);
    if (value != null) {
        XMLConversionManager xmlConversionManager = ((SDOXMLHelper) aHelperContext.getXMLHelper()).getXmlConversionManager();
        java.util.List names = xmlConversionManager.convertObject(value, java.util.List.class);
        currentType.setAliasNames(names);
    }
    String instanceClassValue = simpleType.getAttributesMap().get(SDOConstants.SDOJAVA_INSTANCECLASS_QNAME);
    if (instanceClassValue != null) {
        currentType.setInstanceProperty(SDOConstants.JAVA_CLASS_PROPERTY, instanceClassValue);
        currentType.setBaseTypes(null);
    }
    String extendedInstanceClassValue = simpleType.getAttributesMap().get(SDOConstants.SDOJAVA_EXTENDEDINSTANCECLASS_QNAME);
    if (extendedInstanceClassValue != null) {
        currentType.setInstanceClassName(extendedInstanceClassValue);
    }
    currentType.postInitialize();
}
Also used : XMLConversionManager(org.eclipse.persistence.internal.oxm.XMLConversionManager)

Example 9 with XMLConversionManager

use of org.eclipse.persistence.internal.oxm.XMLConversionManager in project eclipselink by eclipse-ee4j.

the class XMLCollectionReferenceMapping method buildReference.

/**
 * INTERNAL:
 * Create (if necessary) and populate a reference object that will be used
 * during the mapping reference resolution phase after unmarshalling is
 * complete.
 */
public void buildReference(Object srcObject, XMLField xmlField, Object object, AbstractSession session, Object container, ReferenceResolver resolver) {
    if (resolver == null) {
        return;
    }
    Reference reference = resolver.getReference(this, srcObject, xmlField);
    if (reference == null) {
        // if reference is null, create a new instance and set it on the resolver
        reference = new Reference(this, srcObject, referenceClass, new HashMap(), container);
        resolver.addReference(reference);
    }
    CacheId primaryKeys;
    if (null == referenceClass || ClassConstants.OBJECT == referenceClass) {
        HashMap primaryKeyMap = reference.getPrimaryKeyMap();
        CacheId pks = (CacheId) primaryKeyMap.get(null);
        if (pks == null) {
            Object[] pkValues = new Object[1];
            pks = new CacheId(pkValues);
            primaryKeyMap.put(null, pks);
        }
        if (usesSingleNode) {
            for (StringTokenizer stok = new StringTokenizer((String) object); stok.hasMoreTokens(); ) {
                pks.add(stok.nextToken());
                reference = resolver.getReference(this, srcObject, xmlField);
                if (reference == null) {
                    // if reference is null, create a new instance and set it on the resolver
                    reference = new Reference(this, srcObject, referenceClass, new HashMap(), container);
                    resolver.addReference(reference);
                }
                primaryKeyMap = reference.getPrimaryKeyMap();
                pks = (CacheId) primaryKeyMap.get(null);
                if (pks == null) {
                    Object[] pkValues = new Object[1];
                    pks = new CacheId(pkValues);
                    primaryKeyMap.put(null, pks);
                }
            }
        } else {
            pks.add(object);
        }
    } else {
        XMLField tgtFld = (XMLField) getSourceToTargetKeyFieldAssociations().get(xmlField);
        String tgtXPath = tgtFld.getQualifiedName();
        HashMap primaryKeyMap = reference.getPrimaryKeyMap();
        CacheId pks = (CacheId) primaryKeyMap.get(tgtXPath);
        ClassDescriptor descriptor = session.getClassDescriptor(referenceClass);
        if (pks == null) {
            pks = new CacheId(new Object[0]);
            primaryKeyMap.put(tgtXPath, pks);
        }
        Class<?> type = descriptor.getTypedField(tgtFld).getType();
        XMLConversionManager xmlConversionManager = (XMLConversionManager) session.getDatasourcePlatform().getConversionManager();
        if (usesSingleNode) {
            for (StringTokenizer stok = new StringTokenizer((String) object); stok.hasMoreTokens(); ) {
                Object value = xmlConversionManager.convertObject(stok.nextToken(), type);
                if (value != null) {
                    pks.add(value);
                }
                reference = resolver.getReference(this, srcObject, xmlField);
                if (reference == null) {
                    // if reference is null, create a new instance and set it on the resolver
                    reference = new Reference(this, srcObject, referenceClass, new HashMap(), container);
                    resolver.addReference(reference);
                }
                primaryKeyMap = reference.getPrimaryKeyMap();
                pks = (CacheId) primaryKeyMap.get(null);
                if (pks == null) {
                    pks = new CacheId(new Object[0]);
                    primaryKeyMap.put(tgtXPath, pks);
                }
            }
        } else {
            Object value = xmlConversionManager.convertObject(object, type);
            if (value != null) {
                pks.add(value);
            }
        }
    }
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) StringTokenizer(java.util.StringTokenizer) ClassDescriptor(org.eclipse.persistence.descriptors.ClassDescriptor) HashMap(java.util.HashMap) Reference(org.eclipse.persistence.internal.oxm.Reference) CacheId(org.eclipse.persistence.internal.identitymaps.CacheId) XMLConversionManager(org.eclipse.persistence.internal.oxm.XMLConversionManager)

Example 10 with XMLConversionManager

use of org.eclipse.persistence.internal.oxm.XMLConversionManager in project eclipselink by eclipse-ee4j.

the class XMLBinaryDataCollectionMapping method valueFromRow.

@Override
public Object valueFromRow(AbstractRecord row, JoinedAttributeManager joinManager, ObjectBuildingQuery query, CacheKey cacheKey, AbstractSession executionSession, boolean isTargetProtected, Boolean[] wasCacheUsed) {
    ContainerPolicy cp = this.getContainerPolicy();
    Object fieldValue = row.getValues(this.getField());
    if (fieldValue == null) {
        if (reuseContainer) {
            Object currentObject = ((XMLRecord) row).getCurrentObject();
            Object container = getAttributeAccessor().getAttributeValueFromObject(currentObject);
            return container != null ? container : cp.containerInstance();
        } else {
            return cp.containerInstance();
        }
    }
    Vector fieldValues = this.getDescriptor().buildDirectValuesFromFieldValue(fieldValue);
    if (fieldValues == null) {
        if (reuseContainer) {
            Object currentObject = ((XMLRecord) row).getCurrentObject();
            Object container = getAttributeAccessor().getAttributeValueFromObject(currentObject);
            return container != null ? container : cp.containerInstance();
        } else {
            return cp.containerInstance();
        }
    }
    Object result = null;
    if (reuseContainer) {
        Object currentObject = ((XMLRecord) row).getCurrentObject();
        Object container = getAttributeAccessor().getAttributeValueFromObject(currentObject);
        result = container != null ? container : cp.containerInstance();
    } else {
        result = cp.containerInstance(fieldValues.size());
    }
    for (Enumeration stream = fieldValues.elements(); stream.hasMoreElements(); ) {
        Object element = stream.nextElement();
        // PERF: Direct variable access.
        // Object value = row.get(field);
        // Object fieldValue = null;
        XMLUnmarshaller unmarshaller = ((XMLRecord) row).getUnmarshaller();
        if (element instanceof String) {
            if (this.isSwaRef() && (unmarshaller.getAttachmentUnmarshaller() != null)) {
                fieldValue = unmarshaller.getAttachmentUnmarshaller().getAttachmentAsDataHandler((String) element);
            } else if (!this.isSwaRef()) {
                // should be base64
                byte[] bytes = ((XMLConversionManager) executionSession.getDatasourcePlatform().getConversionManager()).convertSchemaBase64ToByteArray(element);
                fieldValue = bytes;
            }
        } else {
            // this was an element, so do the XOP/SWAREF/Inline binary cases for an element
            XMLRecord record = (XMLRecord) element;
            if (getNullPolicy().valueIsNull((Element) record.getDOM())) {
                fieldValue = null;
            } else {
                record.setSession(executionSession);
                if ((unmarshaller.getAttachmentUnmarshaller() != null) && unmarshaller.getAttachmentUnmarshaller().isXOPPackage() && !this.isSwaRef() && !this.shouldInlineBinaryData()) {
                    // look for the include element:
                    String xpath = XMLConstants.EMPTY_STRING;
                    // need a prefix for XOP
                    String prefix = null;
                    NamespaceResolver descriptorResolver = ((XMLDescriptor) getDescriptor()).getNamespaceResolver();
                    if (descriptorResolver != null) {
                        prefix = descriptorResolver.resolveNamespaceURI(XMLConstants.XOP_URL);
                    }
                    if (prefix == null) {
                        prefix = XMLConstants.XOP_PREFIX;
                    }
                    NamespaceResolver tempResolver = new NamespaceResolver();
                    tempResolver.put(prefix, XMLConstants.XOP_URL);
                    xpath = prefix + XMLConstants.COLON + INCLUDE + "/@href";
                    XMLField field = new XMLField(xpath);
                    field.setNamespaceResolver(tempResolver);
                    String includeValue = (String) record.get(field);
                    if (element != null && includeValue != null) {
                        if ((getAttributeElementClass() == ClassConstants.ABYTE) || (getAttributeElementClass() == ClassConstants.APBYTE)) {
                            fieldValue = unmarshaller.getAttachmentUnmarshaller().getAttachmentAsByteArray(includeValue);
                        } else {
                            fieldValue = unmarshaller.getAttachmentUnmarshaller().getAttachmentAsDataHandler(includeValue);
                        }
                    } else {
                        // If we didn't find the Include element, check for inline
                        fieldValue = record.get(XMLConstants.TEXT);
                        // should be a base64 string
                        fieldValue = ((XMLConversionManager) executionSession.getDatasourcePlatform().getConversionManager()).convertSchemaBase64ToByteArray(fieldValue);
                    }
                } else if ((unmarshaller.getAttachmentUnmarshaller() != null) && isSwaRef()) {
                    String refValue = (String) record.get(XMLConstants.TEXT);
                    if (refValue != null) {
                        fieldValue = unmarshaller.getAttachmentUnmarshaller().getAttachmentAsDataHandler(refValue);
                    }
                } else {
                    fieldValue = record.get(XMLConstants.TEXT);
                    // should be a base64 string
                    fieldValue = ((XMLConversionManager) executionSession.getDatasourcePlatform().getConversionManager()).convertSchemaBase64ToByteArray(fieldValue);
                }
            }
        }
        Object attributeValue = convertDataValueToObjectValue(fieldValue, executionSession, unmarshaller);
        cp.addInto(attributeValue, result, query.getSession());
    }
    return result;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) ContainerPolicy(org.eclipse.persistence.internal.queries.ContainerPolicy) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) Enumeration(java.util.Enumeration) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver) XMLUnmarshaller(org.eclipse.persistence.oxm.XMLUnmarshaller) XMLRecord(org.eclipse.persistence.oxm.record.XMLRecord) Vector(java.util.Vector) XMLConversionManager(org.eclipse.persistence.internal.oxm.XMLConversionManager)

Aggregations

XMLConversionManager (org.eclipse.persistence.internal.oxm.XMLConversionManager)34 XMLField (org.eclipse.persistence.oxm.XMLField)12 QName (javax.xml.namespace.QName)10 NamespaceResolver (org.eclipse.persistence.oxm.NamespaceResolver)8 ArrayList (java.util.ArrayList)6 Element (org.w3c.dom.Element)6 Time (java.sql.Time)4 Timestamp (java.sql.Timestamp)4 Vector (java.util.Vector)3 XPathFragment (org.eclipse.persistence.internal.oxm.XPathFragment)3 SDOProperty (org.eclipse.persistence.sdo.SDOProperty)3 SDOType (org.eclipse.persistence.sdo.SDOType)3 DataObject (commonj.sdo.DataObject)2 Property (commonj.sdo.Property)2 Type (commonj.sdo.Type)2 DataHandler (jakarta.activation.DataHandler)2 List (java.util.List)2 XMLMarshalException (org.eclipse.persistence.exceptions.XMLMarshalException)2 XMLBinaryDataHelper (org.eclipse.persistence.internal.oxm.XMLBinaryDataHelper)2 JavaClass (org.eclipse.persistence.jaxb.javamodel.JavaClass)2