Package org.drools.reteoo

Examples of org.drools.reteoo.AlphaNode$ObjectSinkUpdateAdapter


        ReteooWorkingMemoryInterface wm = ((StatefulKnowledgeSessionImpl)kbase.newStatefulKnowledgeSession()).session;

        ObjectTypeNode otnB = getObjectTypeNode(kbase, "B" );
        List<String> sp = getSettableProperties(wm, otnB);

        AlphaNode alphaNode = ( AlphaNode ) otnB.getSinkPropagator().getSinks()[0];
        assertEquals( calculatePositiveMask(list("a"), sp), alphaNode.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "b", "c"), sp), alphaNode.getInferredMask());

        ObjectTypeNode otnA = getObjectTypeNode(kbase, "A" );
        BetaNode betaNodeA1 = ( BetaNode ) otnA.getSinkPropagator().getSinks()[0];
        BetaNode betaNodeA2 = ( BetaNode ) otnA.getSinkPropagator().getSinks()[1];

        assertEquals( calculatePositiveMask(list("i"), sp), betaNodeA1.getRightDeclaredMask() );
        assertEquals( calculatePositiveMask(list("i"), sp), betaNodeA1.getRightInferredMask() );
        assertEquals( calculatePositiveMask(list("b"), sp), betaNodeA1.getLeftDeclaredMask() );
        assertEquals( calculatePositiveMask(list("a", "b"), sp), betaNodeA1.getLeftInferredMask() );

        assertEquals( calculatePositiveMask(list("j"), sp), betaNodeA2.getRightDeclaredMask() );
        assertEquals( calculatePositiveMask(list("j"), sp), betaNodeA2.getRightInferredMask() );
        assertEquals( calculatePositiveMask(list("c"), sp), betaNodeA2.getLeftDeclaredMask() );
        assertEquals( calculatePositiveMask(list("a", "c"), sp), betaNodeA2.getLeftInferredMask() );

        ObjectTypeNode otnC = getObjectTypeNode(kbase, "C" );
        BetaNode betaNodeC = ( BetaNode ) otnC.getSinkPropagator().getSinks()[0];

        assertEquals( 0L, betaNodeC.getRightDeclaredMask() );
        assertEquals( 0L, betaNodeC.getRightInferredMask() );
        assertEquals( Long.MAX_VALUE, betaNodeC.getLeftDeclaredMask() );
        assertEquals( Long.MAX_VALUE, betaNodeC.getLeftInferredMask() );

        ObjectTypeNode otnD = getObjectTypeNode(kbase, "D" );
        BetaNode betaNodeD = ( BetaNode ) otnC.getSinkPropagator().getSinks()[0];

        assertEquals( 0L, betaNodeD.getRightDeclaredMask() );
        assertEquals( 0L, betaNodeD.getRightInferredMask() );
        assertEquals( Long.MAX_VALUE, betaNodeD.getLeftDeclaredMask() );
        assertEquals( Long.MAX_VALUE, betaNodeD.getLeftInferredMask() );

        kbase.removeRule( "org.drools", "r1" );
        assertEquals( calculatePositiveMask(list("a"), sp), alphaNode.getDeclaredMask( ) );
        assertEquals( calculatePositiveMask(list("a", "b"), sp), alphaNode.getInferredMask());
    }
View Full Code Here


        for ( final Iterator it = alphaConstraints.iterator(); it.hasNext(); ) {
            final AlphaNodeFieldConstraint constraint = (AlphaNodeFieldConstraint) it.next();

            context.setObjectSource( (ObjectSource) utils.attachNode( context,
                                                                      new AlphaNode( context.getNextId(),
                                                                                     (AlphaNodeFieldConstraint) constraint,
                                                                                     context.getObjectSource(),
                                                                                     context ) ) );
        }
       
View Full Code Here

        boolean alphaMemory = context.isAlphaMemoryAllowed();

        for ( final AlphaNodeFieldConstraint constraint : alphaConstraints ) {
            context.pushRuleComponent( constraint );
            context.setObjectSource( (ObjectSource) utils.attachNode( context,
                                                                      new AlphaNode( context.getNextId(),
                                                                                     (AlphaNodeFieldConstraint) constraint,
                                                                                     context.getObjectSource(),
                                                                                     context ) ) );
            context.popRuleComponent();
        }       
View Full Code Here

                node = n;
                break;
            }
        }
       
        AlphaNode alphanode = (AlphaNode) node.getSinkPropagator().getSinks()[0];
        AlphaNodeFieldConstraint constraint = alphanode.getConstraint();

        if (constraint instanceof MvelConstraint) {
            assertTrue( (( MvelConstraint )constraint).getFieldExtractor() instanceof ClassFieldReader );
            FieldValue r = (( MvelConstraint )constraint).getField();
            assertEquals( p.getAddress(), r.getValue() );
View Full Code Here

                node = n;
                break;
            }
        }
       
        AlphaNode alphanode = (AlphaNode) node.getSinkPropagator().getSinks()[0];       
        AlphaNodeFieldConstraint constraint = alphanode.getConstraint();

        if (constraint instanceof MvelConstraint) {
            assertTrue( ((MvelConstraint)constraint).getFieldExtractor() instanceof MVELClassFieldReader );
            assertEquals( new Address("s1"), (( MvelConstraint )constraint).getField().getValue() );
        }

        alphanode = (AlphaNode) alphanode.getSinkPropagator().getSinks()[0];
        constraint = alphanode.getConstraint();

        if (constraint instanceof MvelConstraint) {
            assertTrue( (( MvelConstraint )constraint).getFieldExtractor() instanceof MVELClassFieldReader );
            assertEquals( new Address("s1").getStreet(), (( MvelConstraint )constraint).getField().getValue() );
        }
View Full Code Here

                node = n;
                break;
            }
        }
       
        AlphaNode alphanode = (AlphaNode) node.getSinkPropagator().getSinks()[0];       
        AlphaNodeFieldConstraint constraint = alphanode.getConstraint();

        if (constraint instanceof MvelConstraint) {
            assertTrue( (( MvelConstraint ) alphanode.getConstraint()).getFieldExtractor() instanceof MVELClassFieldReader );
            assertEquals( new Address("s1"), (( MvelConstraint ) alphanode.getConstraint()).getField().getValue() );
        }

        alphanode = (AlphaNode) alphanode.getSinkPropagator().getSinks()[0];
        constraint = alphanode.getConstraint();
        if (constraint instanceof MvelConstraint) {
            assertTrue( (( MvelConstraint ) alphanode.getConstraint()).getFieldExtractor() instanceof MVELClassFieldReader );
            assertEquals( new Address("s1").getStreet(), (( MvelConstraint ) alphanode.getConstraint()).getField().getValue() );
        }
    }      
View Full Code Here

                node = n;
                break;
            }
        }
       
        AlphaNode alphanode = (AlphaNode) node.getSinkPropagator().getSinks()[0];       
        AlphaNodeFieldConstraint constraint = alphanode.getConstraint();

        if (constraint instanceof MvelConstraint) {
            assertTrue( (( MvelConstraint ) alphanode.getConstraint()).getFieldExtractor() instanceof MVELClassFieldReader );
            assertEquals( new Address("s1"), (( MvelConstraint ) alphanode.getConstraint()).getField().getValue() );
        }

        alphanode = (AlphaNode) alphanode.getSinkPropagator().getSinks()[0];
        constraint = alphanode.getConstraint();

        if (constraint instanceof MvelConstraint) {
            assertTrue( (( MvelConstraint ) alphanode.getConstraint()).getFieldExtractor() instanceof MVELClassFieldReader );
            assertEquals( new Address("s1").getStreet(), (( MvelConstraint ) alphanode.getConstraint()).getField().getValue() );
        }
    }    
View Full Code Here

        for ( final Iterator<Constraint> it = alphaConstraints.iterator(); it.hasNext(); ) {
            final AlphaNodeFieldConstraint constraint = (AlphaNodeFieldConstraint) it.next();

            context.setObjectSource( (ObjectSource) utils.attachNode( context,
                                                                      new AlphaNode( context.getNextId(),
                                                                                     (AlphaNodeFieldConstraint) constraint,
                                                                                     context.getObjectSource(),
                                                                                     context ) ) );
        }
View Full Code Here

            }
        }   
       
        ReteooWorkingMemory wm = ((StatefulKnowledgeSessionImpl)kbase.newStatefulKnowledgeSession()).session;
       
        AlphaNode alphanode = ( AlphaNode ) node.getSinkPropagator().getSinks()[0];
        LeftInputAdapterNode liaNode = (LeftInputAdapterNode) alphanode.getSinkPropagator().getSinks()[0];
        JoinNode j = ( JoinNode ) liaNode.getSinkPropagator().getSinks()[0]; // $p2
       
        TripleNonIndexSkipBetaConstraints c = ( TripleNonIndexSkipBetaConstraints ) j.getRawConstraints();
        //assertEquals( "$name", ((VariableConstraint)c.getConstraint()).getRequiredDeclarations()[0].getIdentifier() );
        assertTrue( c.isIndexed() );       
View Full Code Here

        ReteooWorkingMemoryInterface wm = ((StatefulKnowledgeSessionImpl)kbase.newStatefulKnowledgeSession()).session;
       
        ObjectTypeNode otn = getObjectTypeNode(kbase, "Cheese" );
        assertNotNull( otn );

        AlphaNode alphaNode1 = ( AlphaNode ) otn.getSinkPropagator().getSinks()[0];
        assertEquals( Long.MAX_VALUE, alphaNode1.getDeclaredMask() );
        assertEquals( Long.MAX_VALUE, alphaNode1.getInferredMask() );
       
       
        // first share
        AlphaNode alphaNode1_1 = ( AlphaNode ) alphaNode1.getSinkPropagator().getSinks()[0];
        assertEquals( Long.MAX_VALUE, alphaNode1_1.getDeclaredMask() );
        assertEquals( Long.MAX_VALUE, alphaNode1_1.getInferredMask() )
       
        BetaNode betaNode1 = ( BetaNode ) alphaNode1_1.getSinkPropagator().getSinks()[0];
       
        assertEquals( Long.MAX_VALUE, betaNode1.getRightDeclaredMask() );
        assertEquals( Long.MAX_VALUE, betaNode1.getRightInferredMask() );
       
       
        // second share
        AlphaNode alphaNode1_2 = ( AlphaNode ) alphaNode1.getSinkPropagator().getSinks()[1];
        assertEquals( Long.MAX_VALUE, alphaNode1_2.getDeclaredMask() );
        assertEquals( Long.MAX_VALUE, alphaNode1_2.getInferredMask() )
       
        BetaNode betaNode2 = ( BetaNode ) alphaNode1_2.getSinkPropagator().getSinks()[0];
       
        assertEquals( Long.MAX_VALUE, betaNode2.getRightDeclaredMask() );
        assertEquals( Long.MAX_VALUE, betaNode2.getRightInferredMask() );
    }      
View Full Code Here

TOP

Related Classes of org.drools.reteoo.AlphaNode$ObjectSinkUpdateAdapter

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.