use of org.drools.core.common.UpdateContext in project drools by kiegroup.
the class ConditionalBranchBuilder method buildConditionalBranchEvaluator.
private ConditionalBranchEvaluator buildConditionalBranchEvaluator(BuildContext context, ConditionalBranch conditionalBranch) {
RuleTerminalNode terminalNode = buildTerminalNodeForNamedConsequence(context, conditionalBranch.getNamedConsequence());
terminalNode.networkUpdated(new UpdateContext());
// adds the terminal node to the list of nodes created/added by this sub-rule
context.getNodes().add(terminalNode);
return new ConditionalBranchEvaluator(conditionalBranch.getEvalCondition(), context.getTupleSource().getPartitionId(), terminalNode, conditionalBranch.getNamedConsequence().isBreaking(), conditionalBranch.getElseBranch() != null ? buildConditionalBranchEvaluator(context, conditionalBranch.getElseBranch()) : null);
}
use of org.drools.core.common.UpdateContext in project drools by kiegroup.
the class NamedConsequenceBuilder method build.
public void build(BuildContext context, BuildUtils utils, RuleConditionElement rce) {
NamedConsequence namedConsequence = (NamedConsequence) rce;
Timer timer = context.getRule().getTimer();
if (timer != null) {
ReteooComponentBuilder builder = utils.getBuilderFor(Timer.class);
builder.build(context, utils, context.getRule().getTimer());
}
RuleTerminalNode terminalNode = buildTerminalNodeForNamedConsequence(context, namedConsequence);
terminalNode.attach(context);
terminalNode.networkUpdated(new UpdateContext());
// adds the terminal node to the list of nodes created/added by this sub-rule
context.getNodes().add(terminalNode);
if (timer != null) {
context.setTupleSource(context.getTupleSource().getLeftTupleSource());
}
context.setTerminated(namedConsequence.isTerminal());
}
use of org.drools.core.common.UpdateContext in project drools by kiegroup.
the class ReteooRuleBuilder method addSubRule.
private TerminalNode addSubRule(final BuildContext context, final GroupElement subrule, final int subruleIndex, final RuleImpl rule) throws InvalidPatternException {
context.setSubRule(subrule);
// gets the appropriate builder
ReteooComponentBuilder builder = this.utils.getBuilderFor(subrule);
// checks if an initial-fact is needed
if (builder.requiresLeftActivation(this.utils, subrule)) {
this.addInitialFactPattern(subrule);
}
// builds and attach
builder.build(context, this.utils, subrule);
if (context.isTerminated()) {
context.setTerminated(false);
return ((TerminalNode) context.getLastNode());
}
if (rule.getTimer() != null) {
builder = this.utils.getBuilderFor(Timer.class);
builder.build(context, this.utils, rule.getTimer());
}
ActivationListenerFactory factory = context.getKnowledgeBase().getConfiguration().getActivationListenerFactory(rule.getActivationListener());
TerminalNode terminal = factory.createActivationListener(context.getNextId(), context.getTupleSource(), rule, subrule, subruleIndex, context);
BaseNode baseTerminalNode = (BaseNode) terminal;
baseTerminalNode.networkUpdated(new UpdateContext());
baseTerminalNode.attach(context);
setPathEndNodes(context);
AddRemoveRule.addRule(terminal, context.getWorkingMemories(), context.getKnowledgeBase());
// adds the terminal node to the list of nodes created/added by this sub-rule
context.getNodes().add(baseTerminalNode);
return terminal;
}
Aggregations