Package org.drools.spi

Examples of org.drools.spi.ActivationGroup


        if ( item.isRuleNetworkEvaluatorActivation() ) {
            return;
        }
        String group = item.getRule().getActivationGroup();
        if ( group != null && group.length() > 0 ) { 
            ActivationGroup actgroup = ( ActivationGroup ) getActivationGroup( group );
           
            // When unlinking don't allow lazy activations to activate, from before it's last trigger point
            if ( this.unlinkingEnabled && actgroup.getTriggeredForRecency() != 0 &&
                    actgroup.getTriggeredForRecency() >=  ((InternalFactHandle)item.getPropagationContext().getFactHandle()).getRecency())  {
                return;
            }
           
            actgroup.addActivation( item );
        }
    }
View Full Code Here


                return;
            }
           
            // All activations started off staged, they are unstaged if they are blocked or
            // allowed to move onto the actual agenda for firing.
            ActivationGroup activationGroup = getStageActivationsGroup()
            if ( activation.getActivationGroupNode() != null && activation.getActivationGroupNode().getActivationGroup() == activationGroup ) {
                // already staged, so return
                return;
            }
         
            activationGroup.addActivation( activation );
        } else {
            if ( !previouslyActive ) {
                addActivation( activation, true );
            } else {
                Timer timer = activation.getRule().getTimer();
View Full Code Here

     * (non-Javadoc)
     *
     * @see org.kie.common.AgendaI#clearActivationGroup(java.lang.String)
     */
    public void clearAndCancelActivationGroup(final String name) {
        final ActivationGroup activationGroup = this.activationGroups.get( name );
        if ( activationGroup != null ) {
            clearAndCancelActivationGroup( activationGroup );
        }
    }
View Full Code Here

                                                                            this.workingMemory );

            if ( activation.getActivationGroupNode() != null ) {
                // We know that this rule will cancel all other activations in the group
                // so lets remove the information now, before the consequence fires
                final ActivationGroup activationGroup = activation.getActivationGroupNode().getActivationGroup();
                activationGroup.removeActivation( activation );
                clearAndCancelActivationGroup( activationGroup );
            }
            activation.setActivated( false );

            try {
View Full Code Here

                return;
            }
           
            // All activations started off staged, they are unstaged if they are blocked or
            // allowed to move onto the actual agenda for firing.
            ActivationGroup activationGroup = getStageActivationsGroup()
            if ( activation.getActivationGroupNode() != null && activation.getActivationGroupNode().getActivationGroup() == activationGroup ) {
                // already staged, so return
                return;
            }
         
            activationGroup.addActivation( activation );
        } else {
            if ( !previouslyActive ) {
                addActivation( activation, true );
            } else {
                Timer timer = activation.getRule().getTimer();
View Full Code Here

     * (non-Javadoc)
     *
     * @see org.drools.common.AgendaI#clearActivationGroup(java.lang.String)
     */
    public void clearAndCancelActivationGroup(final String name) {
        final ActivationGroup activationGroup = this.activationGroups.get( name );
        if ( activationGroup != null ) {
            clearAndCancelActivationGroup( activationGroup );
        }
    }
View Full Code Here

                                                                            this.workingMemory );

            if ( activation.getActivationGroupNode() != null ) {
                // We know that this rule will cancel all other activations in the group
                // so lets remove the information now, before the consequence fires
                final ActivationGroup activationGroup = activation.getActivationGroupNode().getActivationGroup();
                activationGroup.removeActivation( activation );
                clearAndCancelActivationGroup( activationGroup );
            }
            activation.setActivated( false );

            try {
View Full Code Here

        // Assert the tuple and check it was added to activation-group-0
        node0.assertLeftTuple( tuple,
                               context0,
                               workingMemory );
        agenda.unstageActivations();
        final ActivationGroup activationGroup0 = agenda.getActivationGroup( "activation-group-0" );
        assertEquals( 1,
                      activationGroup0.size() );

        // Removing a tuple should remove the activation from the activation-group-0 again
        node0.retractLeftTuple( tuple,
                                context0,
                                workingMemory );
        assertEquals( 0,
                      activationGroup0.size() );

        // Assert the tuple again and check it was added to activation-group-0
        node0.assertLeftTuple( tuple,
                               context0,
                               workingMemory );
        agenda.unstageActivations();
        assertEquals( 1,
                      activationGroup0.size() );

        // Assert another tuple and check it was added to activation-group-0
        node1.assertLeftTuple( tuple,
                               context1,
                               workingMemory );
        agenda.unstageActivations();
        assertEquals( 2,
                      activationGroup0.size() );

        // There should now be two potential activations to fire
        assertEquals( 2,
                      agenda.focusStackSize() );

        // The first tuple should fire, adding itself to the List and clearing and cancelling the other Activations in the activation-group-0
        agenda.fireNextItem( null );

        // Make sure the activation-group-0 is clear
        assertEquals( 0,
                      activationGroup0.size() );

        // Make sure the Agenda  is  empty
        assertEquals( 0,
                      agenda.focusStackSize() );

        // List should only have a single item, "rule0"
        assertEquals( 1,
                      list.size() );
        assertSame( rule1,
                    list.get( 0 ) );

        list.clear();

        //-------------------
        // Now try a more complex scenario involving  two Xor Groups and one  rule not in a Group
        node0.assertLeftTuple( tuple,
                               context0,
                               workingMemory );
        node1.assertLeftTuple( tuple,
                               context1,
                               workingMemory );
        node2.assertLeftTuple( tuple,
                               context2,
                               workingMemory );
        node3.assertLeftTuple( tuple,
                               context3,
                               workingMemory );
        agenda.unstageActivations();

        // activation-group-0 should be populated again
        assertEquals( 2,
                      activationGroup0.size() );

        // make sure the activation-group-3 is cleared when we can clear the Agenda Group for the activation that is in both
        final ActivationGroup activationGroup3 = agenda.getActivationGroup( "activation-group-3" );

        assertEquals( 4,
                      agenda.agendaSize() );
        assertEquals( 1,
                      activationGroup3.size() );

        agenda.clearAndCancelAgendaGroup( "agendaGroup3" );
        assertEquals( 3,
                      agenda.agendaSize() );
        assertEquals( 0,
                      activationGroup3.size() );

        // Activation for activation-group-0 should be next - the activation in no activation/agenda group should remain on the agenda
        agenda.fireNextItem( null );
        assertEquals( 1,
                      agenda.agendaSize() );
View Full Code Here

        // Assert the tuple and check it was added to activation-group-0
        node0.assertLeftTuple( tuple,
                               context0,
                               workingMemory );
        final ActivationGroup activationGroup0 = agenda.getActivationGroup( "activation-group-0" );
        assertEquals( 1,
                      activationGroup0.size() );

        // Removing a tuple should remove the activation from the activation-group-0 again
        node0.retractLeftTuple( tuple,
                                context0,
                                workingMemory );
        assertEquals( 0,
                      activationGroup0.size() );

        // Assert the tuple again and check it was added to activation-group-0
        node0.assertLeftTuple( tuple,
                               context0,
                               workingMemory );
        assertEquals( 1,
                      activationGroup0.size() );

        // Assert another tuple and check it was added to activation-group-0
        node1.assertLeftTuple( tuple,
                               context1,
                               workingMemory );
        assertEquals( 2,
                      activationGroup0.size() );

        // There should now be two potential activations to fire
        assertEquals( 2,
                      agenda.focusStackSize() );

        // The first tuple should fire, adding itself to the List and clearing and cancelling the other Activations in the activation-group-0
        agenda.fireNextItem( null );

        // Make sure the activation-group-0 is clear
        assertEquals( 0,
                      activationGroup0.size() );

        // Make sure the Agenda  is  empty
        assertEquals( 0,
                      agenda.focusStackSize() );

        // List should only have a single item, "rule0"
        assertEquals( 1,
                      list.size() );
        assertSame( rule0,
                    list.get( 0 ) );

        list.clear();

        //-------------------
        // Now try a more complex scenario involving  two Xor Groups and one  rule not in a Group
        node0.assertLeftTuple( tuple,
                               context0,
                               workingMemory );
        node1.assertLeftTuple( tuple,
                               context1,
                               workingMemory );
        node2.assertLeftTuple( tuple,
                               context2,
                               workingMemory );
        node3.assertLeftTuple( tuple,
                               context3,
                               workingMemory );

        // activation-group-0 should be populated again
        assertEquals( 2,
                      activationGroup0.size() );

        // make sure the activation-group-3 is cleared when we can clear the Agenda Group for the activation that is in both
        final ActivationGroup activationGroup3 = agenda.getActivationGroup( "activation-group-3" );

        assertEquals( 4,
                      agenda.agendaSize() );
        assertEquals( 1,
                      activationGroup3.size() );

        agenda.clearAndCancelAgendaGroup( "agendaGroup3" );
        assertEquals( 3,
                      agenda.agendaSize() );
        assertEquals( 0,
                      activationGroup3.size() );

        // Activation for activation-group-0 should be next - the activation in no activation/agenda group should remain on the agenda
        agenda.fireNextItem( null );
        assertEquals( 1,
                      agenda.agendaSize() );
View Full Code Here

        // Assert the tuple and check it was added to activation-group-0
        node0.assertLeftTuple( tuple,
                               context0,
                               workingMemory );
        agenda.unstageActivations();
        final ActivationGroup activationGroup0 = agenda.getActivationGroup( "activation-group-0" );
        assertEquals( 1,
                      activationGroup0.size() );

        // Removing a tuple should remove the activation from the activation-group-0 again
        node0.retractLeftTuple( tuple,
                                context0,
                                workingMemory );
        assertEquals( 0,
                      activationGroup0.size() );

        // Assert the tuple again and check it was added to activation-group-0
        node0.assertLeftTuple( tuple,
                               context0,
                               workingMemory );
        agenda.unstageActivations();
        assertEquals( 1,
                      activationGroup0.size() );

        // Assert another tuple and check it was added to activation-group-0
        node1.assertLeftTuple( tuple,
                               context1,
                               workingMemory );
        agenda.unstageActivations();
        assertEquals( 2,
                      activationGroup0.size() );

        // There should now be two potential activations to fire
        assertEquals( 2,
                      agenda.focusStackSize() );

        // The first tuple should fire, adding itself to the List and clearing and cancelling the other Activations in the activation-group-0
        agenda.fireNextItem( null );

        // Make sure the activation-group-0 is clear
        assertEquals( 0,
                      activationGroup0.size() );

        // Make sure the Agenda  is  empty
        assertEquals( 0,
                      agenda.focusStackSize() );

        // List should only have a single item, "rule0"
        assertEquals( 1,
                      list.size() );
        assertSame( rule1,
                    list.get( 0 ) );

        list.clear();

        //-------------------
        // Now try a more complex scenario involving  two Xor Groups and one  rule not in a Group
        node0.assertLeftTuple( tuple,
                               context0,
                               workingMemory );
        node1.assertLeftTuple( tuple,
                               context1,
                               workingMemory );
        node2.assertLeftTuple( tuple,
                               context2,
                               workingMemory );
        node3.assertLeftTuple( tuple,
                               context3,
                               workingMemory );
        agenda.unstageActivations();

        // activation-group-0 should be populated again
        assertEquals( 2,
                      activationGroup0.size() );

        // make sure the activation-group-3 is cleared when we can clear the Agenda Group for the activation that is in both
        final ActivationGroup activationGroup3 = agenda.getActivationGroup( "activation-group-3" );

        assertEquals( 4,
                      agenda.agendaSize() );
        assertEquals( 1,
                      activationGroup3.size() );

        agenda.clearAndCancelAgendaGroup( "agendaGroup3" );
        assertEquals( 3,
                      agenda.agendaSize() );
        assertEquals( 0,
                      activationGroup3.size() );

        // Activation for activation-group-0 should be next - the activation in no activation/agenda group should remain on the agenda
        agenda.fireNextItem( null );
        assertEquals( 1,
                      agenda.agendaSize() );
View Full Code Here

TOP

Related Classes of org.drools.spi.ActivationGroup

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.