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

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


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

        ActionUpdateField ap = (ActionUpdateField) a;
        assertEquals( "$p",
                      ap.getVariable() );

        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 ActionUpdateField );

        ActionUpdateField ap = (ActionUpdateField) a;
        assertEquals( "$sc",
                      ap.getVariable() );

        assertEquals( 1,
                      ap.getFieldValues().length );
        ActionFieldValue afv = ap.getFieldValues()[ 0 ];
        assertEquals( "cartItemPromoSavings",
                      afv.getField() );
        assertEquals( "($sc.cartItemPromoSavings == 0.0) ? 0.0 : $sc.cartItemPromoSavings * -1",
                      afv.getValue() );
        assertEquals( FieldNatureType.TYPE_FORMULA,
View Full Code Here

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

        ActionUpdateField ap = (ActionUpdateField) a;
        assertEquals( "$sc",
                      ap.getVariable() );

        assertEquals( 1,
                      ap.getFieldValues().length );
        ActionFieldValue afv = ap.getFieldValues()[ 0 ];
        assertEquals( "cartItemPromoSavings",
                      afv.getField() );
        assertEquals( "($sc.cartItemPromoSavings == 0.0) ? 0.0 : $sc.cartItemPromoSavings * -1",
                      afv.getValue() );
        assertEquals( FieldNatureType.TYPE_FORMULA,
View Full Code Here

        assertEquals( 1,
                      m.rhs.length );
        assertTrue( m.rhs[ 0 ] instanceof ActionUpdateField );

        ActionUpdateField field = (ActionUpdateField) m.rhs[ 0 ];
        assertEquals( "$p",
                      field.getVariable() );

        assertTrue( field.getFieldValues()[ 0 ] instanceof ActionFieldValue );
        assertEquals( 1,
                      field.getFieldValues().length );

        ActionFieldValue value = field.getFieldValues()[ 0 ];
        assertEquals( "firstName",
                      value.getField() );
        assertEquals( ",)",
                      value.getValue() );
        assertEquals( FieldNatureType.TYPE_LITERAL,
View Full Code Here

        assertEquals( 1,
                      m.rhs.length );
        assertTrue( m.rhs[ 0 ] instanceof ActionUpdateField );

        ActionUpdateField field = (ActionUpdateField) m.rhs[ 0 ];
        assertEquals( "$p",
                      field.getVariable() );

        assertTrue( field.getFieldValues()[ 0 ] instanceof ActionFieldValue );
        assertEquals( 1,
                      field.getFieldValues().length );

        ActionFieldValue value = field.getFieldValues()[ 0 ];
        assertEquals( "firstName",
                      value.getField() );
        assertEquals( ",)",
                      value.getValue() );
        assertEquals( FieldNatureType.TYPE_LITERAL,
View Full Code Here

                            line.substring( 0,
                                            modifyBlockEnd ).trim() :
                            line;
                }
                if ( modifyBlockEnd >= 0 ) {
                    ActionUpdateField action = new ActionUpdateField();
                    action.setVariable( modifiedVariable );
                    m.addRhsItem( action );
                    addModifiersToAction( modifiers,
                                          action,
                                          boundParams,
                                          dmo,
                                          m.getImports(),
                                          isJavaDialect );
                    modifiedVariable = null;
                    modifiers = null;
                }
            } else if ( line.startsWith( "insertLogical" ) ) {
                String fact = unwrapParenthesis( line );
                String type = getStatementType( fact,
                                                factsType );
                if ( type != null ) {
                    ActionInsertLogicalFact action = new ActionInsertLogicalFact( type );
                    m.addRhsItem( action );
                    if ( factsType.containsKey( fact ) ) {
                        addSettersToAction( setStatements,
                                            fact,
                                            action,
                                            boundParams,
                                            dmo,
                                            m.getImports(),
                                            isJavaDialect );
                    }
                }
            } 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,
                                            boundParams,
                                            dmo,
                                            m.getImports(),
                                            isJavaDialect );
                    }
                }
            } else if ( line.startsWith( "update" ) ) {
                String variable = unwrapParenthesis( line );
                ActionUpdateField action = new ActionUpdateField();
                action.setVariable( variable );
                m.addRhsItem( action );
                addSettersToAction( setStatements,
                                    variable,
                                    action,
                                    boundParams,
                                    dmo,
                                    m.getImports(),
                                    isJavaDialect );
            } else if ( line.startsWith( "modify" ) ) {
                int modifyBlockEnd = line.lastIndexOf( '}' );
                if ( modifyBlockEnd > 0 ) {
                    String variable = line.substring( line.indexOf( '(' ) + 1,
                                                      line.indexOf( ')' ) ).trim();
                    ActionUpdateField action = new ActionUpdateField();
                    action.setVariable( variable );
                    m.addRhsItem( action );
                    addModifiersToAction( line.substring( line.indexOf( '{' ) + 1,
                                                          modifyBlockEnd ).trim(),
                                          action,
                                          boundParams,
View Full Code Here

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

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

        m.addRhsItem( auf1 );

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

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

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

        m.addRhsItem( auf1 );

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

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

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

        m.addRhsItem( auf1 );

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

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

        ActionUpdateField auf1 = new ActionUpdateField( "$p" );
        ActionFieldValue afv0 = new ActionFieldValue();
        afv0.setNature( FieldNatureType.TYPE_TEMPLATE );
        afv0.setField( "field1" );
        afv0.setValue( "$f1" );
        auf1.addFieldValue( afv0 );
        ActionFieldValue afv1 = new ActionFieldValue();
        afv1.setNature( FieldNatureType.TYPE_LITERAL );
        afv1.setField( "field2" );
        afv1.setValue( "bar" );
        auf1.addFieldValue( afv1 );

        m.addRhsItem( auf1 );

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

TOP

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