use of org.eclipse.persistence.exceptions.DescriptorException in project eclipselink by eclipse-ee4j.
the class DBWSBuilderModelProject method buildDBWSBuilderModelDescriptor.
protected ClassDescriptor buildDBWSBuilderModelDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(DBWSBuilderModel.class);
descriptor.setDefaultRootElement("dbws-builder");
XMLCompositeCollectionMapping propertiesMapping = new XMLCompositeCollectionMapping();
propertiesMapping.setReferenceClass(Association.class);
propertiesMapping.setAttributeAccessor(new AttributeAccessor() {
@Override
public String getAttributeName() {
return "properties";
}
@Override
public Object getAttributeValueFromObject(Object object) throws DescriptorException {
DBWSBuilderModel model = (DBWSBuilderModel) object;
Vector<Association> associations = new Vector<Association>();
for (Map.Entry<String, String> me : model.properties.entrySet()) {
associations.add(new Association(me.getKey(), me.getValue()));
}
return associations;
}
@Override
public void setAttributeValueInObject(Object object, Object value) throws DescriptorException {
DBWSBuilderModel model = (DBWSBuilderModel) object;
Vector<Association> associations = (Vector<Association>) value;
for (Association a : associations) {
model.properties.put((String) a.getKey(), (String) a.getValue());
}
}
});
propertiesMapping.setXPath("properties/property");
descriptor.addMapping(propertiesMapping);
XMLChoiceCollectionMapping operationsMapping = new XMLChoiceCollectionMapping();
operationsMapping.setAttributeName("operations");
operationsMapping.setContainerPolicy(new ListContainerPolicy(ArrayList.class));
operationsMapping.addChoiceElement("table", TableOperationModel.class);
operationsMapping.addChoiceElement("procedure", ProcedureOperationModel.class);
operationsMapping.addChoiceElement("plsql-procedure", PLSQLProcedureOperationModel.class);
operationsMapping.addChoiceElement("sql", SQLOperationModel.class);
operationsMapping.addChoiceElement("batch-sql", BatchSQLOperationModel.class);
descriptor.addMapping(operationsMapping);
return descriptor;
}
Aggregations