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

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


        //RHS
        assertEquals( 1,
                      m.rhs.length );
        assertTrue( m.rhs[ 0 ] instanceof ActionSetField );

        final ActionSetField a = (ActionSetField) m.rhs[ 0 ];
        assertEquals( "$a",
                      a.getVariable() );
        assertEquals( 1,
                      a.getFieldValues().length );

        final ActionFieldValue fv = a.getFieldValues()[ 0 ];
        assertEquals( "name",
                      fv.getField() );
        assertEquals( "Michael",
                      fv.getValue() );
    }
View Full Code Here


        final FreeFormLine ffl = (FreeFormLine) m.rhs[ 0 ];
        assertEquals( "Here's something typed by the user as free-format DRL",
                      ffl.getText() );

        assertTrue( m.rhs[ 1 ] instanceof ActionSetField );
        final ActionSetField a1 = (ActionSetField) m.rhs[ 1 ];
        assertEquals( "$a",
                      a1.getVariable() );
        assertEquals( 2,
                      a1.getFieldValues().length );

        final ActionFieldValue fv1a1 = a1.getFieldValues()[ 0 ];
        assertEquals( "name",
                      fv1a1.getField() );
        assertEquals( "Michael",
                      fv1a1.getValue() );

        final ActionFieldValue fv1a2 = a1.getFieldValues()[ 1 ];
        assertEquals( "age",
                      fv1a2.getField() );
        assertEquals( "40",
                      fv1a2.getValue() );
    }
View Full Code Here

                                                                           Collections.EMPTY_LIST,
                                                                           dmo );
        assertEquals( 1,
                      m.rhs.length );
        assertTrue( m.rhs[ 0 ] instanceof ActionSetField );
        ActionSetField actionSetField = (ActionSetField) m.rhs[ 0 ];

        assertEquals( "c", actionSetField.getVariable() );

        assertEquals( 1, actionSetField.getFieldValues().length );

        ActionFieldValue actionFieldValue = actionSetField.getFieldValues()[ 0 ];

        assertEquals( "[\"item1\", \"item2\"]", actionFieldValue.getValue() );
        assertEquals( "emps", actionFieldValue.getField() );
        assertEquals( FieldNatureType.TYPE_FORMULA, actionFieldValue.getNature() );
        assertEquals( DataType.TYPE_COLLECTION, actionFieldValue.getType() );
View Full Code Here

        }
        return clone;
    }

    private ActionSetField visitActionFieldList( ActionSetField afl ) {
        ActionSetField clone = new ActionSetField();
        clone.setVariable( afl.getVariable() );
        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

                }
            }
        }

        for ( Map.Entry<String, List<String>> entry : setStatements.entrySet() ) {
            ActionSetField action = new ActionSetField( entry.getKey() );
            addSettersToAction( entry.getValue(), action, isJavaDialect );
            m.addRhsItem( action );
        }

        if ( expandedDRLInfo.hasDsl ) {
View Full Code Here

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

        // examine the set field action that is produced
        ActionSetField a1 = (ActionSetField) rm.rhs[ 0 ];
        assertEquals( "a",
                      a1.getVariable() );
        assertEquals( 1,
                      a1.getFieldValues().length );

        assertEquals( "field1",
                      a1.getFieldValues()[ 0 ].getField() );
        assertEquals( "actionsetfield1",
                      a1.getFieldValues()[ 0 ].getValue() );
        assertEquals( DataType.TYPE_STRING,
                      a1.getFieldValues()[ 0 ].getType() );

        ActionSetField a2 = (ActionSetField) rm.rhs[ 1 ];
        assertEquals( "a",
                      a2.getVariable() );
        assertEquals( 1,
                      a2.getFieldValues().length );

        assertEquals( "field2",
                      a2.getFieldValues()[ 0 ].getField() );
        assertEquals( "actionupdatefield2",
                      a2.getFieldValues()[ 0 ].getValue() );
        assertEquals( DataType.TYPE_NUMERIC_INTEGER,
                      a2.getFieldValues()[ 0 ].getType() );

        // examine the retract
        ActionRetractFact a3 = (ActionRetractFact) rm.rhs[ 2 ];
        assertEquals( "retract",
                      a3.getVariableName() );
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 );

        assertEquals( 4,
                      mpwd.getResults().size() );

        PortableBooleanParameterDefinition mp1 = (PortableBooleanParameterDefinition) mpwd.getResult( "BooleanResult" );
        assertNotNull( mp1 );

        PortableFloatParameterDefinition mp2 = (PortableFloatParameterDefinition) mpwd.getResult( "FloatResult" );
        assertNotNull( mp2 );

        PortableIntegerParameterDefinition mp3 = (PortableIntegerParameterDefinition) mpwd.getResult( "IntegerResult" );
        assertNotNull( mp3 );

        PortableStringParameterDefinition mp4 = (PortableStringParameterDefinition) mpwd.getResult( "StringResult" );
        assertNotNull( mp4 );

        //Check ActionSetField
        assertEquals( asf.getVariable(),
                      "$r" );
        assertEquals( 4,
                      asf.getFieldValues().length );

        ActionFieldValue fv1 = asf.getFieldValues()[ 0 ];
        assertNotNull( fv1 );
        assertTrue( fv1 instanceof ActionWorkItemFieldValue );
        ActionWorkItemFieldValue wifv1 = (ActionWorkItemFieldValue) fv1;
        assertEquals( "ResultBooleanField",
                      wifv1.getField() );
        assertEquals( DataType.TYPE_BOOLEAN,
                      wifv1.getType() );
        assertEquals( "WorkItem",
                      wifv1.getWorkItemName() );
        assertEquals( "BooleanResult",
                      wifv1.getWorkItemParameterName() );
        assertEquals( Boolean.class.getName(),
                      wifv1.getWorkItemParameterClassName() );

        ActionFieldValue fv2 = asf.getFieldValues()[ 1 ];
        assertNotNull( fv2 );
        assertTrue( fv2 instanceof ActionWorkItemFieldValue );
        ActionWorkItemFieldValue wifv2 = (ActionWorkItemFieldValue) fv2;
        assertEquals( "ResultFloatField",
                      wifv2.getField() );
        assertEquals( DataType.TYPE_NUMERIC_FLOAT,
                      wifv2.getType() );
        assertEquals( "WorkItem",
                      wifv2.getWorkItemName() );
        assertEquals( "FloatResult",
                      wifv2.getWorkItemParameterName() );
        assertEquals( Float.class.getName(),
                      wifv2.getWorkItemParameterClassName() );

        ActionFieldValue fv3 = asf.getFieldValues()[ 2 ];
        assertNotNull( fv3 );
        assertTrue( fv3 instanceof ActionWorkItemFieldValue );
        ActionWorkItemFieldValue wifv3 = (ActionWorkItemFieldValue) fv3;
        assertEquals( "ResultIntegerField",
                      wifv3.getField() );
        assertEquals( DataType.TYPE_NUMERIC_INTEGER,
                      wifv3.getType() );
        assertEquals( "WorkItem",
                      wifv3.getWorkItemName() );
        assertEquals( "IntegerResult",
                      wifv3.getWorkItemParameterName() );
        assertEquals( Integer.class.getName(),
                      wifv3.getWorkItemParameterClassName() );

        ActionFieldValue fv4 = asf.getFieldValues()[ 3 ];
        assertNotNull( fv4 );
        assertTrue( fv4 instanceof ActionWorkItemFieldValue );
        ActionWorkItemFieldValue wifv4 = (ActionWorkItemFieldValue) fv4;
        assertEquals( "ResultStringField",
                      wifv4.getField() );
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 );

        assertEquals( 2,
                      mpwd.getResults().size() );

        PortableBooleanParameterDefinition mp1 = (PortableBooleanParameterDefinition) mpwd.getResult( "BooleanResult" );
        assertNotNull( mp1 );

        PortableFloatParameterDefinition mp2 = (PortableFloatParameterDefinition) mpwd.getResult( "FloatResult" );
        assertNotNull( mp2 );

        //Check ActionSetField
        assertEquals( asf.getVariable(),
                      "$r" );
        assertEquals( 1,
                      asf.getFieldValues().length );

        ActionFieldValue fv1 = asf.getFieldValues()[ 0 ];
        assertNotNull( fv1 );
        assertTrue( fv1 instanceof ActionWorkItemFieldValue );
        ActionWorkItemFieldValue wifv1 = (ActionWorkItemFieldValue) fv1;
        assertEquals( "ResultBooleanField",
                      wifv1.getField() );
View Full Code Here

                                                                           Collections.EMPTY_LIST,
                                                                           dmo );
        assertEquals( 1,
                      m.rhs.length );
        assertTrue( m.rhs[ 0 ] instanceof ActionSetField );
        ActionSetField actionSetField = (ActionSetField) m.rhs[ 0 ];

        assertEquals( "c", actionSetField.getVariable() );

        assertEquals( 1, actionSetField.getFieldValues().length );

        ActionFieldValue actionFieldValue = actionSetField.getFieldValues()[ 0 ];

        assertEquals( "[\"item1\", \"item2\"]", actionFieldValue.getValue() );
        assertEquals( "emps", actionFieldValue.getField() );
        assertEquals( FieldNatureType.TYPE_FORMULA, actionFieldValue.getNature() );
        assertEquals( DataType.TYPE_COLLECTION, actionFieldValue.getType() );
View Full Code Here

        if ( action instanceof ActionInsertFact ) {
            final ActionInsertFact af = (ActionInsertFact) action;
            binding = af.getBoundName();

        } else if ( action instanceof ActionSetField ) {
            final ActionSetField af = (ActionSetField) action;
            binding = af.getVariable();
        }

        //Binding is used to group related field setters together. It is essential for
        //ActionInsertFactCol and ActionSetFieldCol52 columns as these represent single
        //fields and need to be grouped together it is not essential for IAction's as
View Full Code Here

TOP

Related Classes of org.drools.workbench.models.datamodel.rule.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.