Search in sources :

Example 1 with BaseTimer

use of org.drools.core.time.impl.BaseTimer in project drools by kiegroup.

the class TimerBuilder method build.

public void build(final BuildContext context, final BuildUtils utils, final RuleConditionElement rce) {
    final Timer timer = (Timer) rce;
    context.pushRuleComponent(timer);
    Declaration[][] declrs = timer instanceof BaseTimer ? ((BaseTimer) timer).getTimerDeclarations(context.getSubRule().getOuterDeclarations()) : null;
    context.setTupleSource(utils.attachNode(context, context.getComponentFactory().getNodeFactoryService().buildTimerNode(context.getNextId(), timer, context.getRule().getCalendars(), declrs, context.getTupleSource(), context)));
    context.setAlphaConstraints(null);
    context.setBetaconstraints(null);
    context.popRuleComponent();
}
Also used : BaseTimer(org.drools.core.time.impl.BaseTimer) Timer(org.drools.core.time.impl.Timer) BaseTimer(org.drools.core.time.impl.BaseTimer)

Example 2 with BaseTimer

use of org.drools.core.time.impl.BaseTimer in project drools by kiegroup.

the class RuleTerminalNode method setDeclarations.

public void setDeclarations(Map<String, Declaration> decls) {
    if (rule.getSalience() instanceof MVELSalienceExpression) {
        MVELSalienceExpression expr = (MVELSalienceExpression) rule.getSalience();
        Declaration[] declrs = expr.getMVELCompilationUnit().getPreviousDeclarations();
        this.salienceDeclarations = new Declaration[declrs.length];
        int i = 0;
        for (Declaration declr : declrs) {
            this.salienceDeclarations[i++] = decls.get(declr.getIdentifier());
        }
        Arrays.sort(this.salienceDeclarations, SortDeclarations.instance);
    }
    if (rule.getEnabled() instanceof MVELEnabledExpression) {
        MVELEnabledExpression expr = (MVELEnabledExpression) rule.getEnabled();
        Declaration[] declrs = expr.getMVELCompilationUnit().getPreviousDeclarations();
        this.enabledDeclarations = new Declaration[declrs.length];
        int i = 0;
        for (Declaration declr : declrs) {
            this.enabledDeclarations[i++] = decls.get(declr.getIdentifier());
        }
        Arrays.sort(this.enabledDeclarations, SortDeclarations.instance);
    }
    if (rule.getTimer() instanceof BaseTimer) {
        this.timerDeclarations = ((BaseTimer) rule.getTimer()).getTimerDeclarations(decls);
    }
}
Also used : MVELEnabledExpression(org.drools.core.base.mvel.MVELEnabledExpression) MVELSalienceExpression(org.drools.core.base.mvel.MVELSalienceExpression) BaseTimer(org.drools.core.time.impl.BaseTimer) Declaration(org.drools.core.rule.Declaration)

Aggregations

BaseTimer (org.drools.core.time.impl.BaseTimer)2 MVELEnabledExpression (org.drools.core.base.mvel.MVELEnabledExpression)1 MVELSalienceExpression (org.drools.core.base.mvel.MVELSalienceExpression)1 Declaration (org.drools.core.rule.Declaration)1 Timer (org.drools.core.time.impl.Timer)1