use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.
the class ProcessServiceImplTest method testStartAndGetProcessInExternalTransactions.
protected void testStartAndGetProcessInExternalTransactions(RuntimeStrategy strategy) throws Exception {
assertNotNull(deploymentService);
KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
DeploymentDescriptor customDescriptor = new DeploymentDescriptorImpl("org.jbpm.domain");
customDescriptor.getBuilder().runtimeStrategy(strategy);
deploymentUnit.setDeploymentDescriptor(customDescriptor);
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
assertNotNull(processService);
boolean isDeployed = deploymentService.isDeployed(deploymentUnit.getIdentifier());
assertTrue(isDeployed);
UserTransaction ut = InitialContext.doLookup("java:comp/UserTransaction");
ut.begin();
long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(processInstanceId);
assertNotNull(pi);
processService.abortProcessInstance(processInstanceId);
ut.commit();
try {
processService.getProcessInstance(processInstanceId);
} catch (ProcessInstanceNotFoundException e) {
// expected
}
}
use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.
the class UserTaskAdminServiceImplTest method cleanup.
@After
public void cleanup() {
cleanupSingletonSessionId();
if (processInstanceId != null) {
try {
// let's abort process instance to leave the system in clear state
processService.abortProcessInstance(processInstanceId);
ProcessInstance pi = processService.getProcessInstance(processInstanceId);
Assertions.assertThat(pi).isNull();
} catch (ProcessInstanceNotFoundException e) {
// ignore it as it might already be completed/aborted
}
}
if (units != null && !units.isEmpty()) {
for (DeploymentUnit unit : units) {
try {
deploymentService.undeploy(unit);
} catch (Exception e) {
// do nothing in case of some failed tests to avoid next test to fail as well
}
}
units.clear();
}
close();
CountDownListenerFactory.clear();
}
use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.
the class ProcessServiceImpl method setProcessVariable.
@Override
public void setProcessVariable(Long processInstanceId, String variableId, Object value) {
ProcessInstanceDesc piDesc = dataService.getProcessInstanceById(processInstanceId);
if (piDesc == null || piDesc.getState() != ProcessInstance.STATE_ACTIVE) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found");
}
setProcessVariable(piDesc.getDeploymentId(), processInstanceId, variableId, value);
}
use of org.jbpm.services.api.ProcessInstanceNotFoundException in project jbpm by kiegroup.
the class ProcessServiceImpl method getWorkItemByProcessInstance.
@Override
public List<WorkItem> getWorkItemByProcessInstance(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();
List<WorkItem> workItems = new ArrayList<>();
Collection<NodeInstanceDesc> nodes = dataService.getProcessInstanceHistoryActive(processInstanceId, null);
for (NodeInstanceDesc node : nodes) {
if (node.getWorkItemId() != null) {
workItems.add(((WorkItemManager) ksession.getWorkItemManager()).getWorkItem(node.getWorkItemId()));
}
}
return workItems;
} 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.ProcessInstanceNotFoundException in project jbpm by kiegroup.
the class ProcessServiceImpl method signalProcessInstance.
@Override
public void signalProcessInstance(String deploymentId, Long processInstanceId, String signalName, Object event) {
DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentId);
if (deployedUnit == null) {
throw new DeploymentNotFoundException("No deployments available for " + deploymentId);
}
RuntimeManager manager = deployedUnit.getRuntimeManager();
event = process(event, ((InternalRuntimeManager) manager).getEnvironment().getClassLoader());
RuntimeEngine engine = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId));
try {
KieSession ksession = engine.getKieSession();
ksession.signalEvent(signalName, event, processInstanceId);
} catch (SessionNotFoundException e) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " was not found", e);
} finally {
disposeRuntimeEngine(manager, engine);
}
}
Aggregations