Search in sources :

Example 1 with DfDbCommentExtractorOracle

use of org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractorOracle in project dbflute-core by dbflute.

the class DfSynonymExtractorOracle method setupTableColumnComment.

/**
 * Set up table and column comment. <br>
 * This does not support DB link synonym.
 * @param synonymMap The map of synonym. (NotNull)
 */
protected void setupTableColumnComment(Map<String, DfSynonymMeta> synonymMap) {
    final Map<UnifiedSchema, Set<String>> ownerTabSetMap = createOwnerTableSetMap(synonymMap);
    final Map<UnifiedSchema, Map<String, UserTabComments>> ownerTabCommentMap = newLinkedHashMap();
    final Map<UnifiedSchema, Map<String, Map<String, UserColComments>>> ownerTabColCommentMap = newLinkedHashMap();
    for (UnifiedSchema owner : ownerTabSetMap.keySet()) {
        final Set<String> tableSet = ownerTabSetMap.get(owner);
        final DfDbCommentExtractorOracle extractor = createDbCommentExtractor(owner);
        final Map<String, UserTabComments> tabCommentMap = extractor.extractTableComment(tableSet);
        final Map<String, Map<String, UserColComments>> tabColCommentMap = extractor.extractColumnComment(tableSet);
        ownerTabCommentMap.put(owner, tabCommentMap);
        ownerTabColCommentMap.put(owner, tabColCommentMap);
    }
    for (DfSynonymMeta synonym : synonymMap.values()) {
        final UnifiedSchema owner = synonym.getTableOwner();
        final String tableName = synonym.getTableName();
        final Map<String, UserTabComments> tableCommentMap = ownerTabCommentMap.get(owner);
        if (tableCommentMap != null) {
            final UserTabComments userTabComments = tableCommentMap.get(tableName);
            if (userTabComments != null && userTabComments.hasComments()) {
                synonym.setTableComment(userTabComments.getComments());
            }
        }
        final Map<String, Map<String, UserColComments>> tabColCommentMap = ownerTabColCommentMap.get(owner);
        if (tabColCommentMap != null) {
            final Map<String, UserColComments> colCommentMap = tabColCommentMap.get(tableName);
            if (colCommentMap != null && !colCommentMap.isEmpty()) {
                synonym.setColumnCommentMap(colCommentMap);
            }
        }
    }
}
Also used : ResultSet(java.sql.ResultSet) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) UserColComments(org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractor.UserColComments) UserTabComments(org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractor.UserTabComments) DfSynonymMeta(org.dbflute.logic.jdbc.metadata.info.DfSynonymMeta) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) DfDbCommentExtractorOracle(org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractorOracle) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) StringKeyMap(org.dbflute.helper.StringKeyMap)

Example 2 with DfDbCommentExtractorOracle

use of org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractorOracle in project dbflute-core by dbflute.

the class DfDbCommentExtractorFactory method createDbCommentExtractor.

// ===================================================================================
// Create
// ======
/**
 * @return The extractor of DB comments. (NullAllowed)
 */
public DfDbCommentExtractor createDbCommentExtractor() {
    if (_databaseTypeFacadeProp.isDatabaseMySQL()) {
        final DfDbCommentExtractorMySQL extractor = new DfDbCommentExtractorMySQL();
        extractor.setDataSource(_dataSource);
        extractor.setUnifiedSchema(_unifiedSchema);
        return extractor;
    } else if (_databaseTypeFacadeProp.isDatabaseOracle()) {
        final DfDbCommentExtractorOracle extractor = new DfDbCommentExtractorOracle();
        extractor.setDataSource(_dataSource);
        extractor.setUnifiedSchema(_unifiedSchema);
        return extractor;
    } else if (_databaseTypeFacadeProp.isDatabaseSQLServer()) {
        final DfDbCommentExtractorSQLServer extractor = new DfDbCommentExtractorSQLServer();
        extractor.setDataSource(_dataSource);
        extractor.setUnifiedSchema(_unifiedSchema);
        return extractor;
    }
    return null;
}
Also used : DfDbCommentExtractorMySQL(org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractorMySQL) DfDbCommentExtractorSQLServer(org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractorSQLServer) DfDbCommentExtractorOracle(org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractorOracle)

Example 3 with DfDbCommentExtractorOracle

use of org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractorOracle in project dbflute-core by dbflute.

the class DfSynonymExtractorOracle method createDbCommentExtractor.

protected DfDbCommentExtractorOracle createDbCommentExtractor(UnifiedSchema schema) {
    final DfDbCommentExtractorOracle extractor = new DfDbCommentExtractorOracle();
    extractor.setDataSource(_dataSource);
    extractor.setUnifiedSchema(schema);
    return extractor;
}
Also used : DfDbCommentExtractorOracle(org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractorOracle)

Aggregations

DfDbCommentExtractorOracle (org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractorOracle)3 ResultSet (java.sql.ResultSet)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 Set (java.util.Set)1 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)1 StringKeyMap (org.dbflute.helper.StringKeyMap)1 UserColComments (org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractor.UserColComments)1 UserTabComments (org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractor.UserTabComments)1 DfDbCommentExtractorMySQL (org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractorMySQL)1 DfDbCommentExtractorSQLServer (org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractorSQLServer)1 DfSynonymMeta (org.dbflute.logic.jdbc.metadata.info.DfSynonymMeta)1