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);
}
}
}
}
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;
}
}
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);
}
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);
}
}
}
Aggregations