Search in sources :

Example 1 with XMLSchemaURLReference

use of org.eclipse.persistence.oxm.schema.XMLSchemaURLReference in project eclipselink by eclipse-ee4j.

the class EmployeeProject method getBadgeDescriptor.

private XMLDescriptor getBadgeDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setDefaultRootElement("badge-id");
    descriptor.setJavaClass(Badge.class);
    XMLDirectMapping numberMapping = new XMLDirectMapping();
    numberMapping.setAttributeName("number");
    numberMapping.setGetMethodName("getNumber");
    numberMapping.setSetMethodName("setNumber");
    numberMapping.setXPath("text()");
    descriptor.addMapping(numberMapping);
    URL schemaURL = ClassLoader.getSystemResource("org/eclipse/persistence/testing/jaxb/xmlmarshaller/Employee.xsd");
    XMLSchemaURLReference schemaRef = new XMLSchemaURLReference(schemaURL);
    schemaRef.setType(XMLSchemaReference.ELEMENT);
    schemaRef.setSchemaContext("/employee/badge-id");
    descriptor.setSchemaReference(schemaRef);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLSchemaURLReference(org.eclipse.persistence.oxm.schema.XMLSchemaURLReference) URL(java.net.URL)

Example 2 with XMLSchemaURLReference

use of org.eclipse.persistence.oxm.schema.XMLSchemaURLReference 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 idMapping = new XMLDirectMapping();
    idMapping.setAttributeName("id");
    idMapping.setGetMethodName("getID");
    idMapping.setSetMethodName("setID");
    idMapping.setXPath("id/text()");
    descriptor.addMapping(idMapping);
    XMLDirectMapping nameMapping = new XMLDirectMapping();
    nameMapping.setAttributeName("name");
    nameMapping.setGetMethodName("getName");
    nameMapping.setSetMethodName("setName");
    nameMapping.setXPath("name/text()");
    descriptor.addMapping(nameMapping);
    XMLCompositeObjectMapping homeAddressMapping = new XMLCompositeObjectMapping();
    homeAddressMapping.setReferenceClass(Address.class);
    homeAddressMapping.setAttributeName("home-address");
    homeAddressMapping.setGetMethodName("getHomeAddress");
    homeAddressMapping.setSetMethodName("setHomeAddress");
    homeAddressMapping.setXPath("home-address");
    descriptor.addMapping(homeAddressMapping);
    XMLCompositeObjectMapping workAddressMapping = new XMLCompositeObjectMapping();
    workAddressMapping.setReferenceClass(Address.class);
    workAddressMapping.setAttributeName("work-address");
    workAddressMapping.setGetMethodName("getWorkAddress");
    workAddressMapping.setSetMethodName("setWorkAddress");
    workAddressMapping.setXPath("work-address");
    descriptor.addMapping(workAddressMapping);
    XMLCompositeObjectMapping phoneMapping = new XMLCompositeObjectMapping();
    phoneMapping.setReferenceClass(Phone.class);
    phoneMapping.setAttributeName("phone");
    phoneMapping.setGetMethodName("getPhone");
    phoneMapping.setSetMethodName("setPhone");
    phoneMapping.setXPath("phone");
    descriptor.addMapping(phoneMapping);
    XMLCompositeObjectMapping badgeMapping = new XMLCompositeObjectMapping();
    badgeMapping.setReferenceClass(Badge.class);
    badgeMapping.setAttributeName("badge");
    badgeMapping.setGetMethodName("getBadge");
    badgeMapping.setSetMethodName("setBadge");
    badgeMapping.setXPath("badge-id");
    descriptor.addMapping(badgeMapping);
    XMLDirectMapping empCodeMapping = new XMLDirectMapping();
    empCodeMapping.setAttributeName("empCode");
    empCodeMapping.setGetMethodName("getEmpCode");
    empCodeMapping.setSetMethodName("setEmpCode");
    empCodeMapping.setXPath("@empCode");
    descriptor.addMapping(empCodeMapping);
    URL schemaURL = ClassLoader.getSystemResource("org/eclipse/persistence/testing/jaxb/xmlmarshaller/Employee.xsd");
    XMLSchemaURLReference schemaRef = new XMLSchemaURLReference(schemaURL);
    schemaRef.setType(XMLSchemaReference.ELEMENT);
    schemaRef.setSchemaContext("/employee");
    descriptor.setSchemaReference(schemaRef);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLSchemaURLReference(org.eclipse.persistence.oxm.schema.XMLSchemaURLReference) XMLCompositeObjectMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping) URL(java.net.URL)

Example 3 with XMLSchemaURLReference

use of org.eclipse.persistence.oxm.schema.XMLSchemaURLReference in project eclipselink by eclipse-ee4j.

the class EmployeeProject method getPhoneDescriptor.

private XMLDescriptor getPhoneDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Phone.class);
    XMLDirectMapping numberMapping = new XMLDirectMapping();
    numberMapping.setAttributeName("number");
    numberMapping.setGetMethodName("getNumber");
    numberMapping.setSetMethodName("setNumber");
    numberMapping.setXPath("text()");
    descriptor.addMapping(numberMapping);
    URL schemaURL = ClassLoader.getSystemResource("org/eclipse/persistence/testing/jaxb/xmlmarshaller/Employee.xsd");
    XMLSchemaURLReference schemaRef = new XMLSchemaURLReference(schemaURL);
    schemaRef.setType(XMLSchemaReference.SIMPLE_TYPE);
    schemaRef.setSchemaContext("/phone-type");
    descriptor.setSchemaReference(schemaRef);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLSchemaURLReference(org.eclipse.persistence.oxm.schema.XMLSchemaURLReference) URL(java.net.URL)

Example 4 with XMLSchemaURLReference

use of org.eclipse.persistence.oxm.schema.XMLSchemaURLReference in project eclipselink by eclipse-ee4j.

the class EmployeeProject method getJobDescriptor.

private XMLDescriptor getJobDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Job.class);
    descriptor.setDefaultRootElement("job");
    XMLDirectMapping titleMapping = new XMLDirectMapping();
    titleMapping.setAttributeName("title");
    titleMapping.setGetMethodName("getTitle");
    titleMapping.setSetMethodName("setTitle");
    titleMapping.setXPath("title/text()");
    descriptor.addMapping(titleMapping);
    URL schemaURL = ClassLoader.getSystemResource("org/eclipse/persistence/testing/jaxb/xmlmarshaller/Employee.xsd");
    XMLSchemaURLReference schemaRef = new XMLSchemaURLReference(schemaURL);
    schemaRef.setType(XMLSchemaReference.ELEMENT);
    schemaRef.setSchemaContext("/employee/job");
    descriptor.setSchemaReference(schemaRef);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) XMLSchemaURLReference(org.eclipse.persistence.oxm.schema.XMLSchemaURLReference) URL(java.net.URL)

Example 5 with XMLSchemaURLReference

use of org.eclipse.persistence.oxm.schema.XMLSchemaURLReference in project eclipselink by eclipse-ee4j.

the class OracleHelper method buildNewXMLDescriptor.

/**
 * Build an XMLDescriptor based on a given descriptor alias,
 * java class name schema alias, and target namespace.
 */
protected XMLDescriptor buildNewXMLDescriptor(String objectAlias, String javaClassName, String userType, String targetNamespace) {
    XMLDescriptor xdesc = new XMLDescriptor();
    xdesc.setAlias(objectAlias);
    xdesc.setJavaClassName(javaClassName);
    xdesc.getQueryManager();
    XMLSchemaURLReference schemaReference = new XMLSchemaURLReference();
    schemaReference.setSchemaContext(SLASH + userType);
    schemaReference.setType(org.eclipse.persistence.platform.xml.XMLSchemaReference.COMPLEX_TYPE);
    xdesc.setSchemaReference(schemaReference);
    NamespaceResolver nr = new NamespaceResolver();
    nr.setDefaultNamespaceURI(targetNamespace);
    xdesc.setNamespaceResolver(nr);
    xdesc.setDefaultRootElement(userType);
    return xdesc;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLSchemaURLReference(org.eclipse.persistence.oxm.schema.XMLSchemaURLReference) NamespaceResolver(org.eclipse.persistence.oxm.NamespaceResolver)

Aggregations

XMLSchemaURLReference (org.eclipse.persistence.oxm.schema.XMLSchemaURLReference)37 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)36 URL (java.net.URL)27 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)26 XMLCompositeObjectMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)14 XMLField (org.eclipse.persistence.oxm.XMLField)10 QName (javax.xml.namespace.QName)6 NamespaceResolver (org.eclipse.persistence.oxm.NamespaceResolver)6 XMLSchemaReference (org.eclipse.persistence.oxm.schema.XMLSchemaReference)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 StringReader (java.io.StringReader)2 SQLException (java.sql.SQLException)2 DBWSModel (org.eclipse.persistence.dbws.DBWSModel)2 DBWSModelProject (org.eclipse.persistence.dbws.DBWSModelProject)2 XRServiceFactory (org.eclipse.persistence.internal.xr.XRServiceFactory)2 DirectToFieldMapping (org.eclipse.persistence.mappings.DirectToFieldMapping)2 ObjectRelationalDataTypeDescriptor (org.eclipse.persistence.mappings.structures.ObjectRelationalDataTypeDescriptor)2 XMLContext (org.eclipse.persistence.oxm.XMLContext)2 XMLLogin (org.eclipse.persistence.oxm.XMLLogin)2 XMLUnmarshaller (org.eclipse.persistence.oxm.XMLUnmarshaller)2