use of org.dbflute.logic.jdbc.metadata.info.DfColumnMeta in project dbflute-core by dbflute.
the class DfSql2EntityTask method setupColumnComment.
protected void setupColumnComment(Map<String, DfColumnMeta> metaMap, String columnName, Column column) {
final DfColumnMeta columnMeta = metaMap.get(columnName);
final String sql2EntityRelatedTableName = columnMeta.getSql2EntityRelatedTableName();
final Table relatedTable = getRelatedTable(sql2EntityRelatedTableName);
String relatedComment = null;
if (relatedTable != null) {
final String relatedColumnName = columnMeta.getSql2EntityRelatedColumnName();
final Column relatedColumn = relatedTable.getColumn(relatedColumnName);
if (relatedColumn != null) {
relatedComment = relatedColumn.getPlainComment();
}
}
// the meta has its select column comment
final String selectColumnComment = columnMeta.getColumnComment();
final String commentMark = "// ";
final String delimiter = getAliasDelimiterInDbComment();
final StringBuilder sb = new StringBuilder();
if (Srl.is_NotNull_and_NotTrimmedEmpty(relatedComment)) {
sb.append(relatedComment);
if (Srl.is_NotNull_and_NotTrimmedEmpty(selectColumnComment)) {
// both exist
if (Srl.is_NotNull_and_NotTrimmedEmpty(delimiter)) {
// use alias option
if (relatedComment.contains(delimiter)) {
// resolved in related comment
sb.append(ln()).append(commentMark).append(selectColumnComment);
} else {
// unresolved yet
if (isDbCommentOnAliasBasis()) {
// related comment is alias
sb.append(delimiter);
} else {
// related comment is description
sb.append(ln());
}
sb.append(commentMark).append(selectColumnComment);
}
} else {
// no alias option
sb.append(ln()).append(commentMark).append(selectColumnComment);
}
}
} else {
// not found related comment
if (Srl.is_NotNull_and_NotTrimmedEmpty(selectColumnComment)) {
if (Srl.is_NotNull_and_NotTrimmedEmpty(delimiter)) {
// use alias option
if (isDbCommentOnAliasBasis()) {
// select column comment is treated as description
sb.append(delimiter);
}
}
sb.append(commentMark).append(selectColumnComment);
}
}
column.setPlainComment(sb.toString());
}
use of org.dbflute.logic.jdbc.metadata.info.DfColumnMeta in project dbflute-core by dbflute.
the class DfSql2EntityTask method setupTorqueType.
protected void setupTorqueType(Map<String, DfColumnMeta> metaMap, String columnName, Column column, boolean allCommonColumn) {
// - - - - - - - - - -/
if (allCommonColumn) {
final String commonColumnTorqueType = getCommonColumnTorqueType(columnName);
if (commonColumnTorqueType != null) {
column.setJdbcType(commonColumnTorqueType);
return;
}
}
final DfColumnMeta columnMeta = metaMap.get(columnName);
final String columnTorqueType = getColumnTorqueType(columnMeta);
column.setJdbcType(columnTorqueType);
}
use of org.dbflute.logic.jdbc.metadata.info.DfColumnMeta in project dbflute-core by dbflute.
the class DfSql2EntityTask method setupColumnSizeContainsDigit.
protected void setupColumnSizeContainsDigit(Map<String, DfColumnMeta> metaMap, String columnName, Column column) {
final DfColumnMeta columnMeta = metaMap.get(columnName);
final int columnSize = columnMeta.getColumnSize();
final int decimalDigits = columnMeta.getDecimalDigits();
column.setupColumnSize(columnSize, decimalDigits);
}
use of org.dbflute.logic.jdbc.metadata.info.DfColumnMeta in project dbflute-core by dbflute.
the class DfSql2EntityTask method setupDbType.
protected void setupDbType(Map<String, DfColumnMeta> metaMap, String columnName, Column column) {
final DfColumnMeta columnMeta = metaMap.get(columnName);
final String dbTypeName;
final String plainName = columnMeta.getDbTypeName();
if (Srl.contains(plainName, ".")) {
// basically for ARRAY and STRUCT type
final String catalogSchema = Srl.substringLastFront(plainName, ".");
final UnifiedSchema unifiedSchema = UnifiedSchema.createAsDynamicSchema(catalogSchema);
if (unifiedSchema.isMainSchema()) {
dbTypeName = Srl.substringLastRear(plainName, ".");
} else {
dbTypeName = plainName;
}
} else {
dbTypeName = plainName;
}
column.setDbType(dbTypeName);
}
use of org.dbflute.logic.jdbc.metadata.info.DfColumnMeta in project dbflute-core by dbflute.
the class DfColumnValueConverter method processString.
protected String processString(String tableName, String columnName, Map<String, DfColumnMeta> columnMetaMap, String filteredValue, String before, String after) {
if (!"$$String$$".equalsIgnoreCase(before)) {
// no converted
return null;
}
final DfColumnMeta columnMeta = columnMetaMap.get(columnName);
final Class<?> boundType = _bindTypeProvider.provide(tableName, columnMeta);
if (!String.class.isAssignableFrom(boundType)) {
// no converted
return null;
}
if (after.equalsIgnoreCase("$$NullToEmpty$$")) {
if (filteredValue == null) {
return "";
}
}
// no converted
return null;
}
Aggregations