Search in sources :

Example 1 with DfDataColumn

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

the class DfXlsDataHandlerImpl method throwXlsDataColumnDefFailureException.

protected void throwXlsDataColumnDefFailureException(String dataDirectory, File file, DfDataTable dataTable) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The table specified on the xls file does not have (writable) columns.");
    br.addItem("Advice");
    br.addElement("Please confirm the column names about their spellings.");
    br.addElement("And confirm the column definition of the table.");
    // suppress duplicated info (show these elements in failure exception later)
    // br.addItem("Data Directory");
    // br.addElement(dataDirectory);
    // br.addItem("Xls File");
    // br.addElement(file);
    br.addItem("Table");
    br.addElement(dataTable.getTableDbName());
    br.addItem("Defined Column");
    final int columnSize = dataTable.getColumnSize();
    if (columnSize > 0) {
        for (int i = 0; i < dataTable.getColumnSize(); i++) {
            final DfDataColumn dataColumn = dataTable.getColumn(i);
            br.addElement(dataColumn.getColumnDbName());
        }
    } else {
        br.addElement("(no column)");
    }
    final String msg = br.buildExceptionMessage();
    throw new DfXlsDataEmptyColumnDefException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfDataColumn(org.dbflute.helper.dataset.DfDataColumn) DfXlsDataEmptyColumnDefException(org.dbflute.exception.DfXlsDataEmptyColumnDefException)

Example 2 with DfDataColumn

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

the class DfXlsDataHandlerImpl method extractColumnNameList.

protected List<String> extractColumnNameList(DfDataTable dataTable) {
    // for small function
    final List<String> columnNameList = new ArrayList<String>();
    for (int i = 0; i < dataTable.getColumnSize(); i++) {
        final DfDataColumn dataColumn = dataTable.getColumn(i);
        if (!dataColumn.isWritable()) {
            continue;
        }
        final String columnName = dataColumn.getColumnDbName();
        columnNameList.add(columnName);
    }
    return columnNameList;
}
Also used : DfDataColumn(org.dbflute.helper.dataset.DfDataColumn) ArrayList(java.util.ArrayList)

Example 3 with DfDataColumn

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

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

Example 4 with DfDataColumn

use of org.dbflute.helper.dataset.DfDataColumn 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 5 with DfDataColumn

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

the class DfXlsDataWritingExceptionThrower method throwXlsDataColumnDefFailureException.

// -----------------------------------------------------
// Column Definition
// -----------------
public void throwXlsDataColumnDefFailureException(String dataDirectory, File file, DfDataTable dataTable) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The table specified on the xls file does not have (writable) columns.");
    br.addItem("Advice");
    br.addElement("Please confirm the column names about their spellings.");
    br.addElement("And confirm the column definition of the table.");
    // suppress duplicated info (show these elements in failure exception later)
    // br.addItem("Data Directory");
    // br.addElement(dataDirectory);
    // br.addItem("Xls File");
    // br.addElement(file);
    br.addItem("Table");
    br.addElement(dataTable.getTableDbName());
    br.addItem("Defined Column");
    final int columnSize = dataTable.getColumnSize();
    if (columnSize > 0) {
        for (int i = 0; i < dataTable.getColumnSize(); i++) {
            final DfDataColumn dataColumn = dataTable.getColumn(i);
            br.addElement(dataColumn.getColumnDbName());
        }
    } else {
        br.addElement("(no column)");
    }
    final String msg = br.buildExceptionMessage();
    throw new DfXlsDataEmptyColumnDefException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfDataColumn(org.dbflute.helper.dataset.DfDataColumn) DfXlsDataEmptyColumnDefException(org.dbflute.exception.DfXlsDataEmptyColumnDefException)

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