use of org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping in project eclipselink by eclipse-ee4j.
the class RequiredTestProject method getRequiredTestObjectDescriptor.
private XMLDescriptor getRequiredTestObjectDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(RequiredTestObject.class);
descriptor.setAlias("RequiredTestObject");
descriptor.setDefaultRootElement("required-test-object");
XMLDirectMapping directMapping = new XMLDirectMapping();
directMapping.setAttributeName("direct");
directMapping.setXPath("direct/text()");
((XMLField) directMapping.getField()).setRequired(shouldSetMappingsToRequired);
descriptor.addMapping(directMapping);
XMLDirectMapping directAttributeMapping = new XMLDirectMapping();
directAttributeMapping.setAttributeName("directAttribute");
directAttributeMapping.setXPath("@directAttribute");
((XMLField) directAttributeMapping.getField()).setRequired(shouldSetMappingsToRequired);
descriptor.addMapping(directAttributeMapping);
XMLCompositeDirectCollectionMapping directCollectionMapping = new XMLCompositeDirectCollectionMapping();
directCollectionMapping.setAttributeName("directCollection");
directCollectionMapping.setXPath("directCollection/text()");
((XMLField) directCollectionMapping.getField()).setRequired(shouldSetMappingsToRequired);
descriptor.addMapping(directCollectionMapping);
XMLCompositeObjectMapping compositeObjectMapping = new XMLCompositeObjectMapping();
compositeObjectMapping.setAttributeName("compositeObject");
compositeObjectMapping.setXPath("compositeObject/text()");
compositeObjectMapping.setReferenceClass(RequiredTestSubObject.class);
((XMLField) compositeObjectMapping.getField()).setRequired(shouldSetMappingsToRequired);
descriptor.addMapping(compositeObjectMapping);
XMLCompositeCollectionMapping compositeCollectionMapping = new XMLCompositeCollectionMapping();
compositeCollectionMapping.setAttributeName("compositeCollection");
compositeCollectionMapping.setXPath("compositeCollection/text()");
compositeCollectionMapping.setReferenceClass(RequiredTestSubObject.class);
((XMLField) compositeCollectionMapping.getField()).setRequired(shouldSetMappingsToRequired);
descriptor.addMapping(compositeCollectionMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping in project eclipselink by eclipse-ee4j.
the class XMLRootSimpleCollectionProject method getRootDescriptor.
private XMLDescriptor getRootDescriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(RootObjectWithSimpleCollection.class);
xmlDescriptor.setDefaultRootElement("ns0:myRoot");
NamespaceResolver nsResolver = new NamespaceResolver();
nsResolver.put("ns0", "mynamespace");
xmlDescriptor.setNamespaceResolver(nsResolver);
XMLCompositeDirectCollectionMapping theMapping = new XMLCompositeDirectCollectionMapping();
theMapping.setAttributeName("theList");
theMapping.setXPath("text()");
theMapping.setFieldElementClass(Integer.class);
theMapping.setUsesSingleNode(true);
xmlDescriptor.addMapping(theMapping);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping in project eclipselink by eclipse-ee4j.
the class DBWSModelProject method buildBatchQueryDescriptor.
/**
* Build an XMLDescriptor for BatchQueryOperation.
*/
protected XMLDescriptor buildBatchQueryDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(BatchQueryOperation.class);
descriptor.setDefaultRootElement("batch-sql-query");
XMLDirectMapping name = new XMLDirectMapping();
name.setAttributeName("name");
name.setXPath("name/text()");
descriptor.addMapping(name);
XMLCompositeDirectCollectionMapping statementsMapping = new XMLCompositeDirectCollectionMapping();
statementsMapping.setAttributeName("batchSql");
XMLField f1 = new XMLField("batch-statement/text()");
f1.setIsCDATA(true);
statementsMapping.setField(f1);
descriptor.addMapping(statementsMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping in project eclipselink by eclipse-ee4j.
the class TestProject method getEmployeeDescriptor.
private XMLDescriptor getEmployeeDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Employee.class);
descriptor.setAlias("Employee");
descriptor.addPrimaryKeyFieldName("name/text()");
descriptor.setNamespaceResolver(nsr);
if (setSchemaContext) {
XMLSchemaReference sRef = new XMLSchemaURLReference();
sRef.setSchemaContext("/employee-type");
sRef.setType(XMLSchemaReference.COMPLEX_TYPE);
descriptor.setSchemaReference(sRef);
}
if (setDefaultRootElement) {
descriptor.setDefaultRootElement("employee");
}
// create name mapping
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("name");
nameMapping.setXPath("name/text()");
descriptor.addMapping(nameMapping);
// create address mapping
XMLCompositeObjectMapping addressMapping = new XMLCompositeObjectMapping();
addressMapping.setAttributeName("address");
addressMapping.setXPath("address");
addressMapping.setReferenceClass(Address.class);
descriptor.addMapping(addressMapping);
// create phoneNumbers mapping
XMLCompositeCollectionMapping phonesMapping = new XMLCompositeCollectionMapping();
phonesMapping.setAttributeName("phoneNumbers");
phonesMapping.useCollectionClass(ArrayList.class);
phonesMapping.setXPath("phone-numbers");
phonesMapping.setReferenceClass(PhoneNumber.class);
descriptor.addMapping(phonesMapping);
// create projectIDs mapping
XMLCompositeDirectCollectionMapping projectIdsMapping = new XMLCompositeDirectCollectionMapping();
projectIdsMapping.setAttributeName("projectIDs");
projectIdsMapping.useCollectionClass(ArrayList.class);
projectIdsMapping.setXPath("project-id");
TypeConversionConverter tcc = new TypeConversionConverter(projectIdsMapping);
tcc.setObjectClass(BigDecimal.class);
projectIdsMapping.setValueConverter(tcc);
descriptor.addMapping(projectIdsMapping);
// create stuff mapping
XMLAnyCollectionMapping acMapping = new XMLAnyCollectionMapping();
acMapping.setAttributeName("stuff");
descriptor.addMapping(acMapping);
// Enable Choice testing when Bug 269880 has been fixed
// create choice mapping - choice
XMLChoiceObjectMapping choiceMapping = new XMLChoiceObjectMapping();
choiceMapping.setAttributeName("choice");
choiceMapping.addChoiceElement("nickname/text()", String.class);
choiceMapping.addChoiceElement("secondAddress", Address.class);
choiceMapping.addChoiceElement("age/text()", Integer.class);
// descriptor.addMapping(choiceMapping);
// Enable ChoiceCollection testing when Bug 269880 has been fixed
// create choices mapping
XMLChoiceCollectionMapping choiceCMapping = new XMLChoiceCollectionMapping();
choiceCMapping.setAttributeName("choices");
choiceCMapping.addChoiceElement("badgeId/text()", Integer.class);
choiceCMapping.addChoiceElement("alternateAddress", Address.class);
choiceCMapping.addChoiceElement("codename/text()", String.class);
// descriptor.addMapping(choiceCMapping);
// create billingAddress mapping
XMLObjectReferenceMapping orMapping = new XMLObjectReferenceMapping();
orMapping.setAttributeName("billingAddress");
orMapping.setReferenceClass(Address.class);
orMapping.addSourceToTargetKeyFieldAssociation("@bill-address-id", "@aid");
orMapping.addSourceToTargetKeyFieldAssociation("bill-address-city/text()", "city/text()");
descriptor.addMapping(orMapping);
// create data mapping
XMLBinaryDataMapping dataMapping = new XMLBinaryDataMapping();
dataMapping.setAttributeName("data");
XMLField field = new XMLField("data");
field.setSchemaType(XMLConstants.BASE_64_BINARY_QNAME);
dataMapping.setField(field);
dataMapping.setShouldInlineBinaryData(false);
dataMapping.setSwaRef(true);
dataMapping.setMimeType("application/binary");
descriptor.addMapping(dataMapping);
// create bytes mapping
XMLBinaryDataCollectionMapping bytesMapping = new XMLBinaryDataCollectionMapping();
bytesMapping.setAttributeName("bytes");
XMLField theField = new XMLField("bytes");
theField.setSchemaType(XMLConstants.BASE_64_BINARY_QNAME);
bytesMapping.setField(theField);
bytesMapping.setShouldInlineBinaryData(false);
bytesMapping.setSwaRef(false);
bytesMapping.setMimeType("text/plain");
descriptor.addMapping(bytesMapping);
// create URL mapping
XMLDirectMapping urlMapping = new XMLDirectMapping();
urlMapping.setAttributeName("aUrl");
urlMapping.setXPath("aUrl/text()");
descriptor.addMapping(urlMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping in project eclipselink by eclipse-ee4j.
the class TwoDirectCollectionMappingProject method addEmployeeDescriptor.
public void addEmployeeDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setDefaultRootElement("employee");
descriptor.setJavaClass(Employee.class);
XMLCompositeDirectCollectionMapping responsibilities = new XMLCompositeDirectCollectionMapping();
responsibilities.setAttributeName("primaryResponsibilities");
responsibilities.setXPath("primary-responsibilities/responsibility/text()");
responsibilities.getContainerPolicy().setContainerClass(Vector.class);
responsibilities.readOnly();
descriptor.addMapping(responsibilities);
XMLCompositeDirectCollectionMapping responsibilities2 = new XMLCompositeDirectCollectionMapping();
responsibilities2.setAttributeName("primaryResponsibilities2");
responsibilities2.setXPath("primary-responsibilities/responsibility/text()");
responsibilities2.getContainerPolicy().setContainerClass(Vector.class);
descriptor.addMapping(responsibilities2);
this.addDescriptor(descriptor);
}
Aggregations