protected BetaNodeFieldConstraint[] convertToConstraints(LinkedList list) { final BetaNodeFieldConstraint[] array = new BetaNodeFieldConstraint[list.size()]; int i = 0; for ( LinkedListEntry entry = (LinkedListEntry) list.getFirst(); entry != null; entry = (LinkedListEntry) entry.getNext() ) { array[i++] = (BetaNodeFieldConstraint) entry.getObject(); } return array; } }
public Activation[] getActivations() { Activation[] activations = new Activation[this.size]; int j = 0; for ( LinkedList<LinkedListEntry<Activation>> list : array ) { if ( list != null ) { Iterator<LinkedListEntry<Activation>> it = list.iterator(); Activation activation = it.next().getObject(); while ( activation != null) { activations[j++] = activation; activation = it.next().getObject(); } } } return activations; }
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; }
public LogicalRetractCallback(MarshallerReaderContext context) throws IOException { this.tms = context.wm.getTruthMaintenanceSystem(); this.handle = context.handles.get( context.readInt() ); this.context = context.propagationContexts.get( context.readLong() ); this.activation = (Activation) context.terminalTupleMap.get( context.readInt() ).getObject(); this.beliefSet = (BeliefSet) this.tms.getJustifiedMap().get( handle.getId() ); for ( LinkedListEntry entry = (LinkedListEntry) beliefSet.getFirst(); entry != null; entry = (LinkedListEntry) entry.getNext() ) { final LogicalDependency node = (LogicalDependency) entry.getObject(); if ( node.getJustifier() == this.activation ) { this.node = node; break; } } }
/** * The FactHandle is being removed from the system so remove any logical dependencies * between the justified FactHandle and its justifiers. Removes the FactHandle key * from the justifiedMap. It then iterates over all the LogicalDependency nodes, if any, * in the returned Set and removes the LogicalDependency node from the LinkedList maintained * by the Activation. * * @see LogicalDependency * * @param handle - The FactHandle to be removed * @throws FactException */ public void removeLogicalDependencies(final InternalFactHandle handle) throws FactException { final BeliefSet beliefSet = (BeliefSet) this.justifiedMap.remove( handle.getId() ); if ( beliefSet != null && !beliefSet.isEmpty() ) { for ( LinkedListEntry entry = (LinkedListEntry) beliefSet.getFirst(); entry != null; entry = (LinkedListEntry) entry.getNext() ) { final LogicalDependency node = (LogicalDependency) entry.getObject(); node.getJustifier().getLogicalDependencies().remove( node ); } } }
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 LogicalRetractCallback(MarshallerReaderContext context, Action _action) { LogicalRetract _retract = _action.getLogicalRetract(); this.tms = context.wm.getTruthMaintenanceSystem(); this.handle = context.handles.get( _retract.getHandleId() ); this.activation = (Activation) context.filter .getTuplesCache().get( PersisterHelper.createActivationKey( _retract.getActivation().getPackageName(), _retract.getActivation().getRuleName(), _retract.getActivation().getTuple() ) ).getObject(); this.context = this.activation.getPropagationContext(); this.beliefSet = (BeliefSet) this.tms.getJustifiedMap().get( handle.getId() ); for ( LinkedListEntry entry = (LinkedListEntry) beliefSet.getFirst(); entry != null; entry = (LinkedListEntry) entry.getNext() ) { final LogicalDependency node = (LogicalDependency) entry.getObject(); if ( node.getJustifier() == this.activation ) { this.node = node; break; } } }
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; }
LogicalDependency dependency = (LogicalDependency) node.getObject(); org.drools.spi.Activation activation = dependency.getJustifier(); ProtobufMessages.Activation _activation = ProtobufMessages.Activation.newBuilder()