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

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


            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


                     rm );
        assertEquals( 3,
                      rm.rhs.length );

        // examine the set field action that is produced
        ActionSetField a1 = (ActionSetField) rm.rhs[0];
        assertEquals( "a",
                      a1.variable );
        assertEquals( 2,
                      a1.fieldValues.length );
View Full Code Here

                     rm );
        assertEquals( 3,
                      rm.rhs.length );

        // examine the set field action that is produced
        ActionSetField a1 = (ActionSetField) rm.rhs[0];
        assertEquals( "a",
                      a1.variable );
        assertEquals( 2,
                      a1.fieldValues.length );
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_INTEGER );
        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_INTEGER );
        action.addFieldValue( value );

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

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

                               position );
    }

    private void addActionSetField(String itemText,
                                     int position) {
        this.model.addRhsItem( new ActionSetField( itemText ),
                               position );
    }
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

                               position );
    }

    private void addActionSetField(String itemText,
                                     int position) {
        this.model.addRhsItem( new ActionSetField( itemText ),
                               position );
    }
View Full Code Here

import org.drools.ide.common.client.modeldriven.brl.ActionSetField;

public class ActionSetFieldTest extends TestCase {

    public void testRemove() {
        final ActionSetField set = new ActionSetField();
        set.fieldValues = new ActionFieldValue[2];
        final ActionFieldValue v0 = new ActionFieldValue( "x",
                                                          "42",
                                                          SuggestionCompletionEngine.TYPE_NUMERIC );
        final ActionFieldValue v1 = new ActionFieldValue( "y",
                                                          "43",
                                                          SuggestionCompletionEngine.TYPE_NUMERIC );
        set.fieldValues[0] = v0;
        set.fieldValues[1] = v1;

        set.removeField( 1 );

        assertEquals( 1,
                      set.fieldValues.length );
        assertEquals( v0,
                      set.fieldValues[0] );
View Full Code Here

                      set.fieldValues[0] );

    }

    public void testAdd() {
        final ActionSetField set = new ActionSetField();
        set.fieldValues = new ActionFieldValue[2];
        final ActionFieldValue v0 = new ActionFieldValue( "x",
                                                          "42",
                                                          SuggestionCompletionEngine.TYPE_NUMERIC );
        final ActionFieldValue v1 = new ActionFieldValue( "y",
                                                          "43",
                                                          SuggestionCompletionEngine.TYPE_NUMERIC );
        set.fieldValues[0] = v0;
        set.fieldValues[1] = v1;

        final ActionFieldValue q = new ActionFieldValue( "q",
                                                         "q",
                                                         SuggestionCompletionEngine.TYPE_NUMERIC );
        set.addFieldValue( q );

        assertEquals( 3,
                      set.fieldValues.length );
        assertEquals( q,
                      set.fieldValues[2] );
View Full Code Here

  }

  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);
    model.addRhsItem(a1);
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.