Package org.drools

Examples of org.drools.Agenda


                                                            rule1.getLhs(),
                                                            buildContext  );

        final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();

        final Agenda agenda = workingMemory.getAgenda();

        final Consequence consequence = new Consequence() {
            /**
             *
             */
 
View Full Code Here


                                                            rule1,
                                                            rule1.getLhs(),
                                                            buildContext  );
        final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();

        final Agenda agenda = workingMemory.getAgenda();

        final Consequence consequence = new Consequence() {
            /**
             *
             */
 
View Full Code Here

                                                            rule1,
                                                            rule1.getLhs(),
                                                            buildContext  );
        final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();

        final Agenda agenda = workingMemory.getAgenda();

        final Consequence consequence = new Consequence() {
            /**
             *
             */
 
View Full Code Here

                                                            rule1.getLhs(),
                                                            buildContext  );

        final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();

        final Agenda agenda = workingMemory.getAgenda();

        final Consequence consequence = new Consequence() {
            /**
             *
             */
 
View Full Code Here

    public void testDoLoopScheduledActivation() throws Exception {
        IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();

        final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();
        final Agenda agenda = workingMemory.getAgenda();

        final Rule rule = new Rule( "test-rule" );
        final RuleTerminalNode node = new RuleTerminalNode( idGenerator.getNextId(),
                                                            new MockTupleSource( idGenerator.getNextId() ),
                                                            rule,
View Full Code Here

    public void testNoLoopScheduledActivation() throws Exception {
        ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase();
        IdGenerator idGenerator = ruleBase.getReteooBuilder().getIdGenerator();

        final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();
        final Agenda agenda = workingMemory.getAgenda();

        final Rule rule = new Rule( "test-rule" );
        final List data = new ArrayList();

        final RuleTerminalNode node = new RuleTerminalNode( idGenerator.getNextId(),
View Full Code Here

    }
   
    public void testClearAgenda() {
        final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();

        final Agenda agenda = workingMemory.getAgenda();

        final Rule rule1 = new Rule( "test-rule1" );
        final Rule rule2 = new Rule( "test-rule2" );

        final RuleTerminalNode node1 = new RuleTerminalNode( 3,
                                                             new MockTupleSource( 2 ),
                                                             rule1,
                                                             rule1.getLhs(),
                                                             buildContext );
       
        final RuleTerminalNode node2 = new RuleTerminalNode( 5,
                                                             new MockTupleSource( 4 ),
                                                             rule2,
                                                             rule2.getLhs(),
                                                             buildContext );       

        final ReteTuple tuple = new ReteTuple( new DefaultFactHandle( 1,
                                                                      "cheese" ) );

        final PropagationContext context1 = new PropagationContextImpl( 0,
                                                                        PropagationContext.ASSERTION,
                                                                        rule1,
                                                                        null );

        // Add consequence. Notice here the context here for the add to ageyunda
        // is itself
        rule1.setConsequence( new org.drools.spi.Consequence() {
            /**
             *
             */
            private static final long serialVersionUID = 400L;

            public void evaluate(final KnowledgeHelper knowledgeHelper,
                                 final WorkingMemory workingMemory) {
                // do nothing
            }
        } );
       
        // Add consequence. Notice here the context here for the add to ageyunda
        // is itself
        rule2.setConsequence( new org.drools.spi.Consequence() {
            /**
             *
             */
            private static final long serialVersionUID = 400L;

            public void evaluate(final KnowledgeHelper knowledgeHelper,
                                 final WorkingMemory workingMemory) {
                // do nothing
            }
        } );       

        assertEquals( 0,
                      agenda.getFocus().size() );

        rule1.setNoLoop( false );
        rule2.setDuration( 5000 );
       
        node1.assertTuple( tuple,
                           context1,
                           workingMemory );
       
        node2.assertTuple( tuple,
                           context1,
                           workingMemory );               

        // make sure we have an activation in the current focus
        assertEquals( 1,
                      agenda.getFocus().size() );
       
        assertEquals( 1,
                      agenda.getScheduledActivations().length );
       

        agenda.clearAgenda();

        assertEquals( 0,
                      agenda.getFocus().size() );
       
        assertEquals( 0,
                      agenda.getScheduledActivations().length );       
    }
View Full Code Here

                                                            rule1.getLhs(),
                                                            buildContext );

        final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();

        final Agenda agenda = workingMemory.getAgenda();

        final Consequence consequence = new Consequence() {
            /**
             *
             */
 
View Full Code Here

                                                            rule1.getLhs(),
                                                            buildContext );

        final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();

        final Agenda agenda = workingMemory.getAgenda();

        final Consequence consequence = new Consequence() {
            /**
             *
             */
 
View Full Code Here

                                                            rule1,
                                                            rule1.getLhs(),
                                                            buildContext );
        final ReteooWorkingMemory workingMemory = (ReteooWorkingMemory) ruleBase.newStatefulSession();

        final Agenda agenda = workingMemory.getAgenda();

        final Consequence consequence = new Consequence() {
            /**
             *
             */
 
View Full Code Here

TOP

Related Classes of org.drools.Agenda

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.