@Override public GuidedDecisionTableUiCell convertCell( final DTCellValue52 cell, final BaseColumn column, final CellUtilities cellUtilities, final ColumnUtilities columnUtilities) { // If the underlying modelCell does not have a value don't create a UiModelCell. The // underlying model data is fully populated whereas the uiModel is sparsely populated. if (!cell.hasValue()) { return null; } final DataType.DataTypes dataType = columnUtilities.getDataType(column); cellUtilities.convertDTCellValueType(dataType, cell); switch (dataType) { case NUMERIC: return new GuidedDecisionTableUiCell<Number>(cell.getNumericValue(), cell.isOtherwise()); case NUMERIC_BIGDECIMAL: return new GuidedDecisionTableUiCell<BigDecimal>( (BigDecimal) cell.getNumericValue(), cell.isOtherwise()); case NUMERIC_BIGINTEGER: return new GuidedDecisionTableUiCell<BigInteger>( (BigInteger) cell.getNumericValue(), cell.isOtherwise()); case NUMERIC_BYTE: return new GuidedDecisionTableUiCell<Byte>( (Byte) cell.getNumericValue(), cell.isOtherwise()); case NUMERIC_DOUBLE: return new GuidedDecisionTableUiCell<Double>( (Double) cell.getNumericValue(), cell.isOtherwise()); case NUMERIC_FLOAT: return new GuidedDecisionTableUiCell<Float>( (Float) cell.getNumericValue(), cell.isOtherwise()); case NUMERIC_INTEGER: return new GuidedDecisionTableUiCell<Integer>( (Integer) cell.getNumericValue(), cell.isOtherwise()); case NUMERIC_LONG: return new GuidedDecisionTableUiCell<Long>( (Long) cell.getNumericValue(), cell.isOtherwise()); case NUMERIC_SHORT: return new GuidedDecisionTableUiCell<Short>( (Short) cell.getNumericValue(), cell.isOtherwise()); case DATE: return new GuidedDecisionTableUiCell<Date>(cell.getDateValue(), cell.isOtherwise()); case BOOLEAN: return new GuidedDecisionTableUiCell<Boolean>(cell.getBooleanValue(), cell.isOtherwise()); default: return new GuidedDecisionTableUiCell<String>(cell.getStringValue(), cell.isOtherwise()); } }
/** * Convert a Model cell to one that can be used in the UI * * @param dcv * @return */ @Override public CellValue<? extends Comparable<?>> convertModelCellValue( BaseColumn column, DTCellValue52 dcv) { // Analysis cells do not use data-type if (column instanceof AnalysisCol52) { return makeNewAnalysisCellValue(); } // Other cells do use data-type DataType.DataTypes dataType = utilities.getDataType(column); utilities.assertDTCellValue(dataType, dcv); CellValue<? extends Comparable<?>> cell = null; switch (dataType) { case BOOLEAN: cell = makeNewBooleanCellValue(dcv.getBooleanValue()); break; case DATE: cell = makeNewDateCellValue(dcv.getDateValue()); break; case NUMERIC: cell = makeNewNumericCellValue((BigDecimal) dcv.getNumericValue()); break; case NUMERIC_BIGDECIMAL: cell = makeNewBigDecimalCellValue((BigDecimal) dcv.getNumericValue()); break; case NUMERIC_BIGINTEGER: cell = makeNewBigIntegerCellValue((BigInteger) dcv.getNumericValue()); break; case NUMERIC_BYTE: cell = makeNewByteCellValue((Byte) dcv.getNumericValue()); break; case NUMERIC_DOUBLE: cell = makeNewDoubleCellValue((Double) dcv.getNumericValue()); break; case NUMERIC_FLOAT: cell = makeNewFloatCellValue((Float) dcv.getNumericValue()); break; case NUMERIC_INTEGER: cell = makeNewIntegerCellValue((Integer) dcv.getNumericValue()); break; case NUMERIC_LONG: if (column instanceof RowNumberCol52) { cell = makeNewRowNumberCellValue((Long) dcv.getNumericValue()); } else { cell = makeNewLongCellValue((Long) dcv.getNumericValue()); if (column instanceof AttributeCol52) { AttributeCol52 at = (AttributeCol52) column; if (at.getAttribute().equals(RuleAttributeWidget.SALIENCE_ATTR)) { if (at.isUseRowNumber()) { cell = makeNewRowNumberCellValue((Long) dcv.getNumericValue()); } } } } break; case NUMERIC_SHORT: cell = makeNewShortCellValue((Short) dcv.getNumericValue()); break; default: cell = makeNewStringCellValue(dcv.getStringValue()); if (column instanceof AttributeCol52) { AttributeCol52 ac = (AttributeCol52) column; if (ac.getAttribute().equals(RuleAttributeWidget.DIALECT_ATTR)) { cell = makeNewDialectCellValue(dcv.getStringValue()); } } } if (dcv.isOtherwise()) { cell.addState(CellState.OTHERWISE); } return cell; }