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

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


                            ActionGlobalCollectionAdd actionGlobalCollectionAdd = new ActionGlobalCollectionAdd();
                            actionGlobalCollectionAdd.setGlobalName( variable );
                            actionGlobalCollectionAdd.setFactName( factName );
                            m.addRhsItem( actionGlobalCollectionAdd );
                        } else {
                            ActionCallMethod acm = new ActionCallMethod();
                            acm.setMethodName( methodName );
                            acm.setVariable( variable );
                            acm.setState( 1 );
                            m.addRhsItem( acm );
                            String params = unwrapParenthesis( line );
                            for ( String param : params.split( "," ) ) {
                                param = param.trim();
                                if ( param.length() == 0 ) {
                                    continue;
                                }
                                String dataType = inferDataType( param, isJavaDialect );
                                acm.addFieldValue( new ActionFieldFunction( null, adjustParam( dataType, param, isJavaDialect ), dataType ) );
                            }
                        }
                        continue;
                    }
                }
View Full Code Here


    // before that needs to be updated.
    private RuleModel updateMethodCall( RuleModel model ) {

        for ( int i = 0; i < model.rhs.length; i++ ) {
            if ( model.rhs[ i ] instanceof ActionCallMethod ) {
                ActionCallMethod action = (ActionCallMethod) model.rhs[ i ];
                // Check if method name is filled, if not this was made with an older Guvnor version
                if ( action.getMethodName() == null || "".equals( action.getMethodName() ) ) {
                    if ( action.getFieldValues() != null && action.getFieldValues().length >= 1 ) {
                        action.setMethodName( action.getFieldValues()[ 0 ].getField() );

                        action.setFieldValues( new ActionFieldValue[ 0 ] );
                        action.setState( ActionCallMethod.TYPE_DEFINED );
                    }
                }
            }
        }
View Full Code Here

                                 String[] parameters ) {
        this.variable = variable;
        this.methodName = methodName;
        this.parameters = parameters;

        ActionCallMethod actionCallMethod = new ActionCallMethod();
        actionCallMethod.setMethodName( methodName );
        actionCallMethod.setVariable( variable );
        actionCallMethod.setState( ActionCallMethod.TYPE_DEFINED );

        for ( ActionFieldFunction parameter : getActionFieldFunctions() ) {
            actionCallMethod.addFieldValue( parameter );
        }

        return actionCallMethod;
    }
View Full Code Here

                final ActionUpdateField clone = new ActionUpdateField( auf.getVariable() );
                clone.setFieldValues( auf.getFieldValues() );
                return clone;

            } else if ( action instanceof ActionCallMethod ) {
                final ActionCallMethod acm = (ActionCallMethod) action;
                final ActionCallMethod clone = new ActionCallMethod( acm.getVariable() );
                clone.setState( acm.getState() );
                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

                      m.lhs.length );

        assertEquals( 1,
                      m.rhs.length );

        ActionCallMethod actionCallMethod = (ActionCallMethod) m.rhs[ 0 ];
        assertEquals( "sum", actionCallMethod.getMethodName() );
        assertEquals( "s", actionCallMethod.getVariable() );
        assertEquals( 2, actionCallMethod.getFieldValues().length );

        assertEquals( "sum", actionCallMethod.getFieldValue( 0 ).getField() );
        assertEquals( "$age", actionCallMethod.getFieldValue( 0 ).getValue() );
        assertEquals( 2, actionCallMethod.getFieldValue( 0 ).getNature() );
        assertEquals( "Integer", actionCallMethod.getFieldValue( 0 ).getType() );

        assertEquals( "sum", actionCallMethod.getFieldValue( 1 ).getField() );
        assertEquals( "$age", actionCallMethod.getFieldValue( 1 ).getValue() );
        assertEquals( 2, actionCallMethod.getFieldValue( 1 ).getNature() );
        assertEquals( "Integer", actionCallMethod.getFieldValue( 1 ).getType() );
    }
View Full Code Here

                final ActionUpdateField clone = new ActionUpdateField( auf.getVariable() );
                clone.setFieldValues( auf.getFieldValues() );
                return clone;

            } else if ( action instanceof ActionCallMethod ) {
                final ActionCallMethod acm = (ActionCallMethod) action;
                final ActionCallMethod clone = new ActionCallMethod( acm.getVariable() );
                clone.setState( acm.getState() );
                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

                      m.lhs.length );

        assertEquals( 1,
                      m.rhs.length );

        ActionCallMethod actionCallMethod = (ActionCallMethod) m.rhs[ 0 ];
        assertEquals( "testFunction",
                      actionCallMethod.getMethodName() );
        assertEquals( "$t",
                      actionCallMethod.getVariable() );
        assertEquals( 2,
                      actionCallMethod.getFieldValues().length );

        assertEquals( "testFunction",
                      actionCallMethod.getFieldValue( 0 ).getField() );
        assertEquals( "123",
                      actionCallMethod.getFieldValue( 0 ).getValue() );
        assertEquals( FieldNatureType.TYPE_LITERAL,
                      actionCallMethod.getFieldValue( 0 ).getNature() );
        assertEquals( "Integer",
                      actionCallMethod.getFieldValue( 0 ).getType() );

        assertEquals( "testFunction",
                      actionCallMethod.getFieldValue( 1 ).getField() );
        assertEquals( "hello",
                      actionCallMethod.getFieldValue( 1 ).getValue() );
        assertEquals( FieldNatureType.TYPE_LITERAL,
                      actionCallMethod.getFieldValue( 1 ).getNature() );
        assertEquals( "String",
                      actionCallMethod.getFieldValue( 1 ).getType() );
    }
View Full Code Here

        RuleModel m = RuleModelDRLPersistenceImpl.getInstance().unmarshal( drl,
                                                                           Collections.EMPTY_LIST,
                                                                           dmo );

        assertTrue( m.rhs[ 0 ] instanceof ActionCallMethod );
        ActionCallMethod actionGlobalCollectionAdd = (ActionCallMethod) m.rhs[ 0 ];
        assertEquals( "clear", actionGlobalCollectionAdd.getMethodName() );
        assertEquals( "keke", actionGlobalCollectionAdd.getVariable() );
        assertEquals( 1, actionGlobalCollectionAdd.getState() );
        assertEquals( 0, actionGlobalCollectionAdd.getFieldValues().length );

    }
View Full Code Here

                                                                           dmo );

        assertEquals( 2, m.getImports().getImports().size() );

        assertTrue( m.rhs[ 0 ] instanceof ActionCallMethod );
        ActionCallMethod mc = (ActionCallMethod) m.rhs[ 0 ];
        assertEquals( "put", mc.getMethodName() );
        assertEquals( "m", mc.getVariable() );
        assertEquals( 1, mc.getState() );
        assertEquals( 2, mc.getFieldValues().length );

        ActionFieldValue f1 = mc.getFieldValue( 0 );
        assertEquals( "key", f1.getValue() );
        ActionFieldValue f2 = mc.getFieldValue( 1 );
        assertEquals( "a", f2.getValue() );

        String marshalled = RuleModelDRLPersistenceImpl.getInstance().marshal( m );
        System.out.println( marshalled );
View Full Code Here

        RuleModel m = RuleModelDRLPersistenceImpl.getInstance().unmarshal( drl,
                                                                           Collections.EMPTY_LIST,
                                                                           dmo );

        assertTrue( m.rhs[ 0 ] instanceof ActionCallMethod );
        ActionCallMethod mc = (ActionCallMethod) m.rhs[ 0 ];
        assertEquals( "put", mc.getMethodName() );
        assertEquals( "m", mc.getVariable() );
        assertEquals( 1, mc.getState() );
        assertEquals( 2, mc.getFieldValues().length );

        ActionFieldValue f1 = mc.getFieldValue( 0 );
        assertEquals( "\"key\"", f1.getValue() );
        assertEquals( "java.lang.Object", f1.getType() );
        assertEquals( FieldNatureType.TYPE_LITERAL, f1.getNature() );
        ActionFieldValue f2 = mc.getFieldValue( 1 );
        assertEquals( "a", f2.getValue() );
        assertEquals( "java.lang.Object", f2.getType() );
        assertEquals( FieldNatureType.TYPE_VARIABLE, f2.getNature() );

        String marshalled = RuleModelDRLPersistenceImpl.getInstance().marshal( m );
View Full Code Here

TOP

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

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.