Package org.drools.core.common

Examples of org.drools.core.common.ActivationIterator


        StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);
        for ( int i = 0; i < 2; i++ ) {
            ksession.insert( new String( "" + i ) );
        }

        ActivationIterator it = ActivationIterator.iterator( ksession );
        List list = new ArrayList();
        for ( Match act = (Match) it.next(); act != null; act = (Match) it.next() ) {
            if ( act.getRule().getName().equals( "rule3" ) ) {
                list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.getDeclarationValue( "$s2" ) + ":" + act.getDeclarationValue( "$s3" ) + ":" + act.isActive() );
            } else if ( act.getRule().getName().equals( "rule1" ) ) {
                list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.getDeclarationValue( "$s2" ) + ":" + act.isActive() );
            } else if ( act.getRule().getName().equals( "rule2" ) ) {
                list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.isActive() );
            }
        }

        assertContains( new String[]{"rule1:0:0:true", "rule1:0:1:true", "rule1:1:0:true", "rule1:1:1:true",
                                "rule2:1:true", "rule2:0:true",
                                "rule3:0:0:0:true", "rule3:0:0:1:true", "rule3:1:0:0:true", "rule3:1:0:1:true", "rule3:0:1:0:true", "rule3:0:1:1:true", "rule3:1:1:0:true", "rule3:1:1:1:true"},
                        list );

        ksession.fireAllRules();

        it = ActivationIterator.iterator( ksession );
        list = new ArrayList();
        for ( Match act = (Match) it.next(); act != null; act = (Match) it.next() ) {
            if ( act.getRule().getName().equals( "rule3" ) ) {
                list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.getDeclarationValue( "$s2" ) + ":" + act.getDeclarationValue( "$s3" ) + ":" + act.isActive() );
            } else if ( act.getRule().getName().equals( "rule1" ) ) {
                list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.getDeclarationValue( "$s2" ) + ":" + act.isActive() );
            } else if ( act.getRule().getName().equals( "rule2" ) ) {
View Full Code Here


            ksession.insert( new String( "" + i ) );
        }

        ksession.fireAllRules();

        ActivationIterator it = ActivationIterator.iterator( ksession );
        List list = new ArrayList();
        for ( Match act = (Match) it.next(); act != null; act = (Match) it.next() ) {
            if ( act.getRule().getName().equals( "rule3" ) ) {
                list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.getDeclarationValue( "$s2" ) + ":" + act.getDeclarationValue( "$s3" ) + ":" + act.isActive() );
            } else if ( act.getRule().getName().equals( "rule1" ) ) {
                list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.getDeclarationValue( "$s2" ) + ":" + act.isActive() );
            } else if ( act.getRule().getName().equals( "rule2" ) ) {
View Full Code Here

        ksession.insert( "0" );
        ksession.insert( "2" );

        ksession.fireAllRules();

        ActivationIterator it = ActivationIterator.iterator( ksession );
        List list = new ArrayList();
        for ( Match act = (Match) it.next(); act != null; act = (Match) it.next() ) {
            if ( act.getRule().getName().equals( "rule3" ) ) {
                list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.isActive() );
            } else if ( act.getRule().getName().equals( "rule1" ) ) {
                list.add( act.getRule().getName() + ":" + act.isActive() );
            } else if ( act.getRule().getName().equals( "rule2" ) ) {
View Full Code Here

        ksession.insert( "1" );
        ksession.insert( "2" );

        ksession.fireAllRules();

        ActivationIterator it = ActivationIterator.iterator( ksession );
        List list = new ArrayList();
        for ( Match act = (Match) it.next(); act != null; act = (Match) it.next() ) {
            if ( act.getRule().getName().equals( "rule3" ) ) {
                list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.isActive() );
            } else if ( act.getRule().getName().equals( "rule1" ) ) {
                list.add( act.getRule().getName() + ":" + act.isActive() );
            } else if ( act.getRule().getName().equals( "rule2" ) ) {
View Full Code Here

        ksession.setGlobal( "list",
                            list );

        ksession.fireAllRules();

        ActivationIterator it = ActivationIterator.iterator( ksession );
        list = new ArrayList();
        for ( Match act = (Match) it.next(); act != null; act = (Match) it.next() ) {
            list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.isActive() );
        }

        assertContains( new String[]{"rule1:1:true", "rule2:0:true", "rule2:1:true", "rule2:2:true", "rule3:0:true", "rule3:1:true", "rule3:2:false"},
                        list );
View Full Code Here

        ksession.insert( new Integer( 2 ) );
        ksession.insert( new Integer( 3 ) );

        ksession.fireAllRules();

        ActivationIterator it = ActivationIterator.iterator( ksession );
        List list = new ArrayList();
        list = new ArrayList();
        for ( Match act = (Match) it.next(); act != null; act = (Match) it.next() ) {
            list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.isActive() );
        }

        assertContains( new String[]{"rule1:6.0:true", "rule2:6.0:true", "rule3:6.0:false"},
                        list );
View Full Code Here

TOP

Related Classes of org.drools.core.common.ActivationIterator

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.