Search in sources :

Example 31 with ObjectTypeConverter

use of org.eclipse.persistence.mappings.converters.ObjectTypeConverter in project eclipselink by eclipse-ee4j.

the class DirectCollectionObjectTypeConverterProject method getEmployeeDescriptor.

private XMLDescriptor getEmployeeDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(Employee.class);
    descriptor.setDefaultRootElement("employee");
    XMLDirectMapping idMapping = new XMLDirectMapping();
    idMapping.setAttributeName("id");
    idMapping.setXPath("@id");
    descriptor.addMapping(idMapping);
    XMLCompositeDirectCollectionMapping responsibilitiesMapping = new XMLCompositeDirectCollectionMapping();
    responsibilitiesMapping.setAttributeName("responsibilities");
    ObjectTypeConverter objectTypeConverter = new ObjectTypeConverter(responsibilitiesMapping);
    objectTypeConverter.addConversionValue("A", "Cut the grass");
    objectTypeConverter.addConversionValue("B", "Wash the dishes");
    responsibilitiesMapping.setValueConverter(objectTypeConverter);
    responsibilitiesMapping.setXPath("responsibilities/list/responsibility/text()");
    descriptor.addMapping(responsibilitiesMapping);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) ObjectTypeConverter(org.eclipse.persistence.mappings.converters.ObjectTypeConverter) XMLCompositeDirectCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping)

Example 32 with ObjectTypeConverter

use of org.eclipse.persistence.mappings.converters.ObjectTypeConverter in project eclipselink by eclipse-ee4j.

the class PLSQLCallModelTestProject method buildPLSQLargumentDescriptor.

protected ClassDescriptor buildPLSQLargumentDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(PLSQLargument.class);
    descriptor.descriptorIsAggregate();
    XMLDirectMapping nameMapping = new XMLDirectMapping();
    nameMapping.setAttributeName("name");
    nameMapping.setXPath("name/text()");
    descriptor.addMapping(nameMapping);
    XMLDirectMapping indexMapping = new XMLDirectMapping();
    indexMapping.setAttributeName("index");
    indexMapping.setXPath("index/text()");
    indexMapping.setNullValue(-1);
    descriptor.addMapping(indexMapping);
    XMLDirectMapping directionMapping = new XMLDirectMapping();
    directionMapping.setAttributeName("direction");
    directionMapping.setXPath("direction/text()");
    ObjectTypeConverter directionConverter = new ObjectTypeConverter();
    directionConverter.addConversionValue("IN", IN);
    directionConverter.addConversionValue("INOUT", INOUT);
    directionConverter.addConversionValue("OUT", OUT);
    directionMapping.setConverter(directionConverter);
    directionMapping.setNullValue(IN);
    descriptor.addMapping(directionMapping);
    XMLDirectMapping lengthMapping = new XMLDirectMapping();
    lengthMapping.setAttributeName("length");
    lengthMapping.setXPath("length/text()");
    lengthMapping.setNullValue(255);
    descriptor.addMapping(lengthMapping);
    XMLDirectMapping precisionMapping = new XMLDirectMapping();
    precisionMapping.setAttributeName("precision");
    precisionMapping.setXPath("precision/text()");
    precisionMapping.setNullValue(MIN_VALUE);
    descriptor.addMapping(precisionMapping);
    XMLDirectMapping scaleMapping = new XMLDirectMapping();
    scaleMapping.setAttributeName("scale");
    scaleMapping.setXPath("scale/text()");
    scaleMapping.setNullValue(MIN_VALUE);
    descriptor.addMapping(scaleMapping);
    XMLDirectMapping cursorOutputMapping = new XMLDirectMapping();
    cursorOutputMapping.setAttributeName("cursorOutput");
    cursorOutputMapping.setXPath("@cursorOutput");
    cursorOutputMapping.setNullValue(Boolean.FALSE);
    descriptor.addMapping(cursorOutputMapping);
    XMLCompositeObjectMapping databaseTypeMapping = new XMLCompositeObjectMapping();
    databaseTypeMapping.setAttributeName("databaseTypeWrapper");
    databaseTypeMapping.setReferenceClass(DatabaseTypeWrapper.class);
    databaseTypeMapping.setXPath(".");
    descriptor.addMapping(databaseTypeMapping);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) ObjectTypeConverter(org.eclipse.persistence.mappings.converters.ObjectTypeConverter) XMLCompositeObjectMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)

Example 33 with ObjectTypeConverter

use of org.eclipse.persistence.mappings.converters.ObjectTypeConverter in project eclipselink by eclipse-ee4j.

the class DBWSBuilderModelProject method buildProcedureOperationModelDescriptor.

protected ClassDescriptor buildProcedureOperationModelDescriptor() {
    XMLDescriptor descriptor = new XMLDescriptor();
    descriptor.setJavaClass(ProcedureOperationModel.class);
    descriptor.setDefaultRootElement("procedure");
    XMLDirectMapping nameMapping = new XMLDirectMapping();
    nameMapping.setAttributeName("name");
    nameMapping.setXPath("@name");
    descriptor.addMapping(nameMapping);
    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);
    ObjectTypeConverter converter = new ObjectTypeConverter();
    converter.addConversionValue("true", Boolean.TRUE);
    converter.addConversionValue("false", Boolean.FALSE);
    converter.setFieldClassification(String.class);
    XMLDirectMapping isCollectionMapping = new XMLDirectMapping();
    isCollectionMapping.setAttributeName("isCollection");
    isCollectionMapping.setConverter(converter);
    isCollectionMapping.setNullValue(Boolean.FALSE);
    isCollectionMapping.setXPath("@isCollection");
    descriptor.addMapping(isCollectionMapping);
    XMLDirectMapping isSimpleXMLFormatMapping = new XMLDirectMapping();
    isSimpleXMLFormatMapping.setAttributeName("isSimpleXMLFormat");
    isSimpleXMLFormatMapping.setConverter(converter);
    isSimpleXMLFormatMapping.setNullValue(Boolean.FALSE);
    isSimpleXMLFormatMapping.setXPath("@isSimpleXMLFormat");
    descriptor.addMapping(isSimpleXMLFormatMapping);
    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 procedurePatternMapping = new XMLDirectMapping();
    procedurePatternMapping.setAttributeName("procedurePattern");
    procedurePatternMapping.setXPath("@procedurePattern");
    descriptor.addMapping(procedurePatternMapping);
    XMLDirectMapping isAdvancedJDBCMapping = new XMLDirectMapping();
    isAdvancedJDBCMapping.setAttributeName("isAdvancedJDBC");
    isAdvancedJDBCMapping.setConverter(converter);
    isAdvancedJDBCMapping.setNullValue(Boolean.FALSE);
    isAdvancedJDBCMapping.setXPath("@isAdvancedJDBC");
    descriptor.addMapping(isAdvancedJDBCMapping);
    XMLDirectMapping buildStatementMapping = new XMLDirectMapping();
    buildStatementMapping.setAttributeName("buildSql");
    buildStatementMapping.setXPath("build-statement/text()");
    buildStatementMapping.setIsCDATA(true);
    descriptor.addMapping(buildStatementMapping);
    return descriptor;
}
Also used : XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) XMLDirectMapping(org.eclipse.persistence.oxm.mappings.XMLDirectMapping) ObjectTypeConverter(org.eclipse.persistence.mappings.converters.ObjectTypeConverter)

Example 34 with ObjectTypeConverter

use of org.eclipse.persistence.mappings.converters.ObjectTypeConverter 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 35 with ObjectTypeConverter

use of org.eclipse.persistence.mappings.converters.ObjectTypeConverter 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

ObjectTypeConverter (org.eclipse.persistence.mappings.converters.ObjectTypeConverter)35 XMLDirectMapping (org.eclipse.persistence.oxm.mappings.XMLDirectMapping)26 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)25 XMLCompositeObjectMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeObjectMapping)10 DirectToFieldMapping (org.eclipse.persistence.mappings.DirectToFieldMapping)8 RelationalDescriptor (org.eclipse.persistence.descriptors.RelationalDescriptor)6 XMLField (org.eclipse.persistence.oxm.XMLField)5 XMLCompositeCollectionMapping (org.eclipse.persistence.oxm.mappings.XMLCompositeCollectionMapping)5 ArrayList (java.util.ArrayList)4 ClassDescriptor (org.eclipse.persistence.descriptors.ClassDescriptor)4 AttributeAccessor (org.eclipse.persistence.mappings.AttributeAccessor)4 OneToOneMapping (org.eclipse.persistence.mappings.OneToOneMapping)4 HashMap (java.util.HashMap)2 Iterator (java.util.Iterator)2 List (java.util.List)2 Map (java.util.Map)2 Vector (java.util.Vector)2 VersionLockingPolicy (org.eclipse.persistence.descriptors.VersionLockingPolicy)2 CacheIdentityMap (org.eclipse.persistence.internal.identitymaps.CacheIdentityMap)2 FullIdentityMap (org.eclipse.persistence.internal.identitymaps.FullIdentityMap)2