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

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


            //Reconcile ActionSetField and ActionUpdateField calls
            final List<IAction> actions = new ArrayList<IAction>();
            for ( IAction action : model.rhs ) {
                if ( action instanceof ActionSetField ) {
                    final ActionSetField asf = (ActionSetField) action;
                    final ActionSetFieldWrapper afw = findExistingAction( asf,
                                                                          actions );
                    if ( afw == null ) {
                        actions.add( new ActionSetFieldWrapper( asf,
                                                                ( asf instanceof ActionUpdateField ) ) );
                    } else {
                        final List<ActionFieldValue> existingActionFieldValue = new ArrayList<ActionFieldValue>( Arrays.asList( afw.getAction().getFieldValues() ) );
                        for ( ActionFieldValue afv : asf.getFieldValues() ) {
                            existingActionFieldValue.add( afv );
                        }
                        final ActionFieldValue[] temp = new ActionFieldValue[ existingActionFieldValue.size() ];
                        afw.getAction().setFieldValues( existingActionFieldValue.toArray( temp ) );
                    }
View Full Code Here


                }
            }
        }

        for ( Map.Entry<String, List<String>> entry : setStatements.entrySet() ) {
            ActionSetField action = new ActionSetField( entry.getKey() );
            addSettersToAction( entry.getValue(),
                                action,
                                boundParams,
                                dmo,
                                m.getImports(),
View Full Code Here

                clone.setMethodName( acm.getMethodName() );
                clone.setFieldValues( acm.getFieldValues() );
                return clone;

            } else if ( action instanceof ActionSetField ) {
                final ActionSetField clone = new ActionSetField( action.getVariable() );
                clone.setFieldValues( action.getFieldValues() );
                return clone;

            } else {
                return action;
            }
View Full Code Here

            }
            messages.add( new BindingNotFoundParserMessage( binding ) );
            return nodes;

        } else if ( a instanceof ActionSetField ) {
            final ActionSetField asf = (ActionSetField) a;
            final String binding = asf.getVariable();
            for ( TypeNode tn : types ) {
                if ( tn.isBound() ) {
                    if ( tn.getBinding().equals( binding ) ) {
                        final ActionUpdateNode aun = new ActionUpdateNodeImpl( tn );
                        for ( org.drools.workbench.models.datamodel.rule.ActionFieldValue afv : asf.getFieldValues() ) {
                            if ( afv.getNature() != FieldNatureType.TYPE_LITERAL ) {
                                messages.add( new UnsupportedFieldNatureTypeParserMessage() );
                                return nodes;
                            }
                            final String fieldName = afv.getField();
View Full Code Here

                clone.setMethodName( acm.getMethodName() );
                clone.setFieldValues( acm.getFieldValues() );
                return clone;

            } else if ( action instanceof ActionSetField ) {
                final ActionSetField clone = new ActionSetField( action.getVariable() );
                clone.setFieldValues( action.getFieldValues() );
                return clone;

            } else {
                return action;
            }
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

            //Reconcile ActionSetField and ActionUpdateField calls
            final List<IAction> actions = new ArrayList<IAction>();
            for ( IAction action : model.rhs ) {
                if ( action instanceof ActionSetField ) {
                    final ActionSetField asf = (ActionSetField) action;
                    final ActionSetFieldWrapper afw = findExistingAction( asf,
                                                                          actions );
                    if ( afw == null ) {
                        actions.add( new ActionSetFieldWrapper( asf,
                                                                ( asf instanceof ActionUpdateField ) ) );
                    } else {
                        final List<ActionFieldValue> existingActionFieldValue = new ArrayList<ActionFieldValue>( Arrays.asList( afw.getAction().getFieldValues() ) );
                        for ( ActionFieldValue afv : asf.getFieldValues() ) {
                            existingActionFieldValue.add( afv );
                        }
                        final ActionFieldValue[] temp = new ActionFieldValue[ existingActionFieldValue.size() ];
                        afw.getAction().setFieldValues( existingActionFieldValue.toArray( temp ) );
                    }
View Full Code Here

                }
            }
        }

        for ( Map.Entry<String, List<String>> entry : setStatements.entrySet() ) {
            ActionSetField action = new ActionSetField( entry.getKey() );
            addSettersToAction( entry.getValue(),
                                action,
                                boundParams,
                                dmo,
                                m.getImports(),
View Full Code Here

        FactPattern fp = new FactPattern( "Person" );
        fp.setBoundName( "$p" );
        m.addLhsItem( fp );

        ActionSetField asf = new ActionSetField( "$p" );
        ActionFieldValue afv0 = new ActionFieldValue();
        afv0.setNature( FieldNatureType.TYPE_TEMPLATE );
        afv0.setField( "field1" );
        afv0.setValue( "$f1" );
        asf.addFieldValue( afv0 );
        ActionFieldValue afv1 = new ActionFieldValue();
        afv1.setNature( FieldNatureType.TYPE_TEMPLATE );
        afv1.setField( "field2" );
        afv1.setValue( "$f2" );
        asf.addFieldValue( afv1 );

        m.addRhsItem( asf );

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

        FactPattern fp = new FactPattern( "Person" );
        fp.setBoundName( "$p" );
        m.addLhsItem( fp );

        ActionSetField asf = new ActionSetField( "$p" );
        ActionFieldValue afv0 = new ActionFieldValue();
        afv0.setNature( FieldNatureType.TYPE_TEMPLATE );
        afv0.setField( "field1" );
        afv0.setValue( "$f1" );
        asf.addFieldValue( afv0 );
        ActionFieldValue afv1 = new ActionFieldValue();
        afv1.setNature( FieldNatureType.TYPE_TEMPLATE );
        afv1.setField( "field2" );
        afv1.setValue( "$f2" );
        asf.addFieldValue( afv1 );

        m.addRhsItem( asf );

        String expected = "rule \"r1_0\"\n"
                + "dialect \"mvel\"\n"
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.