Search in sources :

Example 11 with DfProcedureColumnMeta

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

the class DfProcedureExtractor method doSetupOverloadInfoOracle.

protected void doSetupOverloadInfoOracle(Map<UnifiedSchema, Map<String, Integer>> parameterOverloadInfoMapMap, List<DfProcedureMeta> metaInfoList, DfProcedureSupplementExtractorOracle extractor) {
    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);
            // Overload
            if (columnInfo.getOverloadNo() == null) {
                // if not exists (it might be set by other processes)
                final UnifiedSchema procedureSchema = metaInfo.getProcedureSchema();
                final Map<String, Integer> overloadMap = parameterOverloadInfoMapMap.get(procedureSchema);
                if (overloadMap != null) {
                    final Integer overloadNo = overloadMap.get(key);
                    if (overloadNo != null) {
                        columnInfo.setOverloadNo(overloadNo);
                    }
                }
            }
        }
    }
}
Also used : DfProcedureColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) DfProcedureMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta)

Example 12 with DfProcedureColumnMeta

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

the class DfProcedureExtractor method adjustPostgreSQLResultSetParameter.

protected void adjustPostgreSQLResultSetParameter(DfProcedureMeta procedureMetaInfo) {
    if (!isDatabasePostgreSQL()) {
        return;
    }
    final List<DfProcedureColumnMeta> columnMetaInfoList = procedureMetaInfo.getProcedureColumnList();
    boolean existsResultSetParameter = false;
    boolean existsResultSetReturn = false;
    int resultSetReturnIndex = 0;
    String resultSetReturnName = null;
    int index = 0;
    for (DfProcedureColumnMeta columnMetaInfo : columnMetaInfoList) {
        final DfProcedureColumnType procedureColumnType = columnMetaInfo.getProcedureColumnType();
        final String dbTypeName = columnMetaInfo.getDbTypeName();
        if (procedureColumnType.equals(DfProcedureColumnType.procedureColumnOut)) {
            if ("refcursor".equalsIgnoreCase(dbTypeName)) {
                existsResultSetParameter = true;
            }
        }
        if (procedureColumnType.equals(DfProcedureColumnType.procedureColumnReturn)) {
            if ("refcursor".equalsIgnoreCase(dbTypeName)) {
                existsResultSetReturn = true;
                resultSetReturnIndex = index;
                resultSetReturnName = columnMetaInfo.getColumnName();
            }
        }
        ++index;
    }
    if (existsResultSetParameter && existsResultSetReturn) {
        // It is a precondition that PostgreSQL does not allow functions to have a result set return
        // when it also has result set parameters (as an out parameter).
        String name = procedureMetaInfo.buildProcedureLoggingName() + "." + resultSetReturnName;
        log("...Removing the result set return which is unnecessary: " + name);
        columnMetaInfoList.remove(resultSetReturnIndex);
    }
}
Also used : DfProcedureColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta) DfProcedureColumnType(org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta.DfProcedureColumnType)

Example 13 with DfProcedureColumnMeta

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

the class DfProcedureExtractor method doSetupOverloadInfoOracleToDBLink.

protected void doSetupOverloadInfoOracleToDBLink(Map<String, Integer> parameterOverloadInfoMap, List<DfProcedureMeta> metaInfoList, DfProcedureSupplementExtractorOracle extractor) {
    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);
            // Overload
            if (columnInfo.getOverloadNo() == null) {
                // if not exists (it might be set by other processes)
                final Integer overloadNo = parameterOverloadInfoMap.get(key);
                if (overloadNo != null) {
                    columnInfo.setOverloadNo(overloadNo);
                }
            }
        }
    }
}
Also used : DfProcedureColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta) DfProcedureMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta)

Example 14 with DfProcedureColumnMeta

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

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

the class DfProcedureNativeTranslatorOracle method createDBLinkProcedureMeta.

protected DfProcedureMeta createDBLinkProcedureMeta(ProcedureNativeInfo nativeInfo, String dbLinkName) {
    final DfProcedureMeta procedureMeta = new DfProcedureMeta();
    setupProcedureName(nativeInfo, procedureMeta, dbLinkName);
    final List<DfProcedureArgumentInfo> argInfoList = nativeInfo.getArgInfoList();
    for (DfProcedureArgumentInfo argInfo : argInfoList) {
        final DfProcedureColumnMeta columnMeta = new DfProcedureColumnMeta();
        columnMeta.setColumnName(argInfo.getArgumentName());
        setupProcedureColumnDataType(argInfo, columnMeta);
        setupProcedureColumnInOutType(argInfo, columnMeta);
        setupProcedureColumnSize(argInfo, columnMeta);
        procedureMeta.addProcedureColumn(columnMeta);
    }
    // assist info (e.g. great walls) is not set here (set later)
    return procedureMeta;
}
Also used : DfProcedureColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta) DfProcedureMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta) DfProcedureArgumentInfo(org.dbflute.logic.jdbc.metadata.info.DfProcedureArgumentInfo)

Aggregations

DfProcedureColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta)27 DfProcedureColumnType (org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta.DfProcedureColumnType)5 DfProcedureMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta)5 LinkedHashSet (java.util.LinkedHashSet)2 DfProcedureNotParamResultMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureNotParamResultMeta)2 CallableStatement (java.sql.CallableStatement)1 Connection (java.sql.Connection)1 ResultSet (java.sql.ResultSet)1 SQLException (java.sql.SQLException)1 HashSet (java.util.HashSet)1 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)1 DfProcedureExecutionMetaGettingFailureException (org.dbflute.exception.DfProcedureExecutionMetaGettingFailureException)1 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)1 DfColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfColumnMeta)1 DfProcedureArgumentInfo (org.dbflute.logic.jdbc.metadata.info.DfProcedureArgumentInfo)1 DfProcedureType (org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta.DfProcedureType)1 DfTypeArrayInfo (org.dbflute.logic.jdbc.metadata.info.DfTypeArrayInfo)1 DfTypeStructInfo (org.dbflute.logic.jdbc.metadata.info.DfTypeStructInfo)1 DfPmbMetaData (org.dbflute.logic.sql2entity.pmbean.DfPmbMetaData)1 DfOutsideSqlProperties (org.dbflute.properties.DfOutsideSqlProperties)1