Search in sources :

Example 6 with DfProcedureMeta

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

the class DfProcedureExtractor method setupProcedureSynonym.

// -----------------------------------------------------
// Procedure Synonym
// -----------------
protected void setupProcedureSynonym(List<DfProcedureMeta> procedureList) {
    if (_procedureSynonymDataSource == null) {
        return;
    }
    final DfOutsideSqlProperties prop = getOutsideSqlProperties();
    final ProcedureSynonymHandlingType handlingType = prop.getProcedureSynonymHandlingType();
    if (handlingType.equals(ProcedureSynonymHandlingType.NONE)) {
        return;
    }
    final DfProcedureSynonymExtractor extractor = createProcedureSynonymExtractor();
    if (extractor == null) {
        // unsupported at the database
        return;
    }
    final Map<String, DfProcedureSynonymMeta> procedureSynonymMap = extractor.extractProcedureSynonymMap();
    if (handlingType.equals(ProcedureSynonymHandlingType.INCLUDE)) {
    // only add procedure synonyms to the procedure list
    } else if (handlingType.equals(ProcedureSynonymHandlingType.SWITCH)) {
        log("...Clearing normal procedures: count=" + procedureList.size());
        // because of switch
        procedureList.clear();
    } else {
        String msg = "Unexpected handling type of procedure sysnonym: " + handlingType;
        throw new IllegalStateException(msg);
    }
    log("...Adding procedure synonyms as procedure: count=" + procedureSynonymMap.size());
    final List<DfProcedureMeta> procedureSynonymList = new ArrayList<DfProcedureMeta>();
    for (Entry<String, DfProcedureSynonymMeta> entry : procedureSynonymMap.entrySet()) {
        final DfProcedureSynonymMeta metaInfo = entry.getValue();
        if (!isSynonymAllowedSchema(metaInfo)) {
            continue;
        }
        // merge synonym to procedure (create copied instance)
        final String beforeName = metaInfo.getProcedureMetaInfo().buildProcedureLoggingName();
        final DfProcedureMeta mergedProcedure = metaInfo.createMergedProcedure();
        final String afterName = mergedProcedure.buildProcedureLoggingName();
        log("  " + beforeName + " to " + afterName);
        procedureSynonymList.add(mergedProcedure);
    }
    procedureList.addAll(procedureSynonymList);
}
Also used : DfProcedureSynonymExtractor(org.dbflute.logic.jdbc.metadata.synonym.DfProcedureSynonymExtractor) DfProcedureSynonymMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureSynonymMeta) DfOutsideSqlProperties(org.dbflute.properties.DfOutsideSqlProperties) ArrayList(java.util.ArrayList) DfProcedureMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta) ProcedureSynonymHandlingType(org.dbflute.properties.DfOutsideSqlProperties.ProcedureSynonymHandlingType)

Example 7 with DfProcedureMeta

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

the class DfProcedureExtractor method arrangeProcedureOrder.

protected Map<String, DfProcedureMeta> arrangeProcedureOrder(Map<String, DfProcedureMeta> procedureHandlingMap) {
    final Map<String, DfProcedureMeta> procedureOrderedMap = newLinkedHashMap();
    final Map<String, DfProcedureMeta> additionalSchemaProcedureMap = newLinkedHashMap();
    final Set<Entry<String, DfProcedureMeta>> entrySet = procedureHandlingMap.entrySet();
    for (Entry<String, DfProcedureMeta> entry : entrySet) {
        final String key = entry.getKey();
        final DfProcedureMeta metaInfo = entry.getValue();
        if (metaInfo.getProcedureSchema().isAdditionalSchema()) {
            additionalSchemaProcedureMap.put(key, metaInfo);
        } else {
            // main schema
            procedureOrderedMap.put(key, metaInfo);
        }
    }
    procedureOrderedMap.putAll(additionalSchemaProcedureMap);
    return procedureOrderedMap;
}
Also used : Entry(java.util.Map.Entry) DfProcedureMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta)

Example 8 with DfProcedureMeta

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

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

the class DfProcedureExtractor method setupAdditionalSchemaProcedure.

// -----------------------------------------------------
// Additional Schema
// -----------------
protected void setupAdditionalSchemaProcedure(DfSchemaSource dataSource, List<DfProcedureMeta> procedureList) throws SQLException {
    if (_suppressAdditionalSchema) {
        return;
    }
    final DfDatabaseProperties databaseProp = getProperties().getDatabaseProperties();
    final List<UnifiedSchema> additionalSchemaList = databaseProp.getAdditionalSchemaList();
    for (UnifiedSchema additionalSchema : additionalSchemaList) {
        final DfAdditionalSchemaInfo schemaInfo = databaseProp.getAdditionalSchemaInfo(additionalSchema);
        if (schemaInfo.isSuppressProcedure()) {
            continue;
        }
        final List<DfProcedureMeta> additionalProcedureList = getPlainProcedureList(dataSource, additionalSchema);
        procedureList.addAll(additionalProcedureList);
    }
}
Also used : DfAdditionalSchemaInfo(org.dbflute.properties.assistant.database.DfAdditionalSchemaInfo) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) DfProcedureMeta(org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta) DfDatabaseProperties(org.dbflute.properties.DfDatabaseProperties)

Example 10 with DfProcedureMeta

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

Aggregations

DfProcedureMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta)24 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)8 SQLException (java.sql.SQLException)5 DfProcedureColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta)5 ArrayList (java.util.ArrayList)4 DfOutsideSqlProperties (org.dbflute.properties.DfOutsideSqlProperties)4 SQLFailureException (org.dbflute.exception.SQLFailureException)3 DfProcedureExtractor (org.dbflute.logic.jdbc.metadata.basic.DfProcedureExtractor)3 Connection (java.sql.Connection)2 ResultSet (java.sql.ResultSet)2 Statement (java.sql.Statement)2 List (java.util.List)2 DfProcedureSynonymMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureSynonymMeta)2 DfProcedureNativeTranslatorOracle (org.dbflute.logic.jdbc.metadata.procedure.DfProcedureNativeTranslatorOracle)2 DatabaseMetaData (java.sql.DatabaseMetaData)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Entry (java.util.Map.Entry)1 DfProcedureArgumentInfo (org.dbflute.logic.jdbc.metadata.info.DfProcedureArgumentInfo)1 DfProcedureColumnType (org.dbflute.logic.jdbc.metadata.info.DfProcedureColumnMeta.DfProcedureColumnType)1