Package org.drools.workbench.models.datamodel.rule

Examples of org.drools.workbench.models.datamodel.rule.ActionInsertFact


    public void testRHSFactBindingFirstBound() {

        RuleModel m = new RuleModel();
        m.name = "test";

        ActionInsertFact ai0 = new ActionInsertFact( "Person" );
        ai0.setBoundName( "fact0" );
        ai0.addFieldValue( new ActionFieldValue( "field1",
                                                 "55",
                                                 DataType.TYPE_NUMERIC_LONG ) );
        ActionInsertFact ai1 = new ActionInsertFact( "Person" );
        ai1.addFieldValue( new ActionFieldValue( "field1",
                                                 "55",
                                                 DataType.TYPE_NUMERIC_LONG ) );
        m.addRhsItem( ai0 );
        m.addRhsItem( ai1 );
View Full Code Here


    public void testRHSFactBindingLastBound() {

        RuleModel m = new RuleModel();
        m.name = "test";

        ActionInsertFact ai0 = new ActionInsertFact( "Person" );
        ai0.addFieldValue( new ActionFieldValue( "field1",
                                                 "55",
                                                 DataType.TYPE_NUMERIC_LONG ) );
        ActionInsertFact ai1 = new ActionInsertFact( "Person" );
        ai1.setBoundName( "fact0" );
        ai1.addFieldValue( new ActionFieldValue( "field1",
                                                 "55",
                                                 DataType.TYPE_NUMERIC_LONG ) );
        m.addRhsItem( ai0 );
        m.addRhsItem( ai1 );
View Full Code Here

        con.setFieldBinding( "$f" );
        p.addConstraint( con );

        m.addLhsItem( p );

        ActionInsertFact ai = new ActionInsertFact( "Person" );
        ActionFieldValue acv = new ActionFieldValue( "field1",
                                                     "=$f",
                                                     DataType.TYPE_OBJECT );
        acv.setNature( FieldNatureType.TYPE_VARIABLE );
        ai.addFieldValue( acv );
        m.addRhsItem( ai );

        String expected = "rule \"variable\"\n"
                + "dialect \"mvel\"\n"
                + "when\n"
View Full Code Here

        assertEquals( 1,
                      m.rhs.length );
        IAction a = m.rhs[ 0 ];
        assertTrue( a instanceof ActionInsertFact );

        ActionInsertFact ap = (ActionInsertFact) a;
        assertEquals( "Person",
                      ap.getFactType() );
        assertEquals( "fact0",
                      ap.getBoundName() );

        assertEquals( 1,
                      ap.getFieldValues().length );
        ActionFieldValue afv = ap.getFieldValues()[ 0 ];
        assertEquals( "field1",
                      afv.getField() );
        assertEquals( FieldNatureType.TYPE_VARIABLE,
                      afv.getNature() );
        assertEquals( "=$f",
View Full Code Here

        assertEquals( 1,
                      m.rhs.length );
        IAction a = m.rhs[ 0 ];
        assertTrue( a instanceof ActionInsertFact );

        ActionInsertFact ap = (ActionInsertFact) a;
        assertEquals( "Person",
                      ap.getFactType() );
        assertEquals( "fact0",
                      ap.getBoundName() );

        assertEquals( 1,
                      ap.getFieldValues().length );
        ActionFieldValue afv = ap.getFieldValues()[ 0 ];
        assertEquals( "field1",
                      afv.getField() );
        assertEquals( FieldNatureType.TYPE_LITERAL,
                      afv.getNature() );
        assertEquals( "55",
View Full Code Here

        assertEquals( 1,
                      m.rhs.length );
        IAction a = m.rhs[ 0 ];
        assertTrue( a instanceof ActionInsertFact );

        ActionInsertFact ap = (ActionInsertFact) a;
        assertEquals( "Person",
                      ap.getFactType() );
        assertEquals( "fact0",
                      ap.getBoundName() );

        assertEquals( 1,
                      ap.getFieldValues().length );
        ActionFieldValue afv = ap.getFieldValues()[ 0 ];
        assertEquals( "field1",
                      afv.getField() );
        assertEquals( FieldNatureType.TYPE_VARIABLE,
                      afv.getNature() );
        assertEquals( "=$f",
View Full Code Here

        assertEquals( 1,
                      m.rhs.length );
        IAction a = m.rhs[ 0 ];
        assertTrue( a instanceof ActionInsertFact );

        ActionInsertFact ap = (ActionInsertFact) a;
        assertEquals( "Person",
                      ap.getFactType() );
        assertEquals( "fact0",
                      ap.getBoundName() );

        assertEquals( 1,
                      ap.getFieldValues().length );
        ActionFieldValue afv = ap.getFieldValues()[ 0 ];
        assertEquals( "field1",
                      afv.getField() );
        assertEquals( FieldNatureType.TYPE_LITERAL,
                      afv.getNature() );
        assertEquals( "55",
View Full Code Here

        return clone;
    }

    //ActionInsertFact, ActionSetField, ActionpdateField
    private ActionInsertFact visitActionFieldList( ActionInsertFact afl ) {
        ActionInsertFact clone = new ActionInsertFact();
        clone.setFactType( afl.getFactType() );
        clone.setBoundName( afl.getBoundName() );
        for ( ActionFieldValue afv : afl.getFieldValues() ) {
            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

                }
            } else if ( line.startsWith( "insert" ) ) {
                String fact = unwrapParenthesis( line );
                String type = getStatementType( fact, factsType );
                if ( type != null ) {
                    ActionInsertFact action = new ActionInsertFact( type );
                    m.addRhsItem( action );
                    if ( factsType.containsKey( fact ) ) {
                        action.setBoundName( fact );
                        addSettersToAction( setStatements, fact, action, isJavaDialect );
                    }
                }
            } else if ( line.startsWith( "update" ) ) {
                String variable = unwrapParenthesis( line );
                ActionUpdateField action = new ActionUpdateField();
                action.setVariable( variable );
                m.addRhsItem( action );
                addSettersToAction( setStatements, variable, action, isJavaDialect );
            } else if ( line.startsWith( "retract" ) ) {
                String variable = unwrapParenthesis( line );
                m.addRhsItem( new ActionRetractFact( variable ) );
View Full Code Here

        ActionRetractFact a3 = (ActionRetractFact) rm.rhs[ 2 ];
        assertEquals( "retract",
                      a3.getVariableName() );

        // examine the insert
        ActionInsertFact a4 = (ActionInsertFact) rm.rhs[ 3 ];
        assertEquals( "Cheese",
                      a4.getFactType() );
        assertEquals( 2,
                      a4.getFieldValues().length );

        assertEquals( "price",
                      a4.getFieldValues()[ 0 ].getField() );
        assertEquals( "actioninsertfact1",
                      a4.getFieldValues()[ 0 ].getValue() );
        assertEquals( DataType.TYPE_NUMERIC_INTEGER,
                      a4.getFieldValues()[ 0 ].getType() );

        assertEquals( "type",
                      a4.getFieldValues()[ 1 ].getField() );
        assertEquals( "actioninsertfact2",
                      a4.getFieldValues()[ 1 ].getValue() );
        assertEquals( DataType.TYPE_NUMERIC_INTEGER,
                      a4.getFieldValues()[ 1 ].getType() );

    }
View Full Code Here

TOP

Related Classes of org.drools.workbench.models.datamodel.rule.ActionInsertFact

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.