Package org.drools.common

Examples of org.drools.common.PropagationContextImpl


        Map<String, Object> map = result.context;

        JoinNode join1 = (JoinNode) map.get( "join1" );
        assertNotNull( join1 );

        PropagationContext context = new PropagationContextImpl( 0,
                                                                 PropagationContext.ASSERTION,
                                                                 null,
                                                                 null,
                                                                 null );
        ReteooWorkingMemory workingMemory = new ReteooWorkingMemory( 1,
View Full Code Here


        final LeftTupleImpl tuple = new LeftTupleImpl( new DefaultFactHandle( 1,
                                                                      "cheese" ),
                                               null,
                                               true );

        final PropagationContext context1 = new PropagationContextImpl( 0,
                                                                        PropagationContext.INSERTION,
                                                                        rule1,
                                                                        null,
                                                                        new DefaultFactHandle() );
View Full Code Here

        Cheese cheese = new Cheese();
        cheese.setPrice( 50 );
        final LeftTupleImpl tuple = new LeftTupleImpl( new DefaultFactHandle( 1, cheese),null,true );

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

        // 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 = 510l;

            public void evaluate(final KnowledgeHelper knowledgeHelper,
                                 final WorkingMemory workingMemory) {
                AgendaItem item = ( AgendaItem ) knowledgeHelper.getMatch();
                final Cheese cheese = ( Cheese ) item.getTuple().getHandle().getObject();
                final int oldPrice = cheese.getPrice();
                cheese.setPrice( 100 );
               
                item.setActivationUnMatchListener( new ActivationUnMatchListener() {
                   
                    public void unMatch(org.kie.runtime.rule.Session wm,
                                        Match activation) {
                        cheese.setPrice( oldPrice );
                    }
                } );
            }

            public void readExternal(ObjectInput in) throws IOException,
                                                    ClassNotFoundException {

            }

            public void writeExternal(ObjectOutput out) throws IOException {

            }

            public String getName() {
                return "default";
            }
        } );

        assertEquals( 50, cheese.getPrice() );
       
        node1.assertLeftTuple( tuple,
                               context1,
                               workingMemory );
  
       
        agenda.unstageActivations();
        agenda.fireNextItem( null );
        assertEquals( 100, cheese.getPrice() );
       
        final PropagationContext context0 = new PropagationContextImpl( 0,
                                                                        PropagationContext.DELETION,
                                                                        rule1,
                                                                        null,
                                                                        new DefaultFactHandle() );
View Full Code Here

        final LeftTupleImpl tuple = new LeftTupleImpl( new DefaultFactHandle( 1,
                                                                      "cheese" ),
                                               node,
                                               true );
        final PropagationContext context = new PropagationContextImpl( 0,
                                                                       PropagationContext.INSERTION,
                                                                       rule,
                                                                       null,
                                                                       new DefaultFactHandle() );
View Full Code Here

                                                             rule0,
                                                             rule0.getLhs(),
                                                             0,
                                                             buildContext );
        rule0.setConsequence( consequence );
        final PropagationContext context0 = new PropagationContextImpl( 0,
                                                                        PropagationContext.INSERTION,
                                                                        rule0,
                                                                        null,
                                                                        new DefaultFactHandle() );

        final Rule rule1 = new Rule( "test-rule1",
                                     "agendaGroup1" );
        final RuleTerminalNode node1 = new RuleTerminalNode( 5,
                                                             new MockTupleSource( 4 ),
                                                             rule1,
                                                             rule1.getLhs(),
                                                             0,
                                                             buildContext );
        rule1.setConsequence( consequence );
        final PropagationContext context1 = new PropagationContextImpl( 0,
                                                                        PropagationContext.INSERTION,
                                                                        rule1,
                                                                        null,
                                                                        new DefaultFactHandle() );

        final Rule rule2 = new Rule( "test-rule2",
                                     "agendaGroup2" );
        final RuleTerminalNode node2 = new RuleTerminalNode( 7,
                                                             new MockTupleSource( 6 ),
                                                             rule2,
                                                             rule2.getLhs(),
                                                             0,
                                                             buildContext );
        rule2.setConsequence( consequence );
        final PropagationContext context2 = new PropagationContextImpl( 0,
                                                                        PropagationContext.INSERTION,
                                                                        rule2,
                                                                        null,
                                                                        new DefaultFactHandle() );

        final Rule rule3 = new Rule( "test-rule3",
                                     "agendaGroup3" );
        final RuleTerminalNode node3 = new RuleTerminalNode( 9,
                                                             new MockTupleSource( 8 ),
                                                             rule3,
                                                             rule3.getLhs(),
                                                             0,
                                                             buildContext );
        rule3.setConsequence( consequence );
        final PropagationContext context3 = new PropagationContextImpl( 0,
                                                                        PropagationContext.INSERTION,
                                                                        rule3,
                                                                        null,
                                                                        new DefaultFactHandle() );
View Full Code Here

                                                            rule,
                                                            rule.getLhs(),
                                                            0,
                                                            buildContext );
        rule.setConsequence( consequence );
        final PropagationContext context = new PropagationContextImpl( 0,
                                                                       PropagationContext.INSERTION,
                                                                       rule,
                                                                       null,
                                                                       new DefaultFactHandle() );
View Full Code Here

                                                            rule,
                                                            rule.getLhs(),
                                                            0,
                                                            buildContext );

        final PropagationContext context = new PropagationContextImpl( 0,
                                                                       PropagationContext.INSERTION,
                                                                       rule,
                                                                       null,
                                                                       new DefaultFactHandle() );
View Full Code Here

                                                             rule0,
                                                             rule0.getLhs(),
                                                             0,
                                                             buildContext );
        rule0.setConsequence( consequence );
        final PropagationContext context0 = new PropagationContextImpl( 0,
                                                                        PropagationContext.INSERTION,
                                                                        rule0,
                                                                        null,
                                                                        new DefaultFactHandle() );

        final Rule rule1 = new Rule( "test-rule1" );
        rule1.setActivationGroup( "activation-group-0" );
        rule1.setSalience( new SalienceInteger(10) );
        final RuleTerminalNode node1 = new RuleTerminalNode( 5,
                                                             new MockTupleSource( 4 ),
                                                             rule1,
                                                             rule1.getLhs(),
                                                             0,
                                                             buildContext );
        rule1.setConsequence( consequence );
        final PropagationContext context1 = new PropagationContextImpl( 0,
                                                                        PropagationContext.INSERTION,
                                                                        rule1,
                                                                        null,
                                                                        new DefaultFactHandle() );

        final Rule rule2 = new Rule( "test-rule2" );
        rule2.setSalience( new SalienceInteger( -5 ) );
        final RuleTerminalNode node2 = new RuleTerminalNode( 7,
                                                             new MockTupleSource( 6 ),
                                                             rule2,
                                                             rule2.getLhs(),
                                                             0,
                                                             buildContext );
        rule2.setConsequence( consequence );
        final PropagationContext context2 = new PropagationContextImpl( 0,
                                                                        PropagationContext.INSERTION,
                                                                        rule2,
                                                                        null,
                                                                        new DefaultFactHandle() );

        final Rule rule3 = new Rule( "test-rule3",
                                     "agendaGroup3" );
        rule3.setSalience( new SalienceInteger( -10 ) );
        rule3.setActivationGroup( "activation-group-3" );
        final RuleTerminalNode node3 = new RuleTerminalNode( 9,
                                                             new MockTupleSource( 8 ),
                                                             rule3,
                                                             rule3.getLhs(),
                                                             0,
                                                             buildContext );
        rule3.setConsequence( consequence );
        final PropagationContext context3 = new PropagationContextImpl( 0,
                                                                        PropagationContext.INSERTION,
                                                                        rule3,
                                                                        null,
                                                                        new DefaultFactHandle() );
View Full Code Here

                                                             rule2,
                                                             rule2.getLhs(),
                                                             0,
                                                             buildContext );

        final PropagationContext context0 = new PropagationContextImpl( 0,
                                                                        PropagationContext.INSERTION,
                                                                        rule0,
                                                                        null,
                                                                        new DefaultFactHandle() );
View Full Code Here

                                                             rule1.getLhs(),
                                                             0,
                                                             buildContext );

        // create context
        final PropagationContext context0 = new PropagationContextImpl( 0,
                                                                        PropagationContext.INSERTION,
                                                                        rule1,
                                                                        null,
                                                                        new DefaultFactHandle() );
View Full Code Here

TOP

Related Classes of org.drools.common.PropagationContextImpl

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.