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);
}
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);
}
}
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);
}
}
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);
}
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);
}
}
Aggregations