use of org.jbpm.ruleflow.instance.RuleFlowProcessInstance in project jbpm by kiegroup.
the class ListTimersCommand method execute.
public List<TimerInstance> execute(Context context) {
List<TimerInstance> timers = new ArrayList<TimerInstance>();
KieSession kieSession = ((RegistryContext) context).lookup(KieSession.class);
TimerManager tm = getTimerManager(kieSession);
RuleFlowProcessInstance wfp = (RuleFlowProcessInstance) kieSession.getProcessInstance(processInstanceId, true);
if (wfp == null) {
throw new ProcessInstanceNotFoundException("No process instance can be found for id " + processInstanceId);
}
processNodeInstance(tm, wfp, timers);
return timers;
}
use of org.jbpm.ruleflow.instance.RuleFlowProcessInstance in project jbpm by kiegroup.
the class RetriggerNodeInstanceCommand method execute.
public Void execute(Context context) {
KieSession kieSession = ((RegistryContext) context).lookup(KieSession.class);
logger.debug("About to retrigger node instance with id {} on process instance {}", nodeInstanceId, processInstanceId);
RuleFlowProcessInstance wfp = (RuleFlowProcessInstance) kieSession.getProcessInstance(processInstanceId, false);
if (wfp == null) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " not found");
}
NodeInstance nodeInstance = wfp.getNodeInstances(true).stream().filter(ni -> ni.getId() == nodeInstanceId).findFirst().orElse(null);
if (nodeInstance == null) {
throw new NodeInstanceNotFoundException("Node instance with id " + nodeInstanceId + " not found");
}
logger.debug("Found node instance {} to be retriggered", nodeInstance);
((NodeInstanceImpl) nodeInstance).retrigger(true);
logger.debug("Node instance {} retriggered successfully", nodeInstance);
return null;
}
use of org.jbpm.ruleflow.instance.RuleFlowProcessInstance in project jbpm by kiegroup.
the class TriggerNodeCommand method execute.
public Void execute(Context context) {
KieSession kieSession = ((RegistryContext) context).lookup(KieSession.class);
logger.debug("About to trigger (create) node instance for node {} in process instance {}", nodeId, processInstanceId);
RuleFlowProcessInstance wfp = (RuleFlowProcessInstance) kieSession.getProcessInstance(processInstanceId, false);
if (wfp == null) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " not found");
}
Node node = wfp.getRuleFlowProcess().getNodesRecursively().stream().filter(ni -> ni.getId() == nodeId).findFirst().orElse(null);
if (node == null) {
throw new NodeNotFoundException("Node instance with id " + nodeId + " not found");
}
logger.debug("Triggering node {} on process instance {}", node, wfp);
wfp.getNodeInstance(node).trigger(null, org.jbpm.workflow.core.Node.CONNECTION_DEFAULT_TYPE);
logger.debug("Node {} successfully triggered", node);
return null;
}
Aggregations