use of org.eclipse.persistence.internal.queries.ListContainerPolicy in project eclipselink by eclipse-ee4j.
the class DBWSBuilderModelProject method buildSQLOperationModelDescriptor.
protected ClassDescriptor buildSQLOperationModelDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(SQLOperationModel.class);
descriptor.setDefaultRootElement("sql");
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("name");
nameMapping.setXPath("@name");
descriptor.addMapping(nameMapping);
ObjectTypeConverter converter = new ObjectTypeConverter();
converter.addConversionValue("true", Boolean.TRUE);
converter.addConversionValue("false", Boolean.FALSE);
converter.setFieldClassification(String.class);
XMLDirectMapping simpleXMLFormatTagMapping = new XMLDirectMapping();
simpleXMLFormatTagMapping.setAttributeName("simpleXMLFormatTag");
simpleXMLFormatTagMapping.setGetMethodName("getSimpleXMLFormatTag");
simpleXMLFormatTagMapping.setSetMethodName("setSimpleXMLFormatTag");
simpleXMLFormatTagMapping.setXPath("@simpleXMLFormatTag");
descriptor.addMapping(simpleXMLFormatTagMapping);
XMLDirectMapping xmlTagMapping = new XMLDirectMapping();
xmlTagMapping.setAttributeName("xmlTag");
xmlTagMapping.setGetMethodName("getXmlTag");
xmlTagMapping.setSetMethodName("setXmlTag");
xmlTagMapping.setXPath("@xmlTag");
descriptor.addMapping(xmlTagMapping);
XMLDirectMapping isCollectionMapping = new XMLDirectMapping();
isCollectionMapping.setAttributeName("isCollection");
isCollectionMapping.setConverter(converter);
isCollectionMapping.setNullValue(Boolean.FALSE);
isCollectionMapping.setXPath("@isCollection");
descriptor.addMapping(isCollectionMapping);
XMLDirectMapping binaryAttachment = new XMLDirectMapping();
binaryAttachment.setAttributeName("binaryAttachment");
binaryAttachment.setConverter(converter);
binaryAttachment.setNullValue(Boolean.FALSE);
binaryAttachment.setXPath("@binaryAttachment");
descriptor.addMapping(binaryAttachment);
XMLDirectMapping attachmentType = new XMLDirectMapping();
attachmentType.setAttributeName("attachmentType");
attachmentType.setXPath("@attachmentType");
descriptor.addMapping(attachmentType);
XMLDirectMapping returnTypeMapping = new XMLDirectMapping();
returnTypeMapping.setAttributeName("returnType");
returnTypeMapping.setXPath("@returnType");
descriptor.addMapping(returnTypeMapping);
// bug 322949
XMLChoiceObjectMapping statementMapping = new XMLChoiceObjectMapping();
statementMapping.setAttributeName("sql");
// support old element name 'text' and new name 'statement'
XMLField f1 = new XMLField("statement/text()");
f1.setIsCDATA(true);
statementMapping.addChoiceElement(f1, String.class);
XMLField f2 = new XMLField("text/text()");
f2.setIsCDATA(true);
statementMapping.addChoiceElement(f2, String.class);
descriptor.addMapping(statementMapping);
XMLDirectMapping buildStatementMapping = new XMLDirectMapping();
buildStatementMapping.setAttributeName("buildSql");
buildStatementMapping.setXPath("build-statement/text()");
buildStatementMapping.setIsCDATA(true);
descriptor.addMapping(buildStatementMapping);
XMLCompositeCollectionMapping bindingsMapping = new XMLCompositeCollectionMapping();
bindingsMapping.setAttributeName("bindings");
bindingsMapping.setReferenceClass(BindingModel.class);
bindingsMapping.setContainerPolicy(new ListContainerPolicy(ArrayList.class));
bindingsMapping.setXPath("binding");
descriptor.addMapping(bindingsMapping);
return descriptor;
}
use of org.eclipse.persistence.internal.queries.ListContainerPolicy 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;
}
use of org.eclipse.persistence.internal.queries.ListContainerPolicy in project eclipselink by eclipse-ee4j.
the class DBWSBuilderModelProject method buildTableOperationModelDescriptor.
protected ClassDescriptor buildTableOperationModelDescriptor() {
XMLDescriptor descriptor = new XMLDescriptor();
descriptor.setJavaClass(TableOperationModel.class);
XMLDirectMapping nameMapping = new XMLDirectMapping();
nameMapping.setAttributeName("name");
nameMapping.setXPath("@name");
descriptor.addMapping(nameMapping);
ObjectTypeConverter converter = new ObjectTypeConverter();
converter.addConversionValue("true", Boolean.TRUE);
converter.addConversionValue("false", Boolean.FALSE);
converter.setFieldClassification(String.class);
XMLDirectMapping simpleXMLFormatTagMapping = new XMLDirectMapping();
simpleXMLFormatTagMapping.setAttributeName("simpleXMLFormatTag");
simpleXMLFormatTagMapping.setGetMethodName("getSimpleXMLFormatTag");
simpleXMLFormatTagMapping.setSetMethodName("setSimpleXMLFormatTag");
simpleXMLFormatTagMapping.setXPath("@simpleXMLFormatTag");
descriptor.addMapping(simpleXMLFormatTagMapping);
XMLDirectMapping xmlTagMapping = new XMLDirectMapping();
xmlTagMapping.setAttributeName("xmlTag");
xmlTagMapping.setGetMethodName("getXmlTag");
xmlTagMapping.setSetMethodName("setXmlTag");
xmlTagMapping.setXPath("@xmlTag");
descriptor.addMapping(xmlTagMapping);
XMLDirectMapping isCollectionMapping = new XMLDirectMapping();
isCollectionMapping.setAttributeName("isCollection");
isCollectionMapping.setConverter(converter);
isCollectionMapping.setNullValue(Boolean.FALSE);
isCollectionMapping.setXPath("@isCollection");
descriptor.addMapping(isCollectionMapping);
XMLDirectMapping binaryAttachment = new XMLDirectMapping();
binaryAttachment.setAttributeName("binaryAttachment");
binaryAttachment.setConverter(converter);
binaryAttachment.setNullValue(Boolean.FALSE);
binaryAttachment.setXPath("@binaryAttachment");
descriptor.addMapping(binaryAttachment);
XMLDirectMapping attachmentType = new XMLDirectMapping();
attachmentType.setAttributeName("attachmentType");
attachmentType.setXPath("@attachmentType");
descriptor.addMapping(attachmentType);
XMLDirectMapping returnTypeMapping = new XMLDirectMapping();
returnTypeMapping.setAttributeName("returnType");
returnTypeMapping.setXPath("@returnType");
descriptor.addMapping(returnTypeMapping);
XMLDirectMapping catalogPatternMapping = new XMLDirectMapping();
catalogPatternMapping.setAttributeName("catalogPattern");
catalogPatternMapping.setXPath("@catalogPattern");
descriptor.addMapping(catalogPatternMapping);
XMLDirectMapping schemaPatternMapping = new XMLDirectMapping();
schemaPatternMapping.setAttributeName("schemaPattern");
schemaPatternMapping.setXPath("@schemaPattern");
descriptor.addMapping(schemaPatternMapping);
XMLDirectMapping tableNamePatternMapping = new XMLDirectMapping();
tableNamePatternMapping.setAttributeName("tablePattern");
tableNamePatternMapping.setXPath("@tableNamePattern");
descriptor.addMapping(tableNamePatternMapping);
XMLChoiceCollectionMapping additionalOperationsMapping = new XMLChoiceCollectionMapping();
additionalOperationsMapping.setAttributeName("additionalOperations");
additionalOperationsMapping.setContainerPolicy(new ListContainerPolicy(ArrayList.class));
additionalOperationsMapping.addChoiceElement("procedure", ProcedureOperationModel.class);
additionalOperationsMapping.addChoiceElement("plsql-procedure", PLSQLProcedureOperationModel.class);
additionalOperationsMapping.addChoiceElement("sql", SQLOperationModel.class);
additionalOperationsMapping.addChoiceElement("batch-sql", BatchSQLOperationModel.class);
descriptor.addMapping(additionalOperationsMapping);
return descriptor;
}
Aggregations