Search in sources :

Example 11 with FieldType

use of org.eclipse.persistence.tools.oracleddl.metadata.FieldType in project eclipselink by eclipse-ee4j.

the class XmlEntityMappingsGenerator method processPLSQLRecordType.

/**
 * Process the given PLSQLRecordType and return a PLSQLRecordMetadata instance.
 */
protected static ComplexTypeMetadata processPLSQLRecordType(PLSQLRecordType plsqlRecordType) {
    // for %ROWTYPE we create a 'place holder' PL/SQL Record - in this case there is no package name
    String packageName = plsqlRecordType.getParentType().getPackageName();
    String typeName = packageName != null ? plsqlRecordType.getParentType().getPackageName() + DOT + plsqlRecordType.getTypeName() : plsqlRecordType.getTypeName();
    String compatiableName = packageName != null ? plsqlRecordType.getParentType().getPackageName() + UNDERSCORE + plsqlRecordType.getTypeName() : plsqlRecordType.getTypeName();
    if (compatiableName.contains(PERCENT)) {
        compatiableName = compatiableName.replace(PERCENT, UNDERSCORE);
    }
    PLSQLRecordMetadata plsqlRecordMetadata = new PLSQLRecordMetadata();
    plsqlRecordMetadata.setName(typeName);
    plsqlRecordMetadata.setCompatibleType(compatiableName);
    if (typeName.endsWith(ROWTYPE_STR)) {
        plsqlRecordMetadata.setJavaType(compatiableName.toLowerCase());
    } else {
        plsqlRecordMetadata.setJavaType(typeName.toLowerCase());
    }
    List<PLSQLParameterMetadata> fields = new ArrayList<PLSQLParameterMetadata>();
    PLSQLParameterMetadata field;
    for (FieldType fld : plsqlRecordType.getFields()) {
        field = new PLSQLParameterMetadata();
        field.setName(fld.getFieldName());
        String pkg = null;
        if (fld.getEnclosedType() != null && fld.getEnclosedType().isPLSQLType()) {
            PLSQLType pType = (PLSQLType) fld.getEnclosedType();
            pkg = pType.getParentType().getPackageName();
        }
        String dbType = fld.getTypeName();
        if (!(getJDBCTypeFromTypeName(dbType) == Types.OTHER)) {
            // OR Metadata doesn't handle VARCHAR2
            if (dbType.equals(VARCHAR2_STR)) {
                dbType = VARCHAR_STR;
            }
            if (!dbType.equals(BOOLEAN_STR)) {
                dbType = dbType.concat(_TYPE_STR);
            }
        }
        dbType = pkg == null ? dbType : pkg + DOT + dbType;
        field.setDatabaseType(dbType);
        fields.add(field);
    }
    plsqlRecordMetadata.setFields(fields);
    return plsqlRecordMetadata;
}
Also used : ArrayList(java.util.ArrayList) PLSQLRecordMetadata(org.eclipse.persistence.internal.jpa.metadata.queries.PLSQLRecordMetadata) PLSQLType(org.eclipse.persistence.tools.oracleddl.metadata.PLSQLType) PLSQLParameterMetadata(org.eclipse.persistence.internal.jpa.metadata.queries.PLSQLParameterMetadata) FieldType(org.eclipse.persistence.tools.oracleddl.metadata.FieldType)

Example 12 with FieldType

use of org.eclipse.persistence.tools.oracleddl.metadata.FieldType in project eclipselink by eclipse-ee4j.

the class OracleHelper method addToOXProjectForObjectTypeArg.

/**
 * Build descriptor and mappings for an Object type argument.  The
 * newly created descriptor will be added to the given OX project.
 */
protected void addToOXProjectForObjectTypeArg(DatabaseType dbType, Project oxProject, String objectName, String objectAlias) {
    XMLDescriptor xdesc = (XMLDescriptor) oxProject.getDescriptorForAlias(objectAlias);
    if (xdesc == null) {
        xdesc = buildAndAddNewXMLDescriptor(oxProject, objectAlias, objectName, nct.generateSchemaAlias(dbType.getTypeName()), buildCustomQName(objectName, dbwsBuilder).getNamespaceURI());
    }
    ObjectType oType = (ObjectType) dbType;
    for (FieldType field : oType.getFields()) {
        // custom transformer may exclude some fields
        if (nct.styleForElement(field.getFieldName()) == ElementStyle.NONE) {
            continue;
        }
        String lFieldName = field.getFieldName().toLowerCase();
        if (xdesc.getMappingForAttributeName(lFieldName) == null) {
            if (field.isComposite()) {
                String targetTypeName2 = field.getEnclosedType().getTypeName();
                String alias = getGeneratedAlias(targetTypeName2);
                XMLDescriptor xdesc2 = (XMLDescriptor) oxProject.getDescriptorForAlias(alias);
                boolean buildDescriptor = xdesc2 == null;
                if (buildDescriptor) {
                    xdesc2 = buildAndAddNewXMLDescriptor(oxProject, alias, nct.generateSchemaAlias(targetTypeName2), buildCustomQName(targetTypeName2, dbwsBuilder).getNamespaceURI());
                }
                // handle ObjectType field
                if (field.getEnclosedType().isObjectType()) {
                    if (buildDescriptor) {
                        // need to update the java class name on the descriptor to include package (project) name
                        xdesc2.setJavaClassName(getGeneratedJavaClassName(alias, dbwsBuilder.getProjectName()));
                        addToOXProjectForObjectTypeArg(field.getEnclosedType(), oxProject, xdesc2.getJavaClassName(), alias);
                    }
                    buildAndAddXMLCompositeObjectMapping(xdesc, lFieldName, xdesc2.getJavaClassName());
                } else if (field.getEnclosedType().isVArrayType()) {
                    // handle VArray field
                    if (buildDescriptor) {
                        // need to update the java class name on the descriptor to include package (project) name
                        xdesc2.setJavaClassName(getGeneratedJavaClassName(alias, dbwsBuilder.getProjectName()));
                        addToOXProjectForVArrayArg(field.getEnclosedType(), oxProject, xdesc2.getJavaClassName(), alias);
                    }
                    buildAndAddXMLCompositeDirectCollectionMapping(xdesc, lFieldName, lFieldName + SLASH + TEXT, getAttributeClassForDatabaseType(field.getEnclosedType()));
                } else if (field.getEnclosedType().isObjectTableType()) {
                    // handle ObjectTableType field
                    if (buildDescriptor) {
                        // need to update the java class name on the descriptor to include package (project) name
                        xdesc2.setJavaClassName(getGeneratedJavaClassName(alias, dbwsBuilder.getProjectName()));
                        // make sure the descriptor is built for the enclosed ObjectType
                        addToOXProjectForObjectTableTypeArg(field.getEnclosedType(), oxProject, targetTypeName2, alias);
                    }
                    ObjectTableType tableType = (ObjectTableType) field.getEnclosedType();
                    if (tableType.getEnclosedType().isComposite()) {
                        String nestedTypeAlias = getGeneratedAlias(((ObjectTableType) field.getEnclosedType()).getEnclosedType().getTypeName());
                        String nestedTypeName = getGeneratedJavaClassName(nestedTypeAlias, dbwsBuilder.getProjectName());
                        buildAndAddXMLCompositeCollectionMapping(xdesc, lFieldName, lFieldName + SLASH + ITEM_MAPPING_NAME, nestedTypeName);
                    } else {
                        buildAndAddXMLCompositeDirectCollectionMapping(xdesc, lFieldName, lFieldName + SLASH + TEXT, getAttributeClassForDatabaseType(tableType));
                    }
                }
            } else {
                // direct mapping
                addDirectMappingForFieldType(xdesc, lFieldName, field);
            }
        }
    }
}
Also used : ObjectType(org.eclipse.persistence.tools.oracleddl.metadata.ObjectType) OracleObjectType(org.eclipse.persistence.platform.database.oracle.jdbc.OracleObjectType) ObjectTableType(org.eclipse.persistence.tools.oracleddl.metadata.ObjectTableType) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) Util.qNameFromString(org.eclipse.persistence.tools.dbws.Util.qNameFromString) FieldType(org.eclipse.persistence.tools.oracleddl.metadata.FieldType)

Example 13 with FieldType

use of org.eclipse.persistence.tools.oracleddl.metadata.FieldType in project eclipselink by eclipse-ee4j.

the class OracleHelper method addToORProjectForPLSQLRecordArg.

/**
 * Build descriptor and mappings for a PL/SQL record argument.  The newly
 * created descriptor will be added to the given OR project.
 */
@SuppressWarnings("rawtypes")
protected void addToORProjectForPLSQLRecordArg(DatabaseType dbType, Project orProject, String recordName, String recordAlias, String targetTypeName, String catalogPattern) {
    ObjectRelationalDataTypeDescriptor ordtDesc = (ObjectRelationalDataTypeDescriptor) orProject.getDescriptorForAlias(recordAlias);
    if (ordtDesc == null) {
        ordtDesc = buildAndAddNewObjectRelationalDataTypeDescriptor(orProject, recordAlias, recordName.toLowerCase());
    }
    // handle fields
    PLSQLRecordType plsqlRecType = (PLSQLRecordType) dbType;
    for (FieldType fType : plsqlRecType.getFields()) {
        String fieldName = fType.getFieldName();
        String lFieldName = fieldName.toLowerCase();
        // handle field ordering
        boolean found = false;
        Vector orderedFields = ordtDesc.getOrderedFields();
        for (Iterator i = orderedFields.iterator(); i.hasNext(); ) {
            Object o = i.next();
            if (o instanceof DatabaseField) {
                DatabaseField field = (DatabaseField) o;
                if (field.getName().equalsIgnoreCase(fieldName)) {
                    found = true;
                    break;
                }
            }
        }
        if (!found) {
            ordtDesc.addFieldOrdering(fieldName);
        }
        if (ordtDesc.getMappingForAttributeName(lFieldName) == null) {
            if (fType.isComposite()) {
                if (fType.getEnclosedType().isPLSQLRecordType()) {
                    buildAndAddStructureMapping(ordtDesc, lFieldName, fieldName, recordName.toLowerCase());
                } else if (fType.getEnclosedType().isPLSQLCollectionType()) {
                    PLSQLCollectionType tableType = (PLSQLCollectionType) fType.getEnclosedType();
                    if (tableType.getEnclosedType().isComposite()) {
                        buildAndAddObjectArrayMapping(ordtDesc, lFieldName, fieldName, (catalogPattern + "." + tableType.getTypeName()).toLowerCase() + COLLECTION_WRAPPER_SUFFIX, getStructureNameForField(fType, catalogPattern));
                    } else {
                        buildAndAddArrayMapping(ordtDesc, lFieldName, fieldName, getStructureNameForField(fType, catalogPattern));
                    }
                } else if (fType.getEnclosedType().isObjectType()) {
                    buildAndAddStructureMapping(ordtDesc, lFieldName, fieldName, getGeneratedJavaClassName(fType.getEnclosedType().getTypeName(), dbwsBuilder.getProjectName()));
                } else if (fType.getEnclosedType().isVArrayType()) {
                    if (((VArrayType) fType.getEnclosedType()).getEnclosedType().isComposite()) {
                        buildAndAddObjectArrayMapping(ordtDesc, lFieldName, fieldName, getGeneratedJavaClassName(((VArrayType) fType.getEnclosedType()).getEnclosedType().getTypeName(), dbwsBuilder.getProjectName()), getStructureNameForField(fType, null));
                    } else {
                        buildAndAddArrayMapping(ordtDesc, lFieldName, fieldName, getStructureNameForField(fType, null));
                    }
                } else if (fType.getEnclosedType().isObjectTableType()) {
                    ObjectTableType nestedType = (ObjectTableType) fType.getEnclosedType();
                    if (nestedType.getEnclosedType().isComposite()) {
                        ObjectType oType = (ObjectType) nestedType.getEnclosedType();
                        String oTypeAlias = oType.getTypeName().toLowerCase();
                        String oTypeName = getGeneratedJavaClassName(oTypeAlias, dbwsBuilder.getProjectName());
                        // ObjectType is composite
                        buildAndAddObjectArrayMapping(ordtDesc, lFieldName, fieldName, oTypeName, oTypeAlias.toUpperCase());
                    } else {
                        buildAndAddArrayMapping(ordtDesc, lFieldName, fieldName, nestedType.getTypeName().toUpperCase());
                    }
                } else if (fType.getEnclosedType().isTYPEType()) {
                    // handle %TYPE
                    TYPEType typeType = (TYPEType) fType.getEnclosedType();
                    if (typeType.getEnclosedType().isFieldType()) {
                        // direct mapping
                        AbstractDirectMapping absDirectMapping = (AbstractDirectMapping) ordtDesc.addDirectMapping(lFieldName, fieldName);
                        try {
                            absDirectMapping.setAttributeClassificationName(getClassFromJDBCType(fType.getTypeName(), dbwsBuilder.getDatabasePlatform()).getName());
                        } catch (Exception x) {
                        }
                    }
                }
            } else {
                // direct mapping
                DirectToFieldMapping dfm = new DirectToFieldMapping();
                dfm.setFieldName(fieldName);
                dfm.setAttributeName(lFieldName);
                dfm.setAttributeClassification(getAttributeClassForDatabaseType(fType.getEnclosedType()));
                ordtDesc.addMapping(dfm);
            }
        }
    }
}
Also used : DirectToFieldMapping(org.eclipse.persistence.mappings.DirectToFieldMapping) PLSQLRecordType(org.eclipse.persistence.tools.oracleddl.metadata.PLSQLRecordType) Util.qNameFromString(org.eclipse.persistence.tools.dbws.Util.qNameFromString) ParseException(org.eclipse.persistence.tools.oracleddl.parser.ParseException) FieldType(org.eclipse.persistence.tools.oracleddl.metadata.FieldType) PLSQLCollectionType(org.eclipse.persistence.tools.oracleddl.metadata.PLSQLCollectionType) ObjectTableType(org.eclipse.persistence.tools.oracleddl.metadata.ObjectTableType) ObjectType(org.eclipse.persistence.tools.oracleddl.metadata.ObjectType) OracleObjectType(org.eclipse.persistence.platform.database.oracle.jdbc.OracleObjectType) ROWTYPEType(org.eclipse.persistence.tools.oracleddl.metadata.ROWTYPEType) TYPEType(org.eclipse.persistence.tools.oracleddl.metadata.TYPEType) VArrayType(org.eclipse.persistence.tools.oracleddl.metadata.VArrayType) AbstractDirectMapping(org.eclipse.persistence.mappings.foundation.AbstractDirectMapping) ObjectRelationalDatabaseField(org.eclipse.persistence.mappings.structures.ObjectRelationalDatabaseField) DatabaseField(org.eclipse.persistence.internal.helper.DatabaseField) Iterator(java.util.Iterator) Vector(java.util.Vector) ObjectRelationalDataTypeDescriptor(org.eclipse.persistence.mappings.structures.ObjectRelationalDataTypeDescriptor)

Example 14 with FieldType

use of org.eclipse.persistence.tools.oracleddl.metadata.FieldType in project eclipselink by eclipse-ee4j.

the class OracleHelper method addToOXProjectForPLSQLRecordArg.

/**
 * Build descriptor and mappings for a PL/SQL record argument.  The newly
 * created descriptor will be added to the given OX project.
 */
protected void addToOXProjectForPLSQLRecordArg(DatabaseType dbType, Project oxProject, String recordName, String recordAlias, String targetTypeName, String catalogPattern) {
    XMLDescriptor xdesc = (XMLDescriptor) oxProject.getDescriptorForAlias(recordAlias);
    if (xdesc == null) {
        xdesc = buildAndAddNewXMLDescriptor(oxProject, recordAlias, recordName.toLowerCase(), nct.generateSchemaAlias(targetTypeName), buildCustomQName(targetTypeName, dbwsBuilder).getNamespaceURI());
    }
    // handle fields
    PLSQLRecordType plsqlRecType = (PLSQLRecordType) dbType;
    for (FieldType fType : plsqlRecType.getFields()) {
        // custom naming transformer may exclude some fields
        if (nct.styleForElement(fType.getFieldName()) == ElementStyle.NONE) {
            continue;
        }
        String lFieldName = fType.getFieldName().toLowerCase();
        if (xdesc.getMappingForAttributeName(lFieldName) == null) {
            if (fType.isComposite()) {
                // handle pl/sql record and pl/sql table fields
                if (fType.getEnclosedType().isPLSQLRecordType()) {
                    buildAndAddXMLCompositeObjectMapping(xdesc, lFieldName, (catalogPattern + DOT + fType.getEnclosedType()).toLowerCase());
                } else if (fType.getEnclosedType().isPLSQLCollectionType()) {
                    PLSQLCollectionType tableType = (PLSQLCollectionType) fType.getEnclosedType();
                    if (tableType.getEnclosedType().isComposite()) {
                        buildAndAddXMLCompositeObjectMapping(xdesc, lFieldName, (catalogPattern + DOT + tableType.getTypeName()).toLowerCase() + COLLECTION_WRAPPER_SUFFIX);
                    } else {
                        Class<?> attributeElementClass = String.class;
                        XMLDescriptor refDesc = (XMLDescriptor) oxProject.getDescriptorForAlias((catalogPattern + UNDERSCORE + tableType.getTypeName()).toLowerCase());
                        if (refDesc != null) {
                            attributeElementClass = ((XMLCompositeDirectCollectionMapping) refDesc.getMappingForAttributeName(ITEMS_MAPPING_ATTRIBUTE_NAME)).getAttributeElementClass();
                        }
                        buildAndAddXMLCompositeDirectCollectionMapping(xdesc, lFieldName, lFieldName + SLASH + ITEM_MAPPING_NAME + SLASH + TEXT, attributeElementClass);
                    }
                } else if (fType.getEnclosedType().isObjectType()) {
                    buildAndAddXMLCompositeObjectMapping(xdesc, lFieldName, getGeneratedJavaClassName(fType.getEnclosedType().getTypeName(), dbwsBuilder.getProjectName()));
                } else if (fType.getEnclosedType().isVArrayType()) {
                    if (((VArrayType) fType.getEnclosedType()).getEnclosedType().isComposite()) {
                        String nestedTypeAlias = ((VArrayType) fType.getEnclosedType()).getEnclosedType().getTypeName().toLowerCase();
                        String nestedTypeName = getGeneratedJavaClassName(nestedTypeAlias, dbwsBuilder.getProjectName());
                        buildAndAddXMLCompositeCollectionMapping(xdesc, lFieldName, lFieldName + SLASH + ITEM_MAPPING_NAME, nestedTypeName);
                    } else {
                        buildAndAddXMLCompositeDirectCollectionMapping(xdesc, lFieldName, lFieldName + SLASH + ITEM_MAPPING_NAME + SLASH + TEXT, getAttributeClassForDatabaseType(fType.getEnclosedType()));
                    }
                } else if (fType.getEnclosedType().isObjectTableType()) {
                    ObjectTableType nestedType = (ObjectTableType) fType.getEnclosedType();
                    if (nestedType.getEnclosedType().isComposite()) {
                        String nestedTypeAlias = nestedType.getEnclosedType().getTypeName().toLowerCase();
                        String nestedTypeName = getGeneratedJavaClassName(nestedTypeAlias, dbwsBuilder.getProjectName());
                        // ObjectType is composite
                        buildAndAddXMLCompositeCollectionMapping(xdesc, lFieldName, lFieldName + SLASH + ITEM_MAPPING_NAME, nestedTypeName);
                    } else {
                        buildAndAddXMLCompositeDirectCollectionMapping(xdesc, lFieldName, lFieldName + SLASH + TEXT, getAttributeClassForDatabaseType(nestedType));
                    }
                } else if (fType.getEnclosedType().isTYPEType()) {
                    // handle %TYPE
                    TYPEType typeType = (TYPEType) fType.getEnclosedType();
                    if (typeType.getEnclosedType().isFieldType()) {
                        // direct mapping
                        addDirectMappingForFieldType(xdesc, lFieldName, (FieldType) typeType.getEnclosedType());
                    }
                }
            } else {
                // direct mapping
                addDirectMappingForFieldType(xdesc, lFieldName, fType);
            }
        }
    }
}
Also used : PLSQLCollectionType(org.eclipse.persistence.tools.oracleddl.metadata.PLSQLCollectionType) ObjectTableType(org.eclipse.persistence.tools.oracleddl.metadata.ObjectTableType) ROWTYPEType(org.eclipse.persistence.tools.oracleddl.metadata.ROWTYPEType) TYPEType(org.eclipse.persistence.tools.oracleddl.metadata.TYPEType) XMLDescriptor(org.eclipse.persistence.oxm.XMLDescriptor) VArrayType(org.eclipse.persistence.tools.oracleddl.metadata.VArrayType) PLSQLRecordType(org.eclipse.persistence.tools.oracleddl.metadata.PLSQLRecordType) XMLCompositeDirectCollectionMapping(org.eclipse.persistence.oxm.mappings.XMLCompositeDirectCollectionMapping) Util.qNameFromString(org.eclipse.persistence.tools.dbws.Util.qNameFromString) FieldType(org.eclipse.persistence.tools.oracleddl.metadata.FieldType)

Example 15 with FieldType

use of org.eclipse.persistence.tools.oracleddl.metadata.FieldType in project eclipselink by eclipse-ee4j.

the class BaseDBWSBuilderHelper method buildDatabaseTypeFromMetadataType.

/**
 * Build a org.eclipse.persistence.internal.helper.DatabaseType  instance  from an
 * org.eclipse.persistence.tools.oracleddl.metadata.DatabaseType instance.  In the
 * the case of PLSQL Packages, the catalog (package) name can be passed in as well.
 */
@SuppressWarnings("rawtypes")
protected org.eclipse.persistence.internal.helper.DatabaseType buildDatabaseTypeFromMetadataType(DatabaseType dType, String catalog) {
    // argument could be from a different package
    if (dType.isPLSQLType()) {
        PLSQLType pType = (PLSQLType) dType;
        catalog = pType.getParentType().getPackageName();
    }
    // handle cursors
    if (dType.isPLSQLCursorType()) {
        if (dType.isArgumentType()) {
            dType = ((ArgumentType) dType).getEnclosedType();
        }
        PLSQLCursorType pType = (PLSQLCursorType) dType;
        return new PLSQLCursor(pType.getParentType().getPackageName() + DOT + pType.getCursorName());
    }
    if (dType.isArgumentType()) {
        dType = ((ArgumentType) dType).getEnclosedType();
    } else if (dType.isTYPEType()) {
        dType = ((TYPEType) dType).getEnclosedType();
    }
    // composite types
    if (dType.isComposite()) {
        String typeName = dType.getTypeName();
        // for %ROWTYPE, the compatible JDBC type name cannot contain '%'
        String compatibleType = typeName.contains(PERCENT) ? typeName.replace(PERCENT, UNDERSCORE) : typeName;
        String javaTypeName = compatibleType.toLowerCase();
        // handle PL/SQL types
        if (dType.isPLSQLType()) {
            // for %ROWTYPE we don't want the catalog name prepended even if non-null
            if (catalog != null && !typeName.contains(ROWTYPE_STR)) {
                typeName = (catalog + DOT).concat(typeName);
                compatibleType = (catalog + UNDERSCORE).concat(compatibleType);
                javaTypeName = (catalog.toLowerCase() + DOT).concat(javaTypeName);
            }
            // handle PL/SQL record
            if (dType.isPLSQLRecordType()) {
                PLSQLrecord plsqlRec = new PLSQLrecord();
                plsqlRec.setTypeName(typeName);
                plsqlRec.setCompatibleType(compatibleType);
                plsqlRec.setJavaTypeName(javaTypeName);
                // process fields
                for (FieldType fld : ((PLSQLRecordType) dType).getFields()) {
                    if (fld.getEnclosedType().isPrecisionType()) {
                        PrecisionType precisionType = (PrecisionType) fld.getEnclosedType();
                        plsqlRec.addField(fld.getFieldName(), buildDatabaseTypeFromMetadataType(precisionType), (int) precisionType.getPrecision(), (int) precisionType.getScale());
                    } else if (fld.getEnclosedType().isSizedType()) {
                        SizedType sizedType = (SizedType) fld.getEnclosedType();
                        plsqlRec.addField(fld.getFieldName(), buildDatabaseTypeFromMetadataType(sizedType), (int) sizedType.getSize());
                    } else {
                        plsqlRec.addField(fld.getFieldName(), buildDatabaseTypeFromMetadataType(fld.getEnclosedType(), catalog));
                    }
                }
                return plsqlRec;
            }
            // assumes PL/SQL collection
            PLSQLCollection plsqlCollection = new PLSQLCollection();
            plsqlCollection.setTypeName(typeName);
            plsqlCollection.setCompatibleType(compatibleType);
            plsqlCollection.setJavaTypeName(javaTypeName + COLLECTION_WRAPPER_SUFFIX);
            plsqlCollection.setNestedType(buildDatabaseTypeFromMetadataType(((PLSQLCollectionType) dType).getEnclosedType(), catalog));
            return plsqlCollection;
        }
        // handle advanced Oracle types
        if (dType.isVArrayType()) {
            OracleArrayType varray = new OracleArrayType();
            varray.setTypeName(typeName);
            varray.setCompatibleType(compatibleType);
            varray.setJavaTypeName(getGeneratedWrapperClassName(javaTypeName, dbwsBuilder.getProjectName()));
            varray.setNestedType(buildDatabaseTypeFromMetadataType(((VArrayType) dType).getEnclosedType(), null));
            return varray;
        }
        if (dType.isObjectType()) {
            OracleObjectType objType = new OracleObjectType();
            objType.setTypeName(typeName);
            objType.setCompatibleType(compatibleType);
            objType.setJavaTypeName(getGeneratedJavaClassName(javaTypeName, dbwsBuilder.getProjectName()));
            objType.setJavaType(getWrapperClass(objType.getJavaTypeName()));
            Map<String, org.eclipse.persistence.internal.helper.DatabaseType> fields = objType.getFields();
            ObjectType oType = (ObjectType) dType;
            for (FieldType field : oType.getFields()) {
                fields.put(field.getFieldName(), buildDatabaseTypeFromMetadataType(field.getEnclosedType()));
            }
            return objType;
        }
        if (dType.isObjectTableType()) {
            OracleArrayType tableType = new OracleArrayType();
            tableType.setTypeName(typeName);
            tableType.setCompatibleType(compatibleType);
            tableType.setJavaTypeName(getGeneratedWrapperClassName(javaTypeName, dbwsBuilder.getProjectName()));
            org.eclipse.persistence.internal.helper.DatabaseType nestedType = buildDatabaseTypeFromMetadataType(((ObjectTableType) dType).getEnclosedType(), null);
            // need to set the Java Type on the nested type
            Class wrapper = getWrapperClass(nestedType);
            if (wrapper != null) {
                ((ComplexDatabaseType) nestedType).setJavaType(wrapper);
            }
            tableType.setNestedType(nestedType);
            return tableType;
        }
        return null;
    } else if (dType.isScalar()) {
        org.eclipse.persistence.internal.helper.DatabaseType theType = OraclePLSQLTypes.getDatabaseTypeForCode(dType.getTypeName());
        if (theType != null) {
            return theType;
        }
    }
    // scalar types
    return JDBCTypes.getDatabaseTypeForCode(org.eclipse.persistence.tools.dbws.Util.getJDBCTypeFromTypeName(dType.getTypeName()));
}
Also used : ScalarDatabaseType(org.eclipse.persistence.tools.oracleddl.metadata.ScalarDatabaseType) CompositeDatabaseType(org.eclipse.persistence.tools.oracleddl.metadata.CompositeDatabaseType) ComplexDatabaseType(org.eclipse.persistence.internal.helper.ComplexDatabaseType) DatabaseType(org.eclipse.persistence.tools.oracleddl.metadata.DatabaseType) PLSQLCursorType(org.eclipse.persistence.tools.oracleddl.metadata.PLSQLCursorType) PrecisionType(org.eclipse.persistence.tools.oracleddl.metadata.PrecisionType) ObjectType(org.eclipse.persistence.tools.oracleddl.metadata.ObjectType) OracleObjectType(org.eclipse.persistence.platform.database.oracle.jdbc.OracleObjectType) VArrayType(org.eclipse.persistence.tools.oracleddl.metadata.VArrayType) OracleObjectType(org.eclipse.persistence.platform.database.oracle.jdbc.OracleObjectType) PLSQLrecord(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLrecord) PLSQLCursor(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLCursor) PLSQLRecordType(org.eclipse.persistence.tools.oracleddl.metadata.PLSQLRecordType) FieldType(org.eclipse.persistence.tools.oracleddl.metadata.FieldType) ComplexDatabaseType(org.eclipse.persistence.internal.helper.ComplexDatabaseType) ROWTYPEType(org.eclipse.persistence.tools.oracleddl.metadata.ROWTYPEType) TYPEType(org.eclipse.persistence.tools.oracleddl.metadata.TYPEType) PLSQLCollectionType(org.eclipse.persistence.tools.oracleddl.metadata.PLSQLCollectionType) PLSQLCollection(org.eclipse.persistence.platform.database.oracle.plsql.PLSQLCollection) SizedType(org.eclipse.persistence.tools.oracleddl.metadata.SizedType) PLSQLType(org.eclipse.persistence.tools.oracleddl.metadata.PLSQLType) OracleArrayType(org.eclipse.persistence.platform.database.oracle.jdbc.OracleArrayType)

Aggregations

FieldType (org.eclipse.persistence.tools.oracleddl.metadata.FieldType)15 ObjectTableType (org.eclipse.persistence.tools.oracleddl.metadata.ObjectTableType)7 ArrayList (java.util.ArrayList)6 CompositeDatabaseType (org.eclipse.persistence.tools.oracleddl.metadata.CompositeDatabaseType)6 ROWTYPEType (org.eclipse.persistence.tools.oracleddl.metadata.ROWTYPEType)6 PLSQLParameterMetadata (org.eclipse.persistence.internal.jpa.metadata.queries.PLSQLParameterMetadata)5 Util.getAttributeTypeNameForFieldType (org.eclipse.persistence.tools.metadata.generation.Util.getAttributeTypeNameForFieldType)5 ObjectType (org.eclipse.persistence.tools.oracleddl.metadata.ObjectType)5 PLSQLRecordType (org.eclipse.persistence.tools.oracleddl.metadata.PLSQLRecordType)5 OracleObjectType (org.eclipse.persistence.platform.database.oracle.jdbc.OracleObjectType)4 Util.qNameFromString (org.eclipse.persistence.tools.dbws.Util.qNameFromString)4 DatabaseType (org.eclipse.persistence.tools.oracleddl.metadata.DatabaseType)4 PLSQLType (org.eclipse.persistence.tools.oracleddl.metadata.PLSQLType)4 TYPEType (org.eclipse.persistence.tools.oracleddl.metadata.TYPEType)4 VArrayType (org.eclipse.persistence.tools.oracleddl.metadata.VArrayType)4 DirectToFieldMapping (org.eclipse.persistence.mappings.DirectToFieldMapping)3 XMLDescriptor (org.eclipse.persistence.oxm.XMLDescriptor)3 PLSQLCollectionType (org.eclipse.persistence.tools.oracleddl.metadata.PLSQLCollectionType)3 Iterator (java.util.Iterator)2 Vector (java.util.Vector)2