Search in sources :

Example 1 with DfXlsReaderReadFailureException

use of org.dbflute.exception.DfXlsReaderReadFailureException in project dbflute-core by dbflute.

the class DfTableXlsReader method throwXlsReaderMappingTableNotFoundException.

protected void throwXlsReaderMappingTableNotFoundException(String sheetName) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The sheetName was not found in the tableNameMap.");
    br.addItem("Xls File");
    br.addElement(_xlsFile);
    br.addItem("Sheet Name");
    br.addElement(sheetName);
    br.addItem("TableName Map");
    if (!_tableNameMap.isEmpty()) {
        for (Entry<String, String> entry : _tableNameMap.entrySet()) {
            br.addElement(entry.getKey() + " = " + entry.getValue());
        }
    } else {
        br.addElement("*empty");
    }
    final String msg = br.buildExceptionMessage();
    throw new DfXlsReaderReadFailureException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfXlsReaderReadFailureException(org.dbflute.exception.DfXlsReaderReadFailureException) RichTextString(org.apache.poi.ss.usermodel.RichTextString)

Example 2 with DfXlsReaderReadFailureException

use of org.dbflute.exception.DfXlsReaderReadFailureException in project dbflute-core by dbflute.

the class DfTableXlsReader method throwLargeDataReferenceDataNotFoundException.

protected void throwLargeDataReferenceDataNotFoundException(DfDataTable table, int columnIndex, Row row, String str, String dataKey) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Not found the reference data of large data for the column.");
    br.addItem("Xls File");
    br.addElement(_xlsFile);
    br.addItem("Table Name");
    br.addElement(table.getTableDbName());
    br.addItem("Column");
    br.addElement(table.getColumnName(columnIndex));
    br.addItem("Row Number");
    br.addElement(row.getRowNum());
    br.addItem("Cell Value");
    br.addElement(str);
    br.addItem("Data Key");
    br.addElement(dataKey);
    final String msg = br.buildExceptionMessage();
    throw new DfXlsReaderReadFailureException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfXlsReaderReadFailureException(org.dbflute.exception.DfXlsReaderReadFailureException) RichTextString(org.apache.poi.ss.usermodel.RichTextString)

Example 3 with DfXlsReaderReadFailureException

use of org.dbflute.exception.DfXlsReaderReadFailureException in project dbflute-core by dbflute.

the class DfTableXlsReader method throwCellValueHandlingException.

protected void throwCellValueHandlingException(DfDataTable table, DfDataColumn column, Row row, Cell cell, Object value, RuntimeException cause) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Failed to handle the cell value on the xls file.");
    br.addItem("Advice");
    br.addElement("Confirm the exception message.");
    br.addElement("The cell value may be wrong type for the column.");
    br.addElement("So confirm the value on the xls file.");
    br.addItem("RuntimeException");
    br.addElement(cause.getMessage());
    br.addItem("Xls File");
    br.addElement(_xlsFile);
    br.addItem("Table");
    br.addElement(table.getTableDbName());
    br.addItem("Column");
    br.addElement(column != null ? column.getColumnDbName() : null);
    br.addItem("Mapping Type");
    final DfDtsColumnType columnType = column.getColumnType();
    br.addElement(columnType != null ? columnType.getType() : null);
    br.addItem("Cell Type");
    if (cell != null) {
        switch(cell.getCellType()) {
            case Cell.CELL_TYPE_NUMERIC:
                br.addElement("CELL_TYPE_NUMERIC");
                break;
            case Cell.CELL_TYPE_STRING:
                br.addElement("CELL_TYPE_STRING");
                break;
            case Cell.CELL_TYPE_FORMULA:
                br.addElement("CELL_TYPE_FORMULA");
                break;
            case Cell.CELL_TYPE_BLANK:
                br.addElement("CELL_TYPE_BLANK");
                break;
            case Cell.CELL_TYPE_BOOLEAN:
                br.addElement("CELL_TYPE_BOOLEAN");
                break;
            case Cell.CELL_TYPE_ERROR:
                br.addElement("CELL_TYPE_ERROR");
                break;
            default:
                br.addElement(cell.getCellType());
                break;
        }
    }
    br.addItem("Cell Value");
    br.addElement(value);
    br.addItem("Row Number");
    br.addElement(column != null ? row.getRowNum() : null);
    final String msg = br.buildExceptionMessage();
    throw new DfXlsReaderReadFailureException(msg, cause);
}
Also used : DfDtsColumnType(org.dbflute.helper.dataset.types.DfDtsColumnType) ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfXlsReaderReadFailureException(org.dbflute.exception.DfXlsReaderReadFailureException) RichTextString(org.apache.poi.ss.usermodel.RichTextString)

Example 4 with DfXlsReaderReadFailureException

use of org.dbflute.exception.DfXlsReaderReadFailureException in project dbflute-core by dbflute.

the class DfTableXlsReader method throwXlsReaderFirstRowNotColumnDefinitionException.

protected void throwXlsReaderFirstRowNotColumnDefinitionException(String tableName) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The first row of the sheet was not column definition.");
    br.addItem("Xls File");
    br.addElement(_xlsFile);
    br.addItem("Table");
    br.addElement(tableName);
    final String msg = br.buildExceptionMessage();
    throw new DfXlsReaderReadFailureException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfXlsReaderReadFailureException(org.dbflute.exception.DfXlsReaderReadFailureException) RichTextString(org.apache.poi.ss.usermodel.RichTextString)

Example 5 with DfXlsReaderReadFailureException

use of org.dbflute.exception.DfXlsReaderReadFailureException in project dbflute-core by dbflute.

the class DfTableXlsReader method throwLargeDataInvalidColumnTitleException.

protected void throwLargeDataInvalidColumnTitleException(String sheetName, String columnTitle) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Invalid column title for large data.");
    br.addItem("Advice");
    br.addElement("It should be [table].[column] e.g. MEMBER.MEMBER_NAME");
    br.addItem("Xls File");
    br.addElement(_xlsFile);
    br.addItem("Sheet Name");
    br.addElement(sheetName);
    br.addItem("Column Title");
    br.addElement(columnTitle);
    final String msg = br.buildExceptionMessage();
    throw new DfXlsReaderReadFailureException(msg);
}
Also used : ExceptionMessageBuilder(org.dbflute.helper.message.ExceptionMessageBuilder) DfXlsReaderReadFailureException(org.dbflute.exception.DfXlsReaderReadFailureException) RichTextString(org.apache.poi.ss.usermodel.RichTextString)

Aggregations

RichTextString (org.apache.poi.ss.usermodel.RichTextString)6 DfXlsReaderReadFailureException (org.dbflute.exception.DfXlsReaderReadFailureException)6 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)6 DfDtsColumnType (org.dbflute.helper.dataset.types.DfDtsColumnType)1