use of org.dbflute.logic.jdbc.metadata.synonym.DfProcedureSynonymExtractor 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);
}
Aggregations