Package org.drools.guvnor.client.modeldriven.brl

Examples of org.drools.guvnor.client.modeldriven.brl.CompositeFieldConstraint


    final FactPattern y = new FactPattern("Car");
    model.lhs[1] = y;
    y.boundName = "y";
    final SingleFieldConstraint[] cons = new SingleFieldConstraint[2];
    y.constraintList = new CompositeFieldConstraint();
    y.constraintList.constraints = cons;
    cons[0] = new SingleFieldConstraint("age");
    cons[1] = new SingleFieldConstraint("make");
    cons[0].fieldBinding = "qbc";
    cons[0].connectives = new ConnectiveConstraint[1];
    cons[0].connectives[0] = new ConnectiveConstraint("&", "x");
    cons[0].connectives[0].constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;

    final FactPattern other = new FactPattern("House");
    model.lhs[2] = other;
    other.boundName = "q";
    final SingleFieldConstraint[] cons2 = new SingleFieldConstraint[1];
    cons2[0] = new SingleFieldConstraint();
    other.constraintList = new CompositeFieldConstraint();
    other.constraintList.constraints = cons2;

    // check the results for correct scope
    List vars = model.getBoundVariablesInScope(cons[0]);
    assertEquals(1, vars.size());
View Full Code Here


  }

  public void testScopedVariablesWithCompositeFact() {
    RuleModel m = new RuleModel();
    FactPattern p = new FactPattern();
    CompositeFieldConstraint cf = new CompositeFieldConstraint();
    cf.addConstraint(new SingleFieldConstraint("x"));
    p.addConstraint(cf);
    SingleFieldConstraint sf = new SingleFieldConstraint("q");
    sf.fieldBinding = "abc";

    p.addConstraint(sf);
    SingleFieldConstraint sf2 = new SingleFieldConstraint("q");
    sf2.fieldBinding = "qed";
    cf.addConstraint(sf2);
    m.addLhsItem(p);

    List vars = m.getAllVariables();
    assertEquals(1, vars.size());
    assertEquals("abc", vars.get(0));
View Full Code Here

        assertEquals( 1,
                      p.constraintList.constraints.length );
        assertEquals( x,
                      p.constraintList.constraints[0] );

        final CompositeFieldConstraint y = new CompositeFieldConstraint();

        y.addConstraint( new SingleFieldConstraint("y") );
        y.addConstraint( new SingleFieldConstraint("z") );       
        p.addConstraint( y );
       
        assertEquals( 2,
                      p.constraintList.constraints.length );
        assertEquals( x,
View Full Code Here

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

public class CompositeFieldConstraintTest extends TestCase {

    public void testCompositeType() {
        CompositeFieldConstraint con = new CompositeFieldConstraint();
        assertEquals(null, con.compositeJunctionType);
    }
View Full Code Here

        CompositeFieldConstraint con = new CompositeFieldConstraint();
        assertEquals(null, con.compositeJunctionType);
    }
   
    public void testAddConstraint() {
        final CompositeFieldConstraint p = new CompositeFieldConstraint();
        final SingleFieldConstraint x = new SingleFieldConstraint( "x" );
        p.addConstraint( x );

        assertEquals( 1,
                      p.constraints.length );
        assertEquals( x,
                      p.constraints[0] );

        final SingleFieldConstraint y = new SingleFieldConstraint( "y" );

        p.addConstraint( y );
        assertEquals( 2,
                      p.constraints.length );
        assertEquals( x,
                      p.constraints[0] );
        assertEquals( y,
View Full Code Here

                      p.constraints[1] );

    }

    public void testRemoveConstraint() {
        final CompositeFieldConstraint p = new CompositeFieldConstraint();
        final SingleFieldConstraint x = new SingleFieldConstraint( "x" );
        p.addConstraint( x );
        final CompositeFieldConstraint y = new CompositeFieldConstraint(  );
        p.addConstraint( y );

        assertEquals( 2,
                      p.constraints.length );
View Full Code Here

        composites.addItem(constants.AnyOfOr(), CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        composites.setSelectedIndex( 0 );

        composites.addChangeListener( new ChangeListener() {
            public void onChange(Widget w) {
                CompositeFieldConstraint comp = new CompositeFieldConstraint();
                comp.compositeJunctionType = composites.getValue( composites.getSelectedIndex() );
                composite.addConstraint( comp );
                modeller.refreshWidget();
                popup.hide();
            }
View Full Code Here

        composites.addItem(constants.AnyOfOr(), CompositeFieldConstraint.COMPOSITE_TYPE_OR );
        composites.setSelectedIndex( 0 );

        composites.addChangeListener( new ChangeListener() {
            public void onChange(Widget w) {
                CompositeFieldConstraint comp = new CompositeFieldConstraint();
                comp.compositeJunctionType = composites.getValue( composites.getSelectedIndex() );
                pattern.addConstraint( comp );
                modeller.refreshWidget();
                popup.hide();
            }
View Full Code Here

         * It will only put brackets in for the ones that aren't at top level.
         * This makes for more readable DRL in the most common cases.
         */
        private void generateConstraint(FieldConstraint con, boolean nested, StringBuffer buf) {
            if (con instanceof CompositeFieldConstraint) {
                CompositeFieldConstraint cfc = (CompositeFieldConstraint) con;
                if (nested) buf.append( "( " );
                FieldConstraint[] nestedConstraints = cfc.constraints;
                if (nestedConstraints != null) {
                    for ( int i = 0; i < nestedConstraints.length; i++ ) {
                        generateConstraint( nestedConstraints[i] , true, buf);
View Full Code Here

TOP

Related Classes of org.drools.guvnor.client.modeldriven.brl.CompositeFieldConstraint

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.