Search in sources :

Example 6 with BRLActionVariableColumn

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

the class BRLRuleModelTest method testUpdateModifyMultipleFieldsWithMultipleSkipped3.

@Test
public void testUpdateModifyMultipleFieldsWithMultipleSkipped3() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    Pattern52 p1 = new Pattern52();
    p1.setBoundName("x");
    p1.setFactType("Context");
    ConditionCol52 c = new ConditionCol52();
    c.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    p1.getChildColumns().add(c);
    dt.getConditions().add(p1);
    BRLActionColumn brlAction1 = new BRLActionColumn();
    ActionUpdateField auf1 = new ActionUpdateField("x");
    auf1.addFieldValue(new ActionFieldValue("f1", "$f1", DataType.TYPE_STRING));
    auf1.getFieldValues()[0].setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE);
    brlAction1.getDefinition().add(auf1);
    brlAction1.getChildColumns().add(new BRLActionVariableColumn("$f1", DataType.TYPE_STRING, "Context", "f1"));
    ActionUpdateField auf2 = new ActionUpdateField("x");
    auf2.addFieldValue(new ActionFieldValue("f2", "$f2", DataType.TYPE_STRING));
    auf2.getFieldValues()[0].setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE);
    brlAction1.getDefinition().add(auf2);
    brlAction1.getChildColumns().add(new BRLActionVariableColumn("$f2", DataType.TYPE_STRING, "Context", "f2"));
    ActionUpdateField auf3 = new ActionUpdateField("x");
    auf3.addFieldValue(new ActionFieldValue("f3", "$f3", DataType.TYPE_STRING));
    auf3.getFieldValues()[0].setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE);
    brlAction1.getDefinition().add(auf3);
    brlAction1.getChildColumns().add(new BRLActionVariableColumn("$f3", DataType.TYPE_STRING, "Context", "f3"));
    dt.getActionCols().add(brlAction1);
    dt.setData(DataUtilities.makeDataLists(new String[][] { new String[] { "1", "desc", "x", null, null, "v3" } }));
    String drl = GuidedDTDRLPersistence.getInstance().marshal(dt);
    final String expected = "//from row number: 1\n" + "//desc\n" + "rule \"Row 1 null\"\n" + "dialect \"mvel\"\n" + "when\n" + "  x : Context( )\n" + "then\n" + "  modify( x ) {\n" + "    setF3( \"v3\" )\n" + "}\n" + "end\n";
    assertEqualsIgnoreWhitespace(expected, drl);
}
Also used : ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) ActionUpdateField(org.drools.workbench.models.datamodel.rule.ActionUpdateField) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) Test(org.junit.Test)

Example 7 with BRLActionVariableColumn

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

the class BRLRuleModelTest method testRHSDelimitedNonEmptyStringValues.

@Test
public void testRHSDelimitedNonEmptyStringValues() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    dt.setTableFormat(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY);
    dt.setTableName("extended-entry");
    Pattern52 p1 = new Pattern52();
    p1.setBoundName("p1");
    p1.setFactType("Smurf");
    BRLActionColumn brlAction = new BRLActionColumn();
    ActionUpdateField auf1 = new ActionUpdateField("p1");
    auf1.addFieldValue(new ActionFieldValue("name", "$name", DataType.TYPE_STRING));
    auf1.getFieldValues()[0].setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE);
    ActionUpdateField auf2 = new ActionUpdateField("p1");
    auf2.addFieldValue(new ActionFieldValue("age", "$age", DataType.TYPE_NUMERIC_INTEGER));
    auf2.getFieldValues()[0].setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE);
    brlAction.getDefinition().add(auf1);
    brlAction.getDefinition().add(auf2);
    brlAction.getChildColumns().add(new BRLActionVariableColumn("$name", DataType.TYPE_STRING, "Smurf", "name"));
    brlAction.getChildColumns().add(new BRLActionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Smurf", "age"));
    dt.getActionCols().add(brlAction);
    // Test 1
    dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc-row1", null, null } }));
    String drl1 = GuidedDTDRLPersistence.getInstance().marshal(dt);
    final String expected1 = "//from row number: 1\n" + "//desc-row1\n" + "rule \"Row 1 extended-entry\"\n" + "  dialect \"mvel\"\n" + "  when\n" + "  then\n" + "end";
    assertEqualsIgnoreWhitespace(expected1, drl1);
    // Test 2
    dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 2l, "desc-row2", "\"   \"", 35l } }));
    String drl2 = GuidedDTDRLPersistence.getInstance().marshal(dt);
    final String expected2 = "//from row number: 1\n" + "//desc-row2\n" + "rule \"Row 2 extended-entry\"\n" + "  dialect \"mvel\"\n" + "  when\n" + "  then\n" + "    modify( p1 ) {\n" + "      setName( \"   \" ),\n" + "      setAge( 35 )\n" + "    }\n" + "end";
    assertEqualsIgnoreWhitespace(expected2, drl2);
    // Test 3
    dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 3l, "desc-row3", "\"\"", null } }));
    String drl3 = GuidedDTDRLPersistence.getInstance().marshal(dt);
    final String expected3 = "//from row number: 1\n" + "//desc-row3\n" + "rule \"Row 3 extended-entry\"\n" + "  dialect \"mvel\"\n" + "  when\n" + "  then\n" + "    modify( p1 ) {\n" + "      setName( \"\" )\n" + "    }\n" + "end";
    assertEqualsIgnoreWhitespace(expected3, drl3);
    // Test 4
    dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 4l, "desc-row4", "\"\"", 35l } }));
    String drl4 = GuidedDTDRLPersistence.getInstance().marshal(dt);
    final String expected4 = "//from row number: 1\n" + "//desc-row4\n" + "rule \"Row 4 extended-entry\"\n" + "  dialect \"mvel\"\n" + "  when\n" + "  then\n" + "    modify( p1 ) {\n" + "      setName( \"\" ),\n" + "      setAge( 35 )\n" + "    }\n" + "end";
    assertEqualsIgnoreWhitespace(expected4, drl4);
}
Also used : BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) ActionUpdateField(org.drools.workbench.models.datamodel.rule.ActionUpdateField) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) Test(org.junit.Test)

Example 8 with BRLActionVariableColumn

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

the class GuidedDTDRLPersistenceTest method testRHSWithBRLColumn_ParseToDRL.

@Test
public // This test checks a Decision Table involving BRL columns is correctly converted into DRL
void testRHSWithBRLColumn_ParseToDRL() {
    GuidedDecisionTable52 dtable = new GuidedDecisionTable52();
    // All three rows are entered, some columns with optional data
    String[][] data = new String[][] { new String[] { "1", "desc", "Gargamel", "Pupa", "50" }, new String[] { "2", "desc", "Gargamel", "", "50" }, new String[] { "3", "desc", "Gargamel", "Pupa", "" } };
    // Simple (mandatory) columns
    dtable.setRowNumberCol(new RowNumberCol52());
    dtable.setDescriptionCol(new DescriptionCol52());
    // Simple Action
    ActionInsertFactCol52 a1 = new ActionInsertFactCol52();
    a1.setBoundName("$b");
    a1.setFactType("Baddie");
    a1.setFactField("name");
    a1.setType(DataType.TYPE_STRING);
    dtable.getActionCols().add(a1);
    // BRL Column
    BRLActionColumn brl1 = new BRLActionColumn();
    // BRL Column definition
    List<IAction> brl1Definition = new ArrayList<IAction>();
    ActionInsertFact brl1DefinitionAction1 = new ActionInsertFact("Smurf");
    ActionFieldValue brl1DefinitionAction1FieldValue1 = new ActionFieldValue("name", "$name", DataType.TYPE_STRING);
    brl1DefinitionAction1FieldValue1.setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE);
    brl1DefinitionAction1.addFieldValue(brl1DefinitionAction1FieldValue1);
    ActionFieldValue brl1DefinitionAction1FieldValue2 = new ActionFieldValue("age", "$age", DataType.TYPE_NUMERIC_INTEGER);
    brl1DefinitionAction1FieldValue2.setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE);
    brl1DefinitionAction1.addFieldValue(brl1DefinitionAction1FieldValue2);
    brl1Definition.add(brl1DefinitionAction1);
    brl1.setDefinition(brl1Definition);
    // Setup BRL column bindings
    BRLActionVariableColumn brl1Variable1 = new BRLActionVariableColumn("$name", DataType.TYPE_STRING, "Person", "name");
    brl1.getChildColumns().add(brl1Variable1);
    BRLActionVariableColumn brl1Variable2 = new BRLActionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Person", "age");
    brl1.getChildColumns().add(brl1Variable2);
    dtable.getActionCols().add(brl1);
    dtable.setData(DataUtilities.makeDataLists(data));
    // Now to test conversion
    int ruleStartIndex;
    int action1StartIndex;
    int action2StartIndex;
    GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
    String drl = p.marshal(dtable);
    // Row 0
    ruleStartIndex = drl.indexOf("//from row number: 1");
    assertFalse(ruleStartIndex == -1);
    action1StartIndex = drl.indexOf("Baddie $b = new Baddie();", ruleStartIndex);
    assertFalse(action1StartIndex == -1);
    action1StartIndex = drl.indexOf("$b.setName( \"Gargamel\" );", action1StartIndex);
    assertFalse(action1StartIndex == -1);
    action1StartIndex = drl.indexOf("insert( $b );", action1StartIndex);
    assertFalse(action1StartIndex == -1);
    action2StartIndex = drl.indexOf("Smurf fact0 = new Smurf();", ruleStartIndex);
    assertFalse(action2StartIndex == -1);
    action2StartIndex = drl.indexOf("fact0.setName( \"Pupa\" );", action2StartIndex);
    assertFalse(action2StartIndex == -1);
    action2StartIndex = drl.indexOf("fact0.setAge( 50 );", action2StartIndex);
    assertFalse(action2StartIndex == -1);
    action2StartIndex = drl.indexOf("insert( fact0 );", action2StartIndex);
    assertFalse(action2StartIndex == -1);
    // Row 1
    ruleStartIndex = drl.indexOf("//from row number: 2");
    int ruleEndIndex = drl.indexOf("//from row number: 3");
    assertFalse(ruleStartIndex == -1);
    action1StartIndex = drl.indexOf("Baddie $b = new Baddie();", ruleStartIndex);
    assertFalse(action1StartIndex == -1);
    action1StartIndex = drl.indexOf("$b.setName( \"Gargamel\" );", action1StartIndex);
    assertFalse(action1StartIndex == -1);
    action1StartIndex = drl.indexOf("insert( $b );", action1StartIndex);
    assertFalse(action1StartIndex == -1);
    action2StartIndex = drl.indexOf("Smurf fact0 = new Smurf();", ruleStartIndex);
    assertFalse(action2StartIndex == -1);
    action2StartIndex = drl.indexOf("fact0.setName(", ruleStartIndex);
    assertFalse(action2StartIndex < ruleEndIndex);
    action2StartIndex = drl.indexOf("fact0.setAge( 50 );", ruleStartIndex);
    assertFalse(action2StartIndex == -1);
    action2StartIndex = drl.indexOf("insert( fact0 );", ruleStartIndex);
    assertFalse(action2StartIndex == -1);
    // Row 2
    ruleStartIndex = drl.indexOf("//from row number: 3");
    assertFalse(ruleStartIndex == -1);
    action1StartIndex = drl.indexOf("Baddie $b = new Baddie();", ruleStartIndex);
    assertFalse(action1StartIndex == -1);
    action1StartIndex = drl.indexOf("$b.setName( \"Gargamel\" );", action1StartIndex);
    assertFalse(action1StartIndex == -1);
    action1StartIndex = drl.indexOf("insert( $b );", action1StartIndex);
    assertFalse(action1StartIndex == -1);
    action2StartIndex = drl.indexOf("Smurf fact0 = new Smurf();", ruleStartIndex);
    assertFalse(action2StartIndex == -1);
    action2StartIndex = drl.indexOf("fact0.setName( \"Pupa\" );", ruleStartIndex);
    assertFalse(action2StartIndex == -1);
    action2StartIndex = drl.indexOf("fact0.setAge( 50 );", ruleStartIndex);
    assertTrue(action2StartIndex == -1);
    action2StartIndex = drl.indexOf("insert( fact0 );", ruleStartIndex);
    assertFalse(action2StartIndex == -1);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) LimitedEntryActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52) IAction(org.drools.workbench.models.datamodel.rule.IAction) ArrayList(java.util.ArrayList) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) 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) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Example 9 with BRLActionVariableColumn

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

the class GuidedDTDRLPersistenceTest method testRHSWithBRLColumn_ParseToRuleModel.

@Test
public // This test checks a Decision Table involving BRL columns is correctly converted into a RuleModel
void testRHSWithBRLColumn_ParseToRuleModel() {
    GuidedDecisionTable52 dtable = new GuidedDecisionTable52();
    GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
    // All three rows are entered, some columns with optional data
    String[][] data = new String[][] { new String[] { "1", "desc", "Gargamel", "Pupa", "50" }, new String[] { "2", "desc", "Gargamel", "", "50" }, new String[] { "3", "desc", "Gargamel", "Pupa", "" } };
    // Simple (mandatory) columns
    dtable.setRowNumberCol(new RowNumberCol52());
    dtable.setDescriptionCol(new DescriptionCol52());
    // Simple Action
    ActionInsertFactCol52 a1 = new ActionInsertFactCol52();
    a1.setBoundName("$b");
    a1.setFactType("Baddie");
    a1.setFactField("name");
    a1.setType(DataType.TYPE_STRING);
    dtable.getActionCols().add(a1);
    // BRL Column
    BRLActionColumn brl1 = new BRLActionColumn();
    // BRL Column definition
    List<IAction> brl1Definition = new ArrayList<IAction>();
    ActionInsertFact brl1DefinitionAction1 = new ActionInsertFact("Smurf");
    ActionFieldValue brl1DefinitionAction1FieldValue1 = new ActionFieldValue("name", "$name", DataType.TYPE_STRING);
    brl1DefinitionAction1FieldValue1.setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE);
    brl1DefinitionAction1.addFieldValue(brl1DefinitionAction1FieldValue1);
    ActionFieldValue brl1DefinitionAction1FieldValue2 = new ActionFieldValue("age", "$age", DataType.TYPE_NUMERIC_INTEGER);
    brl1DefinitionAction1FieldValue2.setNature(BaseSingleFieldConstraint.TYPE_TEMPLATE);
    brl1DefinitionAction1.addFieldValue(brl1DefinitionAction1FieldValue2);
    brl1Definition.add(brl1DefinitionAction1);
    brl1.setDefinition(brl1Definition);
    // Setup BRL column bindings
    BRLActionVariableColumn brl1Variable1 = new BRLActionVariableColumn("$name", DataType.TYPE_STRING, "Person", "name");
    brl1.getChildColumns().add(brl1Variable1);
    BRLActionVariableColumn brl1Variable2 = new BRLActionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Person", "age");
    brl1.getChildColumns().add(brl1Variable2);
    dtable.getActionCols().add(brl1);
    // Now to test conversion
    RuleModel rm = new RuleModel();
    List<BaseColumn> allColumns = dtable.getExpandedColumns();
    List<ActionCol52> allActions = dtable.getActionCols();
    // Row 0
    List<DTCellValue52> dtRowData0 = DataUtilities.makeDataRowList(data[0]);
    TemplateDataProvider rowDataProvider0 = new GuidedDTTemplateDataProvider(allColumns, dtRowData0);
    p.doActions(allColumns, allActions, rowDataProvider0, dtRowData0, rm);
    assertEquals(2, rm.rhs.length);
    assertEquals("Baddie", ((ActionInsertFact) rm.rhs[0]).getFactType());
    assertEquals("Smurf", ((ActionInsertFact) rm.rhs[1]).getFactType());
    // examine the first action
    ActionInsertFact result0Action1 = (ActionInsertFact) rm.rhs[0];
    assertEquals(1, result0Action1.getFieldValues().length);
    ActionFieldValue result0Action1FieldValue1 = (ActionFieldValue) result0Action1.getFieldValues()[0];
    assertEquals(DataType.TYPE_STRING, result0Action1FieldValue1.getType());
    assertEquals("name", result0Action1FieldValue1.getField());
    assertEquals("Gargamel", result0Action1FieldValue1.getValue());
    // examine the second action
    ActionInsertFact result0Action2 = (ActionInsertFact) rm.rhs[1];
    assertEquals(2, result0Action2.getFieldValues().length);
    ActionFieldValue result0Action2FieldValue1 = (ActionFieldValue) result0Action2.getFieldValues()[0];
    assertEquals(DataType.TYPE_STRING, result0Action2FieldValue1.getType());
    assertEquals("name", result0Action2FieldValue1.getField());
    assertEquals("$name", result0Action2FieldValue1.getValue());
    ActionFieldValue result0Action2FieldValue2 = (ActionFieldValue) result0Action2.getFieldValues()[1];
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, result0Action2FieldValue2.getType());
    assertEquals("age", result0Action2FieldValue2.getField());
    assertEquals("$age", result0Action2FieldValue2.getValue());
    // Row 1
    List<DTCellValue52> dtRowData1 = DataUtilities.makeDataRowList(data[1]);
    TemplateDataProvider rowDataProvider1 = new GuidedDTTemplateDataProvider(allColumns, dtRowData1);
    p.doActions(allColumns, allActions, rowDataProvider1, dtRowData1, rm);
    assertEquals(2, rm.rhs.length);
    assertEquals("Baddie", ((ActionInsertFact) rm.rhs[0]).getFactType());
    assertEquals("Smurf", ((ActionInsertFact) rm.rhs[1]).getFactType());
    // examine the first action
    ActionInsertFact result1Action1 = (ActionInsertFact) rm.rhs[0];
    assertEquals(1, result1Action1.getFieldValues().length);
    ActionFieldValue result1Action1FieldValue1 = (ActionFieldValue) result1Action1.getFieldValues()[0];
    assertEquals(DataType.TYPE_STRING, result1Action1FieldValue1.getType());
    assertEquals("name", result1Action1FieldValue1.getField());
    assertEquals("Gargamel", result1Action1FieldValue1.getValue());
    // examine the second action
    ActionInsertFact result1Action2 = (ActionInsertFact) rm.rhs[1];
    assertEquals(2, result1Action2.getFieldValues().length);
    ActionFieldValue result1Action2FieldValue1 = (ActionFieldValue) result1Action2.getFieldValues()[0];
    assertEquals(DataType.TYPE_STRING, result1Action2FieldValue1.getType());
    assertEquals("name", result1Action2FieldValue1.getField());
    assertEquals("$name", result1Action2FieldValue1.getValue());
    ActionFieldValue result1Action2FieldValue2 = (ActionFieldValue) result1Action2.getFieldValues()[1];
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, result1Action2FieldValue2.getType());
    assertEquals("age", result1Action2FieldValue2.getField());
    assertEquals("$age", result1Action2FieldValue2.getValue());
    // Row 2
    List<DTCellValue52> dtRowData2 = DataUtilities.makeDataRowList(data[2]);
    TemplateDataProvider rowDataProvider2 = new GuidedDTTemplateDataProvider(allColumns, dtRowData2);
    p.doActions(allColumns, allActions, rowDataProvider2, dtRowData2, rm);
    assertEquals(2, rm.rhs.length);
    assertEquals("Baddie", ((ActionInsertFact) rm.rhs[0]).getFactType());
    assertEquals("Smurf", ((ActionInsertFact) rm.rhs[1]).getFactType());
    // examine the first action
    ActionInsertFact result2Action1 = (ActionInsertFact) rm.rhs[0];
    assertEquals(1, result2Action1.getFieldValues().length);
    ActionFieldValue result2Action1FieldValue1 = (ActionFieldValue) result2Action1.getFieldValues()[0];
    assertEquals(DataType.TYPE_STRING, result2Action1FieldValue1.getType());
    assertEquals("name", result2Action1FieldValue1.getField());
    assertEquals("Gargamel", result2Action1FieldValue1.getValue());
    // examine the second action
    ActionInsertFact result2Action2 = (ActionInsertFact) rm.rhs[1];
    assertEquals(2, result2Action2.getFieldValues().length);
    ActionFieldValue result2Action2FieldValue1 = (ActionFieldValue) result2Action2.getFieldValues()[0];
    assertEquals(DataType.TYPE_STRING, result2Action2FieldValue1.getType());
    assertEquals("name", result2Action2FieldValue1.getField());
    assertEquals("$name", result2Action2FieldValue1.getValue());
    ActionFieldValue result3Action2FieldValue2 = (ActionFieldValue) result2Action2.getFieldValues()[1];
    assertEquals(DataType.TYPE_NUMERIC_INTEGER, result3Action2FieldValue2.getType());
    assertEquals("age", result3Action2FieldValue2.getField());
    assertEquals("$age", result3Action2FieldValue2.getValue());
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52) LimitedEntryActionInsertFactCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52) IAction(org.drools.workbench.models.datamodel.rule.IAction) ActionCol52(org.drools.workbench.models.guided.dtable.shared.model.ActionCol52) ArrayList(java.util.ArrayList) GuidedDTTemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) BRLActionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionColumn) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) ActionFieldValue(org.drools.workbench.models.datamodel.rule.ActionFieldValue) ActionInsertFact(org.drools.workbench.models.datamodel.rule.ActionInsertFact) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) BRLActionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) GuidedDTTemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider) TemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider) Test(org.junit.Test)

Example 10 with BRLActionVariableColumn

use of org.drools.workbench.models.guided.dtable.shared.model.BRLActionVariableColumn 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)

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