Search in sources :

Example 1 with XMLChoiceCollectionMapping

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

the class EmployeeProject method getEmployeeDescriptor.

private XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Employee.class);
    descriptor.setDefaultRootElement("employee");
    XMLDirectMapping nameMapping = new XMLDirectMapping();
    nameMapping.setAttributeName("name");
    nameMapping.setXPath("name/text()");
    descriptor.addMapping(nameMapping);
    XMLChoiceCollectionMapping choiceMapping = new XMLChoiceCollectionMapping();
    choiceMapping.setAttributeName("choice");
    choiceMapping.addChoiceElement("street/text()", String.class);
    choiceMapping.addChoiceElement("address", Address.class);
    choiceMapping.addChoiceElement("integer/text()", Integer.class);
    choiceMapping.addChoiceElement("simpleAddress", Object.class);
    choiceMapping.setReuseContainer(true);
    descriptor.addMapping(choiceMapping);
    XMLDirectMapping phoneMapping = new XMLDirectMapping();
    phoneMapping.setAttributeName("phone");
    phoneMapping.setXPath("phone/text()");
    descriptor.addMapping(phoneMapping);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLChoiceCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLChoiceCollectionMapping)

Example 2 with XMLChoiceCollectionMapping

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

the class EmployeeWithGroupingElementProject method getEmployeeDescriptor.

private XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Employee.class);
    descriptor.setDefaultRootElement("employee");
    XMLDirectMapping nameMapping = new XMLDirectMapping();
    nameMapping.setAttributeName("name");
    nameMapping.setXPath("name/text()");
    descriptor.addMapping(nameMapping);
    XMLChoiceCollectionMapping choiceMapping = new XMLChoiceCollectionMapping();
    choiceMapping.setAttributeName("choice");
    choiceMapping.addChoiceElement("choice/street/text()", String.class);
    choiceMapping.addChoiceElement("choice/address", Address.class);
    choiceMapping.addChoiceElement("choice/integer/text()", Integer.class);
    descriptor.addMapping(choiceMapping);
    XMLDirectMapping phoneMapping = new XMLDirectMapping();
    phoneMapping.setAttributeName("phone");
    phoneMapping.setXPath("phone/text()");
    descriptor.addMapping(phoneMapping);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLChoiceCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLChoiceCollectionMapping)

Example 3 with XMLChoiceCollectionMapping

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

the class EmployeeProject method getEmployeeDescriptor.

private XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Employee.class);
    descriptor.setDefaultRootElement("employee");
    XMLDirectMapping nameMapping = new XMLDirectMapping();
    nameMapping.setAttributeName("name");
    nameMapping.setXPath("name/text()");
    descriptor.addMapping(nameMapping);
    XMLChoiceCollectionMapping choiceMapping = new XMLChoiceCollectionMapping();
    choiceMapping.setAttributeName("choice");
    choiceMapping.addChoiceElement("street/text()", String.class);
    choiceMapping.addChoiceElement("address", Address.class);
    choiceMapping.addChoiceElement("integer/text()", Integer.class);
    choiceMapping.addChoiceElement("simpleAddress", Object.class);
    choiceMapping.setConverter(new WrapperConverter());
    descriptor.addMapping(choiceMapping);
    XMLDirectMapping phoneMapping = new XMLDirectMapping();
    phoneMapping.setAttributeName("phone");
    phoneMapping.setXPath("phone/text()");
    descriptor.addMapping(phoneMapping);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLChoiceCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLChoiceCollectionMapping)

Example 4 with XMLChoiceCollectionMapping

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

the class EmployeeProject method getEmployeeDescriptor.

private XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Employee.class);
    descriptor.setDefaultRootElement("employee");
    XMLDirectMapping nameMapping = new XMLDirectMapping();
    nameMapping.setAttributeName("name");
    nameMapping.setXPath("name/text()");
    descriptor.addMapping(nameMapping);
    XMLChoiceCollectionMapping choiceMapping = new XMLChoiceCollectionMapping();
    choiceMapping.setAttributeName("choice");
    choiceMapping.addChoiceElement("street/text()", String.class);
    choiceMapping.addChoiceElement("address", Address.class);
    choiceMapping.addChoiceElement("integer/text()", Integer.class);
    choiceMapping.addChoiceElement("simpleAddress", Object.class);
    descriptor.addMapping(choiceMapping);
    XMLDirectMapping phoneMapping = new XMLDirectMapping();
    phoneMapping.setAttributeName("phone");
    phoneMapping.setXPath("phone/text()");
    descriptor.addMapping(phoneMapping);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLChoiceCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLChoiceCollectionMapping)

Example 5 with XMLChoiceCollectionMapping

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

the class XMLChoiceWithReferenceOrderProject method getEmployeeDescriptor.

public XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor desc = new XMLDescriptor();
    desc.setJavaClass(Employee.class);
    XMLDirectMapping name = new XMLDirectMapping();
    name.setAttributeName("name");
    name.setXPath("name/text()");
    desc.addMapping(name);
    XMLChoiceCollectionMapping mapping = new XMLChoiceCollectionMapping();
    mapping.setAttributeName("contact");
    List<XMLField> sourceFields = new ArrayList<XMLField>();
    List<XMLField> targetFields = new ArrayList<XMLField>();
    mapping.addChoiceElement(sourceFields, Address.class, targetFields);
    sourceFields = new ArrayList<XMLField>();
    XMLField source = new XMLField("phone/@id");
    sourceFields.add(source);
    targetFields = new ArrayList<XMLField>();
    XMLField target = new XMLField("@id");
    targetFields.add(target);
    mapping.addChoiceElement(sourceFields, PhoneNumber.class, targetFields);
    source = new XMLField("address/address-id/text()");
    sourceFields.add(source);
    source = new XMLField("address/zip/text()");
    sourceFields.add(source);
    target = new XMLField("@id");
    targetFields.add(target);
    target = new XMLField("zip/text()");
    targetFields.add(target);
    mapping.addChoiceElement(sourceFields, Address.class, targetFields);
    sourceFields = new ArrayList<XMLField>();
    source = new XMLField("work-address/id/text()");
    sourceFields.add(source);
    source = new XMLField("work-address/zip/text()");
    sourceFields.add(source);
    desc.addMapping(mapping);
    return desc;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) ArrayList(java.util.ArrayList) XMLChoiceCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLChoiceCollectionMapping)

Aggregations

XMLChoiceCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLChoiceCollectionMapping)18 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)13 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)11 ArrayList (java.util.ArrayList)6 DatabaseMapping (org.eclipse.persistence.mappings.DatabaseMapping)6 XMLField (org.eclipse.persistence.oxm.XMLField)6 XMLChoiceObjectMapping (org.eclipse.persistence.oxm.mappings.XMLChoiceObjectMapping)6 XMLCompositeCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping)6 XMLCompositeObjectMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)5 XMLBinaryDataCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLBinaryDataCollectionMapping)4 XMLBinaryDataMapping (org.eclipse.persistence.oxm.mappings.XMLBinaryDataMapping)4 XMLCompositeDirectCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)4 XMLObjectReferenceMapping (org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping)4 QName (javax.xml.namespace.QName)3 XMLJavaTypeConverter (org.eclipse.persistence.internal.jaxb.XMLJavaTypeConverter)3 XMLAnyCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLAnyCollectionMapping)3 XMLAnyObjectMapping (org.eclipse.persistence.oxm.mappings.XMLAnyObjectMapping)3 XMLCollectionReferenceMapping (org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping)3 XMLMapping (org.eclipse.persistence.oxm.mappings.XMLMapping)3 XMLTransformationMapping (org.eclipse.persistence.oxm.mappings.XMLTransformationMapping)3