public void setAutoDeactivate(final boolean autoDeactivate) { this.autoDeactivate = autoDeactivate; if ( autoDeactivate && this.active && this.list.isEmpty() ) { this.active = false; } }
public boolean isEmpty() { return this.list.isEmpty(); }
public boolean isEmpty() { return this.list.isEmpty(); }
public void dequeue() { if ( this.agendaGroup != null ) { this.agendaGroup.remove( this ); } this.activated = blockers != null && ! blockers.isEmpty(); this.index = -1; }
/** * Checks if this ruleflow group is active and should automatically deactivate. * If the queue is empty, it deactivates the group. */ public void deactivateIfEmpty() { if ( this.active && this.autoDeactivate && this.list.isEmpty() ) { // deactivate callback WorkingMemoryAction action = new DeactivateCallback( this ); this.workingMemory.queueWorkingMemoryAction( action ); } }
public Activation getNext() { Activation activation = null; while ( this.index <= lastIndex ) { LinkedList<LinkedListEntry<Activation>> list = this.array[this.index]; if ( list != null ) { activation = list.removeFirst().getObject(); if ( list.isEmpty()) { this.array[this.index++] = null; } this.size--; break; } this.index++; } return activation; }
private FieldIndex unregisterFieldIndex(final int index) { final FieldIndex fieldIndex = findFieldIndex( index ); fieldIndex.decreaseCounter(); // if the fieldcount is 0 then remove it from the linkedlist if ( fieldIndex.getCount() == 0 ) { this.hashedFieldIndexes.remove( fieldIndex ); // if the linkedlist is empty then null it if ( this.hashedFieldIndexes.isEmpty() ) { this.hashedFieldIndexes = null; } } return fieldIndex; }
/** * An Activation is no longer true so it no longer justifies any of the logical facts * it logically asserted. It iterates over the Activation's LinkedList of DependencyNodes * it retrieves the justitication set for each DependencyNode's FactHandle and removes * itself. If the Set is empty it retracts the FactHandle from the WorkingMemory. * * @param activation * @param context * @param rule * @throws FactException */ public void removeLogicalDependencies(final Activation activation, final PropagationContext context, final Rule rule) throws FactException { final LinkedList<LogicalDependency> list = activation.getLogicalDependencies(); if ( list == null || list.isEmpty() ) { return; } for ( LogicalDependency node = list.getFirst(); node != null; node = node.getNext() ) { removeLogicalDependency( activation, node, context ); } }
public void clear() { // reset focus stack this.focusStack.clear(); this.focusStack.add( getMainAgendaGroup() ); // reset scheduled activations if ( !this.scheduledActivations.isEmpty() ) { for ( ScheduledAgendaItem item = this.scheduledActivations.removeFirst(); item != null; item = this.scheduledActivations.removeFirst() ) { item.setEnqueued( false ); Scheduler.removeAgendaItem( item, this ); } } // reset staged activations getStageActivationsGroup().clear(); //reset all agenda groups for ( InternalAgendaGroup group : this.agendaGroups.values() ) { group.clear(); } // reset all ruleflows for ( RuleFlowGroup group : this.ruleFlowGroups.values() ) { group.clear(); } // reset all activation groups. for ( ActivationGroup group : this.activationGroups.values() ) { group.clear(); } }
if ( !this.scheduledActivations.isEmpty() ) { for ( ScheduledAgendaItem item = this.scheduledActivations.removeFirst(); item != null; item = this.scheduledActivations.removeFirst() ) { if ( item.getEnqueued().compareAndSet( true, false ) ) {
if ( list != null && !list.isEmpty() ) { for (LogicalDependency node = list.getFirst(); node != null; node = node.getNext() ) { stream.writeShort( PersisterEnums.LOGICAL_DEPENDENCY );
public void unblockAllActivations(org.drools.runtime.rule.Activation act) { AgendaItem targetMatch = ( AgendaItem ) act; boolean wasBlocked = (targetMatch.getBlockers() != null && !targetMatch.getBlockers().isEmpty() ); for ( LinkedListEntry entry = ( LinkedListEntry ) targetMatch.getBlockers().getFirst(); entry != null; ) { LinkedListEntry tmp = ( LinkedListEntry ) entry.getNext(); LogicalDependency dep = ( LogicalDependency ) entry.getObject(); ((AgendaItem)dep.getJustifier()).removeBlocked( dep ); entry = tmp; } if ( wasBlocked ) { // the match is no longer blocked, so stage it ((DefaultAgenda)workingMemory.getAgenda()).getStageActivationsGroup().addActivation( targetMatch ); } }
public void insertAfter(final T existingNode, final T newNode) { if ( newNode.getPrevious() != null || newNode.getNext() != null ) { //do nothing if this node is already inserted somewhere return; } if ( existingNode == null ) { if ( this.isEmpty() ) { this.firstNode = newNode; this.lastNode = newNode; } else { // if existing node is null, then insert it as a first node final LinkedListNode node = this.firstNode; node.setPrevious( newNode ); newNode.setNext( node ); this.firstNode = newNode; } } else if ( existingNode == this.lastNode ) { existingNode.setNext( newNode ); newNode.setPrevious( existingNode ); this.lastNode = newNode; } else { (existingNode.getNext()).setPrevious( newNode ); newNode.setNext( existingNode.getNext() ); existingNode.setNext( newNode ); newNode.setPrevious( existingNode ); } this.size++; }
public void removeAllBlockersAndBlocked(DefaultAgenda agenda){ if ( this.blockers != null ) { // Iterate and remove this node's logical dependency list from each of it's blockers for ( LinkedListEntry<LogicalDependency> node = blockers.getFirst(); node != null; node = node.getNext() ) { LogicalDependency dep = node.getObject(); dep.getJustifier().getBlocked().remove( dep ); } } this.blockers = null; if ( this.blocked != null ) { // Iterate and remove this node's logical dependency list from each of it's blocked for ( LogicalDependency dep = blocked.getFirst(); dep != null; ) { LogicalDependency tmp = dep.getNext(); removeBlocked( dep ); AgendaItem justified = ( AgendaItem ) dep.getJustified(); if ( justified.getBlockers().isEmpty() && justified.isActivated() ) { // the match is no longer blocked, so stage it agenda.getStageActivationsGroup().addActivation( justified ); } dep = tmp; } } this.blocked = null; }
public void cancelRemainingPreviousLogicalDependencies() { if ( this.previousJustified != null ) { for ( LogicalDependency dep = (LogicalDependency) this.previousJustified.getFirst(); dep != null; dep = (LogicalDependency) dep.getNext() ) { this.workingMemory.getTruthMaintenanceSystem().removeLogicalDependency( activation, dep, activation.getPropagationContext() ); } } if ( this.previousBlocked != null ) { for ( LogicalDependency dep = this.previousBlocked.getFirst(); dep != null; ) { LogicalDependency tmp = dep.getNext(); this.previousBlocked.remove( dep ); AgendaItem justified = ( AgendaItem ) dep.getJustified(); justified.getBlockers().remove( dep.getJustifierEntry() ); if (justified.getBlockers().isEmpty() ) { // the match is no longer blocked, so stage it ((DefaultAgenda)workingMemory.getAgenda()).getStageActivationsGroup().addActivation( justified ); } dep = tmp; } } }
public boolean addActivation(final AgendaItem activation) { if ( declarativeAgenda ) { if ( activationObjectTypeConf == null ) { EntryPoint ep = workingMemory.getEntryPoint(); activationObjectTypeConf = ((InternalWorkingMemoryEntryPoint) workingMemory.getWorkingMemoryEntryPoint( ep.getEntryPointId() )).getObjectTypeConfigurationRegistry().getObjectTypeConf( ep, activation ); } InternalFactHandle factHandle = workingMemory.getFactHandleFactory().newFactHandle( activation, activationObjectTypeConf, workingMemory, workingMemory ); workingMemory.getEntryPointNode().assertActivation( factHandle, activation.getPropagationContext(), workingMemory ); activation.setFactHandle( factHandle ); if ( !activation.isCanceled() && ( activation.getBlockers() == null || activation.getBlockers().isEmpty() ) ) { // All activations started off staged, they are unstaged if they are blocked or // allowed to move onto the actual agenda for firing. getStageActivationsGroup().addActivation( activation ); } return true; } else { addActivation( activation, true ); return true; } }
((EventSupport) this.workingMemory).getAgendaEventSupport().fireBeforeRuleFlowGroupActivated( this, this.workingMemory ); if ( this.list.isEmpty() ) { if ( this.autoDeactivate ) {
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(); }