public void addActivation(final Activation activation) { assert activation.getActivationNode() == null; final ActivationNode node = new ActivationNode( activation, this ); activation.setActivationNode( node ); this.list.add( node ); if ( this.active ) { ((InternalAgendaGroup) activation.getAgendaGroup()).add( activation ); } }
/** * @inheritDoc */ public boolean isRuleActiveInRuleFlowGroup(String ruleflowGroupName, String ruleName, 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; } } } return false; }
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 Activation[] getActivations() { Activation[] activations = new Activation[ list.size() ]; final Iterator<ActivationNode> it = this.list.iterator(); int i = 0; for ( ActivationNode node = it.next(); node != null; node = it.next() ) { activations[i++] = node.getActivation(); } return activations; }
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 ); } }
private void triggerActivations() { // iterate all activations adding them to their AgendaGroups final Iterator<ActivationNode> it = this.list.iterator(); for ( ActivationNode node = it.next(); node != null; node = it.next() ) { final Activation activation = node.getActivation(); ((InternalAgendaGroup) activation.getAgendaGroup()).add( activation ); } // making sure we re-evaluate agenda in case we are waiting for activations ((InternalAgenda) workingMemory.getAgenda()).notifyHalt(); }
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 ); } } }
public void clearAndCancelAndCancel(final RuleFlowGroup ruleFlowGroup) { final EventSupport eventsupport = (EventSupport) this.workingMemory; for (ActivationNode node : ruleFlowGroup) { AgendaItem item = (AgendaItem) node.getActivation(); if (item != null) { item.setActivated(false); item.remove(); if (item.getActivationGroupNode() != null) { item.getActivationGroupNode().getActivationGroup().removeActivation(item); } } eventsupport.getAgendaEventSupport().fireActivationCancelled( item, this.workingMemory, ActivationCancelledCause.CLEAR ); } ruleFlowGroup.clear(); if ( ruleFlowGroup.isActive() && ruleFlowGroup.isAutoDeactivate() ) { // deactivate callback WorkingMemoryAction action = new DeactivateCallback( (InternalRuleFlowGroup) ruleFlowGroup ); this.workingMemory.queueWorkingMemoryAction( action ); } }
ruleFlowGroup = (InternalRuleFlowGroup) item.getActivationNode().getParentContainer();
final Iterator<ActivationNode> it = this.list.iterator(); for ( ActivationNode node = it.next(); node != null; node = it.next() ) { final Activation activation = node.getActivation(); activation.remove(); if ( activation.getActivationGroupNode() != null ) {
final InternalRuleFlowGroup ruleFlowGroup = (InternalRuleFlowGroup) activation.getActivationNode().getParentContainer(); ruleFlowGroup.removeActivation( activation );