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

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


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

        model.rhs = new IAction[2];
        ActionUpdateField auf0 = new ActionUpdateField();
        auf0.variable = "$t0";
        ActionFieldValue auf0f0 = new ActionFieldValue( "AUF0F0",
                                                        "AUF0F0Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        auf0f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        auf0.addFieldValue( auf0f0 );
        ActionFieldValue auf0f1 = new ActionFieldValue( "AUF0F1",
                                                        "AUF0F1Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        auf0f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        auf0.addFieldValue( auf0f1 );
        model.rhs[0] = auf0;

        ActionUpdateField auf1 = new ActionUpdateField();
        auf1.variable = "$t1";
        ActionFieldValue auf1f0 = new ActionFieldValue( "AUF1F0",
                                                        "AUF1F0Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        auf1f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        auf1.addFieldValue( auf1f0 );
        ActionFieldValue auf1f1 = new ActionFieldValue( "AUF1F1",
                                                        "AUF1F1Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        auf1f1.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        auf1.addFieldValue( auf1f1 );
        model.rhs[1] = auf1;

        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 ActionUpdateField );
        ActionUpdateField auf0Clone = (ActionUpdateField) clone.rhs[0];
        assertEquals( "$t0",
                      auf0Clone.variable );
        assertEquals( 2,
                      auf0Clone.fieldValues.length );

        assertNotSame( auf0.fieldValues[0],
                       auf0Clone.fieldValues[0] );
        assertNotNull( auf0Clone.fieldValues[0] );
        assertTrue( auf0Clone.fieldValues[0] instanceof ActionFieldValue );
        ActionFieldValue auf0f0Clone = (ActionFieldValue) auf0Clone.fieldValues[0];
        assertEquals( auf0f0.field,
                      auf0f0Clone.field );
        assertEquals( auf0f0.nature,
                      auf0f0Clone.nature );
        assertEquals( auf0f0.type,
                      auf0f0Clone.type );
        assertEquals( auf0f0.value,
                      auf0f0Clone.value );

        assertNotSame( auf0.fieldValues[1],
                       auf0Clone.fieldValues[1] );
        assertNotNull( auf0Clone.fieldValues[1] );
        assertTrue( auf0Clone.fieldValues[1] instanceof ActionFieldValue );
        ActionFieldValue auf0f1Clone = (ActionFieldValue) auf0Clone.fieldValues[1];
        assertEquals( auf0f1.field,
                      auf0f1Clone.field );
        assertEquals( auf0f1.nature,
                      auf0f1Clone.nature );
        assertEquals( auf0f1.type,
                      auf0f1Clone.type );
        assertEquals( auf0f1.value,
                      auf0f1Clone.value );

        assertNotSame( model.rhs[1],
                       clone.rhs[1] );
        assertNotNull( clone.rhs[1] );
        assertTrue( clone.rhs[1] instanceof ActionUpdateField );
        ActionUpdateField auf1Clone = (ActionUpdateField) clone.rhs[1];
        assertEquals( "$t1",
                      auf1Clone.variable );
        assertEquals( 2,
                      auf1Clone.fieldValues.length );
View Full Code Here


                               position );
    }

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

                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(),
View Full Code Here

            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(),
View Full Code Here

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

                                        modeller.getModel().addRhsItem( new ActionUpdateField( factsCombo.getText() ) );

                                        modeller.setDirty( true );
                                        modeller.reloadRhs();
                                        close();
                                    }
View Full Code Here

        }
        return clone;
    }

    private ActionUpdateField visitActionFieldList(ActionUpdateField afl) {
        ActionUpdateField clone = new ActionUpdateField();
        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

        final CompositeFactPattern comp = new CompositeFactPattern( "not" );
        comp.addFactPattern( new FactPattern( "Cancel" ) );
        m.addLhsItem( comp );

        final ActionUpdateField set = new ActionUpdateField();
        set.variable = "p1";
        set.addFieldValue( new ActionFieldValue( "status",
                                                 "rejected",
                                                 SuggestionCompletionEngine.TYPE_STRING ) );
        m.addRhsItem( set );

        final ActionRetractFact ret = new ActionRetractFact( "p1" );
View Full Code Here

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

            m.addLhsItem( p );

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

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

        final CompositeFactPattern comp = new CompositeFactPattern( "not" );
        comp.addFactPattern( new FactPattern( "Cancel" ) );
        m.addLhsItem( comp );

        final ActionUpdateField set = new ActionUpdateField();
        set.variable = "p1";
        set.addFieldValue( new ActionFieldValue( "status",
                                                 "rejected",
                                                 SuggestionCompletionEngine.TYPE_STRING ) );
        m.addRhsItem( set );

        final ActionRetractFact ret = new ActionRetractFact( "p1" );
View Full Code Here

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

                                        modeller.getModel().addRhsItem( new ActionUpdateField( factsCombo.getText() ) );

                                        modeller.setDirty( true );
                                        modeller.reloadRhs();
                                        close();
                                    }
View Full Code Here

TOP

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

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.