use of org.dbflute.logic.jdbc.metadata.info.DfColumnMeta in project dbflute-core by dbflute.
the class DfColumnValueConverter method findTypedColumnConvertMap.
protected Map<String, String> findTypedColumnConvertMap(String columnName, Map<String, DfColumnMeta> columnMetaMap) {
final DfColumnMeta meta = columnMetaMap.get(columnName);
if (meta == null) {
// no way, just in case
throw new IllegalStateException("Not found the column meta: " + columnName);
}
final String jdbcType = TypeMap.findJdbcTypeByJdbcDefValue(meta.getJdbcDefValue());
if (jdbcType == null) {
// as not found
return Collections.emptyMap();
}
if (_typedColumnConvertMap != null) {
final Map<String, String> existingMap = _typedColumnConvertMap.get(jdbcType);
if (existingMap != null) {
return existingMap;
}
} else {
_typedColumnConvertMap = StringKeyMap.createAsCaseInsensitive();
}
// e.g. $$type(VARCHAR)$$
final String typedKey = "$$type(" + jdbcType + ")$$";
final Map<String, String> valueMap = _convertValueMap.getOrDefault(typedKey, Collections.emptyMap());
_typedColumnConvertMap.put(jdbcType, valueMap);
return _typedColumnConvertMap.get(jdbcType);
}
use of org.dbflute.logic.jdbc.metadata.info.DfColumnMeta in project dbflute-core by dbflute.
the class DfDelimiterDataWriterImpl method createSqlBuilder.
protected DfDelimiterDataWriteSqlBuilder createSqlBuilder(DfDelimiterDataResultInfo resultInfo, String tableDbName, final Map<String, DfColumnMeta> columnMetaMap, List<String> columnNameList, List<String> valueList) {
final DfDelimiterDataWriteSqlBuilder sqlBuilder = new DfDelimiterDataWriteSqlBuilder();
sqlBuilder.setTableDbName(tableDbName);
sqlBuilder.setColumnMetaMap(columnMetaMap);
sqlBuilder.setColumnNameList(columnNameList);
sqlBuilder.setValueList(valueList);
sqlBuilder.setNotFoundColumnMap(resultInfo.getNotFoundColumnMap());
sqlBuilder.setConvertValueMap(_convertValueMap);
sqlBuilder.setDefaultValueMap(_defaultValueMap);
sqlBuilder.setBindTypeProvider(new DfColumnBindTypeProvider() {
public Class<?> provide(String tableName, DfColumnMeta columnMeta) {
return getBindType(tableName, columnMeta);
}
});
sqlBuilder.setDefaultValueProp(_defaultValueProp);
return sqlBuilder;
}
use of org.dbflute.logic.jdbc.metadata.info.DfColumnMeta in project dbflute-core by dbflute.
the class DfXlsDataHandlerImpl method convertColumnValueIfNeeds.
// ===================================================================================
// Column Value Filter
// ===================
protected void convertColumnValueIfNeeds(String dataDirectory, String tableName, Map<String, Object> columnValueMap, Map<String, DfColumnMeta> columnMetaMap) {
// handling both convertValueMap and defaultValueMap
final Map<String, Map<String, String>> convertValueMap = getConvertValueMap(dataDirectory);
final Map<String, String> defaultValueMap = getDefaultValueMap(dataDirectory);
// so it does not need to convert here
if (// no convert
(convertValueMap == null || convertValueMap.isEmpty()) && (defaultValueMap == null || defaultValueMap.isEmpty())) {
// and no default
return;
}
final DfColumnValueConverter converter = new DfColumnValueConverter(convertValueMap, defaultValueMap, new DfColumnBindTypeProvider() {
public Class<?> provide(String tableName, DfColumnMeta columnMeta) {
return getBindType(tableName, columnMeta);
}
});
converter.convert(tableName, columnValueMap, columnMetaMap);
}
use of org.dbflute.logic.jdbc.metadata.info.DfColumnMeta in project dbflute-core by dbflute.
the class DfXlsDataHandlerImpl method filterValidColumn.
protected void filterValidColumn(final DfDataSet dataSet) {
for (int i = 0; i < dataSet.getTableSize(); i++) {
final DfDataTable table = dataSet.getTable(i);
final String tableName = table.getTableDbName();
final Map<String, DfColumnMeta> metaMetaMap = getColumnMetaMap(tableName);
for (int j = 0; j < table.getColumnSize(); j++) {
final DfDataColumn dataColumn = table.getColumn(j);
if (!metaMetaMap.containsKey(dataColumn.getColumnDbName())) {
dataColumn.setWritable(false);
}
}
}
}
use of org.dbflute.logic.jdbc.metadata.info.DfColumnMeta in project dbflute-core by dbflute.
the class DfXlsDataHandlerImplTest method test_processBoolean.
// -----------------------------------------------------
// Boolean
// -------
public void test_processBoolean() throws Exception {
// ## Arrange ##
final DfXlsDataHandlerImpl impl = new DfXlsDataHandlerImpl(null, null) {
@Override
protected Class<?> getBindType(String tableName, DfColumnMeta columnMetaInfo) {
return BigDecimal.class;
}
};
Map<String, DfColumnMeta> columnMetaInfoMap = StringKeyMap.createAsCaseInsensitive();
DfColumnMeta info = new DfColumnMeta();
info.setColumnName("foo");
info.setColumnSize(3);
info.setJdbcDefValue(Types.NUMERIC);
columnMetaInfoMap.put("foo", info);
// ## Act ##
boolean actual = impl.processBoolean("tbl", "foo", "0", null, null, 0, columnMetaInfoMap, 3);
// ## Assert ##
log("actual=" + actual);
assertFalse(actual);
}
Aggregations