Search in sources :

Example 1 with LimitedEntryBRLActionColumn

use of org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn in project drools by kiegroup.

the class GuidedDTDRLPersistence method doActions.

void doActions(List<BaseColumn> allColumns, List<ActionCol52> actionCols, TemplateDataProvider rowDataProvider, List<DTCellValue52> row, RuleModel rm) {
    List<LabelledAction> actions = new ArrayList<LabelledAction>();
    for (ActionCol52 c : actionCols) {
        if (c instanceof LimitedEntryBRLActionColumn) {
            doAction(allColumns, (LimitedEntryBRLActionColumn) c, actions, rowDataProvider, row, rm);
        } else if (c instanceof BRLActionColumn) {
            doAction(allColumns, (BRLActionColumn) c, actions, rowDataProvider, row, rm);
        } else {
            int index = allColumns.indexOf(c);
            DTCellValue52 dcv = row.get(index);
            String cell = "";
            if (c instanceof LimitedEntryCol) {
                if (dcv.getBooleanValue() == true) {
                    LimitedEntryCol lec = (LimitedEntryCol) c;
                    cell = GuidedDTDRLUtilities.convertDTCellValueToString(lec.getValue());
                }
            } else {
                cell = GuidedDTDRLUtilities.convertDTCellValueToString(dcv);
            }
            if (validCell(cell, dcv.getDataType())) {
                if (c instanceof ActionWorkItemInsertFactCol52) {
                    doAction(actions, (ActionWorkItemInsertFactCol52) c, cell);
                } else if (c instanceof ActionInsertFactCol52) {
                    doAction(actions, (ActionInsertFactCol52) c, cell);
                } else if (c instanceof ActionWorkItemSetFieldCol52) {
                    doAction(actions, (ActionWorkItemSetFieldCol52) c, cell);
                } else if (c instanceof ActionSetFieldCol52) {
                    doAction(actions, (ActionSetFieldCol52) c, cell);
                } else if (c instanceof ActionRetractFactCol52) {
                    doAction(actions, cell);
                } else if (c instanceof ActionWorkItemCol52) {
                    doAction(actions, (ActionWorkItemCol52) c, cell);
                }
            }
        }
    }
    rm.rhs = new IAction[actions.size()];
    for (int i = 0; i < rm.rhs.length; i++) {
        rm.rhs[i] = actions.get(i).action;
    }
}
Also used : ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) ActionWorkItemInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52) ActionRetractFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52) ActionWorkItemCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ArrayList(java.util.ArrayList) ActionWorkItemSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) ActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52) FieldConstraint(org.drools.workbench.models.datamodel.rule.FieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) LimitedEntryCol(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryCol) LimitedEntryBRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) LimitedEntryBRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn)

Example 2 with LimitedEntryBRLActionColumn

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

the class LimitedEntryBRLActionColumnSynchronizerTest method testMoveColumnTo_OutOfBounds.

@Test
public void testMoveColumnTo_OutOfBounds() throws VetoException {
    final LimitedEntryBRLActionColumn column1 = new LimitedEntryBRLActionColumn();
    column1.setHeader("age");
    final LimitedEntryBRLActionColumn column2 = new LimitedEntryBRLActionColumn();
    column2.setHeader("name");
    modelSynchronizer.appendColumn(column1);
    modelSynchronizer.appendColumn(column2);
    modelSynchronizer.appendRow();
    uiModel.setCellValue(0, 3, new BaseGridCellValue<Boolean>(true));
    uiModel.setCellValue(0, 4, new BaseGridCellValue<Boolean>(false));
    assertEquals(2, model.getActionCols().size());
    assertEquals(column1, model.getActionCols().get(0));
    assertEquals(column2, model.getActionCols().get(1));
    assertEquals(true, model.getData().get(0).get(3).getBooleanValue());
    assertEquals(false, model.getData().get(0).get(4).getBooleanValue());
    assertEquals(5, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_1 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(4);
    assertEquals("age", uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
    assertEquals("name", uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
    assertTrue(uiModelColumn1_1 instanceof BooleanUiColumn);
    assertTrue(uiModelColumn2_1 instanceof BooleanUiColumn);
    assertEquals(3, uiModelColumn1_1.getIndex());
    assertEquals(4, uiModelColumn2_1.getIndex());
    assertEquals(true, uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
    assertEquals(false, uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
    uiModel.moveColumnTo(1, uiModelColumn1_1);
    assertEquals(2, model.getActionCols().size());
    assertEquals(column1, model.getActionCols().get(0));
    assertEquals(column2, model.getActionCols().get(1));
    assertEquals(true, model.getData().get(0).get(3).getBooleanValue());
    assertEquals(false, model.getData().get(0).get(4).getBooleanValue());
    assertEquals(5, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(4);
    assertEquals("age", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
    assertEquals("name", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
    assertTrue(uiModelColumn1_2 instanceof BooleanUiColumn);
    assertTrue(uiModelColumn2_2 instanceof BooleanUiColumn);
    assertEquals(3, uiModelColumn1_2.getIndex());
    assertEquals(4, uiModelColumn2_2.getIndex());
    assertEquals(true, uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
    assertEquals(false, uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
}
Also used : LimitedEntryBRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn) BooleanUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn) Test(org.junit.Test)

Example 3 with LimitedEntryBRLActionColumn

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

the class LimitedEntryBRLActionColumnSynchronizerTest method testDelete.

@Test
public void testDelete() throws VetoException {
    final LimitedEntryBRLActionColumn column = new LimitedEntryBRLActionColumn();
    column.setHeader("col1");
    modelSynchronizer.appendColumn(column);
    assertEquals(1, model.getActionCols().size());
    assertEquals(4, uiModel.getColumns().size());
    modelSynchronizer.deleteColumn(column);
    assertEquals(0, model.getActionCols().size());
    assertEquals(3, uiModel.getColumns().size());
}
Also used : LimitedEntryBRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn) Test(org.junit.Test)

Example 4 with LimitedEntryBRLActionColumn

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

the class LimitedEntryBRLActionColumnSynchronizerTest method testUpdate.

@Test
public void testUpdate() throws VetoException {
    final LimitedEntryBRLActionColumn column = new LimitedEntryBRLActionColumn();
    column.setHeader("col1");
    modelSynchronizer.appendColumn(column);
    final LimitedEntryBRLActionColumn edited = new LimitedEntryBRLActionColumn();
    edited.setHideColumn(true);
    edited.setHeader("updated");
    modelSynchronizer.updateColumn(column, edited);
    assertEquals(1, model.getActionCols().size());
    assertEquals(4, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(3) instanceof BooleanUiColumn);
    assertEquals("updated", uiModel.getColumns().get(3).getHeaderMetaData().get(0).getTitle());
    assertEquals(false, uiModel.getColumns().get(3).isVisible());
}
Also used : LimitedEntryBRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn) BooleanUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn) Test(org.junit.Test)

Example 5 with LimitedEntryBRLActionColumn

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

the class LimitedEntryBRLActionColumnSynchronizerTest method testMoveColumnTo_MoveLeft.

@Test
public void testMoveColumnTo_MoveLeft() throws VetoException {
    final LimitedEntryBRLActionColumn column1 = new LimitedEntryBRLActionColumn();
    column1.setHeader("age");
    final LimitedEntryBRLActionColumn column2 = new LimitedEntryBRLActionColumn();
    column2.setHeader("name");
    modelSynchronizer.appendColumn(column1);
    modelSynchronizer.appendColumn(column2);
    modelSynchronizer.appendRow();
    uiModel.setCellValue(0, 3, new BaseGridCellValue<Boolean>(true));
    uiModel.setCellValue(0, 4, new BaseGridCellValue<Boolean>(false));
    assertEquals(2, model.getActionCols().size());
    assertEquals(column1, model.getActionCols().get(0));
    assertEquals(column2, model.getActionCols().get(1));
    assertEquals(true, model.getData().get(0).get(3).getBooleanValue());
    assertEquals(false, model.getData().get(0).get(4).getBooleanValue());
    assertEquals(5, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_1 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(4);
    assertEquals("age", uiModelColumn1_1.getHeaderMetaData().get(0).getTitle());
    assertEquals("name", uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
    assertTrue(uiModelColumn1_1 instanceof BooleanUiColumn);
    assertTrue(uiModelColumn2_1 instanceof BooleanUiColumn);
    assertEquals(3, uiModelColumn1_1.getIndex());
    assertEquals(4, uiModelColumn2_1.getIndex());
    assertEquals(true, uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
    assertEquals(false, uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
    uiModel.moveColumnTo(3, uiModelColumn2_1);
    assertEquals(2, model.getActionCols().size());
    assertEquals(column2, model.getActionCols().get(0));
    assertEquals(column1, model.getActionCols().get(1));
    assertEquals(false, model.getData().get(0).get(3).getBooleanValue());
    assertEquals(true, model.getData().get(0).get(4).getBooleanValue());
    assertEquals(5, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(4);
    assertEquals("name", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
    assertEquals("age", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
    assertTrue(uiModelColumn1_2 instanceof BooleanUiColumn);
    assertTrue(uiModelColumn2_2 instanceof BooleanUiColumn);
    assertEquals(4, uiModelColumn1_2.getIndex());
    assertEquals(3, uiModelColumn2_2.getIndex());
    assertEquals(false, uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
    assertEquals(true, uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
}
Also used : LimitedEntryBRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn) BooleanUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn) Test(org.junit.Test)

Aggregations

LimitedEntryBRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryBRLActionColumn)12 Test (org.junit.Test)7 BooleanUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.BooleanUiColumn)5 ActionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionCol52)2 ArrayList (java.util.ArrayList)1 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)1 FieldConstraint (org.drools.workbench.models.datamodel.rule.FieldConstraint)1 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)1 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)1 ActionRetractFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionRetractFactCol52)1 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)1 ActionWorkItemCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemCol52)1 ActionWorkItemInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemInsertFactCol52)1 ActionWorkItemSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionWorkItemSetFieldCol52)1 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)1 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)1 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)1 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)1 LimitedEntryCol (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryCol)1 MockInstanceImpl (org.drools.workbench.screens.guided.dtable.client.widget.table.popovers.MockInstanceImpl)1