Search in sources :

Example 1 with DfDataTable

use of org.dbflute.helper.dataset.DfDataTable in project dbflute-core by dbflute.

the class DfLReverseOutputHandler method setupXlsDataTable.

// ===================================================================================
// Xls Data
// ========
protected void setupXlsDataTable(DfDataSet dataSet, Table table, List<Map<String, String>> extractedList, int sheetNumber, List<String> sectionInfoList) {
    final List<Map<String, String>> recordList;
    {
        final String tableInfo = "  " + table.getTableDispName() + " (" + extractedList.size() + ")";
        _log.info(tableInfo);
        sectionInfoList.add(tableInfo);
        if (extractedList.size() > _xlsLimit) {
            // just in case
            recordList = extractedList.subList(0, _xlsLimit);
        } else {
            recordList = extractedList;
        }
    }
    final DfDataTable dataTable = new DfDataTable(resolveSheetName(table, sheetNumber));
    final List<Column> columnList = table.getColumnList();
    for (Column column : columnList) {
        if (isExceptCommonColumn(column)) {
            continue;
        }
        dataTable.addColumn(column.getName(), DfDtsColumnTypes.STRING);
    }
    for (Map<String, String> recordMap : recordList) {
        final Set<String> columnNameSet = recordMap.keySet();
        final DfDataRow dataRow = dataTable.addRow();
        for (String columnName : columnNameSet) {
            if (!dataTable.hasColumn(columnName)) {
                // basically excepted common columns
                continue;
            }
            final String value = recordMap.get(columnName);
            dataRow.addValue(columnName, value);
        }
    }
    dataSet.addTable(dataTable);
}
Also used : Column(org.apache.torque.engine.database.model.Column) DfDataTable(org.dbflute.helper.dataset.DfDataTable) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) DfDataRow(org.dbflute.helper.dataset.DfDataRow)

Example 2 with DfDataTable

use of org.dbflute.helper.dataset.DfDataTable in project dbflute-core by dbflute.

the class DfXlsDataHandlerImpl method doWriteDataSet.

// -----------------------------------------------------
// DataSet
// -------
protected void doWriteDataSet(DfXlsDataResource resource, File file, DfDataSet dataSet, StringBuilder msgSb) {
    msgSb.append(ln()).append(ln()).append("[").append(file.getName()).append("]");
    for (int i = 0; i < dataSet.getTableSize(); i++) {
        final DfDataTable dataTable = dataSet.getTable(i);
        final int loadedCount = doWriteDataTable(resource, file, dataTable);
        msgSb.append(ln()).append("  ").append(dataTable.getTableDbName()).append(" (").append(loadedCount).append(")");
    }
}
Also used : DfDataTable(org.dbflute.helper.dataset.DfDataTable)

Example 3 with DfDataTable

use of org.dbflute.helper.dataset.DfDataTable in project dbflute-core by dbflute.

the class DfXlsDataHandlerImpl 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);
            }
        }
    }
}
Also used : DfColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfColumnMeta) DfDataColumn(org.dbflute.helper.dataset.DfDataColumn) DfDataTable(org.dbflute.helper.dataset.DfDataTable)

Example 4 with DfDataTable

use of org.dbflute.helper.dataset.DfDataTable 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);
            }
        }
    }
}
Also used : DfColumnMeta(org.dbflute.logic.jdbc.metadata.info.DfColumnMeta) DfDataColumn(org.dbflute.helper.dataset.DfDataColumn) DfDataTable(org.dbflute.helper.dataset.DfDataTable)

Example 5 with DfDataTable

use of org.dbflute.helper.dataset.DfDataTable in project dbflute-core by dbflute.

the class DfXlsDataHandlingWriter method doWriteDataSet.

// -----------------------------------------------------
// DataSet
// -------
protected void doWriteDataSet(DfXlsDataResource resource, File file, DfDataSet dataSet, StringBuilder msgSb) {
    msgSb.append(ln()).append(ln()).append("[").append(file.getName()).append("]");
    for (int i = 0; i < dataSet.getTableSize(); i++) {
        final DfDataTable dataTable = dataSet.getTable(i);
        final int loadedCount = doWriteDataTable(resource, file, dataTable);
        msgSb.append(ln()).append("  ").append(dataTable.getTableDbName()).append(" (").append(loadedCount).append(")");
    }
}
Also used : DfDataTable(org.dbflute.helper.dataset.DfDataTable)

Aggregations

DfDataTable (org.dbflute.helper.dataset.DfDataTable)19 DfDataColumn (org.dbflute.helper.dataset.DfDataColumn)9 DfDataRow (org.dbflute.helper.dataset.DfDataRow)9 File (java.io.File)5 ArrayList (java.util.ArrayList)5 DfDataSet (org.dbflute.helper.dataset.DfDataSet)5 DfColumnMeta (org.dbflute.logic.jdbc.metadata.info.DfColumnMeta)4 RichTextString (org.apache.poi.ss.usermodel.RichTextString)3 LinkedHashMap (java.util.LinkedHashMap)2 List (java.util.List)2 Map (java.util.Map)2 Sheet (org.apache.poi.ss.usermodel.Sheet)2 Column (org.apache.torque.engine.database.model.Column)2 DfDtsColumnType (org.dbflute.helper.dataset.types.DfDtsColumnType)2 DfTableXlsReader (org.dbflute.helper.io.xls.DfTableXlsReader)2 Cell (org.apache.poi.ss.usermodel.Cell)1 Row (org.apache.poi.ss.usermodel.Row)1