Search in sources :

Example 6 with DfTypeStructInfo

use of org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo in project dbflute-core by dbflute.

the class DfProcedureSupplementExtractorOracle method doResolveStructAttributeArray.

protected DfTypeArrayInfo doResolveStructAttributeArray(StringKeyMap<DfTypeStructInfo> structInfoMap, StringKeyMap<DfTypeArrayInfo> flatArrayInfoMap, String attrTypeName) {
    if (!flatArrayInfoMap.containsKey(attrTypeName)) {
        return null;
    }
    final DfTypeArrayInfo foundInfo = flatArrayInfoMap.get(attrTypeName);
    final DfTypeArrayInfo typeArrayInfo = new DfTypeArrayInfo(foundInfo.getUnifiedSchema(), foundInfo.getTypeName());
    final String elementType = foundInfo.getElementType();
    typeArrayInfo.setElementType(elementType);
    if (flatArrayInfoMap.containsKey(elementType)) {
        // array in array in ...
        // recursive call
        final DfTypeArrayInfo nestedArrayInfo = doResolveStructAttributeArray(structInfoMap, flatArrayInfoMap, elementType);
        typeArrayInfo.setNestedArrayInfo(nestedArrayInfo);
    } else if (structInfoMap.containsKey(elementType)) {
        // struct in array in ...
        final DfTypeStructInfo elementStructInfo = structInfoMap.get(elementType);
        typeArrayInfo.setElementStructInfo(elementStructInfo);
    }
    return typeArrayInfo;
}
Also used : DfTypeStructInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo) DfTypeArrayInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeArrayInfo)

Example 7 with DfTypeStructInfo

use of org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo in project dbflute-core by dbflute.

the class DfProcedureSupplementExtractorOracle method processArrayNestedElement.

protected void processArrayNestedElement(UnifiedSchema unifiedSchema, final StringKeyMap<DfTypeArrayInfo> flatArrayInfoMap, DfTypeArrayInfo arrayInfo) {
    // ARRAY element
    final DfTypeArrayInfo foundInfo = flatArrayInfoMap.get(arrayInfo.getElementType());
    if (foundInfo != null) {
        final DfTypeArrayInfo nestedInfo = new DfTypeArrayInfo(foundInfo.getUnifiedSchema(), foundInfo.getTypeName());
        nestedInfo.setElementType(foundInfo.getElementType());
        arrayInfo.setNestedArrayInfo(nestedInfo);
        // recursive call
        processArrayNestedElement(unifiedSchema, flatArrayInfoMap, nestedInfo);
    // *ARRAY type of additional schema is unsupported for now
    }
    // STRUCT element
    final StringKeyMap<DfTypeStructInfo> structInfoMap = findParameterStructInfoMap(unifiedSchema);
    final DfTypeStructInfo structInfo = structInfoMap.get(arrayInfo.getElementType());
    if (structInfo != null) {
        // the structInfo has already been resolved about nested objects
        arrayInfo.setElementStructInfo(structInfo);
    // *STRUCT type of additional schema is unsupported for now
    }
}
Also used : DfTypeStructInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo) DfTypeArrayInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeArrayInfo)

Example 8 with DfTypeStructInfo

use of org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo in project dbflute-core by dbflute.

the class DfProcedureSupplementExtractorOracle method doResolveStructAttributeInfo.

protected void doResolveStructAttributeInfo(UnifiedSchema unifiedSchema, StringKeyMap<DfTypeStructInfo> structInfoMap, StringKeyMap<DfTypeArrayInfo> flatArrayInfoMap, DfTypeStructInfo structInfo, DfColumnMeta columnInfo) {
    final String attrTypeName = columnInfo.getDbTypeName();
    final DfTypeArrayInfo arrayInfo = doResolveStructAttributeArray(structInfoMap, flatArrayInfoMap, attrTypeName);
    if (arrayInfo != null) {
        // array attribute
        columnInfo.setTypeArrayInfo(arrayInfo);
    }
    final DfTypeStructInfo nestedStructInfo = structInfoMap.get(attrTypeName);
    if (nestedStructInfo != null) {
        // nested struct
        columnInfo.setTypeStructInfo(nestedStructInfo);
    }
    // for default mapping type
    columnInfo.setProcedureParameter(true);
}
Also used : DfTypeStructInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo) DfTypeArrayInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeArrayInfo)

Example 9 with DfTypeStructInfo

use of org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo in project dbflute-core by dbflute.

the class DfStructExtractorOracle method extractStructInfoMap.

// ===================================================================================
// Extract
// =======
/**
 * Extract the map of struct info. <br>
 * The info is so simple, for example, no nested info.
 * And this sets type name and attributes only.
 * @param unifiedSchema The unified schema. (NotNull)
 * @return The map of struct info. {key = schema.struct-type-name} (NotNull)
 */
public StringKeyMap<DfTypeStructInfo> extractStructInfoMap(UnifiedSchema unifiedSchema) {
    final List<Map<String, String>> resultList = selectStructAttribute(unifiedSchema);
    final StringKeyMap<DfTypeStructInfo> structInfoMap = StringKeyMap.createAsFlexibleOrdered();
    for (Map<String, String> map : resultList) {
        final String typeName = DfTypeStructInfo.generateTypeName(unifiedSchema, map.get("TYPE_NAME"));
        DfTypeStructInfo info = structInfoMap.get(typeName);
        if (info == null) {
            info = new DfTypeStructInfo(unifiedSchema, typeName);
            structInfoMap.put(typeName, info);
        }
        final DfColumnMeta attributeInfo = new DfColumnMeta();
        final String attrName = map.get("ATTR_NAME");
        if (Srl.is_Null_or_TrimmedEmpty(attrName)) {
            continue;
        }
        attributeInfo.setColumnName(attrName);
        final String dbTypeName;
        {
            // ARRAY and STRUCT only
            final String attrTypeOwner = map.get("ATTR_TYPE_OWNER");
            final String attrTypeName = map.get("ATTR_TYPE_NAME");
            dbTypeName = Srl.connectPrefix(attrTypeName, attrTypeOwner, ".");
        }
        attributeInfo.setDbTypeName(dbTypeName);
        final String length = map.get("LENGTH");
        if (Srl.is_NotNull_and_NotTrimmedEmpty(length)) {
            // for example, varchar2
            attributeInfo.setColumnSize(Integer.valueOf(length));
        } else {
            final String precision = map.get("PRECISION");
            if (Srl.is_NotNull_and_NotTrimmedEmpty(precision)) {
                // for example, number
                attributeInfo.setColumnSize(Integer.valueOf(precision));
            }
        }
        final String scale = map.get("SCALE");
        if (Srl.is_NotNull_and_NotTrimmedEmpty(scale)) {
            attributeInfo.setDecimalDigits(Integer.valueOf(scale));
        }
        info.putAttributeInfo(attributeInfo);
    }
    return structInfoMap;
}
Also used : DfColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfColumnMeta) DfTypeStructInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo) Map(java.util.Map) StringKeyMap(org.dbflute.helper.StringKeyMap)

Example 10 with DfTypeStructInfo

use of org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo in project dbflute-core by dbflute.

the class DfProcedurePmbSetupper method setupStructAttribute.

protected void setupStructAttribute(DfTypeStructInfo structInfo, ProcedurePropertyInfo propertyInfo) {
    final StringKeyMap<DfColumnMeta> attrMap = structInfo.getAttributeInfoMap();
    for (DfColumnMeta attrInfo : attrMap.values()) {
        // nested array or struct handling
        if (attrInfo.hasTypeArrayInfo()) {
            // array in struct
            final DfTypeArrayInfo typeArrayInfo = attrInfo.getTypeArrayInfo();
            if (typeArrayInfo.hasElementStructInfo()) {
                // struct in array in struct
                registerEntityInfoIfNeeds(typeArrayInfo.getElementStructInfo(), propertyInfo);
            }
            if (typeArrayInfo.hasElementJavaNative()) {
                final String elementJavaNative = typeArrayInfo.getElementJavaNative();
                attrInfo.setSql2EntityForcedJavaNative(getGenericListClassName(elementJavaNative));
            } else {
                final String elementType;
                if (typeArrayInfo.hasNestedArray()) {
                    // array in array in struct
                    final DfTypeArrayInfo nestedArrayInfo = typeArrayInfo.getNestedArrayInfo();
                    elementType = getGenericListClassName(doProcessArrayProperty(nestedArrayInfo, propertyInfo));
                } else if (typeArrayInfo.hasElementStructInfo()) {
                    // struct in array in struct
                    final DfTypeStructInfo elementStructInfo = typeArrayInfo.getElementStructInfo();
                    elementType = buildStructEntityType(elementStructInfo);
                } else {
                    // scalar in array in struct
                    elementType = findArrayScalarElementPropertyType(attrInfo.getTypeArrayInfo());
                }
                typeArrayInfo.setElementJavaNative(elementType);
                attrInfo.setSql2EntityForcedJavaNative(getGenericListClassName(elementType));
            }
        } else if (attrInfo.hasTypeStructInfo()) {
            final DfTypeStructInfo nestedStructInfo = attrInfo.getTypeStructInfo();
            registerEntityInfoIfNeeds(nestedStructInfo, propertyInfo);
            if (nestedStructInfo.hasEntityType()) {
                attrInfo.setSql2EntityForcedJavaNative(nestedStructInfo.getEntityType());
            } else {
                attrInfo.setSql2EntityForcedJavaNative(buildStructEntityType(nestedStructInfo));
            }
        }
    }
}
Also used : DfColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfColumnMeta) DfTypeStructInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo) DfTypeArrayInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeArrayInfo)

Aggregations

DfTypeStructInfo (org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo)11 DfTypeArrayInfo (org.dbflute.logic.jdbc.metadata.info.DfTypeArrayInfo)9 Map (java.util.Map)2 StringKeyMap (org.dbflute.helper.StringKeyMap)2 DfColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfColumnMeta)2 DfProcedureSupplementExtractorOracle (org.dbflute.logic.jdbc.metadata.procedure.DfProcedureSupplementExtractorOracle)2 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)1 DfProcedureColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta)1 DfProcedureMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta)1 DfStructExtractorOracle (org.dbflute.logic.jdbc.metadata.various.struct.DfStructExtractorOracle)1