Package org.drools.compiler

Examples of org.drools.compiler.FactA


                      "end";

        KnowledgeBase kbase = loadKnowledgeBaseFromString( rule );
        StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();

        ksession.insert( new FactA() );
        ksession.insert( new FactA() );
        ksession.insert( new FactB() );
        ksession.insert( new FactB() );
        ksession.insert( new FactC() );
        ksession.insert( new FactC() );
        ksession.fireAllRules();
View Full Code Here


        List list = new ArrayList();
        ksession.setGlobal( "list", list );       
        ksession.insert ( new Foo(null, null) );
        ksession.insert ( new Pet(null) );
       
        FactA fact1 = new FactA();
        fact1.setField1( "f1" );
        fact1.setField2( 250 );
       
        FactA fact3 = new FactA();
        fact3.setField1( "f2" );
        fact3.setField2( 1000 );
       
        ksession.insert( fact1 );
        ksession.insert( fact3 );
       
        ksession.fireAllRules();
View Full Code Here

        timeService.advanceTime( new Date().getTime(), TimeUnit.MILLISECONDS );
       
        List list = new ArrayList();
        ksession.setGlobal( "list", list );
       
        FactA fact1 = new FactA();
        fact1.setField1( "f1" );
        fact1.setField2( 500 );
        fact1.setField4( 1000 );
        FactHandle fh = (FactHandle) ksession.insert (fact1 );       
               
        ksession.fireAllRules();
        assertEquals( 0, list.size() );

        timeService.advanceTime( 1100, TimeUnit.MILLISECONDS );
        ksession.fireAllRules();
        assertEquals( 1, list.size() );
        assertEquals( fact1, list.get( 0 ) );

        timeService.advanceTime( 1100, TimeUnit.MILLISECONDS );
        ksession.fireAllRules();
        assertEquals( 2, list.size() );
        assertEquals( fact1, list.get( 1 ) );

        timeService.advanceTime( 400, TimeUnit.MILLISECONDS );
        ksession.fireAllRules();
        assertEquals( 3, list.size() );
        assertEquals( fact1, list.get( 2 ) );
        list.clear();

        fact1.setField2( 300 );
        fact1.setField4( 2000 );
        ksession.updatefh, fact1 );

        // 100 has passed of the 1000, from the previous schedule
        // so that should be deducted from the 300 delay above, meaning
        //  we only need to increment another 250
View Full Code Here

        assertTrue( list.contains( cell30 ) );
        assertTrue( list.contains( cell58 ) );

        session = SerializationHelper.getSerialisedStatefulKnowledgeSession( session, kBase, true );

        session.insert( new FactA( 15 ) );
        session.insert( new FactB( 20 ) );
        FactC factC27 = new FactC( 27 );
        session.insert( factC27 );
        FactC factC52 = new FactC( 52 );
        session.insert( factC52 );
View Full Code Here

        final StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);

        final AgendaEventListener al = mock( AgendaEventListener.class );
        ksession.addEventListener( al );

        ksession.insert( new FactA( "a" ) );
        ksession.insert( new FactB( "b" ) );
        ksession.insert( new FactC( "c" ) );

        ksession.fireAllRules();
        verify( al,
View Full Code Here

        final StatefulKnowledgeSession ksession = createKnowledgeSession(kbase);

        final AgendaEventListener al = mock( AgendaEventListener.class );
        ksession.addEventListener( al );

        ksession.insert( new FactA( "a" ) );
        ksession.insert( new FactB( "b" ) );
        ksession.insert( new FactC( "c" ) );

        ksession.fireAllRules();
        verify( al,
View Full Code Here

        List list = new ArrayList();
        ksession.setGlobal( "list", list );       
        ksession.insert ( new Foo(null, null) );
        ksession.insert ( new Pet(null) );
       
        FactA fact1 = new FactA();
        fact1.setField1( "f1" );
        fact1.setField2( 10 );
       
        FactA fact2 = new FactA();
        fact2.setField1( "f1" );
        fact2.setField2( 30 );
       
        FactA fact3 = new FactA();
        fact3.setField1( "f2" );
        fact3.setField2( 20 );
       
        ksession.insert( fact1 );
        ksession.insert( fact2 );
        ksession.insert( fact3 );
       
View Full Code Here

        List list = new ArrayList();
        ksession.setGlobal( "list", list );       
        ksession.insert ( new Foo(null, null) );
        ksession.insert ( new Pet(null) );
       
        FactA fact1 = new FactA();
        fact1.setField1( "f1" );
        fact1.setField2( 10 );
       
        FactA fact2 = new FactA();
        fact2.setField1( "f1" );
        fact2.setField2( 30 );
       
        FactA fact3 = new FactA();
        fact3.setField1( "f2" );
        fact3.setField2( 20 );
       
        ksession.insert( fact1 );
        ksession.insert( fact2 );
        ksession.insert( fact3 );
       
View Full Code Here

        List list = new ArrayList();
        ksession.setGlobal( "list", list );       
        ksession.insert ( new Foo(null, null) );
        ksession.insert ( new Pet(null) );
       
        FactA fact1 = new FactA();
        fact1.setField1( "f1" );
        fact1.setField2( 250 );
       
        FactA fact3 = new FactA();
        fact3.setField1( "f2" );
        fact3.setField2( 1000 );
       
        ksession.insert( fact1 );
        ksession.insert( fact3 );
       
        ksession.fireAllRules();
View Full Code Here

        timeService.advanceTime( new Date().getTime(), TimeUnit.MILLISECONDS );
       
        List list = new ArrayList();
        ksession.setGlobal( "list", list );
       
        FactA fact1 = new FactA();
        fact1.setField1( "f1" );
        fact1.setField2( 500 );
        fact1.setField4( 1000 );
        FactHandle fh = (FactHandle) ksession.insert (fact1 );       
               
        ksession.fireAllRules();
        assertEquals( 0, list.size() );

        timeService.advanceTime( 2600, TimeUnit.MILLISECONDS );
        ksession.fireAllRules();
        assertEquals( 3, list.size() );
        assertEquals( fact1, list.get( 0 ) );
        assertEquals( fact1, list.get( 1 ) );
        assertEquals( fact1, list.get( 2 ) );
        list.clear();
       
        fact1.setField2( 300 );
        fact1.setField4( 2000 );    
        ksession.updatefh, fact1 );
       
        // 100 has passed of the 1000, from the previous schedule
        // so that should be deducted from the 300 delay above, meaning
        //  we only need to increment another 250
View Full Code Here

TOP

Related Classes of org.drools.compiler.FactA

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.