public void removeActivation(final AgendaItem activation) { if ( declarativeAgenda ) { workingMemory.getEntryPointNode().retractActivation( activation.getFactHandle(), activation.getPropagationContext(), workingMemory ); if ( activation.getActivationGroupNode() != null ) { activation.getActivationGroupNode().getActivationGroup().removeActivation( activation ); } } if ( activation instanceof ScheduledAgendaItem ) { removeScheduleItem( (ScheduledAgendaItem) activation ); } }
if ( agendaItem.getActivationGroupNode() != null ) { stream.writeBoolean( true ); stream.writeUTF( agendaItem.getActivationGroupNode().getActivationGroup().getName() );
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 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 ); } }
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 ); } } }
if ( activation.getActivationGroupNode() != null && activation.getActivationGroupNode().getActivationGroup() == activationGroup ) {
public static ProtobufMessages.Activation writeActivation(MarshallerWriteContext context, AgendaItem agendaItem) { ProtobufMessages.Activation.Builder _activation = ProtobufMessages.Activation.newBuilder(); Rule rule = agendaItem.getRule(); _activation.setPackageName(rule.getPackage()); _activation.setRuleName(rule.getName()); ProtobufMessages.Tuple.Builder _tb = ProtobufMessages.Tuple.newBuilder(); for (LeftTuple entry = agendaItem.getTuple(); entry != null; entry = entry.getParent()) { InternalFactHandle handle = entry.getLastHandle(); _tb.addHandleId(handle.getId()); } _activation.setTuple(_tb.build()); _activation.setSalience(agendaItem.getSalience()); _activation.setIsActivated(agendaItem.isActivated()); if (agendaItem.getActivationGroupNode() != null) { _activation.setActivationGroup(agendaItem.getActivationGroupNode().getActivationGroup().getName()); } if (agendaItem.getFactHandle() != null) { _activation.setHandleId(agendaItem.getFactHandle().getId()); } org.drools.core.util.LinkedList<LogicalDependency> list = agendaItem.getLogicalDependencies(); if (list != null && !list.isEmpty()) { for (LogicalDependency node = list.getFirst(); node != null; node = node.getNext()) { _activation.addLogicalDependency(((InternalFactHandle) node.getJustified()).getId()); } } return _activation.build(); }