Search in sources :

Example 1 with UserColComments

use of org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractor.UserColComments 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 UserColComments

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

the class DfColumnMeta method acceptColumnComment.

// ===================================================================================
// Accept
// ======
public void acceptColumnComment(Map<String, UserColComments> columnCommentMap) {
    if (columnCommentMap == null) {
        return;
    }
    final UserColComments userColComments = columnCommentMap.get(_columnName);
    if (userColComments == null) {
        return;
    }
    final String comment = userColComments.getComments();
    if (comment != null && comment.trim().length() > 0) {
        _columnComment = comment;
    }
}
Also used : UserColComments(org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractor.UserColComments)

Example 3 with UserColComments

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

the class DfSchemaXmlSerializer method helpColumnComments.

protected void helpColumnComments(DfTableMeta tableMeta, List<DfColumnMeta> columnList) {
    if (_columnCommentAllMap != null) {
        final String tableName = tableMeta.getTableName();
        final Map<String, Map<String, UserColComments>> tableMap = _columnCommentAllMap.get(tableMeta.getUnifiedSchema());
        if (tableMap != null) {
            // just in case
            final Map<String, UserColComments> columnCommentMap = tableMap.get(tableName);
            if (columnCommentMap != null) {
                // just in case
                for (DfColumnMeta column : columnList) {
                    column.acceptColumnComment(columnCommentMap);
                }
            }
        }
    }
    helpSynonymColumnComments(tableMeta, columnList);
}
Also used : DfColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfColumnMeta) UserColComments(org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractor.UserColComments) Map(java.util.Map) TypeMap(org.apache.torque.engine.database.model.TypeMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) StringKeyMap(org.dbflute.helper.StringKeyMap)

Example 4 with UserColComments

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

the class DfSchemaXmlSerializer method doHelpTableComment.

protected void doHelpTableComment(List<DfTableMeta> tableList, UnifiedSchema unifiedSchema) {
    final DfDbCommentExtractor dbCommentExtractor = createDbCommentExtractor(unifiedSchema);
    if (dbCommentExtractor != null) {
        final Set<String> tableSet = new HashSet<String>();
        for (DfTableMeta table : tableList) {
            tableSet.add(table.getTableName());
        }
        try {
            final Map<String, UserTabComments> tableCommentMap = dbCommentExtractor.extractTableComment(tableSet);
            for (DfTableMeta table : tableList) {
                table.acceptTableComment(tableCommentMap);
            // *Synonym Processing is after loading synonyms.
            }
        } catch (RuntimeException ignored) {
            _log.info("Failed to extract table comments: extractor=" + dbCommentExtractor, ignored);
        }
        try {
            if (_columnCommentAllMap == null) {
                _columnCommentAllMap = new LinkedHashMap<UnifiedSchema, Map<String, Map<String, UserColComments>>>();
            }
            final Map<String, Map<String, UserColComments>> columnCommentMap = _columnCommentAllMap.get(unifiedSchema);
            final Map<String, Map<String, UserColComments>> extractedMap = dbCommentExtractor.extractColumnComment(tableSet);
            if (columnCommentMap == null) {
                _columnCommentAllMap.put(unifiedSchema, extractedMap);
            } else {
                // basically no way, schema is unique but just in case
                // merge
                columnCommentMap.putAll(extractedMap);
            }
        } catch (RuntimeException continued) {
            _log.info("Failed to extract column comments: extractor=" + dbCommentExtractor, continued);
        }
    }
}
Also used : UserColComments(org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractor.UserColComments) UserTabComments(org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractor.UserTabComments) DfDbCommentExtractor(org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractor) UnifiedSchema(org.apache.torque.engine.database.model.UnifiedSchema) DfTableMeta(org.dbflute.logic.jdbc.metadata.info.DfTableMeta) Map(java.util.Map) TypeMap(org.apache.torque.engine.database.model.TypeMap) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) StringKeyMap(org.dbflute.helper.StringKeyMap) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

UserColComments (org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractor.UserColComments)4 LinkedHashMap (java.util.LinkedHashMap)3 Map (java.util.Map)3 StringKeyMap (org.dbflute.helper.StringKeyMap)3 LinkedHashSet (java.util.LinkedHashSet)2 TreeMap (java.util.TreeMap)2 TypeMap (org.apache.torque.engine.database.model.TypeMap)2 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)2 UserTabComments (org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractor.UserTabComments)2 ResultSet (java.sql.ResultSet)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 DfDbCommentExtractor (org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractor)1 DfDbCommentExtractorOracle (org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractorOracle)1 DfColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfColumnMeta)1 DfSynonymMeta (org.dbflute.logic.jdbc.metadata.info.DfSynonymMeta)1 DfTableMeta (org.dbflute.logic.jdbc.metadata.info.DfTableMeta)1