Search in sources :

Example 11 with ExpressionField

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

the class CopyExpressionVisitor method visit.

public void visit(ExpressionField part) {
    add(new ExpressionField(part.getName(), part.getClassType(), part.getGenericType(), part.getParametricType()));
    moveNext(part);
}
Also used : ExpressionField(org.drools.workbench.models.datamodel.rule.ExpressionField)

Example 12 with ExpressionField

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

the class RuleModelDRLPersistenceTest method testLHSExpressionDate.

@Test
public void testLHSExpressionDate() {
    RuleModel m = new RuleModel();
    m.name = "test expressionsDate";
    FactPattern p = new FactPattern("Person");
    SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide();
    con.getExpressionLeftSide().appendPart(new ExpressionUnboundFact(p.getFactType()));
    con.getExpressionLeftSide().appendPart(new ExpressionField("field1", "java.util.Date", DataType.TYPE_DATE));
    con.setOperator("==");
    con.setValue("27-Jun-2011");
    con.setConstraintValueType(SingleFieldConstraint.TYPE_LITERAL);
    p.addConstraint(con);
    m.addLhsItem(p);
    String expected = "rule \"test expressionsDate\"" + "\tdialect \"mvel\"\n when " + "     Person( field1 == \"27-Jun-2011\" )" + " then " + "end";
    checkMarshalling(expected, m);
}
Also used : SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) 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) ExpressionField(org.drools.workbench.models.datamodel.rule.ExpressionField) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) ExpressionUnboundFact(org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact) Test(org.junit.Test)

Example 13 with ExpressionField

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

the class RuleModelDRLPersistenceTest method testLHSExpressionNumber.

@Test
public void testLHSExpressionNumber() {
    RuleModel m = new RuleModel();
    m.name = "test expressionsNumber";
    FactPattern p = new FactPattern("Person");
    SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide();
    con.getExpressionLeftSide().appendPart(new ExpressionUnboundFact(p.getFactType()));
    con.getExpressionLeftSide().appendPart(new ExpressionField("field1", "java.lang.Integer", DataType.TYPE_NUMERIC_INTEGER));
    con.setOperator("==");
    con.setValue("55");
    con.setConstraintValueType(SingleFieldConstraint.TYPE_LITERAL);
    p.addConstraint(con);
    m.addLhsItem(p);
    String expected = "rule \"test expressionsNumber\"" + "\tdialect \"mvel\"\n when " + "     Person( field1 == 55 )" + " then " + "end";
    checkMarshalling(expected, m);
}
Also used : SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) 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) ExpressionField(org.drools.workbench.models.datamodel.rule.ExpressionField) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) ExpressionUnboundFact(org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact) Test(org.junit.Test)

Example 14 with ExpressionField

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

the class RuleModelDRLPersistenceTest method testLHSExpressionNestedJavaEnum.

@Test
public void testLHSExpressionNestedJavaEnum() {
    RuleModel m = new RuleModel();
    m.name = "test expressionsNestedJavaEnum";
    FactPattern p = new FactPattern("Person");
    SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide();
    con.getExpressionLeftSide().appendPart(new ExpressionUnboundFact(p.getFactType()));
    con.getExpressionLeftSide().appendPart(new ExpressionField("favouriteCheese", "Cheese", DataType.TYPE_OBJECT));
    con.getExpressionLeftSide().appendPart(new ExpressionField("genericName", "CHEESE", DataType.TYPE_COMPARABLE));
    con.setOperator("==");
    con.setValue("CHEESE.Cheddar");
    con.setConstraintValueType(SingleFieldConstraint.TYPE_LITERAL);
    p.addConstraint(con);
    m.addLhsItem(p);
    String expected = "rule \"test expressionsNestedJavaEnum\"" + "\tdialect \"mvel\"\n when " + "     Person( favouriteCheese.genericName == CHEESE.Cheddar )" + " then " + "end";
    checkMarshalling(expected, m);
}
Also used : SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) 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) ExpressionField(org.drools.workbench.models.datamodel.rule.ExpressionField) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) ExpressionUnboundFact(org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact) Test(org.junit.Test)

Example 15 with ExpressionField

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

the class RuleModelDRLPersistenceTest method testLHSExpressionBoolean.

@Test
public void testLHSExpressionBoolean() {
    RuleModel m = new RuleModel();
    m.name = "test expressionsBoolean";
    FactPattern p = new FactPattern("Person");
    SingleFieldConstraintEBLeftSide con = new SingleFieldConstraintEBLeftSide();
    con.getExpressionLeftSide().appendPart(new ExpressionUnboundFact(p.getFactType()));
    con.getExpressionLeftSide().appendPart(new ExpressionField("field1", "java.lang.Boolean", DataType.TYPE_BOOLEAN));
    con.setOperator("==");
    con.setValue("true");
    con.setConstraintValueType(SingleFieldConstraint.TYPE_LITERAL);
    p.addConstraint(con);
    m.addLhsItem(p);
    String expected = "rule \"test expressionsBoolean\"" + "\tdialect \"mvel\"\n when " + "     Person( field1 == true )" + " then " + "end";
    checkMarshalling(expected, m);
}
Also used : SingleFieldConstraintEBLeftSide(org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide) 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) ExpressionField(org.drools.workbench.models.datamodel.rule.ExpressionField) RuleModel(org.drools.workbench.models.datamodel.rule.RuleModel) ExpressionUnboundFact(org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact) Test(org.junit.Test)

Aggregations

ExpressionField (org.drools.workbench.models.datamodel.rule.ExpressionField)26 CompositeFactPattern (org.drools.workbench.models.datamodel.rule.CompositeFactPattern)24 FactPattern (org.drools.workbench.models.datamodel.rule.FactPattern)24 FromCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCompositeFactPattern)24 Test (org.junit.Test)24 FromAccumulateCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromAccumulateCompositeFactPattern)23 FromCollectCompositeFactPattern (org.drools.workbench.models.datamodel.rule.FromCollectCompositeFactPattern)23 RuleModel (org.drools.workbench.models.datamodel.rule.RuleModel)23 ExpressionUnboundFact (org.drools.workbench.models.datamodel.rule.ExpressionUnboundFact)21 SingleFieldConstraintEBLeftSide (org.drools.workbench.models.datamodel.rule.SingleFieldConstraintEBLeftSide)21 FromEntryPointFactPattern (org.drools.workbench.models.datamodel.rule.FromEntryPointFactPattern)11 ExpressionMethod (org.drools.workbench.models.datamodel.rule.ExpressionMethod)5 ExpressionVariable (org.drools.workbench.models.datamodel.rule.ExpressionVariable)5 ExpressionFormLine (org.drools.workbench.models.datamodel.rule.ExpressionFormLine)4 IPattern (org.drools.workbench.models.datamodel.rule.IPattern)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ExpressionText (org.drools.workbench.models.datamodel.rule.ExpressionText)2 SingleFieldConstraint (org.drools.workbench.models.datamodel.rule.SingleFieldConstraint)2 MethodInfo (org.kie.soup.project.datamodel.oracle.MethodInfo)2