Search in sources :

Example 1 with TimerInstanceImpl

use of org.jbpm.kie.services.impl.admin.TimerInstanceImpl in project jbpm by kiegroup.

the class ListTimersCommand method buildTimer.

private TimerInstanceImpl buildTimer(org.jbpm.process.instance.timer.TimerInstance timerInstance) {
    TimerInstanceImpl timer = new TimerInstanceImpl();
    if (timerInstance != null) {
        timer.setActivationTime(timerInstance.getActivated());
        timer.setLastFireTime(timerInstance.getLastTriggered());
        timer.setNextFireTime(new Date(timerInstance.getActivated().getTime() + timerInstance.getDelay()));
        timer.setDelay(timerInstance.getDelay());
        timer.setPeriod(timerInstance.getPeriod());
        timer.setRepeatLimit(timerInstance.getRepeatLimit());
        timer.setTimerId(timerInstance.getId());
        timer.setProcessInstanceId(timerInstance.getProcessInstanceId());
        timer.setSessionId(timerInstance.getSessionId());
    }
    return timer;
}
Also used : TimerInstanceImpl(org.jbpm.kie.services.impl.admin.TimerInstanceImpl) Date(java.util.Date)

Example 2 with TimerInstanceImpl

use of org.jbpm.kie.services.impl.admin.TimerInstanceImpl in project jbpm by kiegroup.

the class ListTimersCommand method processNodeInstance.

protected void processNodeInstance(TimerManager tm, NodeInstanceContainer container, List<TimerInstance> timers) {
    for (NodeInstance nodeInstance : container.getNodeInstances()) {
        if (nodeInstance instanceof TimerNodeInstance) {
            TimerNodeInstance tni = (TimerNodeInstance) nodeInstance;
            org.jbpm.process.instance.timer.TimerInstance timer = tm.getTimerMap().get(tni.getTimerId());
            TimerInstanceImpl details = buildTimer(timer);
            details.setTimerName(resolveVariable(tni.getNodeName(), tni));
            timers.add(details);
        } else if (nodeInstance instanceof StateBasedNodeInstance) {
            StateBasedNodeInstance sbni = (StateBasedNodeInstance) nodeInstance;
            List<Long> timerList = sbni.getTimerInstances();
            if (timerList != null) {
                for (Long timerId : timerList) {
                    org.jbpm.process.instance.timer.TimerInstance timer = tm.getTimerMap().get(timerId);
                    TimerInstanceImpl details = buildTimer(timer);
                    details.setTimerName(resolveVariable(sbni.getNodeName(), sbni));
                    timers.add(details);
                }
            }
        }
        if (nodeInstance instanceof NodeInstanceContainer) {
            processNodeInstance(tm, (NodeInstanceContainer) nodeInstance, timers);
        }
    }
}
Also used : StateBasedNodeInstance(org.jbpm.workflow.instance.node.StateBasedNodeInstance) NodeInstanceContainer(org.jbpm.workflow.instance.NodeInstanceContainer) TimerInstance(org.jbpm.services.api.admin.TimerInstance) ArrayList(java.util.ArrayList) List(java.util.List) StateBasedNodeInstance(org.jbpm.workflow.instance.node.StateBasedNodeInstance) NodeInstance(org.kie.api.runtime.process.NodeInstance) TimerNodeInstance(org.jbpm.workflow.instance.node.TimerNodeInstance) TimerNodeInstance(org.jbpm.workflow.instance.node.TimerNodeInstance) TimerInstanceImpl(org.jbpm.kie.services.impl.admin.TimerInstanceImpl)

Aggregations

TimerInstanceImpl (org.jbpm.kie.services.impl.admin.TimerInstanceImpl)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 List (java.util.List)1 TimerInstance (org.jbpm.services.api.admin.TimerInstance)1 NodeInstanceContainer (org.jbpm.workflow.instance.NodeInstanceContainer)1 StateBasedNodeInstance (org.jbpm.workflow.instance.node.StateBasedNodeInstance)1 TimerNodeInstance (org.jbpm.workflow.instance.node.TimerNodeInstance)1 NodeInstance (org.kie.api.runtime.process.NodeInstance)1