Package org.drools.rule

Examples of org.drools.rule.Rule


        final WorkingMemoryImpl workingMemory = (WorkingMemoryImpl) ruleBase.newWorkingMemory();
        final Agenda agenda = workingMemory.getAgenda();
        final Scheduler scheduler = Scheduler.getInstance();

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

        /* 1/10th of a second */
        Duration duration = new Duration()
        {
            public long getDuration(Tuple tuple)
            {
                return 100;
            }

        };

        rule.setDuration( duration );

        // add consequence
        rule.setConsequence( new org.drools.spi.Consequence()
        {
            public void invoke(Activation activation)
            {
                /* on first invoke add another one to the agenda */
                if ( data.size() < 3 )
View Full Code Here


        final WorkingMemoryImpl workingMemory = (WorkingMemoryImpl) ruleBase.newWorkingMemory();
        final Agenda agenda = workingMemory.getAgenda();
        final Scheduler scheduler = Scheduler.getInstance();

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

        /* 1/10th of a second */
        Duration duration = new Duration()
        {
            public long getDuration(Tuple tuple)
            {
                return 100;
            }

        };

        rule.setDuration( duration );
        rule.setNoLoop( true );

        // add consequence
        rule.setConsequence( new org.drools.spi.Consequence()
        {
            public void invoke(Activation activation)
            {
                /* on first invoke add another one to the agenda */
                if ( data.size() < 5 )
View Full Code Here

        WorkingMemoryImpl workingMemory = (WorkingMemoryImpl) ruleBase.newWorkingMemory();
        Agenda agenda = workingMemory.getAgenda();
        final Scheduler scheduler = Scheduler.getInstance();

        final Rule rule = new Rule( "test-rule" );

        // add consequence
        rule.setConsequence( new org.drools.spi.Consequence()
        {
            public void invoke(Activation activation) throws ConsequenceException
            {
                throw new ConsequenceException( "not enough cheese",
                                                rule );
            }
        } );

        /* 1/10th of a second */
        Duration duration = new Duration()
        {
            public long getDuration(Tuple tuple)
            {
                return 100;
            }

        };
        rule.setDuration( duration );

        final List data = new ArrayList();

        PropagationContext context = new PropagationContextImpl( PropagationContext.ASSERTION,
                                                                 null,
View Full Code Here

    /**
     * Setup the BetaNode used in each of the tests
     */
    public void setUp()
    {
        this.rule = new Rule( "test-rule" );
        this.context = new PropagationContextImpl( PropagationContext.ASSERTION,
                                               null,
                                               null );
        this.workingMemory = new WorkingMemoryImpl( new RuleBaseImpl( new Rete() ) );

View Full Code Here

                      source.getObjectSinks() );
    }

    public void testPropagateAssertObject() throws Exception
    {
        Rule rule = new Rule( "test-rule" );
        PropagationContext context = new PropagationContextImpl( PropagationContext.ASSERTION,
                                                             null,
                                                             null );
        WorkingMemoryImpl workingMemory = new WorkingMemoryImpl( new RuleBaseImpl( new Rete() ) );
View Full Code Here

    }

    public void testPropagateRetractObject() throws Exception
    {

        Rule rule = new Rule( "test-rule" );
        PropagationContext context = new PropagationContextImpl( PropagationContext.RETRACTION,
                                                             null,
                                                             null );
        WorkingMemoryImpl workingMemory = new WorkingMemoryImpl( new RuleBaseImpl( new Rete() ) );
View Full Code Here

            public void invoke(Activation activation)
            {
                // do nothing
            }
        };
        final Rule rule1 = new Rule( "test-rule1" );
        rule1.setConsequence( consequence );

        FactHandleImpl handle1 = new FactHandleImpl( 1 );
        ReteTuple tuple1 = new ReteTuple( 0,
                                          handle1,
                                          workingMemory );
View Full Code Here

            public void invoke(Activation activation)
            {
                // do nothing
            }
        };
        final Rule rule1 = new Rule( "test-rule1" );
        rule1.setConsequence( consequence );

        FactHandleImpl handle1 = new FactHandleImpl( 1 );
        ReteTuple tuple1 = new ReteTuple( 0,
                                          handle1,
                                          workingMemory );
View Full Code Here

            public void invoke(Activation activation)
            {
                // do nothing
            }
        };
        final Rule rule1 = new Rule( "test-rule1" );
        rule1.setConsequence( consequence );

        FactHandleImpl handle1 = new FactHandleImpl( 1 );
        ReteTuple tuple1 = new ReteTuple( 0,
                                          handle1,
                                          workingMemory );
View Full Code Here

                // do nothing
            }
        };
       
        /* create the first activation which will justify the fact "logical" */
        final Rule rule1 = new Rule( "test-rule1" );
        rule1.setConsequence( consequence );            

        FactHandleImpl handle1 = new FactHandleImpl( 1 );
        ReteTuple tuple1 = new ReteTuple( 0,
                                          handle1,
                                          workingMemory );

        PropagationContext context =  new PropagationContextImpl( PropagationContext.ASSERTION,
                                                              null,
                                                              null );
       
        Activation activation1 = new AgendaItem( tuple1,
                                                 context,
                                                 rule1 );
           
        /* Assert the logical "logical" fact */
        String logicalString1 = new String ( "logical" );
        FactHandle logicalHandle1 = workingMemory.assertObject( logicalString1,
                                                                false,
                                                                true,
                                                                rule1,
                                                                activation1 );
       
        /* create the second activation to justify the "logical" fact */
        final Rule rule2 = new Rule( "test-rule2" );
        rule2.setConsequence( consequence );         
       
        FactHandleImpl handle2 = new FactHandleImpl( 2 );
        ReteTuple tuple2 = new ReteTuple( 0,
                                          handle2,
                                          workingMemory );
View Full Code Here

TOP

Related Classes of org.drools.rule.Rule

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.