Search in sources :

Example 1 with WorkItemNotFoundException

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

the class ProcessServiceImpl method completeWorkItem.

@Override
public void completeWorkItem(Long id, Map<String, Object> results) {
    NodeInstanceDesc nodeDesc = dataService.getNodeInstanceForWorkItem(id);
    if (nodeDesc == null) {
        throw new WorkItemNotFoundException("Work item with id " + id + " was not found");
    }
    completeWorkItem(nodeDesc.getDeploymentId(), nodeDesc.getProcessInstanceId(), id, results);
}
Also used : WorkItemNotFoundException(org.jbpm.services.api.WorkItemNotFoundException) NodeInstanceDesc(org.jbpm.services.api.model.NodeInstanceDesc)

Example 2 with WorkItemNotFoundException

use of org.jbpm.services.api.WorkItemNotFoundException 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 3 with WorkItemNotFoundException

use of org.jbpm.services.api.WorkItemNotFoundException 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 4 with WorkItemNotFoundException

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

the class ProcessServiceImpl method abortWorkItem.

@Override
public void abortWorkItem(Long id) {
    NodeInstanceDesc nodeDesc = dataService.getNodeInstanceForWorkItem(id);
    if (nodeDesc == null) {
        throw new WorkItemNotFoundException("Work item with id " + id + " was not found");
    }
    abortWorkItem(nodeDesc.getDeploymentId(), nodeDesc.getProcessInstanceId(), id);
}
Also used : WorkItemNotFoundException(org.jbpm.services.api.WorkItemNotFoundException) NodeInstanceDesc(org.jbpm.services.api.model.NodeInstanceDesc)

Example 5 with WorkItemNotFoundException

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

the class ProcessServiceImpl method completeWorkItem.

@Override
public void completeWorkItem(String deploymentId, Long processInstanceId, Long id, Map<String, Object> results) {
    DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
    if (deployedUnit == null) {
        throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
    }
    RuntimeManager manager = deployedUnit.getRuntimeManager();
    results = process(results, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
    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().completeWorkItem(id, results);
    } 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)

Aggregations

WorkItemNotFoundException (org.jbpm.services.api.WorkItemNotFoundException)5 WorkItemManager (org.drools.core.process.instance.WorkItemManager)3 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)3 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)3 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)3 KieSession (org.kie.api.runtime.KieSession)3 RuntimeEngine (org.kie.api.runtime.manager.RuntimeEngine)3 RuntimeManager (org.kie.api.runtime.manager.RuntimeManager)3 WorkItem (org.kie.api.runtime.process.WorkItem)3 InternalRuntimeManager (org.kie.internal.runtime.manager.InternalRuntimeManager)3 SessionNotFoundException (org.kie.internal.runtime.manager.SessionNotFoundException)3 NodeInstanceDesc (org.jbpm.services.api.model.NodeInstanceDesc)2