Search in sources :

Example 1 with ProcedureSynonymHandlingType

use of org.dbflute.properties.DfOutsideSqlProperties.ProcedureSynonymHandlingType 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)

Aggregations

ArrayList (java.util.ArrayList)1 DfProcedureMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureMeta)1 DfProcedureSynonymMeta (org.dbflute.logic.jdbc.metadata.info.DfProcedureSynonymMeta)1 DfProcedureSynonymExtractor (org.dbflute.logic.jdbc.metadata.synonym.DfProcedureSynonymExtractor)1 DfOutsideSqlProperties (org.dbflute.properties.DfOutsideSqlProperties)1 ProcedureSynonymHandlingType (org.dbflute.properties.DfOutsideSqlProperties.ProcedureSynonymHandlingType)1