Search in sources :

Example 1 with DfDbCommentExtractor

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

HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 TypeMap (org.apache.torque.engine.database.model.TypeMap)1 UnifiedSchema (org.apache.torque.engine.database.model.UnifiedSchema)1 StringKeyMap (org.dbflute.helper.StringKeyMap)1 DfDbCommentExtractor (org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractor)1 UserColComments (org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractor.UserColComments)1 UserTabComments (org.dbflute.logic.jdbc.metadata.comment.DfDbCommentExtractor.UserTabComments)1 DfTableMeta (org.dbflute.logic.jdbc.metadata.info.DfTableMeta)1