Search in sources :

Example 31 with XMLSchemaClassPathReference

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;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)

Example 32 with XMLSchemaClassPathReference

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;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLCompositeCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)

Example 33 with XMLSchemaClassPathReference

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;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) QName(javax.xml.namespace.QName) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)

Example 34 with XMLSchemaClassPathReference

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;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) QName(javax.xml.namespace.QName) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)

Example 35 with XMLSchemaClassPathReference

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;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) QName(javax.xml.namespace.QName) XMLSchemaClassPathReference(org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)

Aggregations

XMLSchemaClassPathReference (org.eclipse.persistence.oxm.schema.XMLSchemaClassPathReference)71 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)69 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)52 NamespaceResolver (org.eclipse.persistence.oxm.NamespaceResolver)36 QName (javax.xml.namespace.QName)13 XMLCompositeCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping)9 XMLCompositeObjectMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)9 XMLField (org.eclipse.persistence.oxm.XMLField)8 XMLObjectReferenceMapping (org.eclipse.persistence.oxm.mappings.XMLObjectReferenceMapping)6 XMLSchemaReference (org.eclipse.persistence.oxm.schema.XMLSchemaReference)5 XMLCollectionReferenceMapping (org.eclipse.persistence.oxm.mappings.XMLCollectionReferenceMapping)4 XMLCompositeDirectCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)2 XmlValue (jakarta.xml.bind.annotation.XmlValue)1 XMLAnyCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLAnyCollectionMapping)1 XMLTransformationMapping (org.eclipse.persistence.oxm.mappings.XMLTransformationMapping)1