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

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


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

        model.rhs = new IAction[2];
        ActionSetField asf0 = new ActionSetField( "ASF0" );
        asf0.variable = "$t0";
        ActionFieldValue asf0f0 = new ActionFieldValue( "ASF0F0",
                                                        "ASF0F0Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        asf0f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        asf0.addFieldValue( asf0f0 );
        ActionFieldValue asf0f1 = new ActionFieldValue( "ASF0F1",
                                                        "ASF0F1Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        asf0f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        asf0.addFieldValue( asf0f1 );
        model.rhs[0] = asf0;

        ActionSetField asf1 = new ActionSetField( "ASF1" );
        asf1.variable = "$t1";
        ActionFieldValue asf1f0 = new ActionFieldValue( "ASF1F0",
                                                        "ASF1F0Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        asf1f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        asf1.addFieldValue( asf1f0 );
        ActionFieldValue asf1f1 = new ActionFieldValue( "ASF1F1",
                                                        "ASF1F1Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        asf1f1.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        asf1.addFieldValue( asf1f1 );
        model.rhs[1] = asf1;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 2,
                      clone.rhs.length );

        assertNotSame( model.rhs[0],
                       clone.rhs[0] );
        assertNotNull( clone.rhs[0] );
        assertTrue( clone.rhs[0] instanceof ActionSetField );
        ActionSetField asf0Clone = (ActionSetField) clone.rhs[0];
        assertEquals( "$t0",
                      asf0Clone.variable );
        assertEquals( 2,
                      asf0Clone.fieldValues.length );

        assertNotSame( asf0.fieldValues[0],
                       asf0Clone.fieldValues[0] );
        assertNotNull( asf0Clone.fieldValues[0] );
        assertTrue( asf0Clone.fieldValues[0] instanceof ActionFieldValue );
        ActionFieldValue asf0f0Clone = (ActionFieldValue) asf0Clone.fieldValues[0];
        assertEquals( asf0f0.field,
                      asf0f0Clone.field );
        assertEquals( asf0f0.nature,
                      asf0f0Clone.nature );
        assertEquals( asf0f0.type,
                      asf0f0Clone.type );
        assertEquals( asf0f0.value,
                      asf0f0Clone.value );

        assertNotSame( asf0.fieldValues[1],
                       asf0Clone.fieldValues[1] );
        assertNotNull( asf0Clone.fieldValues[1] );
        assertTrue( asf0Clone.fieldValues[1] instanceof ActionFieldValue );
        ActionFieldValue asf0f1Clone = (ActionFieldValue) asf0Clone.fieldValues[1];
        assertEquals( asf0f1.field,
                      asf0f1Clone.field );
        assertEquals( asf0f1.nature,
                      asf0f1Clone.nature );
        assertEquals( asf0f1.type,
                      asf0f1Clone.type );
        assertEquals( asf0f1.value,
                      asf0f1Clone.value );

        assertNotSame( model.rhs[1],
                       clone.rhs[1] );
        assertNotNull( clone.rhs[1] );
        assertTrue( clone.rhs[1] instanceof ActionSetField );
        ActionSetField asf1Clone = (ActionSetField) clone.rhs[1];
        assertEquals( "$t1",
                      asf1Clone.variable );
        assertEquals( 2,
                      asf1Clone.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

        //Examine RuleModel actions
        ActionExecuteWorkItem aw = (ActionExecuteWorkItem) rm.rhs[0];
        assertNotNull( aw );

        ActionSetField asf = (ActionSetField) rm.rhs[1];
        assertNotNull( asf );

        //Check ActionExecuteWorkItem
        PortableWorkDefinition mpwd = aw.getWorkDefinition();
        assertNotNull( mpwd );
View Full Code Here

        //Examine RuleModel actions
        ActionExecuteWorkItem aw = (ActionExecuteWorkItem) rm.rhs[0];
        assertNotNull( aw );

        ActionSetField asf = (ActionSetField) rm.rhs[1];
        assertNotNull( asf );

        //Check ActionExecuteWorkItem
        PortableWorkDefinition mpwd = aw.getWorkDefinition();
        assertNotNull( mpwd );
View Full Code Here

                               position );
    }

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

            } else if ( col instanceof BRLActionColumn ) {
                BRLActionColumn brl = (BRLActionColumn) col;
                for ( IAction a : brl.getDefinition() ) {
                    if ( a instanceof ActionSetField ) {
                        final ActionSetField action = (ActionSetField) a;
                        if ( action.variable.equals( binding ) ) {
                            return true;
                        }
                    } else if ( a instanceof ActionRetractFact ) {
                        final ActionRetractFact action = (ActionRetractFact) a;
View Full Code Here

                                                     sf.getBoundName() );
            if ( a == null ) {
                a = new LabelledAction();
                a.boundName = sf.getBoundName();
                if ( !sf.isUpdate() ) {
                    a.action = new ActionSetField( sf.getBoundName() );
                } else {
                    a.action = new ActionUpdateField( sf.getBoundName() );
                }
                actions.add( a );
            } else if ( sf.isUpdate() && !(a.action instanceof ActionUpdateField) ) {
                // lets swap it out for an update as the user has asked for it.
                ActionSetField old = (ActionSetField) a.action;
                ActionUpdateField update = new ActionUpdateField( sf.getBoundName() );
                update.fieldValues = old.fieldValues;
                a.action = update;
            }
            ActionSetField asf = (ActionSetField) a.action;
            ActionWorkItemFieldValue val = new ActionWorkItemFieldValue( sf.getFactField(),
                                                                         sf.getType(),
                                                                         sf.getWorkItemName(),
                                                                         sf.getWorkItemResultParameterName(),
                                                                         sf.getParameterClassName() );
            asf.addFieldValue( val );
        }
    }
View Full Code Here

                                                 sf.getBoundName() );
        if ( a == null ) {
            a = new LabelledAction();
            a.boundName = sf.getBoundName();
            if ( !sf.isUpdate() ) {
                a.action = new ActionSetField( sf.getBoundName() );
            } else {
                a.action = new ActionUpdateField( sf.getBoundName() );
            }
            actions.add( a );
        } else if ( sf.isUpdate() && !(a.action instanceof ActionUpdateField) ) {
            // lets swap it out for an update as the user has asked for it.
            ActionSetField old = (ActionSetField) a.action;
            ActionUpdateField update = new ActionUpdateField( sf.getBoundName() );
            update.fieldValues = old.fieldValues;
            a.action = update;
        }
        ActionSetField asf = (ActionSetField) a.action;
        ActionFieldValue val = new ActionFieldValue( sf.getFactField(),
                                                     cell,
                                                     sf.getType() );
        asf.addFieldValue( val );
    }
View Full Code Here

                                         public void handleEvent(Event event) {
                                             if ( globalVarsCombo.getSelectionIndex() == 0 ) {
                                                 return;
                                             }

                                             modeller.getModel().addRhsItem( new ActionSetField( globalVarsCombo.getText() ) );
                                             modeller.setDirty( true );
                                             modeller.reloadRhs();
                                             close();
                                         }
                                     } );
View Full Code Here

        }
        return clone;
    }

    private ActionSetField visitActionFieldList(ActionSetField afl) {
        ActionSetField clone = new ActionSetField();
        clone.variable = afl.variable;
        for ( ActionFieldValue afv : afl.fieldValues ) {
            ActionFieldValue afvClone = new ActionFieldValue();
            afvClone.setField( afv.getField() );
            afvClone.setNature( afv.getNature() );
            afvClone.setType( afv.getType() );
            afvClone.setValue( afv.getValue() );
            clone.addFieldValue( afvClone );
        }
        return clone;
    }
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.