use of org.jbpm.services.api.DeploymentNotFoundException 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.DeploymentNotFoundException 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);
}
}
use of org.jbpm.services.api.DeploymentNotFoundException 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.DeploymentNotFoundException in project jbpm by kiegroup.
the class ProcessServiceImpl method getProcessInstance.
@Override
public ProcessInstance getProcessInstance(String deploymentId, CorrelationKey key) {
DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
if (deployedUnit == null) {
throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
}
RuntimeManager manager = deployedUnit.getRuntimeManager();
RuntimeEngine engine = manager.getRuntimeEngine(CorrelationKeyContext.get(key));
KieSession ksession = engine.getKieSession();
try {
return ((CorrelationAwareProcessRuntime) ksession).getProcessInstance(key);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
use of org.jbpm.services.api.DeploymentNotFoundException in project jbpm by kiegroup.
the class BPMN2DataServicesTest method testHumanTaskProcessBeforeAndAfterUndeploy.
@Test
public void testHumanTaskProcessBeforeAndAfterUndeploy() throws IOException {
assertNotNull(deploymentService);
DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
String processId = "org.jbpm.writedocument";
ProcessDefinition procDef = bpmn2Service.getProcessDefinition(deploymentUnit.getIdentifier(), processId);
assertNotNull(procDef);
assertEquals(procDef.getId(), "org.jbpm.writedocument");
assertEquals(procDef.getName(), "humanTaskSample");
assertEquals(procDef.getKnowledgeType(), "PROCESS");
assertEquals(procDef.getPackageName(), "defaultPackage");
assertEquals(procDef.getType(), "RuleFlow");
assertEquals(procDef.getVersion(), "3");
// now let's undeploy the unit
deploymentService.undeploy(deploymentUnit);
try {
bpmn2Service.getProcessDefinition(deploymentUnit.getIdentifier(), processId);
fail("DeploymentNotFoundException was not thrown");
} catch (DeploymentNotFoundException e) {
// expected
}
}
Aggregations