public void clearAndCancelActivationGroup(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.getActivationNode() != null ) { final InternalRuleFlowGroup ruleFlowGroup = (InternalRuleFlowGroup) activation.getActivationNode().getParentContainer(); ruleFlowGroup.removeActivation( activation ); } eventsupport.getAgendaEventSupport().fireActivationCancelled( activation, this.workingMemory, ActivationCancelledCause.CLEAR ); } } activationGroup.clear(); }
public void clearAndCancelAgendaGroup(final AgendaGroup agendaGroup) { final EventSupport eventsupport = (EventSupport) this.workingMemory; // this is thread safe for BinaryHeapQueue // Binary Heap locks while it returns the array and reset's it's own internal array. Lock is released afer getAndClear() for (Activation aQueueable : ((InternalAgendaGroup) agendaGroup).getAndClear()) { final AgendaItem item = (AgendaItem) aQueueable; if (item == null) { continue; } // this must be set false before removal from the activationGroup. // Otherwise the activationGroup will also try to cancel the Actvation // Also modify won't work properly item.setActivated(false); if (item.getActivationGroupNode() != null) { item.getActivationGroupNode().getActivationGroup().removeActivation(item); } if (item.getActivationNode() != null) { final InternalRuleFlowGroup ruleFlowGroup = (InternalRuleFlowGroup) item.getActivationNode().getParentContainer(); ruleFlowGroup.removeActivation(item); } eventsupport.getAgendaEventSupport().fireActivationCancelled( item, this.workingMemory, ActivationCancelledCause.CLEAR ); } }
public void blockActivation(org.drools.runtime.rule.Activation act) { AgendaItem targetMatch = ( AgendaItem ) act; // iterate to find previous equal logical insertion LogicalDependency dep = null; if ( this.previousJustified != null ) { for ( dep = this.previousJustified.getFirst(); dep != null; dep = dep.getNext() ) { if ( targetMatch == dep.getJustified() ) { this.previousJustified.remove( dep ); break; } } } if ( dep == null ) { dep = new SimpleLogicalDependency( activation, targetMatch ); } this.activation.addBlocked( dep ); if ( targetMatch.getBlockers().size() == 1 && targetMatch.isActive() ) { // it wasn't blocked before, but is now, so we must remove it from all groups, so it cannot be executed. targetMatch.remove(); if ( targetMatch.getActivationGroupNode() != null ) { targetMatch.getActivationGroupNode().getActivationGroup().removeActivation( targetMatch ); } if ( targetMatch.getActivationNode() != null ) { final InternalRuleFlowGroup ruleFlowGroup = (InternalRuleFlowGroup) targetMatch.getActivationNode().getParentContainer(); ruleFlowGroup.removeActivation( targetMatch ); } } }
ruleFlowGroup = (InternalRuleFlowGroup) item.getActivationNode().getParentContainer();
final InternalRuleFlowGroup ruleFlowGroup = (InternalRuleFlowGroup) activation.getActivationNode().getParentContainer(); ruleFlowGroup.removeActivation( activation );