Package org.drools.runtime

Examples of org.drools.runtime.StatefulKnowledgeSession.retract()


    this.handle = handle;
  }

  public Object execute(Context context) {
    StatefulKnowledgeSession ksession = ((KnowledgeCommandContext) context).getStatefulKnowledgesession();
    ksession.retract( handle );
    return null;
  }

  public FactHandle getFactHandle() {
    return this.handle;
View Full Code Here


        FactHandle hatPurchaseHandle = ksession.insert( new Purchase( mark,
                                                                      hat ) );

        ksession.fireAllRules();

        ksession.retract( hatPurchaseHandle );
        System.out.println( "Customer mark has returned the hat" );
        ksession.fireAllRules();
    }

    public static class Customer {
View Full Code Here

        assertEquals( 1,
                      list.size() );
        assertEquals( "ackbar",
                      list.get( 0 ) );
        ksession.retract( ph );
    }

    @Test
    public void testRuleReplacement() throws Exception {
        // test rule replacement
View Full Code Here

        // remove cheese
        ksession = getSerialisedStatefulKnowledgeSession( ksession,
        //                                                  MarshallerFactory.newIdentityMarshallingStrategy(),
                                                          true );
        ksession.retract( ksession.getFactHandle( stilton ) );
        ksession = getSerialisedStatefulKnowledgeSession( ksession,
        //                                                  MarshallerFactory.newIdentityMarshallingStrategy(),
                                                          true );
        ksession.fireAllRules();
        assertEquals( 4,
View Full Code Here

        ksession.fireAllRules();
        assertEquals( 4,
                      list.size() );

        // now remove a cheese, should be no change
        ksession.retract( ksession.getFactHandle( stilton ) );
        //        ksession = getSerialisedStatefulKnowledgeSession( ksession,
        //                                                          MarshallerFactory.newIdentityMarshallingStrategy(),
        //                                                          true );
        ksession.fireAllRules();
        assertEquals( 4,
View Full Code Here

        ksession.fireAllRules();
        assertEquals( 4,
                      list.size() );

        // now remove a person, should be no change
        ksession.retract( ksession.getFactHandle( bobba ) );
        ksession = getSerialisedStatefulKnowledgeSession( ksession,
        //                                                  MarshallerFactory.newIdentityMarshallingStrategy(),
                                                          true );
        ksession.fireAllRules();
        assertEquals( 4,
View Full Code Here

        ksession.fireAllRules();
        assertEquals( 4,
                      list.size() );

        //removal remaining cheese, should increase by one, as one person left
        ksession.retract( ksession.getFactHandle( brie ) );
        ksession = getSerialisedStatefulKnowledgeSession( ksession,
        //                                                  MarshallerFactory.newIdentityMarshallingStrategy(),
                                                          true );
        ksession.fireAllRules();
        assertEquals( 5,
View Full Code Here

        // remove cheese
        ksession = getSerialisedStatefulKnowledgeSession( ksession,
        //                                                  MarshallerFactory.newIdentityMarshallingStrategy(),
                                                          true );
        ksession.retract( ksession.getFactHandle( stilton ) );
        ksession = getSerialisedStatefulKnowledgeSession( ksession,
        //                                                  MarshallerFactory.newIdentityMarshallingStrategy(),
                                                          true );
        ksession.fireAllRules();
        assertEquals( 2,
View Full Code Here

        ksession.fireAllRules();
        assertEquals( 4,
                      list.size() );

        // now remove a cheese, should be no change
        ksession.retract( ksession.getFactHandle( stilton ) );
        ksession = getSerialisedStatefulKnowledgeSession( ksession,
        //                                                  MarshallerFactory.newIdentityMarshallingStrategy(),
                                                          true );
        ksession.fireAllRules();
        assertEquals( 4,
View Full Code Here

        ksession.fireAllRules();
        assertEquals( 4,
                      list.size() );

        // now remove a person, should be no change
        ksession.retract( ksession.getFactHandle( bobba ) );
        ksession = getSerialisedStatefulKnowledgeSession( ksession,
        //                                                  MarshallerFactory.newIdentityMarshallingStrategy(),
                                                          true );
        ksession.fireAllRules();
        assertEquals( 4,
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.