Search in sources :

Example 1 with DfColumnValueConverter

use of org.dbflute.logic.replaceschema.loaddata.base.secretary.DfColumnValueConverter in project dbflute-core by dbflute.

the class DfXlsDataHandlingWriter 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 DfColumnBindTypeProvider bindTypeProvider = new DfColumnBindTypeProvider() {

        public Class<?> provide(String tableName, DfColumnMeta columnMeta) {
            return getBindType(tableName, columnMeta);
        }
    };
    final DfColumnValueConverter converter = new DfColumnValueConverter(convertValueMap, defaultValueMap, bindTypeProvider);
    converter.convert(tableName, columnValueMap, columnMetaMap);
}
Also used : DfColumnValueConverter(org.dbflute.logic.replaceschema.loaddata.base.secretary.DfColumnValueConverter) DfColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfColumnMeta) DfColumnBindTypeProvider(org.dbflute.logic.replaceschema.loaddata.base.secretary.DfColumnBindTypeProvider) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 2 with DfColumnValueConverter

use of org.dbflute.logic.replaceschema.loaddata.base.secretary.DfColumnValueConverter in project dbflute-core by dbflute.

the class DfDelimiterDataWriteSqlBuilder method convertColumnValueIfNeeds.

protected void convertColumnValueIfNeeds(Map<String, Object> columnValueMap) {
    // because it needs to convert empty string to null
    // if ((_convertValueMap == null || _convertValueMap.isEmpty()) // no convert
    // && (_defaultValueMap == null || _defaultValueMap.isEmpty())) { // and no default
    // return;
    // }
    adjustColumnValueBeforeConvert(columnValueMap);
    final DfColumnValueConverter converter = createColumnValueConverter();
    // for compatible with e.g. $$empty$$ = $$empty$$
    converter.treatEmptyBeforeAsNull();
    converter.convert(_tableDbName, columnValueMap, _columnMetaMap);
}
Also used : DfColumnValueConverter(org.dbflute.logic.replaceschema.loaddata.base.secretary.DfColumnValueConverter)

Aggregations

DfColumnValueConverter (org.dbflute.logic.replaceschema.loaddata.base.secretary.DfColumnValueConverter)2 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1 DfColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfColumnMeta)1 DfColumnBindTypeProvider (org.dbflute.logic.replaceschema.loaddata.base.secretary.DfColumnBindTypeProvider)1