Search in sources :

Example 16 with BaseColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.

the class RuleBuilder method resolveColumns.

private void resolveColumns() throws BuildException {
    int columnIndex = 0;
    for (final BaseColumn baseColumn : model.getExpandedColumns()) {
        if (baseColumn instanceof ConditionCol52) {
            final Condition condition = builderFactory.getConditionBuilder().with((ConditionCol52) baseColumn).with(rule).with(row).with(columnIndex).build();
            rule.getConditions().add(condition);
        } else if (baseColumn instanceof ActionCol52) {
            final Action action = builderFactory.getActionBuilder().with(rule).with((ActionCol52) baseColumn).with(row).with(columnIndex).build();
            rule.getActions().add(action);
        }
        columnIndex++;
    }
}
Also used : Condition(org.drools.workbench.services.verifier.api.client.index.Condition) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Action(org.drools.workbench.services.verifier.api.client.index.Action) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)

Example 17 with BaseColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.

the class ModelMetaDataEnhancerTest method conditionCol52Column.

@Test
public void conditionCol52Column() throws Exception {
    final ArrayList<BaseColumn> columns = new ArrayList<>();
    final ConditionCol52 conditionCol52 = new ConditionCol52();
    final Pattern52 pattern52 = new Pattern52();
    columns.add(conditionCol52);
    when(model.getExpandedColumns()).thenReturn(columns);
    when(model.getPattern(conditionCol52)).thenReturn(pattern52);
    final Map<Integer, ModelMetaData> metaData = new ModelMetaDataEnhancer(model).getHeaderMetaData().getPatternsByColumnNumber();
    assertEquals(1, metaData.size());
    assertEquals(pattern52, metaData.get(0).getPattern());
    assertEquals(PatternType.LHS, metaData.get(0).getPatternType());
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ArrayList(java.util.ArrayList) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) ModelMetaData(org.drools.workbench.services.verifier.plugin.client.api.ModelMetaData) Test(org.junit.Test)

Example 18 with BaseColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.

the class DecisionTableAnalyzer method getColumnIndex.

private int getColumnIndex(final BaseColumn baseColumn) {
    List<BaseColumn> cols = model.getExpandedColumns();
    final int indexOf = cols.indexOf(baseColumn);
    if (indexOf < 0) {
        if (baseColumn instanceof BRLConditionColumn) {
            for (final BaseColumn column : model.getExpandedColumns()) {
                if (column instanceof BRLConditionVariableColumn) {
                    if (((BRLConditionColumn) baseColumn).getChildColumns().contains(column)) {
                        return model.getExpandedColumns().indexOf(column);
                    }
                }
            }
            throw new IllegalArgumentException("Could not find BRLConditionColumn: " + baseColumn.toString());
        }
        if (baseColumn instanceof BRLActionColumn) {
            for (final BaseColumn column : model.getExpandedColumns()) {
                if (column instanceof BRLActionVariableColumn) {
                    if (((BRLActionColumn) baseColumn).getChildColumns().contains(column)) {
                        return model.getExpandedColumns().indexOf(column);
                    }
                }
            }
            throw new IllegalArgumentException("Could not find BRLActionColumn: " + baseColumn.toString());
        } else if (baseColumn instanceof BRLVariableColumn) {
            return model.getExpandedColumns().indexOf(model.getBRLColumn((BRLVariableColumn) baseColumn));
        } else {
            throw new IllegalArgumentException("Could not find baseColumn: " + baseColumn.toString());
        }
    } else {
        return indexOf;
    }
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) BRLVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLVariableColumn) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)

Example 19 with BaseColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.

the class GuidedDecisionTablePresenter method initialiseModels.

// Copy Model data to UiModel.
void initialiseModels() {
    initialiseLegacyColumnDataTypes();
    final List<BaseColumn> modelColumns = model.getExpandedColumns();
    for (BaseColumn column : modelColumns) {
        initialiseColumn(column);
    }
    for (List<DTCellValue52> row : model.getData()) {
        initialiseRow(modelColumns, row);
    }
    setOriginalHashCode(model.hashCode());
}
Also used : BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)

Example 20 with BaseColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BaseColumn in project drools-wb by kiegroup.

the class GuidedDecisionTablePresenter method onDeleteSelectedCells.

@Override
public void onDeleteSelectedCells() {
    if (isReadOnly()) {
        return;
    }
    final List<GridData.SelectedCell> selections = uiModel.getSelectedCells();
    if (selections == null || selections.isEmpty()) {
        return;
    }
    for (GridData.SelectedCell sc : selections) {
        final int rowIndex = sc.getRowIndex();
        final int columnIndex = findUiColumnIndex(sc.getColumnIndex());
        final BaseColumn column = model.getExpandedColumns().get(columnIndex);
        final GridColumn<?> uiColumn = uiModel.getColumns().get(columnIndex);
        if (column instanceof RowNumberCol52) {
            continue;
        }
        if (uiColumn instanceof BooleanUiColumn) {
            uiModel.setCellValue(rowIndex, columnIndex, new GuidedDecisionTableUiCell<>(false));
        } else {
            uiModel.deleteCell(rowIndex, columnIndex);
        }
    }
    view.getLayer().draw();
}
Also used : GridData(org.uberfire.ext.wires.core.grids.client.model.GridData) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) BooleanUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)

Aggregations

BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)118 Test (org.junit.Test)69 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)57 ArrayList (java.util.ArrayList)53 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)43 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)30 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)30 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)27 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)25 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)23 List (java.util.List)22 GuidedDTTemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider)20 TemplateDataProvider (org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider)20 CompositeColumn (org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn)20 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)19 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)19 IOException (java.io.IOException)17 InputStream (java.io.InputStream)17 ExcelParser (org.drools.decisiontable.parser.xls.ExcelParser)17 DataListener (org.drools.template.parser.DataListener)17