Search in sources :

Example 1 with Calendars

use of org.kie.api.runtime.Calendars in project drools by kiegroup.

the class PhreakTimerNode method doLeftUpdates.

public void doLeftUpdates(TimerNode timerNode, TimerNodeMemory tm, PathMemory pmem, SegmentMemory smem, LeftTupleSink sink, InternalAgenda agenda, TupleSets<LeftTuple> srcLeftTuples, TupleSets<LeftTuple> trgLeftTuples, TupleSets<LeftTuple> stagedLeftTuples) {
    Timer timer = timerNode.getTimer();
    // Variables may have changed for ExpressionIntervalTimer, so it must be rescheduled
    TimerService timerService = agenda.getWorkingMemory().getTimerService();
    long timestamp = timerService.getCurrentTime();
    String[] calendarNames = timerNode.getCalendarNames();
    Calendars calendars = agenda.getWorkingMemory().getCalendars();
    for (LeftTuple leftTuple = srcLeftTuples.getUpdateFirst(); leftTuple != null; ) {
        LeftTuple next = leftTuple.getStagedNext();
        DefaultJobHandle jobHandle = (DefaultJobHandle) leftTuple.getContextObject();
        if (jobHandle != null) {
            // jobHandle can be null, if the time fired straight away, and never ended up scheduling a job
            timerService.removeJob(jobHandle);
        }
        scheduleLeftTuple(timerNode, tm, pmem, smem, sink, agenda, timer, timerService, timestamp, calendarNames, calendars, leftTuple, trgLeftTuples, stagedLeftTuples);
        leftTuple.clearStaged();
        leftTuple = next;
    }
}
Also used : TimerNodeTimer(org.drools.core.marshalling.impl.ProtobufMessages.Timers.TimerNodeTimer) Timer(org.drools.core.time.impl.Timer) Calendars(org.kie.api.runtime.Calendars) LeftTuple(org.drools.core.reteoo.LeftTuple) TimerService(org.drools.core.time.TimerService) DefaultJobHandle(org.drools.core.time.impl.DefaultJobHandle)

Example 2 with Calendars

use of org.kie.api.runtime.Calendars in project drools by kiegroup.

the class PhreakTimerNode method doLeftInserts.

public void doLeftInserts(TimerNode timerNode, TimerNodeMemory tm, PathMemory pmem, SegmentMemory smem, LeftTupleSink sink, InternalAgenda agenda, TupleSets<LeftTuple> srcLeftTuples, TupleSets<LeftTuple> trgLeftTuples) {
    Timer timer = timerNode.getTimer();
    TimerService timerService = agenda.getWorkingMemory().getTimerService();
    long timestamp = timerService.getCurrentTime();
    String[] calendarNames = timerNode.getCalendarNames();
    Calendars calendars = agenda.getWorkingMemory().getCalendars();
    for (LeftTuple leftTuple = srcLeftTuples.getInsertFirst(); leftTuple != null; ) {
        LeftTuple next = leftTuple.getStagedNext();
        scheduleLeftTuple(timerNode, tm, pmem, smem, sink, agenda, timer, timerService, timestamp, calendarNames, calendars, leftTuple, trgLeftTuples, null);
        leftTuple.clearStaged();
        leftTuple = next;
    }
}
Also used : TimerNodeTimer(org.drools.core.marshalling.impl.ProtobufMessages.Timers.TimerNodeTimer) Timer(org.drools.core.time.impl.Timer) Calendars(org.kie.api.runtime.Calendars) LeftTuple(org.drools.core.reteoo.LeftTuple) TimerService(org.drools.core.time.TimerService)

Example 3 with Calendars

use of org.kie.api.runtime.Calendars in project drools by kiegroup.

the class CompositeMaxDurationTimer method createTrigger.

public Trigger createTrigger(Activation item, InternalWorkingMemory wm) {
    long timestamp = wm.getTimerService().getCurrentTime();
    String[] calendarNames = item.getRule().getCalendars();
    Calendars calendars = wm.getCalendars();
    return createTrigger(getMaxTimestamp(item.getTuple(), timestamp), calendarNames, calendars);
}
Also used : Calendars(org.kie.api.runtime.Calendars)

Example 4 with Calendars

use of org.kie.api.runtime.Calendars in project drools by kiegroup.

the class DurationTimer method createTrigger.

public Trigger createTrigger(Activation item, InternalWorkingMemory wm) {
    long timestamp;
    if (eventFactHandle != null) {
        Tuple leftTuple = item.getTuple();
        EventFactHandle fh = (EventFactHandle) leftTuple.get(eventFactHandle);
        timestamp = fh.getStartTimestamp();
    } else {
        timestamp = wm.getTimerService().getCurrentTime();
    }
    String[] calendarNames = item.getRule().getCalendars();
    Calendars calendars = wm.getCalendars();
    return createTrigger(timestamp, calendarNames, calendars);
}
Also used : Calendars(org.kie.api.runtime.Calendars) EventFactHandle(org.drools.core.common.EventFactHandle) Tuple(org.drools.core.spi.Tuple)

Aggregations

Calendars (org.kie.api.runtime.Calendars)4 TimerNodeTimer (org.drools.core.marshalling.impl.ProtobufMessages.Timers.TimerNodeTimer)2 LeftTuple (org.drools.core.reteoo.LeftTuple)2 TimerService (org.drools.core.time.TimerService)2 Timer (org.drools.core.time.impl.Timer)2 EventFactHandle (org.drools.core.common.EventFactHandle)1 Tuple (org.drools.core.spi.Tuple)1 DefaultJobHandle (org.drools.core.time.impl.DefaultJobHandle)1