use of org.drools.core.util.LinkedListEntry in project drools by kiegroup.
the class ProtobufOutputMarshaller method writeBeliefSet.
private static void writeBeliefSet(MarshallerWriteContext context, BeliefSet beliefSet, org.drools.core.marshalling.impl.ProtobufMessages.EqualityKey.Builder _key) throws IOException {
ProtobufMessages.BeliefSet.Builder _beliefSet = ProtobufMessages.BeliefSet.newBuilder();
_beliefSet.setHandleId(beliefSet.getFactHandle().getId());
ObjectMarshallingStrategyStore objectMarshallingStrategyStore = context.objectMarshallingStrategyStore;
// for ( LinkedListEntry node = (LinkedListEntry) beliefSet.getFirst(); node != null; node = (LinkedListEntry) node.getNext() ) {
FastIterator it = beliefSet.iterator();
for (LinkedListEntry node = (LinkedListEntry) beliefSet.getFirst(); node != null; node = (LinkedListEntry) it.next(node)) {
LogicalDependency belief = (LogicalDependency) node.getObject();
ProtobufMessages.LogicalDependency.Builder _logicalDependency = ProtobufMessages.LogicalDependency.newBuilder();
// _belief.setActivation( value )
LogicalDependency dependency = (LogicalDependency) node.getObject();
org.drools.core.spi.Activation activation = dependency.getJustifier();
ProtobufMessages.Activation _activation = ProtobufMessages.Activation.newBuilder().setPackageName(activation.getRule().getPackage()).setRuleName(activation.getRule().getName()).setTuple(PersisterHelper.createTuple(activation.getTuple())).build();
_logicalDependency.setActivation(_activation);
if (belief.getObject() != null) {
ObjectMarshallingStrategy strategy = objectMarshallingStrategyStore.getStrategyObject(belief.getObject());
Integer index = context.getStrategyIndex(strategy);
_logicalDependency.setObjectStrategyIndex(index);
_logicalDependency.setObject(ByteString.copyFrom(strategy.marshal(context.strategyContext.get(strategy), context, belief.getObject())));
}
if (belief.getMode() != null) {
ObjectMarshallingStrategy strategy = objectMarshallingStrategyStore.getStrategyObject(belief.getMode());
Integer index = context.getStrategyIndex(strategy);
_logicalDependency.setValueStrategyIndex(index);
_logicalDependency.setValue(ByteString.copyFrom(strategy.marshal(context.strategyContext.get(strategy), context, belief.getMode())));
}
_beliefSet.addLogicalDependency(_logicalDependency.build());
}
_key.setBeliefSet(_beliefSet);
}
use of org.drools.core.util.LinkedListEntry in project drools by kiegroup.
the class SimpleBeliefSet method cancel.
public void cancel(PropagationContext context) {
// get all but last, as that we'll do via the BeliefSystem, for cleanup
for (SimpleMode entry = getFirst(); entry != getLast(); ) {
// get next, as we are about to remove it
SimpleMode temp = entry.getNext();
final LogicalDependency<SimpleMode> node = entry.getObject();
node.getJustifier().getLogicalDependencies().remove(node);
remove(entry);
entry = temp;
}
LinkedListEntry last = getFirst();
final LogicalDependency<SimpleMode> node = (LogicalDependency) last.getObject();
node.getJustifier().getLogicalDependencies().remove(node);
beliefSystem.delete(node, this, context);
}
use of org.drools.core.util.LinkedListEntry in project drools by kiegroup.
the class BaseBetaConstraintsTest method convertToConstraints.
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;
}
use of org.drools.core.util.LinkedListEntry in project drools by kiegroup.
the class DefaultKnowledgeHelper method unblockAllMatches.
public void unblockAllMatches(Match 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) {
RuleAgendaItem ruleAgendaItem = targetMatch.getRuleAgendaItem();
InternalAgenda agenda = workingMemory.getAgenda();
agenda.stageLeftTuple(ruleAgendaItem, targetMatch);
}
}
Aggregations