Search in sources :

Example 11 with LimitedEntryConditionCol52

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

the class GuidedDTDRLPersistenceTest method testLimitedEntryActionSet.

@Test
public void testLimitedEntryActionSet() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    dt.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
    dt.setTableName("limited-entry");
    Pattern52 p1 = new Pattern52();
    p1.setBoundName("p1");
    p1.setFactType("Smurf");
    dt.getConditions().add(p1);
    LimitedEntryConditionCol52 cc1 = new LimitedEntryConditionCol52();
    cc1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    cc1.setFieldType(DataType.TYPE_BOOLEAN);
    cc1.setFactField("isSmurf");
    cc1.setOperator("==");
    cc1.setValue(new DTCellValue52("true"));
    p1.getChildColumns().add(cc1);
    LimitedEntryActionSetFieldCol52 asf1 = new LimitedEntryActionSetFieldCol52();
    asf1.setBoundName("p1");
    asf1.setFactField("colour");
    asf1.setValue(new DTCellValue52("Blue"));
    dt.getActionCols().add(asf1);
    dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc", true, true }, new Object[] { 2l, "desc", true, false } }));
    GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
    String drl = p.marshal(dt);
    int index = -1;
    index = drl.indexOf("Smurf( isSmurf == true )");
    assertTrue(index > -1);
    index = drl.indexOf("p1.setColour( \"Blue\" )", index + 1);
    assertTrue(index > -1);
    index = drl.indexOf("Smurf( isSmurf == true )", index + 1);
    assertTrue(index > -1);
    index = drl.indexOf("p1.setColour( \"Blue\" )", index + 1);
    assertFalse(index > -1);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) LimitedEntryActionSetFieldCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52) Test(org.junit.Test)

Example 12 with LimitedEntryConditionCol52

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

the class GuidedDTDRLPersistenceTest method testLimitedEntryConditionsNoConstraints.

@Test
public void testLimitedEntryConditionsNoConstraints() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    dt.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
    dt.setTableName("limited-entry");
    Pattern52 p1 = new Pattern52();
    p1.setBoundName("p1");
    p1.setFactType("Smurf");
    dt.getConditions().add(p1);
    // This is a hack consistent with how the Expanded Form decision table
    // works. I wouldn't be too surprised if this changes at some time, but
    // GuidedDTDRLPersistence.marshal does not support empty patterns at
    // present.
    LimitedEntryConditionCol52 cc1 = new LimitedEntryConditionCol52();
    cc1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    cc1.setValue(new DTCellValue52("y"));
    p1.getChildColumns().add(cc1);
    dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc", true }, new Object[] { 2l, "desc", false } }));
    GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
    String drl = p.marshal(dt);
    int index = -1;
    index = drl.indexOf("Smurf( )");
    assertTrue(index > -1);
    index = drl.indexOf("Smurf( )", index + 1);
    assertFalse(index > -1);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) Test(org.junit.Test)

Example 13 with LimitedEntryConditionCol52

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

the class GuidedDTDRLPersistenceTest method testLimitedEntryLHSIsNullOperatorWithNullValues.

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

Example 14 with LimitedEntryConditionCol52

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

the class GuidedDTDRLPersistenceTest method testLimitedEntryConditionsConstraints2.

@Test
public void testLimitedEntryConditionsConstraints2() {
    GuidedDecisionTable52 dt = new GuidedDecisionTable52();
    dt.setTableFormat(GuidedDecisionTable52.TableFormat.LIMITED_ENTRY);
    dt.setTableName("limited-entry");
    Pattern52 p1 = new Pattern52();
    p1.setBoundName("p1");
    p1.setFactType("Smurf");
    dt.getConditions().add(p1);
    LimitedEntryConditionCol52 cc1 = new LimitedEntryConditionCol52();
    cc1.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    cc1.setFieldType(DataType.TYPE_STRING);
    cc1.setFactField("name");
    cc1.setOperator("==");
    cc1.setValue(new DTCellValue52("Pupa"));
    p1.getChildColumns().add(cc1);
    LimitedEntryConditionCol52 cc2 = new LimitedEntryConditionCol52();
    cc2.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    cc2.setFieldType(DataType.TYPE_STRING);
    cc2.setFactField("name");
    cc2.setOperator("==");
    cc2.setValue(new DTCellValue52("Smurfette"));
    p1.getChildColumns().add(cc2);
    LimitedEntryConditionCol52 cc3 = new LimitedEntryConditionCol52();
    cc3.setConstraintValueType(BaseSingleFieldConstraint.TYPE_LITERAL);
    cc3.setFieldType(DataType.TYPE_STRING);
    cc3.setFactField("colour");
    cc3.setOperator("==");
    cc3.setValue(new DTCellValue52("Blue"));
    p1.getChildColumns().add(cc3);
    dt.setData(DataUtilities.makeDataLists(new Object[][] { new Object[] { 1l, "desc", true, false, true }, new Object[] { 2l, "desc", false, true, true }, new Object[] { 3l, "desc", false, false, true } }));
    GuidedDTDRLPersistence p = GuidedDTDRLPersistence.getInstance();
    String drl = p.marshal(dt);
    int index = -1;
    index = drl.indexOf("Smurf( name == \"Pupa\" , colour == \"Blue\" )");
    assertTrue(index > -1);
    index = drl.indexOf("Smurf( name == \"Smurfette\" , colour == \"Blue\" )", index + 1);
    assertTrue(index > -1);
    index = drl.indexOf("Smurf( colour == \"Blue\" )", index + 1);
    assertTrue(index > -1);
}
Also used : GuidedDecisionTable52(org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52) Pattern52(org.drools.workbench.models.guided.dtable.shared.model.Pattern52) LimitedEntryConditionCol52(org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52) DTCellValue52(org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) Test(org.junit.Test)

Example 15 with LimitedEntryConditionCol52

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

the class GuidedDTDRLPersistenceTest method testLimitedEntryLHSIsNotNullOperatorWithNullValues.

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

Aggregations

LimitedEntryConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryConditionCol52)20 Pattern52 (org.drools.workbench.models.guided.dtable.shared.model.Pattern52)14 Test (org.junit.Test)14 GuidedDecisionTable52 (org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52)12 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)10 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)10 DTCellValue52 (org.drools.workbench.models.guided.dtable.shared.model.DTCellValue52)9 ConditionCol52 (org.drools.workbench.models.guided.dtable.shared.model.ConditionCol52)3 LimitedEntryActionSetFieldCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionSetFieldCol52)2 ValueChangeEvent (com.google.gwt.event.logical.shared.ValueChangeEvent)1 ValueChangeHandler (com.google.gwt.event.logical.shared.ValueChangeHandler)1 MultiSelectionModel (com.google.gwt.view.client.MultiSelectionModel)1 SelectionChangeEvent (com.google.gwt.view.client.SelectionChangeEvent)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 BaseColumn (org.drools.workbench.models.guided.dtable.shared.model.BaseColumn)1 LimitedEntryActionInsertFactCol52 (org.drools.workbench.models.guided.dtable.shared.model.LimitedEntryActionInsertFactCol52)1 CEPOperatorsDropdown (org.drools.workbench.screens.guided.rule.client.editor.CEPOperatorsDropdown)1