Search in sources :

Example 46 with ProcessInstanceNotFoundException

use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.

the class ProcessInstanceAdminServiceImpl method triggerNode.

@Override
public void triggerNode(long processInstanceId, long nodeId) throws NodeNotFoundException, ProcessInstanceNotFoundException {
    ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
    if (pi == null) {
        throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " not found");
    }
    processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(processInstanceId), new TriggerNodeCommand(processInstanceId, nodeId));
}
Also used : ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) TriggerNodeCommand(org.jbpm.kie.services.impl.admin.commands.TriggerNodeCommand)

Example 47 with ProcessInstanceNotFoundException

use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.

the class ProcessInstanceAdminServiceImpl method retriggerNodeInstance.

@Override
public void retriggerNodeInstance(long processInstanceId, long nodeInstanceId) throws NodeInstanceNotFoundException, ProcessInstanceNotFoundException {
    ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
    if (pi == null) {
        throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " not found");
    }
    processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(processInstanceId), new RetriggerNodeInstanceCommand(processInstanceId, nodeInstanceId));
}
Also used : RetriggerNodeInstanceCommand(org.jbpm.kie.services.impl.admin.commands.RetriggerNodeInstanceCommand) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException)

Example 48 with ProcessInstanceNotFoundException

use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.

the class ProcessInstanceAdminServiceImpl method getTimerInstances.

@Override
public Collection<TimerInstance> getTimerInstances(long processInstanceId) throws ProcessInstanceNotFoundException {
    ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
    if (pi == null) {
        throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " not found");
    }
    Collection<TimerInstance> timers = processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(processInstanceId), new ListTimersCommand(processInstanceId));
    return timers;
}
Also used : TimerInstance(org.jbpm.services.api.admin.TimerInstance) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) ListTimersCommand(org.jbpm.kie.services.impl.admin.commands.ListTimersCommand) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException)

Example 49 with ProcessInstanceNotFoundException

use of org.jbpm.services.api.ProcessInstanceNotFoundException 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;
}
Also used : RuleFlowProcessInstance(org.jbpm.ruleflow.instance.RuleFlowProcessInstance) TimerInstance(org.jbpm.services.api.admin.TimerInstance) ArrayList(java.util.ArrayList) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext) TimerManager(org.jbpm.process.instance.timer.TimerManager) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException)

Example 50 with ProcessInstanceNotFoundException

use of org.jbpm.services.api.ProcessInstanceNotFoundException 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;
}
Also used : NodeInstanceImpl(org.jbpm.workflow.instance.impl.NodeInstanceImpl) RuleFlowProcessInstance(org.jbpm.ruleflow.instance.RuleFlowProcessInstance) NodeInstanceNotFoundException(org.jbpm.services.api.NodeInstanceNotFoundException) KieSession(org.kie.api.runtime.KieSession) RegistryContext(org.drools.core.command.impl.RegistryContext) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) NodeInstance(org.kie.api.runtime.process.NodeInstance)

Aggregations

ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)56 KieSession (org.kie.api.runtime.KieSession)21 ProcessInstance (org.kie.api.runtime.process.ProcessInstance)21 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)16 ProcessInstanceDesc (org.jbpm.services.api.model.ProcessInstanceDesc)16 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)13 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)13 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)13 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)13 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)13 SessionNotFoundException (org.kie.internal.runtime.manager.SessionNotFoundException)13 DeploymentUnit (org.jbpm.services.api.model.DeploymentUnit)10 After (org.junit.After)10 RegistryContext (org.drools.core.command.impl.RegistryContext)8 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)7 RuleFlowProcessInstance (org.jbpm.ruleflow.instance.RuleFlowProcessInstance)7 Test (org.junit.Test)7 HashMap (java.util.HashMap)4 WorkItem (org.kie.api.runtime.process.WorkItem)4 ArrayList (java.util.ArrayList)3