Search in sources :

Example 6 with ProcessInstanceNotFoundException

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

the class ProcessServiceImpl method abortWorkItem.

@Override
public void abortWorkItem(String deploymentId, Long processInstanceId, Long id) {
    DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
    if (deployedUnit == null) {
        throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
    }
    RuntimeManager manager = deployedUnit.getRuntimeManager();
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
    try {
        KieSession ksession = engine.getKieSession();
        WorkItem workItem = ((WorkItemManager) ksession.getWorkItemManager()).getWorkItem(id);
        if (workItem == null) {
            throw new WorkItemNotFoundException("Work item with id " + id + " was not found");
        }
        ksession.getWorkItemManager().abortWorkItem(id);
    } catch (SessionNotFoundException e) {
        throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found", e);
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) WorkItemNotFoundException(org.jbpm.services.api.WorkItemNotFoundException) KieSession(org.kie.api.runtime.KieSession) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) WorkItem(org.kie.api.runtime.process.WorkItem) WorkItemManager(org.drools.core.process.instance.WorkItemManager) SessionNotFoundException(org.kie.internal.runtime.manager.SessionNotFoundException)

Example 7 with ProcessInstanceNotFoundException

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

the class ProcessServiceImpl method getProcessInstance.

@Override
public ProcessInstance getProcessInstance(String deploymentId, Long processInstanceId) {
    DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
    if (deployedUnit == null) {
        throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
    }
    RuntimeManager manager = deployedUnit.getRuntimeManager();
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
    try {
        KieSession ksession = engine.getKieSession();
        return ksession.getProcessInstance(processInstanceId);
    } catch (SessionNotFoundException e) {
        throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found", e);
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) KieSession(org.kie.api.runtime.KieSession) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) SessionNotFoundException(org.kie.internal.runtime.manager.SessionNotFoundException)

Example 8 with ProcessInstanceNotFoundException

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

the class ProcessServiceImpl method getWorkItem.

@Override
public WorkItem getWorkItem(String deploymentId, Long processInstanceId, Long id) {
    DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
    if (deployedUnit == null) {
        throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
    }
    RuntimeManager manager = deployedUnit.getRuntimeManager();
    RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
    try {
        KieSession ksession = engine.getKieSession();
        WorkItem workItem = ((WorkItemManager) ksession.getWorkItemManager()).getWorkItem(id);
        if (workItem == null) {
            throw new WorkItemNotFoundException("Work item with id " + id + " was not found");
        }
        return workItem;
    } catch (SessionNotFoundException e) {
        throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found", e);
    } finally {
        disposeRuntimeEngine(manager, engine);
    }
}
Also used : DeploymentNotFoundException(org.jbpm.services.api.DeploymentNotFoundException) RuntimeEngine(org.kie.api.runtime.manager.RuntimeEngine) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) RuntimeManager(org.kie.api.runtime.manager.RuntimeManager) InternalRuntimeManager(org.kie.internal.runtime.manager.InternalRuntimeManager) WorkItemNotFoundException(org.jbpm.services.api.WorkItemNotFoundException) KieSession(org.kie.api.runtime.KieSession) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) WorkItem(org.kie.api.runtime.process.WorkItem) WorkItemManager(org.drools.core.process.instance.WorkItemManager) SessionNotFoundException(org.kie.internal.runtime.manager.SessionNotFoundException)

Example 9 with ProcessInstanceNotFoundException

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

the class ProcessInstanceAdminServiceImpl method updateTimerRelative.

@Override
public void updateTimerRelative(long processInstanceId, long timerId, long delay, long period, int repeatLimit) 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 RelativeUpdateTimerCommand(processInstanceId, timerId, delay, period, repeatLimit));
}
Also used : ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException) RelativeUpdateTimerCommand(org.jbpm.process.instance.command.RelativeUpdateTimerCommand)

Example 10 with ProcessInstanceNotFoundException

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

the class ProcessInstanceAdminServiceImpl method cancelNodeInstance.

@Override
public void cancelNodeInstance(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 CancelNodeInstanceCommand(processInstanceId, nodeInstanceId));
}
Also used : CancelNodeInstanceCommand(org.jbpm.kie.services.impl.admin.commands.CancelNodeInstanceCommand) ProcessInstanceDesc(org.jbpm.services.api.model.ProcessInstanceDesc) ProcessInstanceNotFoundException(org.jbpm.services.api.ProcessInstanceNotFoundException)

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