Search in sources :

Example 6 with ConditionCol52

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

the class GuidedDTDRLPersistenceTest method multipleLHSNotPatternInclusion.

@Test
public void multipleLHSNotPatternInclusion() {
    GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
    Object[] row = new Object[] { "1", "desc", "mike", true, true };
    Object[][] data = new Object[1][];
    data[0] = row;
    List<BaseColumn> allColumns = new ArrayList<>();
    List<CompositeColumn<? extends BaseColumn>> allPatterns = new ArrayList<>();
    allColumns.add(new RowNumberCol52());
    allColumns.add(new DescriptionCol52());
    Pattern52 p1 = new Pattern52();
    p1.setBoundName("p1");
    p1.setFactType("Person");
    allPatterns.add(p1);
    ConditionCol52 p1col = new ConditionCol52();
    p1col.setFactField("name");
    p1col.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    p1col.setOperator("==");
    p1.getChildColumns().add(p1col);
    allColumns.add(p1col);
    Pattern52 p2 = new Pattern52();
    p2.setBoundName("");
    p2.setNegated(true);
    p2.setFactType("Cheese");
    allPatterns.add(p2);
    ConditionCol52 p2col = new ConditionCol52();
    p2col.setFactField("this");
    p2col.setOperator("");
    p2col.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    p2.getChildColumns().add(p2col);
    allColumns.add(p2col);
    Pattern52 p3 = new Pattern52();
    p3.setBoundName("");
    p3.setNegated(true);
    p3.setFactType("Smurf");
    allPatterns.add(p3);
    ConditionCol52 p3col = new ConditionCol52();
    p3col.setFactField("this");
    p3col.setOperator("!= null");
    p3col.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    p3.getChildColumns().add(p3col);
    allColumns.add(p3col);
    List<DTCellValue52> rowData = DataUtilities.makeDataRowList(row);
    TemplateDataProvider rowDataProvider = new GuidedDTTemplateDataProvider(allColumns, rowData);
    RuleModel rm = new RuleModel();
    rm.name = "r0";
    p.doConditions(allColumns, allPatterns, rowDataProvider, rowData, DataUtilities.makeDataLists(data), rm);
    final String actualRuleModelDrl = RuleModelDRLPersistenceImpl.getInstance().marshal(rm);
    final String expectedRuleModelDrl = "rule \"r0\"\n" + "  dialect \"mvel\"\n" + "  when\n" + "    p1 : Person( name == \"mike\" )\n" + "    not Cheese()\n" + "    not Smurf( this != null )\n" + "  then\n" + "end\n";
    assertEqualsIgnoreWhitespace(expectedRuleModelDrl, actualRuleModelDrl);
    final GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    dt.setTableName("dt");
    dt.getConditions().add(p1);
    dt.getConditions().add(p2);
    dt.getConditions().add(p3);
    dt.getData().addAll(DataUtilities.makeDataLists(data));
    final String actualDecisionTableDrl = GuidedDTDRLPersistence.getInstance().marshal(dt);
    final String expectedDecisionTableDrl = "//from row number: 1\n" + "//desc\n" + "rule \"Row1dt\"\n" + "  dialect \"mvel\"\n" + "  when\n" + "    p1 : Person( name == \"mike\" )\n" + "    not Cheese()\n" + "    not Smurf( this != null )\n" + "  then\n" + "end\n";
    assertEqualsIgnoreWhitespace(expectedDecisionTableDrl, actualDecisionTableDrl);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) 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) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) 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 7 with ConditionCol52

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

the class GuidedDTDRLPersistenceTest method testLHSWithBRLColumn_ParseToRuleModel.

@Test
public // This test checks a Decision Table involving BRL columns is correctly converted into a RuleModel
void testLHSWithBRLColumn_ParseToRuleModel() {
    GuidedDecisionTable52 dtable = new GuidedDecisionTable52();
    GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
    // All 3 rows should render, as the code is now lower down for skipping columns with empty cells
    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 Condition
    Pattern52 p1 = new Pattern52();
    p1.setFactType("Baddie");
    ConditionCol52 con = new ConditionCol52();
    con.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    con.setFactField("name");
    con.setOperator("==");
    p1.getChildColumns().add(con);
    dtable.getConditions().add(p1);
    // BRL Column
    BRLConditionColumn brl1 = new BRLConditionColumn();
    // BRL Column definition
    List<IPattern> brl1Definition = new ArrayList<IPattern>();
    FactPattern brl1DefinitionFactPattern1 = new FactPattern("Smurf");
    SingleFieldConstraint brl1DefinitionFactPattern1Constraint1 = new SingleFieldConstraint();
    brl1DefinitionFactPattern1Constraint1.setFieldType(DataType.TYPE_STRING);
    brl1DefinitionFactPattern1Constraint1.setConstraintValueType(SingleFieldConstraint.TYPE_TEMPLATE);
    brl1DefinitionFactPattern1Constraint1.setFieldName("name");
    brl1DefinitionFactPattern1Constraint1.setOperator("==");
    brl1DefinitionFactPattern1Constraint1.setValue("$name");
    brl1DefinitionFactPattern1.addConstraint(brl1DefinitionFactPattern1Constraint1);
    SingleFieldConstraint brl1DefinitionFactPattern1Constraint2 = new SingleFieldConstraint();
    brl1DefinitionFactPattern1Constraint2.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
    brl1DefinitionFactPattern1Constraint2.setConstraintValueType(SingleFieldConstraint.TYPE_TEMPLATE);
    brl1DefinitionFactPattern1Constraint2.setFieldName("age");
    brl1DefinitionFactPattern1Constraint2.setOperator("==");
    brl1DefinitionFactPattern1Constraint2.setValue("$age");
    brl1DefinitionFactPattern1.addConstraint(brl1DefinitionFactPattern1Constraint2);
    brl1Definition.add(brl1DefinitionFactPattern1);
    brl1.setDefinition(brl1Definition);
    // Setup BRL column bindings
    BRLConditionVariableColumn brl1Variable1 = new BRLConditionVariableColumn("$name", DataType.TYPE_STRING, "Person", "name");
    brl1.getChildColumns().add(brl1Variable1);
    BRLConditionVariableColumn brl1Variable2 = new BRLConditionVariableColumn("$age", DataType.TYPE_NUMERIC_INTEGER, "Person", "age");
    brl1.getChildColumns().add(brl1Variable2);
    dtable.getConditions().add(brl1);
    // Now to test conversion
    RuleModel rm = new RuleModel();
    List<BaseColumn> allColumns = dtable.getExpandedColumns();
    List<CompositeColumn<? extends BaseColumn>> allPatterns = dtable.getConditions();
    List<List<DTCellValue52>> dtData = DataUtilities.makeDataLists(data);
    // Row 0
    List<DTCellValue52> dtRowData0 = DataUtilities.makeDataRowList(data[0]);
    TemplateDataProvider rowDataProvider0 = new GuidedDTTemplateDataProvider(allColumns, dtRowData0);
    p.doConditions(allColumns, allPatterns, rowDataProvider0, dtRowData0, dtData, rm);
    assertEquals(2, rm.lhs.length);
    assertEquals("Baddie", ((FactPattern) rm.lhs[0]).getFactType());
    assertEquals("Smurf", ((FactPattern) rm.lhs[1]).getFactType());
    // examine the first pattern
    FactPattern result0Fp1 = (FactPattern) rm.lhs[0];
    assertEquals(1, result0Fp1.getConstraintList().getConstraints().length);
    SingleFieldConstraint result0Fp1Con1 = (SingleFieldConstraint) result0Fp1.getConstraint(0);
    assertEquals(BaseSingleFieldConstraint.TYPE_LITERAL, result0Fp1Con1.getConstraintValueType());
    assertEquals("name", result0Fp1Con1.getFieldName());
    assertEquals("==", result0Fp1Con1.getOperator());
    assertEquals("Gargamel", result0Fp1Con1.getValue());
    // examine the second pattern
    FactPattern result0Fp2 = (FactPattern) rm.lhs[1];
    assertEquals(2, result0Fp2.getConstraintList().getConstraints().length);
    SingleFieldConstraint result0Fp2Con1 = (SingleFieldConstraint) result0Fp2.getConstraint(0);
    assertEquals(BaseSingleFieldConstraint.TYPE_TEMPLATE, result0Fp2Con1.getConstraintValueType());
    assertEquals("name", result0Fp2Con1.getFieldName());
    assertEquals("==", result0Fp2Con1.getOperator());
    assertEquals("$name", result0Fp2Con1.getValue());
    SingleFieldConstraint result0Fp2Con2 = (SingleFieldConstraint) result0Fp2.getConstraint(1);
    assertEquals(BaseSingleFieldConstraint.TYPE_TEMPLATE, result0Fp2Con2.getConstraintValueType());
    assertEquals("age", result0Fp2Con2.getFieldName());
    assertEquals("==", result0Fp2Con2.getOperator());
    assertEquals("$age", result0Fp2Con2.getValue());
    // Row 1
    List<DTCellValue52> dtRowData1 = DataUtilities.makeDataRowList(data[1]);
    TemplateDataProvider rowDataProvider1 = new GuidedDTTemplateDataProvider(allColumns, dtRowData1);
    p.doConditions(allColumns, allPatterns, rowDataProvider1, dtRowData1, dtData, rm);
    assertEquals(2, rm.lhs.length);
    assertEquals("Baddie", ((FactPattern) rm.lhs[0]).getFactType());
    // examine the first pattern
    FactPattern result1Fp1 = (FactPattern) rm.lhs[0];
    assertEquals(1, result1Fp1.getConstraintList().getConstraints().length);
    SingleFieldConstraint result1Fp1Con1 = (SingleFieldConstraint) result1Fp1.getConstraint(0);
    assertEquals(BaseSingleFieldConstraint.TYPE_LITERAL, result1Fp1Con1.getConstraintValueType());
    assertEquals("name", result1Fp1Con1.getFieldName());
    assertEquals("==", result1Fp1Con1.getOperator());
    assertEquals("Gargamel", result1Fp1Con1.getValue());
    // examine the second pattern
    FactPattern result1Fp2 = (FactPattern) rm.lhs[1];
    assertEquals(2, result1Fp2.getConstraintList().getConstraints().length);
    SingleFieldConstraint result1Fp2Con1 = (SingleFieldConstraint) result1Fp2.getConstraint(0);
    assertEquals(BaseSingleFieldConstraint.TYPE_TEMPLATE, result1Fp2Con1.getConstraintValueType());
    assertEquals("name", result1Fp2Con1.getFieldName());
    assertEquals("==", result1Fp2Con1.getOperator());
    assertEquals("$name", result1Fp2Con1.getValue());
    SingleFieldConstraint result1Fp2Con2 = (SingleFieldConstraint) result1Fp2.getConstraint(1);
    assertEquals(BaseSingleFieldConstraint.TYPE_TEMPLATE, result1Fp2Con2.getConstraintValueType());
    assertEquals("age", result1Fp2Con2.getFieldName());
    assertEquals("==", result1Fp2Con2.getOperator());
    assertEquals("$age", result1Fp2Con2.getValue());
    // Row 2
    List<DTCellValue52> dtRowData2 = DataUtilities.makeDataRowList(data[2]);
    TemplateDataProvider rowDataProvider2 = new GuidedDTTemplateDataProvider(allColumns, dtRowData2);
    p.doConditions(allColumns, allPatterns, rowDataProvider2, dtRowData2, dtData, rm);
    assertEquals(2, rm.lhs.length);
    assertEquals("Baddie", ((FactPattern) rm.lhs[0]).getFactType());
    // examine the first pattern
    FactPattern result2Fp1 = (FactPattern) rm.lhs[0];
    assertEquals(1, result2Fp1.getConstraintList().getConstraints().length);
    SingleFieldConstraint result2Fp1Con1 = (SingleFieldConstraint) result2Fp1.getConstraint(0);
    assertEquals(BaseSingleFieldConstraint.TYPE_LITERAL, result2Fp1Con1.getConstraintValueType());
    assertEquals("name", result2Fp1Con1.getFieldName());
    assertEquals("==", result2Fp1Con1.getOperator());
    assertEquals("Gargamel", result2Fp1Con1.getValue());
    // examine the second pattern
    FactPattern result2Fp2 = (FactPattern) rm.lhs[1];
    assertEquals(2, result2Fp2.getConstraintList().getConstraints().length);
    SingleFieldConstraint result2Fp2Con1 = (SingleFieldConstraint) result2Fp2.getConstraint(0);
    assertEquals(BaseSingleFieldConstraint.TYPE_TEMPLATE, result2Fp2Con1.getConstraintValueType());
    assertEquals("name", result2Fp2Con1.getFieldName());
    assertEquals("==", result2Fp2Con1.getOperator());
    assertEquals("$name", result2Fp2Con1.getValue());
    SingleFieldConstraint result2Fp2Con2 = (SingleFieldConstraint) result2Fp2.getConstraint(1);
    assertEquals(BaseSingleFieldConstraint.TYPE_TEMPLATE, result2Fp2Con2.getConstraintValueType());
    assertEquals("age", result2Fp2Con2.getFieldName());
    assertEquals("==", result2Fp2Con2.getOperator());
    assertEquals("$age", result2Fp2Con2.getValue());
}
Also used : BRLConditionColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionColumn) IPattern(org.drools.workbench.models.datamodel.rule.IPattern) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) ArrayList(java.util.ArrayList) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) BRLConditionVariableColumn(org.drools.workbench.models.guided.dtable.shared.model.BRLConditionVariableColumn) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) List(java.util.List) ArrayList(java.util.ArrayList) GuidedDTTemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider) TemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.TemplateDataProvider) GuidedDTTemplateDataProvider(org.drools.workbench.models.guided.dtable.backend.util.GuidedDTTemplateDataProvider) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) RowNumberCol52(org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52) Test(org.junit.Test)

Example 8 with ConditionCol52

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

the class GuidedDTDRLPersistenceTest method testNoOperator.

@Test
public void testNoOperator() {
    GuidedDTDRLPersistence p = new GuidedDTDRLPersistence();
    String[] row = new String[] { "1", "desc", "a", "> 42" };
    String[][] data = new String[1][];
    data[0] = row;
    List<BaseColumn> allColumns = new ArrayList<BaseColumn>();
    List<CompositeColumn<? extends BaseColumn>> allPatterns = new ArrayList<CompositeColumn<? extends BaseColumn>>();
    allColumns.add(new RowNumberCol52());
    allColumns.add(new DescriptionCol52());
    allColumns.add(new MetadataCol52());
    Pattern52 p1 = new Pattern52();
    p1.setBoundName("p1");
    p1.setFactType("Person");
    allPatterns.add(p1);
    ConditionCol52 col1 = new ConditionCol52();
    col1.setFactField("age");
    col1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    col1.setOperator("");
    p1.getChildColumns().add(col1);
    allColumns.add(col1);
    RuleModel rm = new RuleModel();
    List<DTCellValue52> rowData = DataUtilities.makeDataRowList(row);
    TemplateDataProvider rowDataProvider = new GuidedDTTemplateDataProvider(allColumns, rowData);
    p.doConditions(allColumns, allPatterns, rowDataProvider, rowData, DataUtilities.makeDataLists(data), rm);
    String drl = RuleModelDRLPersistenceImpl.getInstance().marshal(rm);
    assertTrue(drl.indexOf("age > \"42\"") > 0);
}
Also used : 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) CompositeColumn(org.drools.workbench.models.guided.dtable.shared.model.CompositeColumn) MetadataCol52(org.drools.workbench.models.guided.dtable.shared.model.MetadataCol52) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) DescriptionCol52(org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) BaseColumn(org.drools.workbench.models.guided.dtable.shared.model.BaseColumn) 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 9 with ConditionCol52

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

the class GuidedDTDRLPersistenceTest method testInWithSimpleSingleLiteralValue.

@Test
public void testInWithSimpleSingleLiteralValue() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    dt.setTableName("in_operator");
    Pattern52 p1 = new Pattern52();
    p1.setFactType("Person");
    ConditionCol52 con = new ConditionCol52();
    con.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    con.setFieldType(DataType.TYPE_STRING);
    con.setFactField("field1");
    con.setHeader("Person field1");
    con.setOperator("in");
    p1.getChildColumns().add(con);
    dt.getConditions().add(p1);
    dt.setData(DataUtilities.makeDataLists(new String[][] { new String[] { "1", "desc1", "ak1,mk1" }, new String[] { "2", "desc2", "(ak2,mk2)" }, new String[] { "3", "desc3", "( ak3, mk3 )" }, new String[] { "4", "desc4", "( \"ak4\", \"mk4\" )" }, new String[] { "5", "desc5", "( \"ak5 \", \" mk5\" )" } }));
    GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
    String drl = p.marshal(dt);
    String expected = "//from row number: 1\n" + "//desc1\n" + "rule \"Row 1 in_operator\"\n" + "dialect \"mvel\"\n" + "when\n" + "  Person( field1 in ( \"ak1\", \"mk1\" ) )\n" + "then\n" + "end\n" + "//from row number: 2\n" + "//desc2\n" + "rule \"Row 2 in_operator\"\n" + "dialect \"mvel\"\n" + "when\n" + "  Person( field1 in ( \"ak2\", \"mk2\" ) )\n" + "then\n" + "end\n" + "//from row number: 3\n" + "//desc3\n" + "rule \"Row 3 in_operator\"\n" + "dialect \"mvel\"\n" + "when\n" + "  Person( field1 in ( \"ak3\", \"mk3\" ) )\n" + "then\n" + "end\n" + "//from row number: 4\n" + "//desc4\n" + "rule \"Row 4 in_operator\"\n" + "dialect \"mvel\"\n" + "when\n" + "  Person( field1 in ( \"ak4\", \"mk4\" ) )\n" + "then\n" + "end\n" + "//from row number: 5\n" + "//desc5\n" + "rule \"Row 5 in_operator\"\n" + "dialect \"mvel\"\n" + "when\n" + "  Person( field1 in ( \"ak5 \", \" mk5\" ) )\n" + "then\n" + "end";
    assertEqualsIgnoreWhitespace(expected, drl);
}
Also used : LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) Test(org.junit.Test)

Example 10 with ConditionCol52

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

the class GuidedDTDRLPersistenceTest method testLHSNotInOperator.

@Test
public void testLHSNotInOperator() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    dt.setTableFormat(GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY);
    dt.setTableName("extended-entry");
    Pattern52 p1 = new Pattern52();
    p1.setBoundName("p1");
    p1.setFactType("Smurf");
    dt.getConditions().add(p1);
    ConditionCol52 cc1 = new ConditionCol52();
    cc1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    cc1.setFieldType(DataType.TYPE_STRING);
    cc1.setFactField("name");
    cc1.setOperator("not in");
    p1.getChildColumns().add(cc1);
    ConditionCol52 cc2 = new ConditionCol52();
    cc2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    cc2.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
    cc2.setFactField("age");
    cc2.setOperator("not in");
    p1.getChildColumns().add(cc2);
    dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc", "Pupa, Brains", "55, 66" }, new Object[] { 2l, "desc", "", "" } }));
    GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
    String drl = p.marshal(dt);
    int index = -1;
    index = drl.indexOf("Smurf( name not in ( \"Pupa\", \"Brains\" ) , age not in ( 55, 66 ) )");
    assertTrue(index > -1);
    index = drl.indexOf("Smurf( )", index + 1);
    assertFalse(index > -1);
}
Also used : LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) ConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52) GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) Test(org.junit.Test)

Aggregations

ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)229 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)184 Test (org.junit.Test)170 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)74 LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)59 ActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionSetFieldCol52)38 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)38 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)34 ActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.ActionInsertFactCol52)31 ArrayList (java.util.ArrayList)27 Path (org.uberfire.backend.vfs.Path)27 StringUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.StringUiColumn)25 RawMVELEvaluator (org.kie.soup.project.datamodel.commons.util.RawMVELEvaluator)25 PackageDataModelOracleBaselinePayload (org.kie.workbench.common.services.datamodel.model.PackageDataModelOracleBaselinePayload)25 AsyncPackageDataModelOracle (org.kie.workbench.common.widgets.client.datamodel.AsyncPackageDataModelOracle)25 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)24 IntegerUiColumn (org.drools.workbench.screens.guided.dtable.client.widget.table.columns.IntegerUiColumn)24 DescriptionCol52 (org.drools.workbench.models.guided.dtable.shared.model.DescriptionCol52)23 RowNumberCol52 (org.drools.workbench.models.guided.dtable.shared.model.RowNumberCol52)23 ModelField (org.kie.soup.project.datamodel.oracle.ModelField)23