Package org.drools.reteoo

Examples of org.drools.reteoo.RuleTerminalNode$RTNCleanupAdapter


        AlphaNode alphaNode1_1 = ( AlphaNode ) alphaNode1.getSinkPropagator().getSinks()[0];
        assertEquals( calculatePositiveMask(list("b"), sp), alphaNode1_1.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "b"), sp), alphaNode1_1.getInferredMask() )
       
        LeftInputAdapterNode liaNode1 = ( LeftInputAdapterNode ) alphaNode1_1.getSinkPropagator().getSinks()[0];
        RuleTerminalNode rtNode1 = ( RuleTerminalNode ) liaNode1.getSinkPropagator().getSinks()[0];
       
        assertEquals( 0, rtNode1.getDeclaredMask() );
        assertEqualscalculatePositiveMask(list("a", "b"), sp), rtNode1.getInferredMask() );
       
       
        // second share
        AlphaNode alphaNode1_2 = ( AlphaNode ) alphaNode1.getSinkPropagator().getSinks()[1];
        assertEquals( calculatePositiveMask(list("i"), sp), alphaNode1_2.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "i"), sp), alphaNode1_2.getInferredMask() );
       
        LeftInputAdapterNode liaNode2 = ( LeftInputAdapterNode ) alphaNode1_2.getSinkPropagator().getSinks()[0];
        RuleTerminalNode rtNode2 = ( RuleTerminalNode ) liaNode2.getSinkPropagator().getSinks()[0];
       
        assertEquals( 0, rtNode2.getDeclaredMask() );
        assertEqualscalculatePositiveMask(list("a", "i"), sp), rtNode2.getInferredMask() );
       
        // test rule removal       
        kbase.removeRule( "org.drools", "r0" );
        assertEquals( calculatePositiveMask(list("a"), sp), alphaNode1.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "i"), sp), alphaNode1.getInferredMask() );

        assertEquals( calculatePositiveMask(list("i"), sp), alphaNode1_2.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "i"), sp), alphaNode1_2.getInferredMask() );
       
        assertEquals0, rtNode2.getDeclaredMask() );
        assertEqualscalculatePositiveMask(list("a", "i"), sp), rtNode2.getInferredMask() );
       
        // have to rebuild to remove r1
        kbase = getKnowledgeBase(rule1, rule2);
       
        kbase.removeRule( "org.drools", "r1" );
View Full Code Here


        AlphaNode alphaNode1_1 = ( AlphaNode ) alphaNode1.getSinkPropagator().getSinks()[0];
        assertEquals( calculatePositiveMask(list("b"), sp), alphaNode1_1.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "b", "c"), sp), alphaNode1_1.getInferredMask() )
       
        LeftInputAdapterNode liaNode1 = ( LeftInputAdapterNode ) alphaNode1_1.getSinkPropagator().getSinks()[0];
        RuleTerminalNode rtNode1 = ( RuleTerminalNode ) liaNode1.getSinkPropagator().getSinks()[0];
       
        assertEqualscalculatePositiveMask(list("c"), sp), rtNode1.getDeclaredMask() );
        assertEqualscalculatePositiveMask(list("b", "c"), sp), rtNode1.getInferredMask() );
        assertEqualscalculateNegativeMask(list("!a"), sp), rtNode1.getNegativeMask() );

       
        // second share
        AlphaNode alphaNode1_2 = ( AlphaNode ) alphaNode1.getSinkPropagator().getSinks()[1];
        assertEquals( calculatePositiveMask(list("i"), sp), alphaNode1_2.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "i", "s"), sp), alphaNode1_2.getInferredMask() )
       
        LeftInputAdapterNode liaNode2 = ( LeftInputAdapterNode ) alphaNode1_2.getSinkPropagator().getSinks()[0];
        RuleTerminalNode rtNode2 = ( RuleTerminalNode ) liaNode2.getSinkPropagator().getSinks()[0];
       
        assertEqualscalculatePositiveMask(list("s"), sp), rtNode2.getDeclaredMask() );
        assertEqualscalculatePositiveMask(list("a", "s"), sp), rtNode2.getInferredMask() );
        assertEqualscalculateNegativeMask(list("!i"), sp), rtNode2.getNegativeMask() );

        // test rule removal       
        kbase.removeRule( "org.drools", "r0" );
        assertEquals( calculatePositiveMask(list("a"), sp), alphaNode1.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "i", "s"), sp), alphaNode1.getInferredMask() );

        assertEquals( calculatePositiveMask(list("i"), sp), alphaNode1_2.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "i", "s"), sp), alphaNode1_2.getInferredMask() );
       
        assertEqualscalculatePositiveMask(list("s"), sp), rtNode2.getDeclaredMask() );
        assertEqualscalculatePositiveMask(list("a", "s"), sp), rtNode2.getInferredMask() );
        assertEqualscalculateNegativeMask(list("!i"), sp), rtNode2.getNegativeMask() );

        // have to rebuild to remove r1
        kbase = getKnowledgeBase(rule1, rule2);
       
        kbase.removeRule( "org.drools", "r1" );
View Full Code Here

                                                                                      org.drools.rule.Rule rule,
                                                                                      GroupElement subrule,
                                                                                      int subruleIndex,
                                                                                      BuildContext context,
                                                                                      Object... args ) {
                                            return new RuleTerminalNode( id,
                                                                         source,
                                                                         rule,
                                                                         subrule,
                                                                         0,
                                                                         context ) {
View Full Code Here

        BuildContext buildContext = new BuildContext((InternalRuleBase) knowledgeBase.getRuleBase(), ((ReteooRuleBase) knowledgeBase.getRuleBase())
                .getReteooBuilder().getIdGenerator());
        //simple rule that fires after 10 seconds
        final Rule rule = new Rule("test-rule");
        new RuleTerminalNode(1,new MockTupleSource(2), rule, rule.getLhs(), 0, buildContext);
       
        final List<String> fired = new ArrayList<String>();
       
        rule.setConsequence( new Consequence() {
            public void evaluate(KnowledgeHelper knowledgeHelper,
View Full Code Here

                                                                                      org.drools.rule.Rule rule,
                                                                                      GroupElement subrule,
                                                                                      int subruleIndex,
                                                                                      BuildContext context,
                                                                                      Object... args ) {
                                            return new RuleTerminalNode( id,
                                                                         source,
                                                                         rule,
                                                                         subrule,
                                                                         0,
                                                                         context ) {
View Full Code Here

        String pkgName = stream.readUTF();
        String ruleName = stream.readUTF();
        Package pkg = ruleBase.getPackage( pkgName );
        Rule rule = pkg.getRule( ruleName );

        RuleTerminalNode ruleTerminalNode = (RuleTerminalNode) leftTuple.getLeftTupleSink();

        PropagationContext pc = context.propagationContexts.get( stream.readLong() );

        AgendaItem activation;
View Full Code Here

import static org.mvel2.asm.Opcodes.RETURN;

public class ConsequenceGenerator {

    public static void generate(final ConsequenceStub stub, KnowledgeHelper knowledgeHelper, WorkingMemory workingMemory) {
        RuleTerminalNode rtn = (RuleTerminalNode) knowledgeHelper.getActivation().getTuple().getLeftTupleSink();
        final Declaration[] declarations = rtn.getDeclarations();
        final boolean isOrRule = rtn.getRule().getTransformedLhs().length > 1;
        final LeftTuple tuple = (LeftTuple)knowledgeHelper.getTuple();

        // Sort declarations based on their offset, so it can ascend the tuple's parents stack only once
        final List<DeclarationMatcher> declarationMatchers = matchDeclarationsToTuple(declarations);
View Full Code Here

                                                                                      org.drools.rule.Rule rule,
                                                                                      GroupElement subrule,
                                                                                      int subruleIndex,
                                                                                      BuildContext context,
                                                                                      Object... args ) {
                                            return new RuleTerminalNode( id,
                                                                         source,
                                                                         rule,
                                                                         subrule,
                                                                         0,
                                                                         context ) {
View Full Code Here

        BuildContext buildContext = new BuildContext((InternalRuleBase) knowledgeBase.getRuleBase(), ((ReteooRuleBase) knowledgeBase.getRuleBase())
                .getReteooBuilder().getIdGenerator());
        //simple rule that fires after 10 seconds
        final Rule rule = new Rule("test-rule");
        new RuleTerminalNode(1,new MockTupleSource(2), rule, rule.getLhs(), 0, buildContext);

        final List<String> fired = new ArrayList<String>();

        rule.setConsequence( new Consequence() {
            public void evaluate(KnowledgeHelper knowledgeHelper,
View Full Code Here

                                                new PropagationContextImpl( 1,
                                                                            1,
                                                                            null,
                                                                            tuple,
                                                                            null ),
                                                new RuleTerminalNode(0, null, context.getRule(), subrule, new BuildContext( (InternalRuleBase) ruleBase, null ))  );
        final DefaultKnowledgeHelper kbHelper = new DefaultKnowledgeHelper( wm );
        kbHelper.setActivation( item );
        ((MVELConsequence) context.getRule().getConsequence()).compile( Thread.currentThread().getContextClassLoader() );
        context.getRule().getConsequence().evaluate( kbHelper,
                                                     wm );
View Full Code Here

TOP

Related Classes of org.drools.reteoo.RuleTerminalNode$RTNCleanupAdapter

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.