Search in sources :

Example 16 with DfDataColumn

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);
}
Also used : DfDataColumn(org.dbflute.helper.dataset.DfDataColumn) ArrayList(java.util.ArrayList) DfDataTable(org.dbflute.helper.dataset.DfDataTable)

Example 17 with DfDataColumn

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;
}
Also used : DfDataColumn(org.dbflute.helper.dataset.DfDataColumn) RichTextString(org.apache.poi.ss.usermodel.RichTextString)

Example 18 with DfDataColumn

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;
}
Also used : DfDataColumn(org.dbflute.helper.dataset.DfDataColumn) List(java.util.List) RichTextString(org.apache.poi.ss.usermodel.RichTextString)

Example 19 with DfDataColumn

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;
}
Also used : DfDataColumn(org.dbflute.helper.dataset.DfDataColumn) RichTextString(org.apache.poi.ss.usermodel.RichTextString)

Example 20 with DfDataColumn

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);
    }
}
Also used : DfDataColumn(org.dbflute.helper.dataset.DfDataColumn) RichTextString(org.apache.poi.ss.usermodel.RichTextString) DfDataRow(org.dbflute.helper.dataset.DfDataRow) Cell(org.apache.poi.ss.usermodel.Cell)

Aggregations

DfDataColumn (org.dbflute.helper.dataset.DfDataColumn)22 DfDataTable (org.dbflute.helper.dataset.DfDataTable)9 ArrayList (java.util.ArrayList)7 RichTextString (org.apache.poi.ss.usermodel.RichTextString)6 DfDataRow (org.dbflute.helper.dataset.DfDataRow)5 File (java.io.File)3 DfDataSet (org.dbflute.helper.dataset.DfDataSet)3 DfXlsDataEmptyColumnDefException (org.dbflute.exception.DfXlsDataEmptyColumnDefException)2 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)2 DfColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfColumnMeta)2 List (java.util.List)1 Cell (org.apache.poi.ss.usermodel.Cell)1 Sheet (org.apache.poi.ss.usermodel.Sheet)1 ScopeInfo (org.dbflute.util.Srl.ScopeInfo)1