use of org.dbflute.logic.jdbc.metadata.info.DfColumnMeta in project dbflute-core by dbflute.
the class DfLoadingControlProp method resolveRelativeDate.
// ===================================================================================
// Date Adjustment
// ===============
public void resolveRelativeDate(String dataDirectory, String tableName, Map<String, Object> columnValueMap, Map<String, DfColumnMeta> columnMetaMap, Set<String> sysdateColumnSet, DfColumnBindTypeProvider bindTypeProvider, int rowNumber) {
// was born at LUXA
if (!hasDateAdjustment(dataDirectory, tableName)) {
return;
}
final Map<String, Object> resolvedMap = new HashMap<String, Object>();
for (Entry<String, Object> entry : columnValueMap.entrySet()) {
final String columnName = entry.getKey();
if (isSysdateColumn(sysdateColumnSet, columnName)) {
// keep sysdate as default value
continue;
}
final Object value = entry.getValue();
if (value == null) {
continue;
}
if (!isDateAdjustmentAllowedValueType(value)) {
// out of target type
continue;
}
if (!hasDateAdjustmentExp(dataDirectory, tableName, columnName)) {
// no-adjustment column
continue;
}
final DfColumnMeta columnMeta = columnMetaMap.get(columnName);
final Class<?> bindType = bindTypeProvider.provide(tableName, columnMeta);
if (bindType == null) {
// unknown column type
continue;
}
if (!isDateAdjustmentAllowedBindType(dataDirectory, tableName, columnName, bindType)) {
// cannot be date
continue;
}
final String dateExp = toAdjustedResourceDateExp(tableName, columnName, bindType, value);
if (dateExp == null) {
// e.g. wrong value
continue;
}
final String adjusted = adjustDateIfNeeds(dataDirectory, tableName, columnName, dateExp, rowNumber);
resolvedMap.put(columnName, convertAdjustedValueToDateType(tableName, columnName, bindType, adjusted));
}
for (Entry<String, Object> entry : resolvedMap.entrySet()) {
// to keep original map instance
columnValueMap.put(entry.getKey(), entry.getValue());
}
}
use of org.dbflute.logic.jdbc.metadata.info.DfColumnMeta in project dbflute-core by dbflute.
the class DfAbsractDataWriter method processXml.
// -----------------------------------------------------
// XML
// ---
protected boolean processXml(String tableName, String columnName, String value, PreparedStatement ps, int bindCount, Map<String, DfColumnMeta> columnInfoMap, int rowNumber) throws SQLException {
if (value == null || value.trim().length() == 0) {
// cannot be XML
return false;
}
final DfColumnMeta columnInfo = columnInfoMap.get(columnName);
if (columnInfo != null) {
if (getBasicProperties().isDatabasePostgreSQL()) {
final String dbTypeName = columnInfo.getDbTypeName();
if (!dbTypeName.startsWith("xml")) {
return false;
}
value = filterXmlValue(value);
ps.setObject(bindCount, value, Types.OTHER);
return true;
}
}
// unsupported when meta data is not found
return false;
}
use of org.dbflute.logic.jdbc.metadata.info.DfColumnMeta in project dbflute-core by dbflute.
the class DfAbsractDataWriter method processNotNullNotString.
// -----------------------------------------------------
// NotNull NotString
// -----------------
protected boolean processNotNullNotString(String dataDirectory, String tableName, String columnName, Object obj, Connection conn, PreparedStatement ps, int bindCount, Map<String, DfColumnMeta> columnInfoMap, int rowNumber) throws SQLException {
if (!isNotNullNotString(obj)) {
return false;
}
final DfColumnMeta columnInfo = columnInfoMap.get(columnName);
if (columnInfo != null) {
final Class<?> columnType = getBindType(tableName, columnInfo);
if (columnType != null) {
bindNotNullValueByColumnType(tableName, columnName, conn, ps, bindCount, obj, columnType, rowNumber);
return true;
}
}
bindNotNullValueByInstance(tableName, columnName, conn, ps, bindCount, obj, rowNumber);
return true;
}
use of org.dbflute.logic.jdbc.metadata.info.DfColumnMeta in project dbflute-core by dbflute.
the class DfAbsractDataWriter method processArray.
// -----------------------------------------------------
// ARRAY
// -----
protected boolean processArray(String tableName, String columnName, String value, PreparedStatement ps, int bindCount, Map<String, DfColumnMeta> columnInfoMap, int rowNumber) throws SQLException {
if (value == null || value.trim().length() == 0) {
// cannot be array
return false;
}
final DfColumnMeta columnInfo = columnInfoMap.get(columnName);
if (columnInfo != null) {
if (getBasicProperties().isDatabasePostgreSQL()) {
// rsMeta#getColumnTypeName() returns value starts with "_" if
// rsMeta#getColumnType() returns Types.ARRAY in PostgreSQL.
// e.g. UUID[] -> _uuid
final int jdbcDefValue = columnInfo.getJdbcDefValue();
final String dbTypeName = columnInfo.getDbTypeName();
if (jdbcDefValue != Types.ARRAY || !dbTypeName.startsWith("_")) {
return false;
}
value = filterArrayValue(value);
ps.setObject(bindCount, value, Types.OTHER);
return true;
}
}
// unsupported when meta data is not found
return false;
}
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