use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class XMLRootComplexInheritanceProject method getPersonDescriptor.
private XMLDescriptor getPersonDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(Person.class);
// descriptor.setDefaultRootElement("oxm:pRoot");
XMLField classIndicatorField = new XMLField("@xsi:type");
descriptor.getInheritancePolicy().setClassIndicatorField(classIndicatorField);
descriptor.getInheritancePolicy().addClassIndicator(Employee.class, "oxm:emp");
descriptor.getInheritancePolicy().addClassIndicator(Person.class, "oxm:person");
descriptor.getInheritancePolicy().setShouldReadSubclasses(true);
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("name");
nameMapping.setGetMethodName("getName");
nameMapping.setSetMethodName("setName");
nameMapping.setXPath("name/text()");
descriptor.addMapping(nameMapping);
XMLSchemaClassPathReference schemaReference = new XMLSchemaClassPathReference();
schemaReference.setSchemaContext("/oxm:person");
schemaReference.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
descriptor.setSchemaReference(schemaReference);
namespaceResolver.put("oxm", "test");
descriptor.setNamespaceResolver(namespaceResolver);
return descriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class EclipseLinkObjectPersistenceRuntimeXMLProject method buildProjectDescriptor.
@Override
protected ClassDescriptor buildProjectDescriptor() {
XMLDescriptor descriptor = (XMLDescriptor) super.buildProjectDescriptor();
descriptor.setSchemaReference(new XMLSchemaClassPathReference(SCHEMA_DIR + ECLIPSELINK_SCHEMA));
XMLCompositeCollectionMapping projectQueriesMapping = new XMLCompositeCollectionMapping();
projectQueriesMapping.useCollectionClass(NonSynchronizedVector.class);
projectQueriesMapping.setAttributeName("queries");
projectQueriesMapping.setSetMethodName("setQueries");
projectQueriesMapping.setGetMethodName("getQueries");
projectQueriesMapping.setReferenceClass(DatabaseQuery.class);
projectQueriesMapping.setXPath(getSecondaryNamespaceXPath() + "queries/" + getSecondaryNamespaceXPath() + "query");
descriptor.addMapping(projectQueriesMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class TypeProject method getContactMethodDescriptor.
public XMLDescriptor getContactMethodDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(ContactMethod.class);
descriptor.setDefaultRootElement("contact-method");
descriptor.setDefaultRootElementType(new QName("http://www.example.com/toplink-oxm", "contact-method-type"));
descriptor.setNamespaceResolver(namespaceResolver);
XMLSchemaClassPathReference ref = new XMLSchemaClassPathReference();
ref.setSchemaContext("/oxm:contact-method-type");
ref.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
descriptor.setSchemaReference(ref);
XMLField classIndicatorField = new XMLField("@xsi:type");
descriptor.getInheritancePolicy().setClassIndicatorField(classIndicatorField);
descriptor.getInheritancePolicy().addClassIndicator(ContactMethod.class, "oxm:contact-method-type");
descriptor.getInheritancePolicy().addClassIndicator(Address.class, "address-type");
descriptor.getInheritancePolicy().addClassIndicator(CanadianAddress.class, "canadian-address-type");
descriptor.getInheritancePolicy().setShouldReadSubclasses(true);
XMLDirectMapping idMapping = new XMLDirectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("id/text()");
descriptor.addMapping(idMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class TypeProject method getCdnAddressDescriptor.
public XMLDescriptor getCdnAddressDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(CanadianAddress.class);
descriptor.setDefaultRootElement("contact-method");
descriptor.setDefaultRootElementType(new QName("http://www.example.com/toplink-oxm", "contact-method-type"));
descriptor.setNamespaceResolver(namespaceResolver);
descriptor.getInheritancePolicy().setParentClass(Address.class);
XMLSchemaClassPathReference ref = new XMLSchemaClassPathReference();
ref.setSchemaContext("/canadian-address-type");
ref.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
descriptor.setSchemaReference(ref);
XMLDirectMapping postalCodeMapping = new XMLDirectMapping();
postalCodeMapping.setAttributeName("postalCode");
postalCodeMapping.setXPath("postal-code/text()");
descriptor.addMapping(postalCodeMapping);
return descriptor;
}
use of org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference in project eclipselink by eclipse-ee4j.
the class AnyTypeProject method getContactMethodDescriptor.
public XMLDescriptor getContactMethodDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(ContactMethod.class);
descriptor.setDefaultRootElement("contact-method");
descriptor.setDefaultRootElementType(new QName("http://www.example.com/toplink-oxm", "contact-method-type"));
descriptor.setNamespaceResolver(namespaceResolver);
XMLSchemaClassPathReference ref = new XMLSchemaClassPathReference();
ref.setSchemaContext("/oxm:contact-method-type");
ref.setType(XMLSchemaClassPathReference.COMPLEX_TYPE);
descriptor.setSchemaReference(ref);
XMLField classIndicatorField = new XMLField("@xsi:type");
descriptor.getInheritancePolicy().setClassIndicatorField(classIndicatorField);
descriptor.getInheritancePolicy().addClassIndicator(ContactMethod.class, "oxm:contact-method-type");
descriptor.getInheritancePolicy().addClassIndicator(Address.class, "oxm:address-type");
descriptor.getInheritancePolicy().addClassIndicator(CanadianAddress.class, "oxm:canadian-address-type");
descriptor.getInheritancePolicy().setShouldReadSubclasses(true);
XMLDirectMapping idMapping = new XMLDirectMapping();
idMapping.setAttributeName("id");
idMapping.setXPath("id/text()");
descriptor.addMapping(idMapping);
return descriptor;
}
Aggregations