Search in sources :

Example 36 with BRLActionColumn

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

the class BRLActionColumnSynchronizer method isBRLFragment.

private boolean isBRLFragment(final List<? extends MetaData> metaData) {
    if (!metaData.stream().allMatch((c) -> (c instanceof MoveColumnToMetaData))) {
        return false;
    }
    if (!metaData.stream().allMatch((c) -> ((MoveColumnToMetaData) c).getColumn() instanceof BRLActionVariableColumn)) {
        return false;
    }
    final MoveColumnToMetaData md = (MoveColumnToMetaData) metaData.get(0);
    final BRLActionVariableColumn srcModelColumn = (BRLActionVariableColumn) md.getColumn();
    final BRLActionColumn srcModelPattern = model.getBRLColumn(srcModelColumn);
    return srcModelPattern.getChildColumns().size() == metaData.size();
}
Also used : BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) HashMap(java.util.HashMap) BaseColumnFieldDiff(org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff) ArrayList(java.util.ArrayList) ModelSynchronizer(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer) VetoException(org.drools.workbench.screens.guided.dtable.client.widget.table.model.synchronizers.ModelSynchronizer.VetoException) List(java.util.List) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) Dependent(javax.enterprise.context.Dependent) Map(java.util.Map) Collections(java.util.Collections) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)

Example 37 with BRLActionColumn

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

the class BRLActionColumnSynchronizerTest method testAppend2.

@Test
public void testAppend2() throws VetoException {
    // Single Column, multiple variables
    final BRLActionColumn column = 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(5, model.getExpandedColumns().size());
    assertEquals(1, model.getActionCols().size());
    assertEquals(5, uiModel.getColumns().size());
    assertTrue(uiModel.getColumns().get(3) instanceof IntegerUiColumn);
    assertTrue(uiModel.getColumns().get(4) instanceof StringUiColumn);
    assertEquals("col1v0", uiModel.getColumns().get(3).getHeaderMetaData().get(0).getTitle());
    assertEquals("$age", uiModel.getColumns().get(3).getHeaderMetaData().get(1).getTitle());
    assertEquals("col1v1", uiModel.getColumns().get(4).getHeaderMetaData().get(0).getTitle());
    assertEquals("$name", uiModel.getColumns().get(4).getHeaderMetaData().get(1).getTitle());
}
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) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) Test(org.junit.Test)

Example 38 with BRLActionColumn

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

the class BRLActionColumnSynchronizerTest method testMoveActionAfter.

@Test
public void testMoveActionAfter() throws VetoException {
    final ActionInsertFactCol52 column1 = new ActionInsertFactCol52();
    column1.setHeader("country");
    column1.setBoundName("$a");
    column1.setFactType("Address");
    column1.setFactField("country");
    final BRLActionColumn column2 = new BRLActionColumn();
    final BRLActionVariableColumn column2v0 = new BRLActionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Applicant", "age");
    column2v0.setHeader("age");
    final BRLActionVariableColumn column2v1 = new BRLActionVariableColumn("$name", DataType.TYPE_STRING, "Applicant", "name");
    column2v1.setHeader("name");
    column2.getChildColumns().add(column2v0);
    column2.getChildColumns().add(column2v1);
    modelSynchronizer.appendColumn(column1);
    modelSynchronizer.appendColumn(column2);
    modelSynchronizer.appendRow();
    uiModel.setCellValue(0, 3, new BaseGridCellValue<>("Canada"));
    uiModel.setCellValue(0, 4, new BaseGridCellValue<>(55));
    uiModel.setCellValue(0, 5, new BaseGridCellValue<>("Smurf"));
    assertEquals(2, model.getActionCols().size());
    assertEquals(column1, model.getActionCols().get(0));
    assertEquals(column2, model.getActionCols().get(1));
    assertEquals("Canada", model.getData().get(0).get(3).getStringValue());
    assertEquals(55, model.getData().get(0).get(4).getNumericValue());
    assertEquals("Smurf", model.getData().get(0).get(5).getStringValue());
    assertEquals(6, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_1 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(4);
    final GridColumn<?> uiModelColumn3_1 = uiModel.getColumns().get(5);
    assertEquals("age", uiModelColumn2_1.getHeaderMetaData().get(0).getTitle());
    assertEquals("name", uiModelColumn3_1.getHeaderMetaData().get(0).getTitle());
    assertTrue(uiModelColumn1_1 instanceof StringUiColumn);
    assertTrue(uiModelColumn2_1 instanceof IntegerUiColumn);
    assertTrue(uiModelColumn3_1 instanceof StringUiColumn);
    assertEquals(3, uiModelColumn1_1.getIndex());
    assertEquals(4, uiModelColumn2_1.getIndex());
    assertEquals(5, uiModelColumn3_1.getIndex());
    assertEquals("Canada", uiModel.getRow(0).getCells().get(uiModelColumn1_1.getIndex()).getValue().getValue());
    assertEquals(55, uiModel.getRow(0).getCells().get(uiModelColumn2_1.getIndex()).getValue().getValue());
    assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn3_1.getIndex()).getValue().getValue());
    uiModel.moveColumnTo(5, uiModelColumn1_1);
    assertEquals(2, model.getActionCols().size());
    assertEquals(column2, model.getActionCols().get(0));
    assertEquals(column1, model.getActionCols().get(1));
    assertEquals(55, model.getData().get(0).get(3).getNumericValue());
    assertEquals("Smurf", model.getData().get(0).get(4).getStringValue());
    assertEquals("Canada", model.getData().get(0).get(5).getStringValue());
    assertEquals(6, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(4);
    final GridColumn<?> uiModelColumn3_2 = uiModel.getColumns().get(5);
    assertEquals("age", uiModelColumn1_2.getHeaderMetaData().get(0).getTitle());
    assertEquals("name", uiModelColumn2_2.getHeaderMetaData().get(0).getTitle());
    assertEquals("$a : Address", uiModelColumn3_2.getHeaderMetaData().get(0).getTitle());
    assertTrue(uiModelColumn1_2 instanceof IntegerUiColumn);
    assertTrue(uiModelColumn2_2 instanceof StringUiColumn);
    assertTrue(uiModelColumn3_2 instanceof StringUiColumn);
    assertEquals(4, uiModelColumn1_2.getIndex());
    assertEquals(5, uiModelColumn2_2.getIndex());
    assertEquals(3, uiModelColumn3_2.getIndex());
    assertEquals(55, uiModel.getRow(0).getCells().get(uiModelColumn1_2.getIndex()).getValue().getValue());
    assertEquals("Smurf", uiModel.getRow(0).getCells().get(uiModelColumn2_2.getIndex()).getValue().getValue());
    assertEquals("Canada", 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)

Example 39 with BRLActionColumn

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

the class BRLActionColumnSynchronizerTest method testMoveBRLActionBlockTo.

@Test
public void testMoveBRLActionBlockTo() 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, 3, new BaseGridCellValue<>(55));
    uiModel.setCellValue(0, 4, new BaseGridCellValue<>("Smurf"));
    uiModel.setCellValue(0, 5, 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(3).getNumericValue());
    assertEquals("Smurf", model.getData().get(0).get(4).getStringValue());
    assertEquals("Canada", model.getData().get(0).get(5).getStringValue());
    assertEquals(6, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_1 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(4);
    final GridColumn<?> uiModelColumn3_1 = uiModel.getColumns().get(5);
    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(3, uiModelColumn1_1.getIndex());
    assertEquals(4, uiModelColumn2_1.getIndex());
    assertEquals(5, 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.moveColumnsTo(5, new ArrayList<GridColumn<?>>() {

        {
            add(uiModelColumn1_1);
            add(uiModelColumn2_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(3).getStringValue());
    assertEquals(55, model.getData().get(0).get(4).getNumericValue());
    assertEquals("Smurf", model.getData().get(0).get(5).getStringValue());
    assertEquals(6, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(4);
    final GridColumn<?> uiModelColumn3_2 = uiModel.getColumns().get(5);
    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(5, uiModelColumn1_2.getIndex());
    assertEquals(3, uiModelColumn2_2.getIndex());
    assertEquals(4, 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) GridColumn(org.uberfire.ext.wires.core.grids.client.model.GridColumn) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) Test(org.junit.Test)

Example 40 with BRLActionColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn 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, 3, new BaseGridCellValue<>(55));
    uiModel.setCellValue(0, 4, new BaseGridCellValue<>("Smurf"));
    uiModel.setCellValue(0, 5, 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(3).getNumericValue());
    assertEquals("Smurf", model.getData().get(0).get(4).getStringValue());
    assertEquals("Canada", model.getData().get(0).get(5).getStringValue());
    assertEquals(6, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_1 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn2_1 = uiModel.getColumns().get(4);
    final GridColumn<?> uiModelColumn3_1 = uiModel.getColumns().get(5);
    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(3, uiModelColumn1_1.getIndex());
    assertEquals(4, uiModelColumn2_1.getIndex());
    assertEquals(5, 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(3, 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(3).getStringValue());
    assertEquals(55, model.getData().get(0).get(4).getNumericValue());
    assertEquals("Smurf", model.getData().get(0).get(5).getStringValue());
    assertEquals(6, uiModel.getColumns().size());
    final GridColumn<?> uiModelColumn1_2 = uiModel.getColumns().get(3);
    final GridColumn<?> uiModelColumn2_2 = uiModel.getColumns().get(4);
    final GridColumn<?> uiModelColumn3_2 = uiModel.getColumns().get(5);
    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(5, uiModelColumn1_2.getIndex());
    assertEquals(3, uiModelColumn2_2.getIndex());
    assertEquals(4, 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

BRLActionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn)78 BRLActionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn)56 Test (org.junit.Test)53 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)33 ActionFieldValue (org.drools.workbench.models.datamodel.rule.ActionFieldValue)26 ArrayList (java.util.ArrayList)24 IAction (org.drools.workbench.models.datamodel.rule.IAction)22 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)20 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)20 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)19 BRLConditionColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn)18 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)17 BRLConditionVariableColumn (org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn)17 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)17 ActionInsertFact (org.drools.workbench.models.datamodel.rule.ActionInsertFact)15 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)15 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)14 RuleNameColumn (org.drools.workbench.models.guided.dtable.shared.model.RuleNameColumn)14 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)13 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)12