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

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


       
       
    }
   
    public void testIsBound() {
        FactPattern pat = new FactPattern();
        pat.boundName = "x";
        assertTrue(pat.isBound());
       
        pat = new FactPattern();
        assertFalse(pat.isBound());
    }
View Full Code Here


        pat = new FactPattern();
        assertFalse(pat.isBound());
    }
   
    public void testGetFieldConstraints() {
        FactPattern pat = new FactPattern();
        assertEquals(0, pat.getFieldConstraints().length);
        assertNull(pat.constraintList);
       
        pat.addConstraint( new SingleFieldConstraint() );
        assertNotNull(pat.constraintList);
        assertEquals(1, pat.getFieldConstraints().length);
    }
View Full Code Here

public class CompositeFactPatternTest extends TestCase {

    public void testAddPattern() {
        final CompositeFactPattern pat = new CompositeFactPattern();
        final FactPattern x = new FactPattern();
        pat.addFactPattern( x );
        assertEquals( 1,
                      pat.patterns.length );

        final FactPattern y = new FactPattern();
        pat.addFactPattern( y );
        assertEquals( 2,
                      pat.patterns.length );
        assertEquals( x,
                      pat.patterns[0] );
View Full Code Here

    assertEquals("Cheese", ((FactPattern)rm.lhs[1]).factType);
    assertEquals("c", ((FactPattern)rm.lhs[1]).boundName);

    //examine the first pattern
    FactPattern person = (FactPattern) rm.lhs[0];
    assertEquals(3, person.constraintList.constraints.length);
    SingleFieldConstraint cons = (SingleFieldConstraint) person.constraintList.constraints[0];
    assertEquals(ISingleFieldConstraint.TYPE_LITERAL, cons.constraintValueType);
    assertEquals("name", cons.fieldName);
    assertEquals("==", cons.operator);
    assertEquals("mike", cons.value);

    cons = (SingleFieldConstraint) person.constraintList.constraints[1];
    assertEquals(ISingleFieldConstraint.TYPE_RET_VALUE, cons.constraintValueType);
    assertEquals("age", cons.fieldName);
    assertEquals("<", cons.operator);
    assertEquals("33 + 1", cons.value);

    cons = (SingleFieldConstraint) person.constraintList.constraints[2];
    assertEquals(ISingleFieldConstraint.TYPE_PREDICATE, cons.constraintValueType);
    assertEquals("age > 6", cons.value);


    //examine the second pattern
    FactPattern cheese = (FactPattern) rm.lhs[1];
    assertEquals(1, cheese.constraintList.constraints.length);
    cons = (SingleFieldConstraint) cheese.constraintList.constraints[0];
    assertEquals("type", cons.fieldName);
    assertEquals("==", cons.operator);
    assertEquals("stilton", cons.value);
View Full Code Here

        layout.setStyleName( "model-builderInner-Background" );
        if (completions.isGlobalVariable( set.variable )) {
            this.fieldCompletions = completions.getFieldCompletionsForGlobalVariable( set.variable );
            this.variableClass = (String) completions.globalTypes.get( set.variable );
        } else {
            FactPattern pattern = mod.getModel().getBoundFact( set.variable );
            this.fieldCompletions = completions.getFieldCompletions( pattern.factType );
            this.variableClass = pattern.factType;
            this.isBoundFact = true;
        }
View Full Code Here

        popup.addAttribute(constants.chooseFactType(),
                            box );

        box.addChangeListener( new ChangeListener() {
            public void onChange(Widget w) {
                pattern.addFactPattern( new FactPattern( box.getItemText( box.getSelectedIndex() ) ) );
                modeller.refreshWidget();
                popup.hide();
            }
        } );
View Full Code Here

        layout.setStyleName( "model-builderInner-Background" ); //NON-NLS
        if (completions.isGlobalVariable( set.variable )) {
            this.fieldCompletions = completions.getFieldCompletionsForGlobalVariable( set.variable );
            this.variableClass = (String) completions.globalTypes.get( set.variable );
        } else {
            FactPattern pattern = mod.getModel().getBoundFact( set.variable );
            this.fieldCompletions = completions.getFieldCompletions( pattern.factType );
            this.variableClass = pattern.factType;
            this.isBoundFact = true;
        }
View Full Code Here

      ConditionCol c = (ConditionCol) conditionCols.get(i);
      String cell = row[i + GuidedDecisionTable.INTERNAL_ELEMENTS + numOfAttributesAndMeta];
      if (validCell(cell)) {

        //get or create the pattern it belongs too
        FactPattern fp = find(patterns, c.boundName);
        if (fp == null) {
          fp = new FactPattern(c.factType);
          fp.boundName = c.boundName;
          patterns.add(fp);
        }



        //now add the constraint from this cell
        switch (c.constraintValueType) {
          case ISingleFieldConstraint.TYPE_LITERAL:
          case ISingleFieldConstraint.TYPE_RET_VALUE:
            SingleFieldConstraint sfc = new SingleFieldConstraint(c.factField);
            if (no(c.operator)) {

              String[] a = cell.split("\\s");
              if (a.length > 1) {
                sfc.operator = a[0];
                sfc.value = a[1];
              } else {
                sfc.value = cell;
              }
            } else {
              sfc.operator = c.operator;
              sfc.value = cell;
            }
            sfc.constraintValueType = c.constraintValueType;
            fp.addConstraint(sfc);
            break;
          case ISingleFieldConstraint.TYPE_PREDICATE:
            SingleFieldConstraint pred = new SingleFieldConstraint();
            pred.constraintValueType = c.constraintValueType;
            pred.value = cell;
            fp.addConstraint(pred);
            break;
        default:
          throw new IllegalArgumentException("Unknown constraintValueType: " + c.constraintValueType);
        }
      }
View Full Code Here

TOP

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

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.