@RequestMapping(value = "/rest/query/history/tasks", method = RequestMethod.POST, produces = "application/json") public ResultListDataRepresentation listTasks(@RequestBody ObjectNode requestNode) { if (requestNode == null) { throw new BadRequestException("No request found"); } HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery(); User currentUser = SecurityUtils.getCurrentUserObject(); JsonNode processInstanceIdNode = requestNode.get("processInstanceId"); if (processInstanceIdNode != null && !processInstanceIdNode.isNull()) { String processInstanceId = processInstanceIdNode.asText(); if (permissionService.hasReadPermissionOnProcessInstance(currentUser, processInstanceId)) { taskQuery.processInstanceId(processInstanceId); } else { throw new NotPermittedException(); } } JsonNode finishedNode = requestNode.get("finished"); if (finishedNode != null && !finishedNode.isNull()) { boolean isFinished = finishedNode.asBoolean(); if (isFinished) { taskQuery.finished(); } else { taskQuery.unfinished(); } } List<HistoricTaskInstance> tasks = taskQuery.list(); // get all users to have the user object available in the task on the client side ResultListDataRepresentation result = new ResultListDataRepresentation(convertTaskInfoList(tasks)); return result; }
metrics.put("completedTaskCount", processEngine.getHistoryService().createHistoricTaskInstanceQuery().finished().count()); metrics.put("completedTaskCountToday", processEngine.getHistoryService().createHistoricTaskInstanceQuery().finished().taskCompletedAfter( new Date(System.currentTimeMillis() - secondsForDays(1))).count());
protected void assertHistoricTasksDeleteReason(ProcessInstance processInstance, String expectedDeleteReason, String... taskNames) { if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.AUDIT)) { for (String taskName : taskNames) { List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery() .processInstanceId(processInstance.getId()).taskName(taskName).list(); assertTrue(historicTaskInstances.size() > 0); for (HistoricTaskInstance historicTaskInstance : historicTaskInstances) { assertNotNull(historicTaskInstance.getEndTime()); if (expectedDeleteReason == null) { assertNull(historicTaskInstance.getDeleteReason()); } else { assertTrue(historicTaskInstance.getDeleteReason().startsWith(expectedDeleteReason)); } } } } }
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery() .processInstanceId(processInstanceId).list(); if (historicTaskInstances != null && historicTaskInstances.size() > 0) {
List<HistoricTaskInstance> historicTaskInstances = historyService.createHistoricTaskInstanceQuery() .processInstanceId(processInstanceId).list();