Search in sources :

Example 1 with XMLFragmentCollectionMapping

use of org.eclipse.persistence.oxm.mappings.XMLFragmentCollectionMapping in project eclipselink by eclipse-ee4j.

the class SimpleXMLFormatProject method buildXRRowSetModelDescriptor.

public ClassDescriptor buildXRRowSetModelDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.descriptorIsAggregate();
    descriptor.setJavaClass(SimpleXMLFormatModel.class);
    descriptor.setAlias(DEFAULT_SIMPLE_XML_FORMAT_TAG);
    descriptor.setNamespaceResolver(ns);
    descriptor.setDefaultRootElement(DEFAULT_SIMPLE_XML_FORMAT_TAG);
    XMLSchemaURLReference schemaReference = new XMLSchemaURLReference("");
    schemaReference.setSchemaContext("/" + DEFAULT_SIMPLE_XML_FORMAT_TAG);
    schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
    descriptor.setSchemaReference(schemaReference);
    XMLFragmentCollectionMapping fragMapping = new XMLFragmentCollectionMapping();
    fragMapping.setAttributeName("simpleXML");
    fragMapping.setXPath(DEFAULT_SIMPLE_XML_TAG);
    descriptor.addMapping(fragMapping);
    return descriptor;
}
Also used : XMLFragmentCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLFragmentCollectionMapping) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLSchemaURLReference(org.eclipse.persistence.oxm.schema.XMLSchemaURLReference)

Example 2 with XMLFragmentCollectionMapping

use of org.eclipse.persistence.oxm.mappings.XMLFragmentCollectionMapping in project eclipselink by eclipse-ee4j.

the class XMLFragmentCollectionElementProject method addEmployeeDescriptor.

public void addEmployeeDescriptor() {
    XMLDescriptor desc = new XMLDescriptor();
    desc.setJavaClass(Employee.class);
    desc.setDefaultRootElement("employee");
    desc.setNamespaceResolver(namespaceResolver);
    // setup first-name mapping
    XMLDirectMapping mapping = new XMLDirectMapping();
    mapping.setAttributeName("firstName");
    mapping.setXPath("first-name/text()");
    desc.addMapping(mapping);
    // setup last-name mapping
    mapping = new XMLDirectMapping();
    mapping.setAttributeName("lastName");
    mapping.setXPath("last-name/text()");
    desc.addMapping(mapping);
    // setup xml-node mapping
    XMLFragmentCollectionMapping mapping2 = new XMLFragmentCollectionMapping();
    mapping2.setAttributeName("xmlnodes");
    mapping2.setXPath("xml-node");
    mapping2.useCollectionClass(ArrayList.class);
    desc.addMapping(mapping2);
    // add the descriptor to the project
    this.addDescriptor(desc);
}
Also used : XMLFragmentCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLFragmentCollectionMapping) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping)

Example 3 with XMLFragmentCollectionMapping

use of org.eclipse.persistence.oxm.mappings.XMLFragmentCollectionMapping in project eclipselink by eclipse-ee4j.

the class QueryOperation method addSimpleXMLFormatModelDescriptor.

protected void addSimpleXMLFormatModelDescriptor(XRServiceAdapter xrService) {
    if (isSimpleXMLFormat()) {
        Session oxSession = xrService.getOXSession();
        XMLDescriptor simpleXMLFormatDescriptor = (XMLDescriptor) oxSession.getProject().getClassDescriptor(SimpleXMLFormatModel.class);
        if (simpleXMLFormatDescriptor == null) {
            simpleXMLFormatDescriptor = new XMLDescriptor();
            simpleXMLFormatDescriptor.setJavaClass(SimpleXMLFormatModel.class);
            simpleXMLFormatDescriptor.setAlias(DEFAULT_SIMPLE_XML_FORMAT_TAG);
            simpleXMLFormatDescriptor.setDefaultRootElement(DEFAULT_SIMPLE_XML_FORMAT_TAG);
            XMLFragmentCollectionMapping xmlTag = new XMLFragmentCollectionMapping();
            xmlTag.setAttributeName(SIMPLEXML_STR);
            xmlTag.setXPath(DEFAULT_SIMPLE_XML_TAG);
            simpleXMLFormatDescriptor.addMapping(xmlTag);
            NamespaceResolver nr = new NamespaceResolver();
            simpleXMLFormatDescriptor.setNamespaceResolver(nr);
            XMLSchemaURLReference schemaReference = new XMLSchemaURLReference(EMPTY_STR);
            schemaReference.setSchemaContext(SIMPLEXML_FORMAT_STR);
            schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
            simpleXMLFormatDescriptor.setSchemaReference(schemaReference);
            oxSession.getProject().addDescriptor(simpleXMLFormatDescriptor);
            ((DatabaseSessionImpl) oxSession).initializeDescriptorIfSessionAlive(simpleXMLFormatDescriptor);
            xrService.getXMLContext().storeXMLDescriptorByQName(simpleXMLFormatDescriptor);
        }
    }
}
Also used : XMLFragmentCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLFragmentCollectionMapping) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) DatabaseSessionImpl(org.eclipse.persistence.internal.sessions.DatabaseSessionImpl) XMLSchemaURLReference(org.eclipse.persistence.oxm.schema.XMLSchemaURLReference) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver) SimpleXMLFormatModel(org.eclipse.persistence.internal.xr.sxf.SimpleXMLFormatModel) AbstractSession(org.eclipse.persistence.internal.sessions.AbstractSession) Session(org.eclipse.persistence.sessions.Session)

Example 4 with XMLFragmentCollectionMapping

use of org.eclipse.persistence.oxm.mappings.XMLFragmentCollectionMapping in project eclipselink by eclipse-ee4j.

the class XMLFragmentCollectionNSProject method addEmployeeDescriptor.

public void addEmployeeDescriptor() {
    XMLDescriptor desc = new XMLDescriptor();
    desc.setJavaClass(Employee.class);
    desc.setDefaultRootElement("employee");
    desc.setNamespaceResolver(nsresolver);
    // setup first-name mapping
    XMLDirectMapping mapping = new XMLDirectMapping();
    mapping.setAttributeName("firstName");
    mapping.setXPath("first-name/text()");
    desc.addMapping(mapping);
    // setup last-name mapping
    mapping = new XMLDirectMapping();
    mapping.setAttributeName("lastName");
    mapping.setXPath("last-name/text()");
    desc.addMapping(mapping);
    // setup xml-node mapping
    XMLFragmentCollectionMapping mapping2 = new XMLFragmentCollectionMapping();
    mapping2.setAttributeName("xmlnodes");
    mapping2.setXPath("xml-node");
    mapping2.useCollectionClass(ArrayList.class);
    desc.addMapping(mapping2);
    // add the descriptor to the project
    this.addDescriptor(desc);
}
Also used : XMLFragmentCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLFragmentCollectionMapping) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping)

Example 5 with XMLFragmentCollectionMapping

use of org.eclipse.persistence.oxm.mappings.XMLFragmentCollectionMapping in project eclipselink by eclipse-ee4j.

the class SDOProperty method buildXMLFragmentCollectionMapping.

public XMLFragmentCollectionMapping buildXMLFragmentCollectionMapping(String mappingUri) {
    XMLFragmentCollectionMapping mapping = new XMLFragmentCollectionMapping();
    mapping.setAttributeName(getName());
    mapping.setXPath(getQualifiedXPath(mappingUri, false));
    mapping.setAttributeAccessor(new SDOFragmentMappingAttributeAccessor(this, aHelperContext));
    return mapping;
}
Also used : XMLFragmentCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLFragmentCollectionMapping) SDOFragmentMappingAttributeAccessor(org.eclipse.persistence.sdo.helper.SDOFragmentMappingAttributeAccessor)

Aggregations

XMLFragmentCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLFragmentCollectionMapping)6 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)5 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)2 XMLSchemaURLReference (org.eclipse.persistence.oxm.schema.XMLSchemaURLReference)2 ArrayList (java.util.ArrayList)1 AbstractSession (org.eclipse.persistence.internal.sessions.AbstractSession)1 DatabaseSessionImpl (org.eclipse.persistence.internal.sessions.DatabaseSessionImpl)1 SimpleXMLFormatModel (org.eclipse.persistence.internal.xr.sxf.SimpleXMLFormatModel)1 NamespaceResolver (org.eclipse.persistence.oxm.NamespaceResolver)1 XMLField (org.eclipse.persistence.oxm.XMLField)1 XMLAnyObjectMapping (org.eclipse.persistence.oxm.mappings.XMLAnyObjectMapping)1 XMLBinaryDataCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLBinaryDataCollectionMapping)1 XMLBinaryDataMapping (org.eclipse.persistence.oxm.mappings.XMLBinaryDataMapping)1 XMLChoiceCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLChoiceCollectionMapping)1 XMLChoiceObjectMapping (org.eclipse.persistence.oxm.mappings.XMLChoiceObjectMapping)1 XMLCollectionReferenceMapping (org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping)1 XMLCompositeCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping)1 XMLCompositeDirectCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)1 XMLCompositeObjectMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)1 XMLFragmentMapping (org.eclipse.persistence.oxm.mappings.XMLFragmentMapping)1