use of org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping in project eclipselink by eclipse-ee4j.
the class ChangeSummaryProject method getChild1Descriptor.
private XMLDescriptor getChild1Descriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Child1.class);
xmlDescriptor.addPrimaryKeyFieldName("@id");
NamespaceResolver namespaceResolver = new NamespaceResolver();
namespaceResolver.put("tns", "urn:changesummary");
xmlDescriptor.setNamespaceResolver(namespaceResolver);
XMLSchemaClassPathReference schemaReference = new XMLSchemaClassPathReference();
schemaReference.setSchemaContext("/tns:child1");
schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
xmlDescriptor.setSchemaReference(schemaReference);
XMLDirectMapping idMapping = new XMLDirectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("@id");
xmlDescriptor.addMapping(idMapping);
XMLCollectionReferenceMapping child2CollectionMapping = new XMLCollectionReferenceMapping();
child2CollectionMapping.setReferenceClass(Child2.class);
child2CollectionMapping.setAttributeName("child2Collection");
child2CollectionMapping.addSourceToTargetKeyFieldAssociation("tns:child2/text()", "@id");
xmlDescriptor.addMapping(child2CollectionMapping);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping in project eclipselink by eclipse-ee4j.
the class MappingsProject method getChild1Descriptor.
private XMLDescriptor getChild1Descriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Child1.class);
xmlDescriptor.addPrimaryKeyFieldName("@id");
NamespaceResolver namespaceResolver = new NamespaceResolver();
namespaceResolver.put("tns", "urn:mappings");
xmlDescriptor.setNamespaceResolver(namespaceResolver);
XMLSchemaClassPathReference schemaReference = new XMLSchemaClassPathReference();
schemaReference.setSchemaContext("/tns:child1");
schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
xmlDescriptor.setSchemaReference(schemaReference);
XMLDirectMapping idMapping = new XMLDirectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("@id");
xmlDescriptor.addMapping(idMapping);
XMLCollectionReferenceMapping child2CollectionMapping = new XMLCollectionReferenceMapping();
child2CollectionMapping.setReferenceClass(Child2.class);
child2CollectionMapping.setAttributeName("child2Collection");
child2CollectionMapping.addSourceToTargetKeyFieldAssociation("tns:child2/text()", "@id");
xmlDescriptor.addMapping(child2CollectionMapping);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping in project eclipselink by eclipse-ee4j.
the class CopyHelperProject method getChild1Descriptor.
private XMLDescriptor getChild1Descriptor() {
XMLDescriptor xmlDescriptor = new XMLDescriptor();
xmlDescriptor.setJavaClass(Child1.class);
xmlDescriptor.addPrimaryKeyFieldName("@id");
NamespaceResolver namespaceResolver = new NamespaceResolver();
namespaceResolver.put("tns", "urn:copy");
xmlDescriptor.setNamespaceResolver(namespaceResolver);
XMLSchemaClassPathReference schemaReference = new XMLSchemaClassPathReference();
schemaReference.setSchemaContext("/tns:child1");
schemaReference.setType(XMLSchemaReference.COMPLEX_TYPE);
xmlDescriptor.setSchemaReference(schemaReference);
XMLDirectMapping idMapping = new XMLDirectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("@id");
xmlDescriptor.addMapping(idMapping);
XMLObjectReferenceMapping child2Mapping = new XMLObjectReferenceMapping();
child2Mapping.setReferenceClass(Child2.class);
child2Mapping.setAttributeName("child2");
child2Mapping.addSourceToTargetKeyFieldAssociation("tns:child2/text()", "@id");
xmlDescriptor.addMapping(child2Mapping);
XMLCollectionReferenceMapping child2CollectionMapping = new XMLCollectionReferenceMapping();
child2CollectionMapping.setReferenceClass(Child2.class);
child2CollectionMapping.setAttributeName("child2Collection");
child2CollectionMapping.addSourceToTargetKeyFieldAssociation("tns:child2collection/text()", "@id");
xmlDescriptor.addMapping(child2CollectionMapping);
return xmlDescriptor;
}
use of org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping in project eclipselink by eclipse-ee4j.
the class TestModelProject method addRootDescriptor.
public void addRootDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClassName("org.persistence.testing.jaxb.dynamic.xxx.Root");
descriptor.setNamespaceResolver(nsResolver);
XMLCompositeObjectMapping compObj = new XMLCompositeObjectMapping();
compObj.setAttributeName("compObj");
compObj.setXPath("comp-obj");
compObj.setReferenceClassName("org.persistence.testing.jaxb.dynamic.xxx.CompositeObjectTarget");
descriptor.addMapping(compObj);
XMLCompositeCollectionMapping compColl = new XMLCompositeCollectionMapping();
compColl.setAttributeName("compColl");
compColl.setXPath("comp-coll/item");
compColl.setReferenceClassName("org.persistence.testing.jaxb.dynamic.xxx.CompositeCollectionTarget");
compColl.useCollectionClass(ArrayList.class);
compColl.setContainerPolicy(ContainerPolicy.buildPolicyFor(ArrayList.class));
descriptor.addMapping(compColl);
XMLCompositeDirectCollectionMapping compDirColl = new XMLCompositeDirectCollectionMapping();
compDirColl.setAttributeName("compDirColl");
compDirColl.setXPath("comp-dir-coll");
descriptor.addMapping(compDirColl);
XMLBinaryDataMapping binData = new XMLBinaryDataMapping();
binData.setAttributeName("binData");
XMLField binDataField = new XMLField("bin-data");
binDataField.setSchemaType(XMLConstants.BASE_64_BINARY_QNAME);
binData.setField(binDataField);
binData.setShouldInlineBinaryData(true);
descriptor.addMapping(binData);
XMLBinaryDataCollectionMapping binDataColl = new XMLBinaryDataCollectionMapping();
binDataColl.setAttributeName("binDataColl");
XMLField binDataCollField = new XMLField("bin-data-coll");
binDataCollField.setSchemaType(XMLConstants.BASE_64_BINARY_QNAME);
binDataColl.setField(binDataCollField);
binDataColl.setShouldInlineBinaryData(true);
descriptor.addMapping(binDataColl);
XMLAnyObjectMapping anyObj = new XMLAnyObjectMapping();
anyObj.setAttributeName("anyObj");
anyObj.setField(new XMLField("any-obj"));
descriptor.addMapping(anyObj);
XMLCompositeObjectMapping anyAtt = new XMLCompositeObjectMapping();
anyAtt.setAttributeName("anyAtt");
anyAtt.setXPath("any-att");
anyAtt.setReferenceClassName("org.persistence.testing.jaxb.dynamic.xxx.AnyAttributeTarget");
descriptor.addMapping(anyAtt);
XMLTransformationMapping transform = new XMLTransformationMapping();
transform.setAttributeName("transform");
transform.setAttributeTransformer(new AttributeTransformer());
transform.addFieldTransformer("transform/first-val/text()", new FirstFieldTransformer());
transform.addFieldTransformer("transform/second-val/text()", new SecondFieldTransformer());
descriptor.addMapping(transform);
XMLFragmentMapping frag = new XMLFragmentMapping();
frag.setAttributeName("frag");
frag.setXPath("frag");
descriptor.addMapping(frag);
XMLFragmentCollectionMapping fragColl = new XMLFragmentCollectionMapping();
fragColl.setAttributeName("fragColl");
fragColl.setXPath("frag-coll");
fragColl.useCollectionClass(ArrayList.class);
descriptor.addMapping(fragColl);
XMLObjectReferenceMapping objRef = new XMLObjectReferenceMapping();
objRef.setAttributeName("objRef");
objRef.setReferenceClassName("org.persistence.testing.jaxb.dynamic.xxx.ObjectReferenceTarget");
objRef.addSourceToTargetKeyFieldAssociation("obj-ref-id/text()", "@id");
descriptor.addMapping(objRef);
XMLCollectionReferenceMapping collRef = new XMLCollectionReferenceMapping();
collRef.setAttributeName("collRef");
collRef.setReferenceClassName("org.persistence.testing.jaxb.dynamic.xxx.CollectionReferenceTarget");
collRef.addSourceToTargetKeyFieldAssociation("coll-ref-id/text()", "@id");
descriptor.addMapping(collRef);
XMLChoiceObjectMapping choice = new XMLChoiceObjectMapping();
choice.setAttributeName("choice");
choice.addChoiceElement("choice-int/text()", Integer.class);
choice.addChoiceElement("choice-float/text()", Float.class);
descriptor.addMapping(choice);
XMLChoiceCollectionMapping choiceColl = new XMLChoiceCollectionMapping();
choiceColl.setAttributeName("choiceColl");
choiceColl.addChoiceElement("choice-coll-double/text()", Double.class);
choiceColl.addChoiceElement("choice-coll-string/text()", String.class);
choiceColl.addChoiceElement("choice-coll-boolean/text()", Boolean.class);
descriptor.addMapping(choiceColl);
this.addDescriptor(descriptor);
}
Aggregations