use of org.jbpm.services.api.admin.ProcessNode in project jbpm by kiegroup.
the class ProcessInstanceAdminServiceImpl method getProcessNodes.
@Override
public Collection<ProcessNode> getProcessNodes(long processInstanceId) throws ProcessInstanceNotFoundException {
ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
if (pi == null) {
throw new ProcessInstanceNotFoundException("Process instance with id " + processInstanceId + " not found");
}
Collection<ProcessNode> nodes = processService.execute(pi.getDeploymentId(), ProcessInstanceIdContext.get(processInstanceId), new ListNodesCommand(processInstanceId));
return nodes;
}
use of org.jbpm.services.api.admin.ProcessNode in project jbpm by kiegroup.
the class ListNodesCommand method execute.
public List<ProcessNode> execute(Context context) {
List<ProcessNode> nodes = null;
KieSession kieSession = ((RegistryContext) context).lookup(KieSession.class);
RuleFlowProcessInstance wfp = (RuleFlowProcessInstance) kieSession.getProcessInstance(processInstanceId, true);
if (wfp == null) {
throw new ProcessInstanceNotFoundException("No process instance can be found for id " + processInstanceId);
}
String processId = wfp.getProcessId();
nodes = wfp.getRuleFlowProcess().getNodesRecursively().stream().map(n -> new ProcessNodeImpl(n.getName(), n.getId(), n.getClass().getSimpleName(), processId)).collect(Collectors.toList());
return nodes;
}
use of org.jbpm.services.api.admin.ProcessNode in project jbpm by kiegroup.
the class ProcessInstanceAdminServiceImplTest method testTrigerLastActionNode.
@Test
public void testTrigerLastActionNode() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
Collection<NodeInstanceDesc> activeNodes = processAdminService.getActiveNodeInstances(processInstanceId);
assertNotNull(activeNodes);
assertEquals(1, activeNodes.size());
NodeInstanceDesc active = activeNodes.iterator().next();
assertEquals("Write a Document", active.getName());
List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
assertEquals(1, tasks.size());
Collection<ProcessNode> processNodes = processAdminService.getProcessNodes(processInstanceId);
ProcessNode writeDocNode = processNodes.stream().filter(pn -> pn.getNodeName().equals("Report")).findFirst().orElse(null);
processAdminService.triggerNode(processInstanceId, writeDocNode.getNodeId());
activeNodes = processAdminService.getActiveNodeInstances(processInstanceId);
assertNotNull(activeNodes);
assertEquals(0, activeNodes.size());
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
assertEquals(0, tasks.size());
ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
assertEquals(ProcessInstance.STATE_COMPLETED, pi.getState().intValue());
processInstanceId = null;
}
use of org.jbpm.services.api.admin.ProcessNode in project jbpm by kiegroup.
the class ProcessInstanceAdminServiceImplTest method testCancelAndTriger.
@Test
public void testCancelAndTriger() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
Collection<NodeInstanceDesc> activeNodes = processAdminService.getActiveNodeInstances(processInstanceId);
assertNotNull(activeNodes);
assertEquals(1, activeNodes.size());
NodeInstanceDesc active = activeNodes.iterator().next();
assertEquals("Write a Document", active.getName());
List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
assertEquals(1, tasks.size());
processAdminService.cancelNodeInstance(processInstanceId, active.getId());
activeNodes = processAdminService.getActiveNodeInstances(processInstanceId);
assertNotNull(activeNodes);
assertEquals(0, activeNodes.size());
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
assertEquals(0, tasks.size());
Collection<ProcessNode> processNodes = processAdminService.getProcessNodes(processInstanceId);
ProcessNode writeDocNode = processNodes.stream().filter(pn -> pn.getNodeName().equals(active.getName())).findFirst().orElse(null);
processAdminService.triggerNode(processInstanceId, writeDocNode.getNodeId());
activeNodes = processAdminService.getActiveNodeInstances(processInstanceId);
assertNotNull(activeNodes);
assertEquals(1, activeNodes.size());
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
assertEquals(1, tasks.size());
}
use of org.jbpm.services.api.admin.ProcessNode in project jbpm by kiegroup.
the class ProcessInstanceAdminServiceImplTest method testCancelAndTrigerAnotherNode.
@Test
public void testCancelAndTrigerAnotherNode() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
Collection<NodeInstanceDesc> activeNodes = processAdminService.getActiveNodeInstances(processInstanceId);
assertNotNull(activeNodes);
assertEquals(1, activeNodes.size());
NodeInstanceDesc active = activeNodes.iterator().next();
assertEquals("Write a Document", active.getName());
List<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
assertEquals(1, tasks.size());
processAdminService.cancelNodeInstance(processInstanceId, active.getId());
activeNodes = processAdminService.getActiveNodeInstances(processInstanceId);
assertNotNull(activeNodes);
assertEquals(0, activeNodes.size());
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
assertEquals(0, tasks.size());
Collection<ProcessNode> processNodes = processAdminService.getProcessNodes(processInstanceId);
ProcessNode writeDocNode = processNodes.stream().filter(pn -> pn.getNodeName().equals("Report")).findFirst().orElse(null);
processAdminService.triggerNode(processInstanceId, writeDocNode.getNodeId());
activeNodes = processAdminService.getActiveNodeInstances(processInstanceId);
assertNotNull(activeNodes);
assertEquals(0, activeNodes.size());
tasks = runtimeDataService.getTasksAssignedAsPotentialOwner("salaboy", new QueryFilter());
assertEquals(0, tasks.size());
ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId);
assertEquals(ProcessInstance.STATE_COMPLETED, pi.getState().intValue());
processInstanceId = null;
}
Aggregations