Search in sources :

Example 16 with FromCollectCompositeFactPattern

use of org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern in project drools by kiegroup.

the class RuleTemplateModelDRLPersistenceTest method testSimpleFromCollectMultipleSubPatternValuesFirstValue.

@Test
public void testSimpleFromCollectMultipleSubPatternValuesFirstValue() {
    TemplateModel m = new TemplateModel();
    m.name = "r1";
    FactPattern fp = new FactPattern("Person");
    SingleFieldConstraint sfc = new SingleFieldConstraint("field1");
    sfc.setConstraintValueType(SingleFieldConstraint.TYPE_TEMPLATE);
    sfc.setFieldType(DataType.TYPE_STRING);
    sfc.setOperator("==");
    sfc.setValue("$f1");
    fp.addConstraint(sfc);
    SingleFieldConstraint sfc1 = new SingleFieldConstraint("field2");
    sfc1.setConstraintValueType(SingleFieldConstraint.TYPE_TEMPLATE);
    sfc1.setFieldType(DataType.TYPE_STRING);
    sfc1.setOperator("==");
    sfc1.setValue("$f2");
    fp.addConstraint(sfc1);
    FactPattern fp2 = new FactPattern("java.util.List");
    SingleFieldConstraint sfc2 = new SingleFieldConstraint("size");
    sfc2.setConstraintValueType(SingleFieldConstraint.TYPE_TEMPLATE);
    sfc2.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
    sfc2.setOperator(">");
    sfc2.setValue("$f3");
    fp2.addConstraint(sfc2);
    FromCollectCompositeFactPattern fac = new FromCollectCompositeFactPattern();
    fac.setRightPattern(fp);
    fac.setFactPattern(fp2);
    m.addLhsItem(fac);
    String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "java.util.List( size > 1 ) from collect ( Person( field1 == \"foo\" ) ) \n" + "then\n" + "end";
    m.addRow(new String[] { "1", "foo", null });
    checkMarshall(expected, m);
}
Also used : BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) TemplateModel(org.drools.workbench.models.guided.template.shared.TemplateModel) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) Test(org.junit.Test)

Example 17 with FromCollectCompositeFactPattern

use of org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern in project drools by kiegroup.

the class RuleTemplateModelDRLPersistenceTest method testSimpleFromCollectMultipleSubPatternValuesSecondValue.

@Test
public void testSimpleFromCollectMultipleSubPatternValuesSecondValue() {
    TemplateModel m = new TemplateModel();
    m.name = "r1";
    FactPattern fp = new FactPattern("Person");
    SingleFieldConstraint sfc = new SingleFieldConstraint("field1");
    sfc.setConstraintValueType(SingleFieldConstraint.TYPE_TEMPLATE);
    sfc.setFieldType(DataType.TYPE_STRING);
    sfc.setOperator("==");
    sfc.setValue("$f1");
    fp.addConstraint(sfc);
    SingleFieldConstraint sfc1 = new SingleFieldConstraint("field2");
    sfc1.setConstraintValueType(SingleFieldConstraint.TYPE_TEMPLATE);
    sfc1.setFieldType(DataType.TYPE_STRING);
    sfc1.setOperator("==");
    sfc1.setValue("$f2");
    fp.addConstraint(sfc1);
    FactPattern fp2 = new FactPattern("java.util.List");
    SingleFieldConstraint sfc2 = new SingleFieldConstraint("size");
    sfc2.setConstraintValueType(SingleFieldConstraint.TYPE_TEMPLATE);
    sfc2.setFieldType(DataType.TYPE_NUMERIC_INTEGER);
    sfc2.setOperator(">");
    sfc2.setValue("$f3");
    fp2.addConstraint(sfc2);
    FromCollectCompositeFactPattern fac = new FromCollectCompositeFactPattern();
    fac.setRightPattern(fp);
    fac.setFactPattern(fp2);
    m.addLhsItem(fac);
    String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "java.util.List( size > 1 ) from collect ( Person( field2 == \"bar\" ) ) \n" + "then\n" + "end";
    m.addRow(new String[] { "1", null, "bar" });
    checkMarshall(expected, m);
}
Also used : BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) TemplateModel(org.drools.workbench.models.guided.template.shared.TemplateModel) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) Test(org.junit.Test)

Example 18 with FromCollectCompositeFactPattern

use of org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern in project drools by kiegroup.

the class RuleTemplateModelDRLPersistenceTest method testFromCollectFreeFormLineFirstValue.

@Test
public void testFromCollectFreeFormLineFirstValue() {
    TemplateModel m = new TemplateModel();
    m.name = "r1";
    FreeFormLine ffl = new FreeFormLine();
    ffl.setText("Person( field1 == \"@{f1}\", field2 == \"@{f2}\" )");
    FactPattern fp = new FactPattern("java.util.List");
    FromCollectCompositeFactPattern fac = new FromCollectCompositeFactPattern();
    fac.setRightPattern(ffl);
    fac.setFactPattern(fp);
    m.addLhsItem(fac);
    String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "then\n" + "end";
    m.addRow(new String[] { "foo", null });
    checkMarshall(expected, m);
}
Also used : FreeFormLine(org.drools.workbench.models.datamodel.rule.FreeFormLine) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) TemplateModel(org.drools.workbench.models.guided.template.shared.TemplateModel) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) Test(org.junit.Test)

Example 19 with FromCollectCompositeFactPattern

use of org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern in project drools by kiegroup.

the class RuleTemplateModelDRLPersistenceTest method testSimpleFromCollect.

@Test
public void testSimpleFromCollect() {
    TemplateModel m = new TemplateModel();
    m.name = "r1";
    FactPattern fp = new FactPattern("Person");
    SingleFieldConstraint sfc = new SingleFieldConstraint("field1");
    sfc.setConstraintValueType(SingleFieldConstraint.TYPE_TEMPLATE);
    sfc.setFieldType(DataType.TYPE_STRING);
    sfc.setOperator("==");
    sfc.setValue("$f1");
    fp.addConstraint(sfc);
    FromCollectCompositeFactPattern fac = new FromCollectCompositeFactPattern();
    fac.setRightPattern(fp);
    fac.setFactPattern(new FactPattern("java.util.List"));
    m.addLhsItem(fac);
    String expected = "rule \"r1_0\"\n" + "dialect \"mvel\"\n" + "when\n" + "java.util.List( ) from collect ( Person( field1 == \"foo\" ) ) \n" + "then\n" + "end";
    m.addRow(new String[] { "foo" });
    checkMarshall(expected, m);
}
Also used : BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) TemplateModel(org.drools.workbench.models.guided.template.shared.TemplateModel) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) Test(org.junit.Test)

Example 20 with FromCollectCompositeFactPattern

use of org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern in project drools by kiegroup.

the class RuleModelDRLPersistenceTest method testFromCollectWithEmbeddedFromEntryPoint.

@Test
public void testFromCollectWithEmbeddedFromEntryPoint() {
    RuleModel m = new RuleModel();
    m.name = "r1";
    SingleFieldConstraint sfc = new SingleFieldConstraint("bar");
    sfc.setFactType(DataType.TYPE_NUMERIC_INTEGER);
    sfc.setFieldBinding("$a");
    sfc.setOperator("==");
    sfc.setValue("777");
    FactPattern fp = new FactPattern("Foo");
    fp.addConstraint(sfc);
    FromEntryPointFactPattern fep = new FromEntryPointFactPattern();
    fep.setEntryPointName("ep");
    fep.setFactPattern(fp);
    FromCollectCompositeFactPattern fac = new FromCollectCompositeFactPattern();
    fac.setRightPattern(fep);
    fac.setFactPattern(new FactPattern("java.util.List"));
    m.addLhsItem(fac);
    String expected = "rule \"r1\"\n" + "dialect \"mvel\"\n" + "when\n" + "java.util.List( ) from collect ( Foo( $a : bar == 777 ) from entry-point \"ep\" ) \n" + "then\n" + "end";
    checkMarshalling(expected, m);
}
Also used : SingleFieldConstraint(org.drools.workbench.models.datamodel.rule.SingleFieldConstraint) BaseSingleFieldConstraint(org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) FromEntryPointFactPattern(org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern) CompositeFactPattern(org.drools.workbench.models.datamodel.rule.CompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) FactPattern(org.drools.workbench.models.datamodel.rule.FactPattern) FromAccumulateCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern) FromCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern) FromCollectCompositeFactPattern(org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) Test(org.junit.Test)

Aggregations

FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)27 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)24 CompositeFactPattern (org.drools.workbench.models.datamodel.rule.CompositeFactPattern)20 Test (org.junit.Test)18 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)15 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)15 BaseSingleFieldConstraint (org.drools.workbench.models.datamodel.rule.BaseSingleFieldConstraint)12 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)12 FromEntryPointFactPattern (org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern)10 TemplateModel (org.drools.workbench.models.guided.template.shared.TemplateModel)10 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)6 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)5 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)5 Widget (com.google.gwt.user.client.ui.Widget)5 FreeFormLine (org.drools.workbench.models.datamodel.rule.FreeFormLine)5 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)4 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)4 ExpressionFormLine (org.drools.workbench.models.datamodel.rule.ExpressionFormLine)4 ExpressionVariable (org.drools.workbench.models.datamodel.rule.ExpressionVariable)4 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)4