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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations