use of org.drools.core.phreak.RuleAgendaItem in project drools by kiegroup.
the class ProtobufOutputMarshaller method evaluateRuleActivations.
private static void evaluateRuleActivations(StatefulKnowledgeSessionImpl wm) {
// ET: NOTE: initially we were only resolving partially evaluated rules
// but some tests fail because of that. Have to resolve all rule agenda items
// in order to fix the tests
// find all partially evaluated rule activations
// ActivationIterator it = ActivationIterator.iterator( wm );
// Set<String> evaluated = new HashSet<String>();
// for ( org.drools.core.spi.Activation item = (org.drools.core.spi.Activation) it.next(); item != null; item = (org.drools.core.spi.Activation) it.next() ) {
// if ( !item.isRuleAgendaItem() ) {
// evaluated.add( item.getRule().getPackageName()+"."+item.getRule().getName() );
// }
// }
// need to evaluate all lazy partially evaluated activations before serializing
boolean dirty = true;
while (dirty) {
for (Activation activation : wm.getAgenda().getActivations()) {
if (activation.isRuleAgendaItem()) /*&& evaluated.contains( activation.getRule().getPackageName()+"."+activation.getRule().getName() )*/
{
// evaluate it
((RuleAgendaItem) activation).getRuleExecutor().reEvaluateNetwork(wm);
((RuleAgendaItem) activation).getRuleExecutor().removeRuleAgendaItemWhenEmpty(wm);
}
}
dirty = false;
// network evaluation with phreak and TMS may make previous processed rules dirty again, so need to reprocess until all is flushed.
for (Activation activation : wm.getAgenda().getActivations()) {
if (activation.isRuleAgendaItem() && ((RuleAgendaItem) activation).getRuleExecutor().isDirty()) {
dirty = true;
break;
}
}
wm.flushPropagations();
}
}
use of org.drools.core.phreak.RuleAgendaItem 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