Package org.drools.brms.client.modeldriven.brl

Examples of org.drools.brms.client.modeldriven.brl.SingleFieldConstraint


        model.lhs = new IPattern[2];
        final FactPattern x = new FactPattern( "Car" );
        model.lhs[0] = x;
        x.boundName = "boundFact";       
       
        SingleFieldConstraint sfc = new SingleFieldConstraint("q");
        x.addConstraint( sfc );
        sfc.fieldBinding = "field1";
       
        SingleFieldConstraint sfc2 = new SingleFieldConstraint("q");
        x.addConstraint( sfc2 );
        sfc2.fieldBinding = "field2";
       
       
        model.lhs[1] = new CompositeFactPattern();
View Full Code Here


import org.drools.brms.client.modeldriven.brl.SingleFieldConstraint;

public class ConstraintTest extends TestCase {

    public void testAdd() {
        final SingleFieldConstraint con = new SingleFieldConstraint();
        con.addNewConnective();

        assertEquals( 1,
                      con.connectives.length );
        assertNotNull( con.connectives[0] );

        con.addNewConnective();

        assertEquals( 2,
                      con.connectives.length );
        assertNotNull( con.connectives[1] );
View Full Code Here

      sce.dataEnumLists.put("Fact.type", new String[] {"sex", "colour"});
      sce.dataEnumLists.put("Fact.value[type=sex]", new String[] {"M", "F"});
      sce.dataEnumLists.put("Fact.value[type=colour]", new String[] {"RED", "WHITE", "BLUE"});

      FactPattern pat = new FactPattern("Fact");
      SingleFieldConstraint sfc = new SingleFieldConstraint("type");
      sfc.value = "sex";
      pat.addConstraint(sfc);
      String[] result = sce.getEnums(pat, "value");
      assertEquals(2, result.length);
      assertEquals("M", result[0]);
      assertEquals("F", result[1]);


      pat = new FactPattern("Fact");
      sfc = new SingleFieldConstraint("type");
      sfc.value = "colour";
      pat.addConstraint(sfc);

      result = sce.getEnums(pat, "value");
      assertEquals(3, result.length);
View Full Code Here

        final RuleModel m = new RuleModel();
        m.name = "Complex Rule";
        final FactPattern pat = new FactPattern();
        pat.boundName = "p1";
        pat.factType = "Person";
        final SingleFieldConstraint con = new SingleFieldConstraint();
        con.fieldBinding = "f1";
        con.fieldName = "age";
//        con.operator = "<";
//        con.value = "42";
        pat.addConstraint( con );
View Full Code Here

                                           "aGroup" ) );

        final FactPattern pat = new FactPattern();
        pat.boundName = "p1";
        pat.factType = "Person";
        final SingleFieldConstraint con = new SingleFieldConstraint();
        con.fieldBinding = "f1";
        con.fieldName = "age";
        con.operator = "<";
        con.value = "42";
        pat.addConstraint( con );
View Full Code Here

        m.addLhsItem( p );
        CompositeFieldConstraint comp = new CompositeFieldConstraint();
        comp.compositeJunctionType = CompositeFieldConstraint.COMPOSITE_TYPE_OR;
        p.addConstraint( comp );

        final SingleFieldConstraint X = new SingleFieldConstraint();
        X.fieldName = "goo";
        X.constraintValueType = SingleFieldConstraint.TYPE_LITERAL;
        X.value = "foo";
        X.operator = "==";
        X.connectives = new ConnectiveConstraint[1];
        X.connectives[0] = new ConnectiveConstraint();
        X.connectives[0].constraintValueType = ConnectiveConstraint.TYPE_LITERAL;
        X.connectives[0].operator = "|| ==";
        X.connectives[0].value = "bar";
        comp.addConstraint( X );

        final SingleFieldConstraint Y = new SingleFieldConstraint();
        Y.fieldName = "goo2";
        Y.constraintValueType = SingleFieldConstraint.TYPE_LITERAL;
        Y.value = "foo";
        Y.operator = "==";
        comp.addConstraint( Y );

        CompositeFieldConstraint comp2 = new CompositeFieldConstraint();
        comp2.compositeJunctionType = CompositeFieldConstraint.COMPOSITE_TYPE_AND;
        final SingleFieldConstraint Q1 = new SingleFieldConstraint();
        Q1.fieldName = "goo";
        Q1.operator = "==";
        Q1.value = "whee";
        Q1.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;

        comp2.addConstraint( Q1 );

        final SingleFieldConstraint Q2 = new SingleFieldConstraint();
        Q2.fieldName = "gabba";
        Q2.operator = "==";
        Q2.value = "whee";
        Q2.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;

        comp2.addConstraint( Q2 );

        //now nest it
        comp.addConstraint( comp2 );



        final SingleFieldConstraint Z = new SingleFieldConstraint();
        Z.fieldName = "goo3";
        Z.constraintValueType = SingleFieldConstraint.TYPE_LITERAL;
        Z.value = "foo";
        Z.operator = "==";
View Full Code Here

        FactPattern p = new FactPattern();
        p.factType = "Person";

        //this isn't an effective constraint, so it should be ignored.
        p.addConstraint( new SingleFieldConstraint("field1") );

        m.addLhsItem( p );

        String actual = BRDRLPersistence.getInstance().marshal( m );

        String expected = "rule \"boo\" \tdialect \"mvel\"\n when Person() then end";

        assertEqualsIgnoreWhitespace( expected, actual );

        SingleFieldConstraint con = (SingleFieldConstraint) p.constraintList.constraints[0];
        con.fieldBinding = "q";

        //now it should appear, as we are binding a var to it

        actual = BRDRLPersistence.getInstance().marshal( m );
View Full Code Here

        RuleModel m = new RuleModel();
        m.name = "test literal strings";

        FactPattern p = new FactPattern("Person");
        SingleFieldConstraint con = new SingleFieldConstraint();
        con.fieldName = "field1";
        con.operator = "==";
        con.value = "goo";
        con.constraintValueType = SingleFieldConstraint.TYPE_LITERAL;
        p.addConstraint( con );


        SingleFieldConstraint con2 = new SingleFieldConstraint();
        con2.fieldName = "field2";
        con2.operator = "==";
        con2.value = "variableHere";
        con2.constraintValueType = SingleFieldConstraint.TYPE_VARIABLE;
        p.addConstraint( con2 );
View Full Code Here

        RuleModel m = new RuleModel();
        m.name = "yeah";

        FactPattern p = new FactPattern();

        SingleFieldConstraint con = new SingleFieldConstraint();
        con.constraintValueType = SingleFieldConstraint.TYPE_RET_VALUE;
        con.value = "someFunc(x)";
        con.operator = "==";
        con.fieldName = "goo";
        p.factType = "Goober";
View Full Code Here

        RuleModel m = new RuleModel();
        m.name = "yeah";

        FactPattern p = new FactPattern();

        SingleFieldConstraint con = new SingleFieldConstraint();
        con.constraintValueType = SingleFieldConstraint.TYPE_PREDICATE;
        con.value = "field soundslike 'poo'";

        p.factType = "Goober";
View Full Code Here

TOP

Related Classes of org.drools.brms.client.modeldriven.brl.SingleFieldConstraint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.