use of org.dbflute.helper.dataset.DfDataColumn in project dbflute-core by dbflute.
the class DfXlsDataHandlingWriter 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.helper.dataset.DfDataColumn in project dbflute-core by dbflute.
the class DfXlsDataHandlingWriter method checkHeaderColumnIfNeeds.
protected void checkHeaderColumnIfNeeds(DfXlsDataResource resource, File file, DfDataTable dataTable, Map<String, DfColumnMeta> columnMetaMap) {
final String dataDirectory = resource.getDataDirectory();
if (!isCheckColumnDef(dataDirectory)) {
return;
}
final List<String> columnDefNameList = new ArrayList<String>();
for (int i = 0; i < dataTable.getColumnSize(); i++) {
// all columns are target
final DfDataColumn dataColumn = dataTable.getColumn(i);
final String columnName = dataColumn.getColumnDbName();
columnDefNameList.add(columnName);
}
// use columnMetaMap to check (not use DataTable's meta data here)
// at old age, columnMetaMap is not required but required now
checkColumnDef(file, dataTable.getTableDbName(), columnDefNameList, columnMetaMap);
}
use of org.dbflute.helper.dataset.DfDataColumn in project dbflute-core by dbflute.
the class DfXlsDataHandlingWriter method createColumnContainer.
// ===================================================================================
// Column Container
// ================
protected ColumnContainer createColumnContainer(DfDataTable dataTable, DfDataRow dataRow) {
final ColumnContainer container = new ColumnContainer();
for (int i = 0; i < dataTable.getColumnSize(); i++) {
final DfDataColumn dataColumn = dataTable.getColumn(i);
if (!dataColumn.isWritable()) {
continue;
}
final Object columnValue = dataRow.getValue(i);
final String columnName = dataColumn.getColumnDbName();
container.addColumnValue(columnName, columnValue);
container.addColumnObject(columnName, dataColumn);
}
return container;
}
use of org.dbflute.helper.dataset.DfDataColumn in project dbflute-core by dbflute.
the class DfTableXlsReaderTest method test_read_basic.
// ===================================================================================
// Basic Read
// ==========
public void test_read_basic() throws IOException {
// ## Arrange ##
final File xlsFile = prepareTestBasicXlsFile();
final DfTableXlsReader reader = createTableXlsReader(xlsFile, null, false);
// ## Act ##
final DfDataSet dataSet = reader.read();
// ## Assert ##
log("[DataSet]:" + ln() + dataSet);
final int tableSize = dataSet.getTableSize();
assertTrue(tableSize > 0);
for (int tableIndex = 0; tableIndex < tableSize; tableIndex++) {
final DfDataTable table = dataSet.getTable(tableIndex);
final int columnSize = table.getColumnSize();
assertTrue(columnSize > 0);
final int rowSize = table.getRowSize();
assertTrue(rowSize > 0);
for (int rowIndex = 0; rowIndex < rowSize; rowIndex++) {
final DfDataRow row = table.getRow(rowIndex);
for (int columnIndex = 0; columnIndex < columnSize; columnIndex++) {
final DfDataColumn column = table.getColumn(columnIndex);
final String columnDbName = column.getColumnDbName();
final Object value = row.getValue(columnDbName);
if (columnDbName.equals("AAA")) {
assertNotNull(value);
} else if (columnDbName.equals("BBB")) {
markHere("nullBBB");
} else if (columnDbName.equals("CCC")) {
assertNotNull(value);
} else if (columnDbName.equals("DDD")) {
assertNotNull(value);
String str = (String) value;
if (str.length() > str.trim().length()) {
markHere("trimmed_DDD");
}
} else if (columnDbName.equals("EEE")) {
assertNotNull(value);
String str = (String) value;
if (str.length() > str.trim().length()) {
markHere("trimmed_EEE");
}
}
}
}
}
assertMarked("nullBBB");
assertMarked("trimmed_DDD");
assertMarked("trimmed_EEE");
}
use of org.dbflute.helper.dataset.DfDataColumn in project dbflute-core by dbflute.
the class DfTableXlsReaderTest method test_read_largeData.
// ===================================================================================
// Large Data
// ==========
public void test_read_largeData() throws IOException {
// ## Arrange ##
final File xlsFile = prepareTestLargeDataXlsFile();
final DfTableXlsReader reader = createTableXlsReader(xlsFile, null, false);
// ## Act ##
final DfDataSet dataSet = reader.read();
// ## Assert ##
log("[DataSet]:" + ln() + dataSet);
final String expected1stFoo = "large 1st foo second row";
final String expected2ndFoo = "large 2nd foo";
final String expected2ndBar = "large 2nd bar&second row more row starts with space ends with space {brace}{brace} terminal row ";
int tableSize = dataSet.getTableSize();
assertTrue(tableSize > 0);
for (int tableIndex = 0; tableIndex < tableSize; tableIndex++) {
final DfDataTable table = dataSet.getTable(tableIndex);
final String tableDbName = table.getTableDbName();
log("[" + tableDbName + "]");
final int columnSize = table.getColumnSize();
final int rowSize = table.getRowSize();
for (int rowIndex = 0; rowIndex < rowSize; rowIndex++) {
final DfDataRow row = table.getRow(rowIndex);
log("(" + row.getRowNumber() + ")");
for (int columnIndex = 0; columnIndex < columnSize; columnIndex++) {
final DfDataColumn column = table.getColumn(columnIndex);
final String columnDbName = column.getColumnDbName();
final Object value = row.getValue(columnDbName);
log(columnDbName + " = " + value);
if (tableDbName.equals("FIRST_TABLE")) {
if (columnDbName.equals("CCC") && value != null && value.equals(expected1stFoo)) {
markHere("expected1stFoo");
}
}
if (tableDbName.equals("SECOND_TABLE")) {
if (columnDbName.equals("BBB") && value != null && value.equals(expected2ndFoo)) {
markHere("expected2ndFoo");
}
if (columnDbName.equals("CCC") && value != null && value.equals(expected2ndBar)) {
markHere("expected2ndBar");
}
}
}
}
}
assertMarked("expected1stFoo");
assertMarked("expected2ndFoo");
assertMarked("expected2ndBar");
String actualExp = dataSet.toString();
assertFalse(actualExp.contains(DfTableXlsReader.LDATA_SHEET_NAME));
assertFalse(actualExp.contains(DfTableXlsReader.LDATA_KEY_DELIMITER));
assertFalse(actualExp.contains(DfTableXlsReader.LDATA_REF_PREFIX));
}
Aggregations