use of org.dbflute.helper.dataset.DfDataColumn in project dbflute-core by dbflute.
the class DfDtsRemovedState method getSqlContext.
protected DfDtsSqlContext getSqlContext(DfDataRow row) {
final DfDataTable table = row.getTable();
final StringBuffer sb = new StringBuffer(100);
final List<Object> argList = new ArrayList<Object>();
final List<Class<?>> argTypeList = new ArrayList<Class<?>>();
sb.append("delete from ");
sb.append(table.getTableSqlName());
sb.append(" where ");
for (int i = 0; i < table.getColumnSize(); ++i) {
final DfDataColumn column = table.getColumn(i);
if (column.isPrimaryKey()) {
sb.append(column.getColumnSqlName());
sb.append(" = ? and ");
argList.add(row.getValue(i));
argTypeList.add(column.getColumnType().getType());
}
}
sb.setLength(sb.length() - 5);
return createDtsSqlContext(sb.toString(), argList, argTypeList);
}
use of org.dbflute.helper.dataset.DfDataColumn in project dbflute-core by dbflute.
the class DfTableXlsReader method isEmptyStringTarget.
public boolean isEmptyStringTarget(DfDataTable table, int columnIndex) {
final String tableName = table.getTableDbName();
if (!_emptyStringTableColumnMap.containsKey(tableName)) {
return false;
}
final List<String> emptyStringTargetColumnList = _emptyStringTableColumnMap.get(tableName);
final DfDataColumn column = table.getColumn(columnIndex);
final String target = column.getColumnDbName();
for (String specified : emptyStringTargetColumnList) {
if (target.equalsIgnoreCase(specified)) {
return true;
}
}
return false;
}
use of org.dbflute.helper.dataset.DfDataColumn in project dbflute-core by dbflute.
the class DfTableXlsWriter method resolveLargeDataReferenceIfNeeds.
protected String resolveLargeDataReferenceIfNeeds(DfDataTable table, int columnIndex, Row row, String strValue) {
final String mark = "...";
final int splitLength = getCellLengthLimit() - mark.length();
if (strValue != null && strValue.length() > splitLength) {
final String filteredValue;
if (_largeDataHandling) {
if (_largeDataMap == null) {
_largeDataMap = StringKeyMap.createAsFlexibleOrdered();
}
final String tableDbName = table.getTableDbName();
final DfDataColumn column = table.getColumn(columnIndex);
final String columnDbName = column.getColumnDbName();
final String columnTitle = tableDbName + "." + columnDbName;
Map<String, List<String>> dataMap = _largeDataMap.get(columnTitle);
if (dataMap == null) {
dataMap = DfCollectionUtil.newLinkedHashMap();
_largeDataMap.put(columnTitle, dataMap);
}
final String plainKey = columnTitle + ":" + row.getRowNum();
final String dataKey = Integer.toHexString(plainKey.hashCode());
dataMap.put(dataKey, toLargeDataSplitList(strValue));
filteredValue = toLargeDataReferenceExp(dataKey);
} else {
filteredValue = strValue.substring(0, splitLength) + mark;
}
return filteredValue;
}
return strValue;
}
use of org.dbflute.helper.dataset.DfDataColumn in project dbflute-core by dbflute.
the class DfTableXlsReader method isNotTrimTarget.
public boolean isNotTrimTarget(DfDataTable table, Cell cell) {
final String tableName = table.getTableDbName();
if (!_notTrimTableColumnMap.containsKey(tableName)) {
return false;
}
final List<String> notTrimTargetColumnList = _notTrimTableColumnMap.get(tableName);
final DfDataColumn column = table.getColumn(cell.getColumnIndex());
final String target = column.getColumnDbName();
for (String specified : notTrimTargetColumnList) {
if (target.equalsIgnoreCase(specified)) {
return true;
}
}
return false;
}
use of org.dbflute.helper.dataset.DfDataColumn in project dbflute-core by dbflute.
the class DfTableXlsReader method setupRow.
protected void setupRow(DfDataTable table, Row row) {
final DfDataRow dataRow = table.addRow();
Cell cell = null;
Object value = null;
DfDataColumn column = null;
try {
for (int columnIndex = 0; columnIndex < table.getColumnSize(); ++columnIndex) {
cell = row.getCell(columnIndex);
value = extractCellValue(table, columnIndex, row, cell);
column = table.getColumn(columnIndex);
final String columnName = column.getColumnDbName();
try {
dataRow.addValue(columnName, value);
} catch (NumberFormatException e) {
if (cell.getCellType() != Cell.CELL_TYPE_STRING) {
throw e;
}
_log.info("...Changing the column type to STRING type: name=" + columnName + " value=" + value);
column.setColumnType(DfDtsColumnTypes.STRING);
dataRow.addValue(columnName, value);
}
}
} catch (RuntimeException e) {
throwCellValueHandlingException(table, column, row, cell, value, e);
}
}
Aggregations