public void undoPreviousMatch(AgendaItem agendaItem) { Object callback = agendaItem.getCallback(); // Some rules don't have a callback because their RHS doesn't do addConstraintMatch() if (callback instanceof ConstraintActivationUnMatchListener) { ((ConstraintActivationUnMatchListener) callback).run(); agendaItem.setCallback(null); } }
List list = new ArrayList(); for ( AgendaItem act = (AgendaItem) it.next(); act != null; act = (AgendaItem) it.next() ) { if ( act.getRule().getName().equals( "rule3" ) ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.getDeclarationValue( "$s2" ) + ":" + act.getDeclarationValue( "$s3" ) + ":" + act.isQueued() ); } else if ( act.getRule().getName().equals( "rule1" ) ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.getDeclarationValue( "$s2" ) + ":" + act.isQueued() ); } else if ( act.getRule().getName().equals( "rule2" ) ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.isQueued() ); list = new ArrayList(); for ( AgendaItem act = (AgendaItem) it.next(); act != null; act = (AgendaItem) it.next() ) { if ( act.getRule().getName().equals( "rule3" ) ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.getDeclarationValue( "$s2" ) + ":" + act.getDeclarationValue( "$s3" ) + ":" + act.isQueued() ); } else if ( act.getRule().getName().equals( "rule1" ) ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.getDeclarationValue( "$s2" ) + ":" + act.isQueued() ); } else if ( act.getRule().getName().equals( "rule2" ) ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.isQueued() );
protected void callOnUpdate(RuleContext ruleContext) { AgendaItem<?> agendaItem = (AgendaItem) ruleContext.getMatch(); agendaItem.getCallback().run(); }
import org.drools.event.rule.AfterActivationFiredEvent; import org.drools.event.rule.DefaultAgendaEventListener; ... StatelessKnowledgeSession ksession = kbase.newStatelessKnowledgeSession(); ksession.addEventListener(new DefaultAgendaEventListener() { @Override public void afterActivationFired(AfterActivationFiredEvent event) { AgendaItem item = (AgendaItem) event.getActivation(); System.out.println("Name: " + item.getRule().getName() + "; Salience: " + item.getRule().getSalience()); } });
public void evaluate(final KnowledgeHelper knowledgeHelper, final WorkingMemory workingMemory) { AgendaItem item = (AgendaItem) knowledgeHelper.getMatch(); final Cheese cheese = (Cheese) item.getTuple().getFactHandle().getObject(); final int oldPrice = cheese.getPrice(); cheese.setPrice(100); item.setActivationUnMatchListener(new ActivationUnMatchListener() { public void unMatch(org.kie.api.runtime.rule.RuleRuntime wm, Match activation) { cheese.setPrice(oldPrice); } }); }
protected void registerConstraintMatch(RuleContext kcontext, final Runnable constraintUndoListener, Supplier<Score_> scoreSupplier) { AgendaItem<?> agendaItem = (AgendaItem) kcontext.getMatch(); ConstraintActivationUnMatchListener constraintActivationUnMatchListener = new ConstraintActivationUnMatchListener(constraintUndoListener); agendaItem.setCallback(constraintActivationUnMatchListener); if (constraintMatchEnabled) { List<Object> justificationList = extractJustificationList(kcontext); // Not needed in fast code: Add ConstraintMatch constraintActivationUnMatchListener.constraintMatchTotal = findConstraintMatchTotal(kcontext); ConstraintMatch constraintMatch = constraintActivationUnMatchListener.constraintMatchTotal .addConstraintMatch(justificationList, scoreSupplier.get()); List<Indictment> indictmentList = justificationList.stream() .distinct() // One match might have the same justification twice .map(justification -> { Indictment indictment = indictmentMap.computeIfAbsent(justification, k -> new Indictment(justification, zeroScore)); indictment.addConstraintMatch(constraintMatch); return indictment; }).collect(Collectors.toList()); constraintActivationUnMatchListener.constraintMatch = constraintMatch; constraintActivationUnMatchListener.indictmentList = indictmentList; } }
List list = new ArrayList(); for ( AgendaItem act = (AgendaItem) it.next(); act != null; act = (AgendaItem) it.next() ) { if ( act.getRule().getName().equals( "rule3" ) ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.getDeclarationValue( "$s2" ) + ":" + act.getDeclarationValue( "$s3" ) + ":" + act.isQueued() ); } else if ( act.getRule().getName().equals( "rule1" ) ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.getDeclarationValue( "$s2" ) + ":" + act.isQueued() ); } else if ( act.getRule().getName().equals( "rule2" ) ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.isQueued() );
protected void callOnDelete(RuleContext ruleContext) { AgendaItem<?> agendaItem = (AgendaItem) ruleContext.getMatch(); agendaItem.getCallback().run(); }
List list = new ArrayList(); for ( AgendaItem act = (AgendaItem) it.next(); act != null; act = (AgendaItem) it.next() ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.getDeclarationValue( "$s2" ) + ":" + act.isQueued() ); list = new ArrayList(); for ( AgendaItem act = (AgendaItem) it.next(); act != null; act = (AgendaItem) it.next() ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.getDeclarationValue( "$s2" ) + ":" + act.isQueued() );
List list = new ArrayList(); for ( AgendaItem act = (AgendaItem) it.next(); act != null; act = (AgendaItem) it.next() ) { if ( act.getRule().getName().equals( "rule3" ) ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.isQueued() ); } else if ( act.getRule().getName().equals( "rule1" ) ) { list.add( act.getRule().getName() + ":" + act.isQueued() ); } else if ( act.getRule().getName().equals( "rule2" ) ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.isQueued() );
List list = new ArrayList(); for ( AgendaItem act = (AgendaItem) it.next(); act != null; act = (AgendaItem) it.next() ) { if ( act.getRule().getName().equals( "rule3" ) ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.isQueued() ); } else if ( act.getRule().getName().equals( "rule1" ) ) { list.add( act.getRule().getName() + ":" + act.isQueued() ); } else if ( act.getRule().getName().equals( "rule2" ) ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.isQueued() );
List list = new ArrayList(); for ( AgendaItem act = (AgendaItem) it.next(); act != null; act = (AgendaItem) it.next() ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.getDeclarationValue( "$s2" ) + ":" + act.isQueued() ); list = new ArrayList(); for ( AgendaItem act = (AgendaItem) it.next(); act != null; act = (AgendaItem) it.next() ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.getDeclarationValue( "$s2" ) + ":" + act.isQueued() );
List list = new ArrayList(); for ( AgendaItem act = (AgendaItem) it.next(); act != null; act = (AgendaItem) it.next() ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s" ) + ":" + act.isQueued() ); list = new ArrayList(); for ( AgendaItem act = (AgendaItem) it.next(); act != null; act = (AgendaItem) it.next() ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s" ) + ":" + act.isQueued() );
List list = new ArrayList(); for ( AgendaItem act = (AgendaItem) it.next(); act != null; act = (AgendaItem) it.next() ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s" ) + ":" + act.isQueued() ); list = new ArrayList(); for ( AgendaItem act = (AgendaItem) it.next(); act != null; act = (AgendaItem) it.next() ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s" ) + ":" + act.isQueued() );
list = new ArrayList(); for ( AgendaItem act = (AgendaItem) it.next(); act != null; act = (AgendaItem) it.next() ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.isQueued() );
list = new ArrayList(); for ( AgendaItem act = (AgendaItem) it.next(); act != null; act = (AgendaItem) it.next() ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s1" ) + ":" + act.isQueued() );
list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s" ) + ":" + act.isQueued() ); list = new ArrayList(); for ( AgendaItem act = (AgendaItem) it.next(); act != null; act = (AgendaItem) it.next() ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s" ) + ":" + act.isQueued() );
List list = new ArrayList(); for ( AgendaItem act = (AgendaItem) it.next(); act != null; act = (AgendaItem) it.next() ) { list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s" ) + ":" + act.isQueued() ); list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s" ) + ":" + act.isQueued() );
list.add( act.getRule().getName() + ":" + act.getDeclarationValue( "$s" ) + ":" + act.isQueued() );