@RequestMapping(value = "/show", method = RequestMethod.GET) public ProcessInstanceDesc getProcessInstance(@RequestParam String id) { long processInstanceId = Long.parseLong(id); ProcessInstanceDesc processInstance = runtimeDataService.getProcessInstanceById(processInstanceId); return processInstance; }
@RequestMapping(value = "/show", method = RequestMethod.GET) public ProcessDefinition getProcessDefinition(@RequestParam String deployment, @RequestParam String id) { ProcessDefinition definition = runtimeDataService.getProcessesByDeploymentIdProcessId(deployment, id); return definition; }
public NodeInstanceList getProcessInstanceHistory(long processInstanceId, Boolean active, Boolean completed, Integer page, Integer pageSize) { logger.debug("About to search for node instances with page {} and page size {}", page, pageSize); Collection<NodeInstanceDesc> result = null; if ((Boolean.TRUE.equals(active) && Boolean.TRUE.equals(completed)) || (active == null && completed == null)) { logger.debug("Searching for active and completed node instances for process instance with id {}", processInstanceId); result = runtimeDataService.getProcessInstanceFullHistory(processInstanceId, buildQueryContext(page, pageSize)); } else if (Boolean.TRUE.equals(active)) { logger.debug("Searching for active node instances for process instance with id {}", processInstanceId); result = runtimeDataService.getProcessInstanceHistoryActive(processInstanceId, buildQueryContext(page, pageSize)); } else if (Boolean.TRUE.equals(completed)) { logger.debug("Searching for completed node instances for process instance with id {}", processInstanceId); result = runtimeDataService.getProcessInstanceHistoryCompleted(processInstanceId, buildQueryContext(page, pageSize)); } NodeInstanceList nodeInstanceList = convertToNodeInstanceList(result); logger.debug("Returning result of node instances search: {}", nodeInstanceList); return nodeInstanceList; }
@Override public Collection<NodeInstanceSummary> getProcessInstanceCompletedNodes(long processInstanceId) { ProcessInstanceDesc piDesc = dataService.getProcessInstanceById(processInstanceId); // TODO make use of paging properly as it's currently limiting to 100 return NodeInstanceHelper.adaptCollection(dataService.getProcessInstanceHistoryCompleted( processInstanceId, new QueryContext(0, 100))); }
@Override public Collection<ProcessInstanceSummary> getProcessInstances(List<Integer> states, String filterText, String initiator) { Collection<ProcessInstanceDesc> result = null; // TODO make use of paging properly as it's currently limiting to 100 if (!filterText.equals("")) { // search by process name result = dataService.getProcessInstancesByProcessName(states, filterText, initiator, new QueryContext(0, 100)); } else { result = dataService.getProcessInstances(states, initiator, new QueryContext(0, 100)); } return ProcessInstanceHelper.adaptCollection(result); }
private void testProcessWithStrategy(RuntimeStrategy strategy) { KModuleDeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION); deploymentUnit.setStrategy(strategy); deploymentService.deploy(deploymentUnit); String userId = "john"; Long processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "hiring"); List<Long> taskIdList = runtimeDataService.getTasksByProcessInstanceId(processInstanceId); Assertions.assertThat(taskIdList).hasSize(1); long taskId = taskIdList.get(0); userTaskService.claim(taskId, userId); userTaskService.start(taskId, userId); userTaskService.complete(taskId, userId, null); List<Status> taskStatus = new ArrayList<Status>(); taskStatus.add(Status.Completed); taskStatus.add(Status.Created); taskStatus.add(Status.InProgress); taskStatus.add(Status.Reserved); List<TaskSummary> taskSummaryList = runtimeDataService.getTasksByStatusByProcessInstanceId(processInstanceId, taskStatus, null); Assertions.assertThat(taskSummaryList).hasSize(1); processService.abortProcessInstance(processInstanceId); ProcessInstanceDesc pi = runtimeDataService.getProcessInstanceById(processInstanceId); assertNotNull(pi); assertEquals(ProcessInstance.STATE_ABORTED, pi.getState().intValue()); }
public String getActiveProcessImage(String containerId, long procInstId) { ProcessInstanceDesc instance = dataService.getProcessInstanceById(procInstId); if (instance == null) { throw new ProcessInstanceNotFoundException("No instance found for process instance id " + procInstId); } String imageSVGString = null; // get SVG String byte[] imageSVG = getProcessImageAsBytes(instance.getDeploymentId(), instance.getProcessId()); if (imageSVG != null) { // find active nodes and modify image Map<String, String> subProcessLinks = new HashMap<>(); Collection<NodeInstanceDesc> activeLogs = dataService.getProcessInstanceHistoryActive(procInstId, new QueryContext(0, 1000)); Collection<NodeInstanceDesc> completedLogs = dataService.getProcessInstanceHistoryCompleted(procInstId, new QueryContext(0, 1000)); Map<Long, String> active = new HashMap<Long, String>(); List<String> completed = new ArrayList<String>(); for (NodeInstanceDesc activeNode : activeLogs) { active.put(activeNode.getId(), activeNode.getNodeId()); populateSubProcessLink(containerId, activeNode, subProcessLinks); } for (NodeInstanceDesc completeNode : completedLogs) { completed.add(completeNode.getNodeId()); active.remove(completeNode.getId()); populateSubProcessLink(containerId, completeNode, subProcessLinks); } ByteArrayInputStream svgStream = new ByteArrayInputStream(imageSVG); imageSVGString = SVGImageProcessor.transform(svgStream, completed, new ArrayList<String>(active.values()), subProcessLinks); return imageSVGString; } throw new IllegalArgumentException("No process found for " + instance.getProcessId() + " within container " + containerId); }
@Override public Collection<ProcessVariableSummary> getVariablesCurrentState(long processInstanceId, String processId) { ProcessInstanceDesc piDesc = dataService.getProcessInstanceById(processInstanceId); Map<String, String> properties = new HashMap<String, String>(bpmn2Service.getProcessVariables(piDesc.getDeploymentId(), processId)); return VariableHelper.adaptCollection(dataService.getVariablesCurrentState(processInstanceId), properties, processInstanceId); }
assertNotNull(processInstanceId); List<TaskSummary> taskSummaries = runtimeDataService.getTasksAssignedAsPotentialOwner("john", new QueryFilter(0, 10)); assertNotNull(taskSummaries); assertEquals(1, taskSummaries.size()); List<Long> tasks = runtimeDataService.getTasksByProcessInstanceId(processInstanceId); assertNotNull(tasks); assertEquals(1, tasks.size()); ProcessInstanceDesc desc = runtimeDataService.getProcessInstanceById(processInstanceId); assertNotNull(desc); assertEquals(2, (int)desc.getState());
public ProcessDefinitionList getProcessesByFilter(String filter, Integer page, Integer pageSize, String sort, boolean sortOrder) { Collection<ProcessDefinition> definitions; if (sort == null || sort.isEmpty()) { sort = "ProcessName"; } if (filter != null && !filter.isEmpty()) { logger.debug("About to search for process definitions with filter '{}' with page {} and page size {}", filter, page, pageSize); definitions = runtimeDataService.getProcessesByFilter(filter, buildQueryContext(page, pageSize, sort, sortOrder)); logger.debug("Found {} process definitions with filter '{}'", definitions.size(), filter); } else { logger.debug("About to search for process definitions with page {} and page size {}", page, pageSize); definitions = runtimeDataService.getProcesses(buildQueryContext(page, pageSize, sort, sortOrder)); logger.debug("Found {} process definitions", definitions.size(), filter); } ProcessDefinitionList processDefinitionList = convertToProcessList(definitions); logger.debug("Returning result of process definition search: {}", processDefinitionList); return processDefinitionList; }
Collection<NodeInstanceDesc> activeNodes = runtimeDataService.getProcessInstanceHistoryActive( processInstance.getId(), new QueryContext()); assertNotNull(activeNodes); assertEquals(1, activeNodes.size()); Collection<NodeInstanceDesc> completedNodes = runtimeDataService.getProcessInstanceHistoryCompleted( processInstance.getId(), new QueryContext()); assertNotNull(completedNodes); activeNodes = runtimeDataService.getProcessInstanceHistoryActive( processInstance.getId(), new QueryContext()); assertNotNull(activeNodes); assertEquals(1, activeNodes.size()); completedNodes = runtimeDataService.getProcessInstanceHistoryCompleted( processInstance.getId(), new QueryContext()); assertNotNull(completedNodes); activeNodes = runtimeDataService.getProcessInstanceHistoryActive( processInstance.getId(), new QueryContext()); assertNotNull(activeNodes); assertEquals(1, activeNodes.size()); completedNodes = runtimeDataService.getProcessInstanceHistoryCompleted( processInstance.getId(), new QueryContext()); assertNotNull(completedNodes); activeNodes = runtimeDataService.getProcessInstanceHistoryActive( processInstance.getId(), new QueryContext());
Collection<NodeInstanceDesc> nodeInstanceLogs = runtimeDataService.getProcessInstanceHistoryCompleted( processInstance.getId(), new QueryContext()); assertEquals("End", log2.getName()); Collection<NodeInstanceDesc> fullNodeInstanceLogs = runtimeDataService.getProcessInstanceFullHistory( processInstance.getId(), new QueryContext());
@RequestMapping(value = "/", method = RequestMethod.GET) public Collection<ProcessInstanceDesc> getProcessInstances() { Collection<ProcessInstanceDesc> processInstances = runtimeDataService.getProcessInstances(new QueryContext(0, 100, "status", true)); return processInstances; }
public TaskSummaryList getTasksAssignedAsPotentialOwner(List<String> status, List<String> groupIds, String userId, Integer page, Integer pageSize, String sort, boolean sortOrder, String filter) { List<Status> taskStatuses = buildTaskStatuses(status); userId = getUser(userId); logger.debug("About to search for task assigned as potential owner for user '{}'", userId); List<TaskSummary> tasks; QueryFilter queryFilter = buildTaskByNameQueryFilter(page, pageSize, sort, sortOrder, filter); if (groupIds != null && !groupIds.isEmpty()) { if (taskStatuses == null) { tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(userId, groupIds, queryFilter); } else { tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(userId, groupIds, taskStatuses, queryFilter); } } else if (taskStatuses != null) { tasks = runtimeDataService.getTasksAssignedAsPotentialOwnerByStatus(userId, taskStatuses, queryFilter); } else { tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(userId, queryFilter); } logger.debug("Found {} tasks for user '{}' assigned as potential owner", tasks.size(), userId); TaskSummaryList result = convertToTaskSummaryList(tasks); return result; }
@Override public boolean existInDatabase(long taskId) { return runtimeDataService.getTaskById(taskId) == null ? false : true; }
@Override public Collection<NodeInstanceSummary> getProcessInstanceActiveNodes(long processInstanceId) { // TODO make use of paging properly as it's currently limiting to 100 return NodeInstanceHelper.adaptCollection(dataService.getProcessInstanceHistoryActive( processInstanceId, new QueryContext(0, 100))); }
@RequestMapping(value = "/", method = RequestMethod.GET) public Collection<TaskSummary> getTasks() { String userId = getAuthUser(); Collection<TaskSummary> tasks = runtimeDataService.getTasksAssignedAsPotentialOwner(userId, new QueryFilter(0, 100)); return tasks; }
@RequestMapping(value = "/", method = RequestMethod.GET) public Collection<ProcessDefinition> getProcessDef() { Collection<ProcessDefinition> processDefinitions = runtimeDataService.getProcesses(new QueryContext(0, 100)); return processDefinitions; }
@Override public Collection<ProcessSummary> getProcessesByFilter(String filter) { // TODO make use of paging properly as it's currently limiting to 100 return ProcessHelper.adaptCollection(dataService.getProcessesByFilter(filter, new QueryContext(0, 100))); }
@Override public Collection<NodeInstanceSummary> getProcessInstanceFullHistory(long processInstanceId) { // TODO make use of paging properly as it's currently limiting to 100 return NodeInstanceHelper.adaptCollection(dataService.getProcessInstanceFullHistory( processInstanceId, new QueryContext(0, 100))); }