Package org.drools.ide.common.client.modeldriven.brl

Examples of org.drools.ide.common.client.modeldriven.brl.ActionSetField


    assertEquals(y, model.getBoundFact("y"));
    assertEquals(x, model.getBoundFact("x"));

    model.rhs = new IAction[1];
    final ActionSetField set = new ActionSetField();
    set.variable = "x";
    model.rhs[0] = set;

    assertTrue(model.isBoundFactUsed("x"));
    assertFalse(model.isBoundFactUsed("y"));
View Full Code Here


    assertFalse(m.hasDSLSentences());

    m.addLhsItem(new FactPattern());
    assertFalse(m.hasDSLSentences());

    m.addRhsItem(new ActionSetField("q"));

    assertFalse(m.hasDSLSentences());

    m.addLhsItem(new DSLSentence());
    assertTrue(m.hasDSLSentences());
View Full Code Here

  }

        public void testAddItemRhsAtSpecificPosition() {
    final RuleModel model = new RuleModel();

                final ActionSetField a = new ActionSetField();
    model.addRhsItem(a);

                assertEquals(1, model.rhs.length);

    final ActionSetField b = new ActionSetField();
    model.addRhsItem(b);

    assertEquals(2, model.rhs.length);

                final ActionSetField c = new ActionSetField();
    model.addRhsItem(c,true);

    assertEquals(3, model.rhs.length);

    assertEquals(a, model.rhs[0]);
    assertEquals(b, model.rhs[1]);
    assertEquals(c, model.rhs[2]);

                final ActionSetField d = new ActionSetField();
    model.addRhsItem(d,false);

                assertEquals(4, model.rhs.length);

    assertEquals(d, model.rhs[0]);
    assertEquals(a, model.rhs[1]);
    assertEquals(b, model.rhs[2]);
    assertEquals(c, model.rhs[3]);

                final ActionSetField e = new ActionSetField();
    model.addRhsItem(e,2);

                assertEquals(5, model.rhs.length);

    assertEquals(d, model.rhs[0]);
    assertEquals(a, model.rhs[1]);
    assertEquals(e, model.rhs[2]);
    assertEquals(b, model.rhs[3]);
    assertEquals(c, model.rhs[4]);

                //test auto-bound
                final ActionSetField f = new ActionSetField();
                final ActionSetField g = new ActionSetField();
    model.addRhsItem(f,-1);
    model.addRhsItem(g,100);

                assertEquals(7, model.rhs.length);
View Full Code Here

            con.setConstraintValueType( SingleFieldConstraint.TYPE_LITERAL );
            p.addConstraint( con );

            m.addLhsItem( p );

            ActionSetField au = new ActionSetField( "$p" );
            au.addFieldValue( new ActionFieldValue( "dob",
                                                    "31-Jan-2000",
                                                    SuggestionCompletionEngine.TYPE_DATE ) );
            m.addRhsItem( au );

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

    }

    @Test
    public void testAddItemRhs() {
        final RuleModel model = new RuleModel();
        final IAction a0 = new ActionSetField();
        final IAction a1 = new ActionSetField();

        model.addRhsItem( a0 );

        assertEquals( 1,
                      model.rhs.length );
View Full Code Here

                      model.getLHSBoundFact( "y" ) );
        assertEquals( x,
                      model.getLHSBoundFact( "x" ) );

        model.rhs = new IAction[1];
        final ActionSetField set = new ActionSetField();
        set.variable = "x";
        model.rhs[0] = set;

        assertTrue( model.isBoundFactUsed( "x" ) );
        assertFalse( model.isBoundFactUsed( "y" ) );
View Full Code Here

        assertFalse( m.hasDSLSentences() );

        m.addLhsItem( new FactPattern() );
        assertFalse( m.hasDSLSentences() );

        m.addRhsItem( new ActionSetField( "q" ) );

        assertFalse( m.hasDSLSentences() );

        m.addLhsItem( new DSLSentence() );
        assertTrue( m.hasDSLSentences() );
View Full Code Here

    @Test
    public void testAddItemRhsAtSpecificPosition() {
        final RuleModel model = new RuleModel();

        final ActionSetField a = new ActionSetField();
        model.addRhsItem( a );

        assertEquals( 1,
                      model.rhs.length );

        final ActionSetField b = new ActionSetField();
        model.addRhsItem( b );

        assertEquals( 2,
                      model.rhs.length );

        final ActionSetField c = new ActionSetField();
        model.addRhsItem( c,
                          true );

        assertEquals( 3,
                      model.rhs.length );

        assertEquals( a,
                      model.rhs[0] );
        assertEquals( b,
                      model.rhs[1] );
        assertEquals( c,
                      model.rhs[2] );

        final ActionSetField d = new ActionSetField();
        model.addRhsItem( d,
                          false );

        assertEquals( 4,
                      model.rhs.length );

        assertEquals( d,
                      model.rhs[0] );
        assertEquals( a,
                      model.rhs[1] );
        assertEquals( b,
                      model.rhs[2] );
        assertEquals( c,
                      model.rhs[3] );

        final ActionSetField e = new ActionSetField();
        model.addRhsItem( e,
                          2 );

        assertEquals( 5,
                      model.rhs.length );

        assertEquals( d,
                      model.rhs[0] );
        assertEquals( a,
                      model.rhs[1] );
        assertEquals( e,
                      model.rhs[2] );
        assertEquals( b,
                      model.rhs[3] );
        assertEquals( c,
                      model.rhs[4] );

        //test auto-bound
        final ActionSetField f = new ActionSetField();
        final ActionSetField g = new ActionSetField();
        model.addRhsItem( f,
                          -1 );
        model.addRhsItem( g,
                          100 );
View Full Code Here

        RuleModel model = new RuleModel();
        model.name = "rule2";
        FactPattern pattern = new FactPattern("Person");
        pattern.setBoundName("p");
        ActionSetField action = new ActionSetField("p");
        ActionFieldValue value = new ActionFieldValue("age",
                "42",
                SuggestionCompletionEngine.TYPE_NUMERIC);
        action.addFieldValue(value);

        model.addLhsItem(pattern);
        model.addRhsItem(action);

        DSLSentence dslCondition = new DSLSentence();
        dslCondition.setDefinition( "This is a sentence" );

        model.addLhsItem(dslCondition);

        DSLSentence dslAction = new DSLSentence();
        dslAction.setDefinition( "say {42}" );

        model.addRhsItem(dslAction);

        rule1.updateContent(BRXMLPersistence.getInstance().marshal(model));
        rule1.checkin("");
        repo.save();

        //now add a rule with no DSL
        model = new RuleModel();
        model.name = "ruleNODSL";
        pattern = new FactPattern("Person");
        pattern.setBoundName("p");
        action = new ActionSetField("p");
        value = new ActionFieldValue("age",
                "42",
                SuggestionCompletionEngine.TYPE_NUMERIC);
        action.addFieldValue(value);

        model.addLhsItem(pattern);
        model.addRhsItem(action);

        AssetItem ruleNODSL = pkg.addAsset("ruleNoDSL",
View Full Code Here

        con.setConstraintValueType( BaseSingleFieldConstraint.TYPE_PREDICATE );
        con.setValue( "name soundslike 'foobar'" );
        pattern.addConstraint( con );

        pattern.setBoundName( "p" );
        ActionSetField action = new ActionSetField( "p" );
        ActionFieldValue value = new ActionFieldValue( "age",
                                                       "42",
                                                       SuggestionCompletionEngine.TYPE_NUMERIC );
        action.addFieldValue( value );

        model.addLhsItem( pattern );
        model.addRhsItem( action );

        rule2.updateContent( BRXMLPersistence.getInstance().marshal( model ) );
View Full Code Here

TOP

Related Classes of org.drools.ide.common.client.modeldriven.brl.ActionSetField

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.