Search in sources :

Example 1 with DfXlsDataEmptyColumnDefException

use of org.dbflute.exception.DfXlsDataEmptyColumnDefException 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 DfXlsDataEmptyColumnDefException

use of org.dbflute.exception.DfXlsDataEmptyColumnDefException 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

DfXlsDataEmptyColumnDefException (org.dbflute.exception.DfXlsDataEmptyColumnDefException)2 DfDataColumn (org.dbflute.helper.dataset.DfDataColumn)2 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)2