Search in sources :

Example 1 with ListContainerPolicy

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;
}
Also used : XMLField(org.eclipse.persistence.oxm.XMLField) XMLChoiceObjectMapping(org.eclipse.persistence.oxm.mappings.XMLChoiceObjectMapping) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) ListContainerPolicy(org.eclipse.persistence.internal.queries.ListContainerPolicy) ObjectTypeConverter(org.eclipse.persistence.mappings.converters.ObjectTypeConverter) XMLCompositeCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping) ArrayList(java.util.ArrayList)

Example 2 with ListContainerPolicy

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;
}
Also used : DescriptorException(org.eclipse.persistence.exceptions.DescriptorException) ListContainerPolicy(org.eclipse.persistence.internal.queries.ListContainerPolicy) ArrayList(java.util.ArrayList) XMLChoiceCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLChoiceCollectionMapping) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) Association(org.eclipse.persistence.mappings.Association) XMLCompositeCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping) AttributeAccessor(org.eclipse.persistence.mappings.AttributeAccessor) Vector(java.util.Vector)

Example 3 with ListContainerPolicy

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;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) ListContainerPolicy(org.eclipse.persistence.internal.queries.ListContainerPolicy) ObjectTypeConverter(org.eclipse.persistence.mappings.converters.ObjectTypeConverter) ArrayList(java.util.ArrayList) XMLChoiceCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLChoiceCollectionMapping)

Aggregations

ArrayList (java.util.ArrayList)3 ListContainerPolicy (org.eclipse.persistence.internal.queries.ListContainerPolicy)3 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)3 ObjectTypeConverter (org.eclipse.persistence.mappings.converters.ObjectTypeConverter)2 XMLChoiceCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLChoiceCollectionMapping)2 XMLCompositeCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping)2 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)2 Vector (java.util.Vector)1 DescriptorException (org.eclipse.persistence.exceptions.DescriptorException)1 Association (org.eclipse.persistence.mappings.Association)1 AttributeAccessor (org.eclipse.persistence.mappings.AttributeAccessor)1 XMLField (org.eclipse.persistence.oxm.XMLField)1 XMLChoiceObjectMapping (org.eclipse.persistence.oxm.mappings.XMLChoiceObjectMapping)1