Search in sources :

Example 6 with DataType

use of org.kie.soup.project.datamodel.oracle.DataType in project drools-wb by kiegroup.

the class BRLConditionColumnDefinitionBuilder method makeRowData.

private List<DTCellValue52> makeRowData(final ColumnUtilities columnUtilities, final BRLConditionColumn brlColumn) {
    final List<DTCellValue52> row = new ArrayList<>();
    row.add(new DTCellValue52(1));
    row.add(new DTCellValue52("desc"));
    for (BRLConditionVariableColumn brlVariableColumn : brlColumn.getChildColumns()) {
        final DataType.DataTypes dataType = columnUtilities.getDataType(brlVariableColumn);
        row.add(makeCell(dataType));
    }
    return row;
}
Also used : ArrayList(java.util.ArrayList) DataType(org.kie.soup.project.datamodel.oracle.DataType) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)

Example 7 with DataType

use of org.kie.soup.project.datamodel.oracle.DataType in project drools-wb by kiegroup.

the class BaseColumnDefinitionBuilder method makeRowData.

protected List<DTCellValue52> makeRowData(final ColumnUtilities columnUtilities, final BaseColumn column) {
    final List<DTCellValue52> row = new ArrayList<>();
    row.add(new DTCellValue52(1));
    row.add(new DTCellValue52("desc"));
    final DataType.DataTypes dataType = columnUtilities.getDataType(column);
    row.add(makeCell(dataType));
    return row;
}
Also used : ArrayList(java.util.ArrayList) DataType(org.kie.soup.project.datamodel.oracle.DataType) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Example 8 with DataType

use of org.kie.soup.project.datamodel.oracle.DataType in project drools-wb by kiegroup.

the class BaseSynchronizer method makeModelCellValue.

protected DTCellValue52 makeModelCellValue(final BaseColumn modelColumn) {
    DTCellValue52 dcv;
    final DTCellValue52 defaultValue = modelColumn.getDefaultValue();
    final DataType.DataTypes dataType = columnUtilities.getDataType(modelColumn);
    if (modelColumn instanceof LimitedEntryCol) {
        dcv = new DTCellValue52(Boolean.FALSE);
    } else if (dataType == DataType.DataTypes.BOOLEAN) {
        if (defaultValue == null) {
            dcv = new DTCellValue52(false);
        } else if (defaultValue.getBooleanValue() == null) {
            dcv = new DTCellValue52(false);
        } else {
            dcv = new DTCellValue52(defaultValue.getBooleanValue());
        }
    } else {
        dcv = new DTCellValue52(defaultValue);
    }
    cellUtilities.convertDTCellValueType(dataType, dcv);
    return dcv;
}
Also used : DataType(org.kie.soup.project.datamodel.oracle.DataType) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) LimitedEntryCol(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryCol)

Example 9 with DataType

use of org.kie.soup.project.datamodel.oracle.DataType in project drools-wb by kiegroup.

the class TemplateDataCellValueFactory method convertModelCellValue.

/**
 * Convert a Model cell to one that can be used in the UI
 *
 * @param column
 * @param dcv
 * @return
 */
@Override
public CellValue<? extends Comparable<?>> convertModelCellValue(TemplateDataColumn column, String dcv) {
    DataType.DataTypes dataType = getDataType(column);
    CellValue<? extends Comparable<?>> cell = null;
    switch(dataType) {
        case BOOLEAN:
            Boolean b = Boolean.FALSE;
            try {
                b = Boolean.valueOf(dcv);
            } catch (Exception e) {
            }
            cell = makeNewBooleanCellValue(b);
            break;
        case DATE:
            Date d = null;
            try {
                if (DATE_CONVERTOR == null) {
                    throw new IllegalArgumentException("DATE_CONVERTOR has not been initialised.");
                }
                d = DATE_CONVERTOR.parse(dcv);
            } catch (Exception e) {
            }
            cell = makeNewDateCellValue(d);
            break;
        case NUMERIC:
            BigDecimal numericValue = null;
            try {
                numericValue = new BigDecimal(dcv);
            } catch (Exception e) {
            }
            cell = makeNewNumericCellValue(numericValue);
            break;
        case NUMERIC_BIGDECIMAL:
            BigDecimal bigDecimalValue = null;
            try {
                bigDecimalValue = new BigDecimal(dcv);
            } catch (Exception e) {
            }
            cell = makeNewBigDecimalCellValue(bigDecimalValue);
            break;
        case NUMERIC_BIGINTEGER:
            BigInteger bigIntegerValue = null;
            try {
                bigIntegerValue = new BigInteger(dcv);
            } catch (Exception e) {
            }
            cell = makeNewBigIntegerCellValue(bigIntegerValue);
            break;
        case NUMERIC_BYTE:
            Byte byteValue = null;
            try {
                byteValue = Byte.valueOf(dcv);
            } catch (Exception e) {
            }
            cell = makeNewByteCellValue(byteValue);
            break;
        case NUMERIC_DOUBLE:
            Double doubleValue = null;
            try {
                doubleValue = new Double(dcv);
            } catch (Exception e) {
            }
            cell = makeNewDoubleCellValue(doubleValue);
            break;
        case NUMERIC_FLOAT:
            Float floatValue = null;
            try {
                floatValue = new Float(dcv);
            } catch (Exception e) {
            }
            cell = makeNewFloatCellValue(floatValue);
            break;
        case NUMERIC_INTEGER:
            Integer integerValue = null;
            try {
                integerValue = Integer.valueOf(dcv);
            } catch (Exception e) {
            }
            cell = makeNewIntegerCellValue(integerValue);
            break;
        case NUMERIC_LONG:
            Long longValue = null;
            try {
                longValue = Long.valueOf(dcv);
            } catch (Exception e) {
            }
            cell = makeNewLongCellValue(longValue);
            break;
        case NUMERIC_SHORT:
            Short shortValue = null;
            try {
                shortValue = Short.valueOf(dcv);
            } catch (Exception e) {
            }
            cell = makeNewShortCellValue(shortValue);
            break;
        default:
            cell = makeNewStringCellValue(dcv);
    }
    return cell;
}
Also used : Date(java.util.Date) BigDecimal(java.math.BigDecimal) BigInteger(java.math.BigInteger) DataType(org.kie.soup.project.datamodel.oracle.DataType) BigInteger(java.math.BigInteger)

Example 10 with DataType

use of org.kie.soup.project.datamodel.oracle.DataType in project drools-wb by kiegroup.

the class AnalyzerUpdateTestBase method newRow.

private ArrayList<DTCellValue52> newRow(final DataType.DataTypes[] dataTypes) {
    final ArrayList<DTCellValue52> row = new ArrayList<>();
    // Row number
    row.add(new DTCellValue52());
    // Explanation
    row.add(new DTCellValue52());
    for (final DataType.DataTypes dataType : dataTypes) {
        row.add(new DTCellValue52(dataType, true));
    }
    return row;
}
Also used : ArrayList(java.util.ArrayList) DataType(org.kie.soup.project.datamodel.oracle.DataType) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Aggregations

DataType (org.kie.soup.project.datamodel.oracle.DataType)10 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)9 ArrayList (java.util.ArrayList)4 BigDecimal (java.math.BigDecimal)1 BigInteger (java.math.BigInteger)1 Date (java.util.Date)1 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)1 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)1 LimitedEntryCol (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryCol)1 CellUtilities (org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.CellUtilities)1 ColumnUtilities (org.drools.workbench.screens.guided.dtable.client.widget.table.utilities.ColumnUtilities)1 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)1