Search in sources :

Example 1 with DfTypeArrayInfo

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

the class DfProcedurePmbSetupper method doProcessArrayProperty.

// -----------------------------------------------------
// Array Property
// --------------
protected String doProcessArrayProperty(DfTypeArrayInfo arrayInfo, ProcedurePropertyInfo propertyInfo) {
    final String propertyType;
    if (arrayInfo.hasNestedArray()) {
        // array in array
        final DfTypeArrayInfo nestedArrayInfo = arrayInfo.getNestedArrayInfo();
        // recursive call
        final String nestedType = doProcessArrayProperty(nestedArrayInfo, propertyInfo);
        propertyType = getGenericListClassName(nestedType);
    } else if (arrayInfo.hasElementStructInfo()) {
        // struct in array
        final DfTypeStructInfo structInfo = arrayInfo.getElementStructInfo();
        propertyType = doProcessStructProperty(structInfo, propertyInfo);
    } else {
        // scalar in array
        final String dbTypeName = arrayInfo.getElementType();
        propertyType = findPlainPropertyType(Types.OTHER, dbTypeName, null, null);
    }
    arrayInfo.setElementJavaNative(propertyType);
    return propertyType;
}
Also used : DfTypeStructInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo) DfTypeArrayInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeArrayInfo)

Example 2 with DfTypeArrayInfo

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

the class DfProcedureExtractor method doSetupGreatWallOracle.

// ===================================================================================
// Great Wall
// ==========
protected void doSetupGreatWallOracle(StringKeyMap<DfTypeArrayInfo> parameterArrayInfoMap, StringKeyMap<DfTypeStructInfo> structInfoMap, List<DfProcedureMeta> metaInfoList, DfProcedureSupplementExtractorOracle extractor) {
    final Set<String> resolvedArrayDispSet = new LinkedHashSet<String>();
    final Set<String> resolvedStructDispSet = new LinkedHashSet<String>();
    for (DfProcedureMeta metaInfo : metaInfoList) {
        final String catalog = metaInfo.getProcedureCatalog();
        final String procedureName = metaInfo.getProcedureName();
        final List<DfProcedureColumnMeta> columnList = metaInfo.getProcedureColumnList();
        for (DfProcedureColumnMeta columnInfo : columnList) {
            final String columnName = columnInfo.getColumnName();
            final String key = extractor.generateParameterInfoMapKey(catalog, procedureName, columnName);
            // Array
            final DfTypeArrayInfo arrayInfo = parameterArrayInfoMap.get(key);
            if (arrayInfo != null) {
                resolvedArrayDispSet.add(arrayInfo.toString());
                columnInfo.setTypeArrayInfo(arrayInfo);
            }
            // Struct
            final String dbTypeName = columnInfo.getDbTypeName();
            final DfTypeStructInfo structInfo = structInfoMap.get(dbTypeName);
            if (structInfo != null) {
                resolvedStructDispSet.add(structInfo.toString());
                columnInfo.setTypeStructInfo(structInfo);
            }
        }
    }
    if (!resolvedArrayDispSet.isEmpty()) {
        log("Array related to parameter: " + resolvedArrayDispSet.size());
        for (String arrayInfo : resolvedArrayDispSet) {
            log("  " + arrayInfo);
        }
    }
    if (!resolvedStructDispSet.isEmpty()) {
        log("Struct related to parameter: " + resolvedStructDispSet.size());
        for (String structInfo : resolvedStructDispSet) {
            log("  " + structInfo);
        }
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DfProcedureColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta) DfTypeStructInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo) DfProcedureMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta) DfTypeArrayInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeArrayInfo)

Example 3 with DfTypeArrayInfo

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

the class DfProcedureExtractor method doResolveAssistInfoOracleToDBLink.

protected void doResolveAssistInfoOracleToDBLink(DfSchemaSource dataSource, List<DfProcedureMeta> metaInfoList, String dbLinkName) {
    final DfProcedureSupplementExtractorOracle extractor = getSupplementExtractorOracle(dataSource);
    // Overload
    final Map<String, Integer> overloadInfoMapMap = extractor.extractParameterOverloadInfoToDBLinkMap(dbLinkName);
    doSetupOverloadInfoOracleToDBLink(overloadInfoMapMap, metaInfoList, extractor);
    // GreatWall
    // DBLink procedure's GreatWalls are unsupported yet
    // final StringKeyMap<DfTypeArrayInfo> parameterArrayInfoMap = extractor.extractParameterArrayInfoToDBLinkMap();
    // final StringKeyMap<DfTypeStructInfo> structInfoMap = extractor.extractStructInfoToDBLinkMap();
    // empty
    final StringKeyMap<DfTypeArrayInfo> parameterArrayInfoMap = StringKeyMap.createAsFlexible();
    // empty
    final StringKeyMap<DfTypeStructInfo> structInfoMap = StringKeyMap.createAsFlexible();
    doSetupGreatWallOracle(parameterArrayInfoMap, structInfoMap, metaInfoList, extractor);
}
Also used : DfTypeStructInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo) DfTypeArrayInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeArrayInfo) DfProcedureSupplementExtractorOracle(org.dbflute.logic.jdbc.metadata.procedure.DfProcedureSupplementExtractorOracle)

Example 4 with DfTypeArrayInfo

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

the class DfProcedureSupplementExtractorOracle method findParameterArrayInfoMap.

protected StringKeyMap<DfTypeArrayInfo> findParameterArrayInfoMap(UnifiedSchema unifiedSchema) {
    StringKeyMap<DfTypeArrayInfo> parameterArrayInfoMap = _arrayInfoMapMap.get(unifiedSchema);
    if (parameterArrayInfoMap != null) {
        return parameterArrayInfoMap;
    }
    final List<DfProcedureArgumentInfo> argInfoList = findProcedureArgumentInfoList(unifiedSchema);
    parameterArrayInfoMap = StringKeyMap.createAsFlexibleOrdered();
    final StringKeyMap<DfTypeArrayInfo> flatArrayInfoMap = findFlatArrayInfoMap(unifiedSchema);
    for (int i = 0; i < argInfoList.size(); i++) {
        final DfProcedureArgumentInfo argInfo = argInfoList.get(i);
        final String argumentName = argInfo.getArgumentName();
        if (Srl.is_Null_or_TrimmedEmpty(argumentName)) {
            continue;
        }
        final String realTypeName = buildArrayTypeName(argInfo);
        final DfTypeArrayInfo foundInfo = flatArrayInfoMap.get(realTypeName);
        if (foundInfo == null) {
            continue;
        }
        final DfTypeArrayInfo arrayInfo = new DfTypeArrayInfo(foundInfo.getUnifiedSchema(), foundInfo.getTypeName());
        arrayInfo.setElementType(foundInfo.getElementType());
        processArrayNestedElement(unifiedSchema, flatArrayInfoMap, arrayInfo);
        final String packageName = argInfo.getPackageName();
        final String objectName = argInfo.getObjectName();
        final String key = generateParameterInfoMapKey(packageName, objectName, argumentName);
        parameterArrayInfoMap.put(key, arrayInfo);
    }
    log("Array Parameter: " + unifiedSchema);
    for (Entry<String, DfTypeArrayInfo> entry : parameterArrayInfoMap.entrySet()) {
        log("  " + entry.getKey() + " = " + entry.getValue());
    }
    _arrayInfoMapMap.put(unifiedSchema, parameterArrayInfoMap);
    return _arrayInfoMapMap.get(unifiedSchema);
}
Also used : DfTypeArrayInfo(org.dbflute.logic.jdbc.metadata.info.DfTypeArrayInfo) DfProcedureArgumentInfo(org.dbflute.logic.jdbc.metadata.info.DfProcedureArgumentInfo)

Example 5 with DfTypeArrayInfo

use of org.dbflute.logic.jdbc.metadata.info.DfTypeArrayInfo 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

DfTypeArrayInfo (org.dbflute.logic.jdbc.metadata.info.DfTypeArrayInfo)14 DfTypeStructInfo (org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo)9 DfProcedureArgumentInfo (org.dbflute.logic.jdbc.metadata.info.DfProcedureArgumentInfo)3 Map (java.util.Map)2 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)2 StringKeyMap (org.dbflute.helper.StringKeyMap)2 DfProcedureSupplementExtractorOracle (org.dbflute.logic.jdbc.metadata.procedure.DfProcedureSupplementExtractorOracle)2 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 StringSet (org.dbflute.helper.StringSet)1 DfColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfColumnMeta)1 DfProcedureColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta)1 DfProcedureMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta)1 DfArrayExtractorOracle (org.dbflute.logic.jdbc.metadata.various.array.DfArrayExtractorOracle)1