Package org.drools.spi

Examples of org.drools.spi.Activation


    public void clearActivationGroup(final ActivationGroup activationGroup) {
        final EventSupport eventsupport = (EventSupport) this.workingMemory;

        for ( final Iterator it = activationGroup.iterator(); it.hasNext(); ) {
            final ActivationGroupNode node = (ActivationGroupNode) it.next();
            final Activation activation = node.getActivation();
            activation.setActivationGroupNode( null );

            if ( activation.isActivated() ) {
                activation.setActivated( false );
                activation.remove();

                if ( activation.getRuleFlowGroupNode() != null ) {
                    final InternalRuleFlowGroup ruleFlowGroup = activation.getRuleFlowGroupNode().getRuleFlowGroup();
                    ruleFlowGroup.removeActivation( activation );
                }

                eventsupport.getAgendaEventSupport().fireActivationCancelled( activation,
                                                                              this.workingMemory );
View Full Code Here


        wm.insert( p3 );

        assertEquals( 3, created.size() );
        assertEquals( 0, cancelled.size() );

        final Activation item = ((ActivationCreatedEvent) created.get( 2 )).getActivation();

        // simulate a modify inside a consequence
        wm.update( stiltonHandle, stilton, item.getRule(), item );

        // with true modify, no reactivations should be triggered
        assertEquals( 3, created.size() );
        assertEquals( 0, cancelled.size() );
    }
View Full Code Here

        final HashMap map = new HashMap();
        workingMemory.setGlobal( "map",
                                 map );

        final Tuple tuple = new MockTuple( new HashMap() );
        final Activation activation = new MockActivation( rule,
                                                          0,
                                                          rule.getLhs(),
                                                          tuple );

        DefaultKnowledgeHelper knowledgeHelper = new org.drools.base.DefaultKnowledgeHelper( workingMemory );
View Full Code Here

        workingMemory.setGlobal( "map",
                                 map );

        final Tuple tuple = new MockTuple( new HashMap() );
        final Activation activation = new MockActivation( newRule,
                                                          0,
                                                          newRule.getLhs(),
                                                          tuple );

        final DefaultKnowledgeHelper knowledgeHelper = new org.drools.base.DefaultKnowledgeHelper( workingMemory );
View Full Code Here

   * @return
   */
  public void add(EObject e, KnowledgeHelper drools) {
    objects.add(e);
    helpers.add(drools);
    Activation a = drools.getActivation();
    activations.add(a);
   
    // should we track the insertions for each activation?
    if (trackInsertions) {
      // map from EObject to Activation
View Full Code Here

                // do not add the activation if the rule is "lock-on-active" and the AgendaGroup is active
                // we must check the context to determine if its a new tuple or an exist re-activated tuple as part of the retract               
                if ( context.getType() == PropagationContext.MODIFICATION ) {
                    if ( this.rule.isLockOnActive() && agendaGroup.isActive() ) {
                        Activation justifier = context.removeRetractedTuple( this.rule,
                                                                             tuple );
                        if ( justifier == null ) {
                            // This rule is locked and active, do not allow new tuples to activate
                            return;
                        } else if ( this.rule.hasLogicalDependency() ) {
                            copyLogicalDependencies( context,
                                                     workingMemory,
                                                     item,
                                                     justifier );
                        }
                    } else if ( this.rule.hasLogicalDependency() ) {
                        Activation justifier = context.removeRetractedTuple( this.rule,
                                                                             tuple );
                        copyLogicalDependencies( context,
                                                 workingMemory,
                                                 item,
                                                 justifier );
                    }
                } else if ( this.rule.isLockOnActive() && agendaGroup.isActive() ) {
                    return;
                }

                agendaGroup.add( item );
            } else {
                //There is  a RuleFlowNode so add it there, instead  of the Agenda
                RuleFlowGroup rfg = memory.getRuleFlowGroup();
                // Lazy cache ruleFlowGroup
                if ( rfg == null ) {
                    rfg = workingMemory.getAgenda().getRuleFlowGroup( this.rule.getRuleFlowGroup() );
                    memory.setRuleFlowGroup( rfg );
                }

                // do not add the activation if the rule is "lock-on-active" and the RuleFlowGroup is active
                // we must check the context to determine if its a new tuple or an exist re-activated tuple as part of the retract               
                if ( context.getType() == PropagationContext.MODIFICATION ) {
                    if ( this.rule.isLockOnActive() && rfg.isActive() ) {
                        Activation justifier = context.removeRetractedTuple( this.rule,
                                                                             tuple );
                        if ( justifier == null ) {
                            // This rule is locked and active, do not allow new tuples to activate
                            return;
                        } else if ( this.rule.hasLogicalDependency() ) {
                            copyLogicalDependencies( context,
                                                     workingMemory,
                                                     item,
                                                     justifier );
                        }
                    } else if ( this.rule.hasLogicalDependency() ) {
                        Activation justifier = context.removeRetractedTuple( this.rule,
                                                                             tuple );
                        copyLogicalDependencies( context,
                                                 workingMemory,
                                                 item,
                                                 justifier );
View Full Code Here

            // tuple should only be null if it was asserted and reached a no-loop causing it to exit early
            // before being added to the node memory and an activation created and attached
            return;
        }

        final Activation activation = tuple.getActivation();
        if ( activation.getLogicalDependencies() != null && !activation.getLogicalDependencies().isEmpty() ) {
            context.addRetractedTuple( this.rule,
                                       activation );
        }

        if ( activation.isActivated() ) {
            if ( context.getType() == PropagationContext.MODIFICATION ) {
                // during a modify if we have either isLockOnActive or the activation has logical dependencies
                // then we need to track retractions, so we know which are exising activations and which are truly new
                if ( this.rule.isLockOnActive() ) {
                    context.addRetractedTuple( this.rule,
                                               activation );
                }
            }

            activation.remove();

            if ( activation.getActivationGroupNode() != null ) {
                activation.getActivationGroupNode().getActivationGroup().removeActivation( activation );
            }

            if ( activation.getRuleFlowGroupNode() != null ) {
                final InternalRuleFlowGroup ruleFlowGroup = activation.getRuleFlowGroupNode().getRuleFlowGroup();
                ruleFlowGroup.removeActivation( activation );
            }

            ((EventSupport) workingMemory).getAgendaEventSupport().fireActivationCancelled( activation,
                                                                           workingMemory );
View Full Code Here

            final InternalWorkingMemory workingMemory = workingMemories[i];

            final TerminalNodeMemory memory = (TerminalNodeMemory) workingMemory.getNodeMemory( this );
            final Iterator it = memory.getTupleMemory().iterator();
            for ( ReteTuple tuple = (ReteTuple) it.next(); tuple != null; tuple = (ReteTuple) it.next() ) {
                final Activation activation = tuple.getActivation();

                if ( activation.isActivated() ) {
                    activation.remove();
                    ((EventSupport) workingMemory).getAgendaEventSupport().fireActivationCancelled( activation,
                                                                                   workingMemory );
                }

                final PropagationContext propagationContext = new PropagationContextImpl( workingMemory.getNextPropagationIdCounter(),
View Full Code Here

       
        activationGroup.setTriggeredForRecency( this.workingMemory.getFactHandleFactory().getRecency() );

        for ( final Iterator it = activationGroup.iterator(); it.hasNext(); ) {
            final ActivationGroupNode node = (ActivationGroupNode) it.next();
            final Activation activation = node.getActivation();
            activation.setActivationGroupNode( null );

            if ( activation.isActivated() ) {
                activation.setActivated( false );
                activation.remove();

                if ( activation.getActivationNode() != null ) {
                    final InternalRuleFlowGroup ruleFlowGroup = (InternalRuleFlowGroup) activation.getActivationNode().getParentContainer();
                    ruleFlowGroup.removeActivation( activation );
                }

                eventsupport.getAgendaEventSupport().fireActivationCancelled( activation,
                                                                              this.workingMemory,
View Full Code Here

                                               long processInstanceId) {

        RuleFlowGroup systemRuleFlowGroup = this.getRuleFlowGroup( ruleflowGroupName );

        for (ActivationNode aSystemRuleFlowGroup : systemRuleFlowGroup) {
            Activation activation = aSystemRuleFlowGroup.getActivation();
            if (ruleName.equals(activation.getRule().getName())) {
                if (checkProcessInstance(activation, processInstanceId)) {
                    return true;
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.drools.spi.Activation

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.