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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations