Search in sources :

Example 26 with BRLActionVariableColumn

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

the class ConditionColumnSynchronizerTest method actionCallMethod.

private BRLActionColumn actionCallMethod(final String boundName) {
    final ActionCallMethod action = new ActionCallMethod();
    action.setVariable(boundName);
    action.setMethodName("toString()");
    final BRLActionColumn brl = new BRLActionColumn();
    brl.setHeader("brl-action");
    brl.setDefinition(Collections.singletonList(action));
    brl.getChildColumns().add(new BRLActionVariableColumn() {

        {
            setHeader("brl-action-v0");
        }
    });
    return brl;
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) ActionCallMethod(org.drools.workbench.models.datamodel.rule.ActionCallMethod) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)

Example 27 with BRLActionVariableColumn

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

the class BRLActionColumnDefinitionBuilderTest method setupBRLActionColumn.

private void setupBRLActionColumn() {
    final BRLActionColumn brl = new BRLActionColumn();
    final ActionInsertFact ifc1 = new ActionInsertFact();
    ifc1.setFactType("Person");
    ifc1.setBoundName("$a");
    final ActionFieldValue afv1 = new ActionFieldValue();
    afv1.setNature(FieldNatureType.TYPE_TEMPLATE);
    afv1.setField("name");
    afv1.setValue("f1");
    ifc1.addFieldValue(afv1);
    final ActionFieldValue afv2 = new ActionFieldValue();
    afv2.setNature(FieldNatureType.TYPE_TEMPLATE);
    afv2.setField("age");
    afv2.setValue("f2");
    ifc1.addFieldValue(afv2);
    brl.getDefinition().add(ifc1);
    brl.getChildColumns().add(new BRLActionVariableColumn("f1", DataType.TYPE_STRING));
    brl.getChildColumns().add(new BRLActionVariableColumn("f2", DataType.TYPE_NUMERIC_INTEGER));
    model.getActionCols().add(brl);
    when(dmo.getFieldType(eq("Person"), eq("name"))).thenReturn(DataType.TYPE_STRING);
    when(dmo.getFieldType(eq("Person"), eq("age"))).thenReturn(DataType.TYPE_NUMERIC_INTEGER);
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) ActionInsertFact(org.drools.workbench.models.datamodel.rule.ActionInsertFact) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)

Example 28 with BRLActionVariableColumn

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

the class BRLActionColumnPluginTest method testSetupEditingColWhenColumnIsNotNew.

@Test
public void testSetupEditingColWhenColumnIsNotNew() throws Exception {
    final BRLActionColumn originalColumn = mock(BRLActionColumn.class);
    final BRLActionColumn editingColumn = mock(BRLActionColumn.class);
    final String header = "header";
    final ArrayList<IAction> definition = new ArrayList<>();
    final ArrayList<BRLActionVariableColumn> childColumns = new ArrayList<>();
    final boolean isHideColumn = false;
    doReturn(false).when(plugin).isNewColumn();
    doReturn(editingColumn).when(plugin).newBRLActionColumn();
    doReturn(originalColumn).when(plugin).getOriginalColumnConfig52();
    doReturn(header).when(originalColumn).getHeader();
    doReturn(definition).when(originalColumn).getDefinition();
    doReturn(childColumns).when(originalColumn).getChildColumns();
    doReturn(isHideColumn).when(originalColumn).isHideColumn();
    plugin.setupEditingCol();
    verify(editingColumn).setHeader(header);
    verify(editingColumn).setDefinition(definition);
    verify(editingColumn).setChildColumns(childColumns);
    verify(editingColumn).setHideColumn(isHideColumn);
    assertEquals(editingColumn, plugin.editingCol());
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) IAction(org.drools.workbench.models.datamodel.rule.IAction) ArrayList(java.util.ArrayList) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) Test(org.junit.Test)

Example 29 with BRLActionVariableColumn

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

the class BRLActionColumnSynchronizerTest method testUpdate2.

@Test
public void testUpdate2() throws VetoException {
    // Single Column, multiple variables
    final BRLActionColumn column = spy(new BRLActionColumn());
    final BRLActionVariableColumn columnV0 = new BRLActionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
    final BRLActionVariableColumn columnV1 = new BRLActionVariableColumn("$name", DataType.TYPE_STRING, "Applicant", "name");
    column.getChildColumns().add(columnV0);
    column.getChildColumns().add(columnV1);
    column.setHeader("col1");
    columnV0.setHeader("col1v0");
    columnV1.setHeader("col1v1");
    modelSynchronizer.appendColumn(column);
    assertEquals(4, model.getExpandedColumns().size());
    assertEquals(1, model.getActionCols().size());
    assertEquals(4, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof IntegerUiColumn);
    assertTrue(uiModel.getColumns().get(3) instanceof StringUiColumn);
    final BRLActionColumn edited = new BRLActionColumn();
    final BRLActionVariableColumn editedColumnV0 = new BRLActionVariableColumn("$name", DataType.TYPE_STRING, "Applicant", "name");
    edited.getChildColumns().add(editedColumnV0);
    edited.setHideColumn(true);
    edited.setHeader("updated");
    editedColumnV0.setHeader("updated");
    List<BaseColumnFieldDiff> diffs = modelSynchronizer.updateColumn(column, edited);
    assertEquals(6, // header, hide, field name, field type, binding, removed column
    diffs.size());
    verify(column).diff(edited);
    assertEquals(3, model.getExpandedColumns().size());
    assertEquals(1, model.getActionCols().size());
    assertEquals(3, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(2) instanceof StringUiColumn);
    assertEquals("updated", uiModel.getColumns().get(2).getHeaderMetaData().get(0).getTitle());
    assertEquals("$name", uiModel.getColumns().get(2).getHeaderMetaData().get(1).getTitle());
    assertEquals(false, uiModel.getColumns().get(2).isVisible());
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) StringUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) Test(org.junit.Test)

Example 30 with BRLActionVariableColumn

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

the class BRLActionColumnSynchronizerTest method testMoveActionBefore.

@Test
public void testMoveActionBefore() throws VetoException {
    final BRLActionColumn column1 = new BRLActionColumn();
    final BRLActionVariableColumn column1v0 = new BRLActionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
    column1v0.setHeader("age");
    final BRLActionVariableColumn column1v1 = new BRLActionVariableColumn("$name", DataType.TYPE_STRING, "Applicant", "name");
    column1v1.setHeader("name");
    final ActionInsertFactCol52 column2 = new ActionInsertFactCol52();
    column2.setHeader("country");
    column2.setBoundName("$a");
    column2.setFactType("Address");
    column2.setFactField("country");
    column1.getChildColumns().add(column1v0);
    column1.getChildColumns().add(column1v1);
    modelSynchronizer.appendColumn(column1);
    modelSynchronizer.appendColumn(column2);
    modelSynchronizer.appendRow();
    uiModel.setCellValue(0, 2, new BaseGridCellValue<>(55));
    uiModel.setCellValue(0, 3, new BaseGridCellValue<>("Smurf"));
    uiModel.setCellValue(0, 4, new BaseGridCellValue<>("Canada"));
    assertEquals(2, model.getActionCols().size());
    assertEquals(column1, model.getActionCols().get(0));
    assertEquals(column2, model.getActionCols().get(1));
    assertEquals(55, model.getData().get(0).get(2).getNumericValue());
    assertEquals("Smurf", model.getData().get(0).get(3).getStringValue());
    assertEquals("Canada", model.getData().get(0).get(4).getStringValue());
    assertEquals(5, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_1 = uiModel.getColumns().get(2);
    final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn3_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 IntegerUiColumn);
    assertTrue(uiModelColumn2_1 instanceof StringUiColumn);
    assertTrue(uiModelColumn3_1 instanceof StringUiColumn);
    assertEquals(2, uiModelColumn1_1.getIndex());
    assertEquals(3, uiModelColumn2_1.getIndex());
    assertEquals(4, uiModelColumn3_1.getIndex());
    assertEquals(55, uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
    assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
    assertEquals("Canada", uiModel.getRow(0).getCells().get(uiModelColumn3_1.getIndex()).getValue().getValue());
    uiModel.moveColumnTo(2, uiModelColumn3_1);
    assertEquals(2, model.getActionCols().size());
    assertEquals(column2, model.getActionCols().get(0));
    assertEquals(column1, model.getActionCols().get(1));
    assertEquals("Canada", model.getData().get(0).get(2).getStringValue());
    assertEquals(55, model.getData().get(0).get(3).getNumericValue());
    assertEquals("Smurf", model.getData().get(0).get(4).getStringValue());
    assertEquals(5, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(2);
    final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn3_2 = uiModel.getColumns().get(4);
    assertEquals("$a : Address", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
    assertEquals("age", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
    assertEquals("name", uiModelColumn3_2.getHeaderMetaData().get(0).getTitle());
    assertTrue(uiModelColumn1_2 instanceof StringUiColumn);
    assertTrue(uiModelColumn2_2 instanceof IntegerUiColumn);
    assertTrue(uiModelColumn3_2 instanceof StringUiColumn);
    assertEquals(4, uiModelColumn1_2.getIndex());
    assertEquals(2, uiModelColumn2_2.getIndex());
    assertEquals(3, uiModelColumn3_2.getIndex());
    assertEquals("Canada", uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
    assertEquals(55, uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
    assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn3_2.getIndex()).getValue().getValue());
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) StringUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn) IntegerUiColumn(org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) Test(org.junit.Test)

Aggregations

BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)63 BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)51 Test (org.junit.Test)38 ArrayList (java.util.ArrayList)27 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)27 ActionFieldValue (org.drools.workbench.models.datamodel.rule.ActionFieldValue)21 IAction (org.drools.workbench.models.datamodel.rule.IAction)19 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)18 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)18 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)17 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)16 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)15 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)14 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)11 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)11 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)11 IOException (java.io.IOException)10 InputStream (java.io.InputStream)10 ExcelParser (org.drools.decisiontable.parser.xls.ExcelParser)10 DataListener (org.drools.template.parser.DataListener)10