@Override public void delete(String id) { if (getHistoryManager().isHistoryEnabled()) { HistoricTaskInstanceEntity historicTaskInstance = findById(id); if (historicTaskInstance != null) { List<HistoricTaskInstanceEntity> subTasks = historicTaskInstanceDataManager.findHistoricTasksByParentTaskId(historicTaskInstance.getId()); for (HistoricTaskInstance subTask: subTasks) { delete(subTask.getId()); } getHistoricDetailEntityManager().deleteHistoricDetailsByTaskId(id); getHistoricVariableInstanceEntityManager().deleteHistoricVariableInstancesByTaskId(id); getCommentEntityManager().deleteCommentsByTaskId(id); getAttachmentEntityManager().deleteAttachmentsByTaskId(id); getHistoricIdentityLinkEntityManager().deleteHistoricIdentityLinksByTaskId(id); delete(historicTaskInstance); } } }
assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no work time", historicTaskInstance.getWorkTimeInMillis()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no id", historicTaskInstance.getId()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no process instance id", historicTaskInstance.getProcessInstanceId()); assertNotNull("Historic task " + historicTaskInstance.getTaskDefinitionKey() + " has no execution id", historicTaskInstance.getExecutionId());
/** * 判断流程是否可撤回 * 历史流程节点中最后一个审批人是userId */ @Override public Result canWithdraw(HistoricProcessInstance processInstance, String userId) { List<HistoricTaskInstance> taskInstances = historyService.createHistoricTaskInstanceQuery().processUnfinished() .processInstanceId(processInstance.getId()).orderByTaskCreateTime().desc().orderByTaskId().desc() .list(); //Task activeTask=taskService.createTaskQuery().processInstanceId(processInstance.getId()).singleResult(); if (taskInstances.isEmpty() || taskInstances.size() < 2) return new Result(false, null, "已办理,不可撤回"); else { HistoricTaskInstance taskInstance = taskInstances.get(1); HistoricTaskInstance taskCurrent = taskInstances.get(0); //流程审批人未未指定(未签收+未办理) if (StrUtil.isEmpty(taskCurrent.getAssignee())) { if (taskInstance.getAssignee() != null && taskInstance.getAssignee().equals(userId)) { return new Result(true, taskInstance, "可以撤回"); } } //流程定义时指定了办理人,也可以撤回 else if (getTaskState(taskCurrent.getId())) { if (taskInstance.getAssignee() != null && taskInstance.getAssignee().equals(userId)) { return new Result(true, taskInstance, "可以撤回"); } } } return new Result(false, null, "任务被签收或办理,不可撤回"); }
public Result deleteCurrentTaskInstance(String taskId, HistoricTaskInstance taskInstance) { //删除正在执行的任务 //删除HistoricTaskInstance String sql_task = "delete from " + managementService.getTableName(HistoricTaskInstance.class) + " where " + "ID_='" + taskId + "' or ID_='" + taskInstance.getId() + "'"; this.executeSql(sql_task); //删除HistoricActivityInstance String sql_activity = "delete from " + managementService.getTableName(HistoricActivityInstance.class) + " where " + "TASK_ID_='" + taskId + "' or TASK_ID_='" + taskInstance.getId() + "'"; this.executeSql(sql_activity); //获取当前的任务,保存签收人 Task task = taskService.createTaskQuery().executionId(taskInstance.getExecutionId()).singleResult(); task.setAssignee(taskInstance.getAssignee()); task.setOwner(taskInstance.getOwner()); taskService.saveTask(task); //解决HistoricActivityInstance的Assignee为空的现象 if (!StrUtil.isEmpty(taskInstance.getAssignee())) { String sql_update = "update " + managementService.getTableName(HistoricActivityInstance.class) + " set " + "ASSIGNEE_='" + taskInstance.getAssignee() + "' where TASK_ID_='" + task.getId() + "'"; this.executeSql(sql_update); } String sql_update_execution = "update " + managementService.getTableName(Execution.class) + " set " + "ACT_ID_='" + taskInstance.getTaskDefinitionKey() + "' where ID_='" + taskInstance.getExecutionId() + "'"; this.executeSql(sql_update_execution); return new Result(true); }
public void buttonClick(ClickEvent event) { viewManager.showTaskPage(parentTask.getId()); } });
@ApiOperation(value = "Get all comments on a task", tags = {"Tasks"}, nickname = "listTaskComments") @ApiResponses(value = { @ApiResponse(code = 201, message = "Indicates the task was found and the comments are returned."), @ApiResponse(code = 404, message = "Indicates the requested task was not found.") }) @RequestMapping(value = "/runtime/tasks/{taskId}/comments", method = RequestMethod.GET, produces = "application/json") public List<CommentResponse> getComments(@ApiParam(name = "taskId", value="The id of the task to get the comments for.") @PathVariable String taskId, HttpServletRequest request) { HistoricTaskInstance task = getHistoricTaskFromRequest(taskId); return restResponseFactory.createRestCommentList(taskService.getTaskComments(task.getId())); }
@ApiOperation(value = "Get all events for a task", tags = {"Tasks"}) @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the task was found and the events are returned."), @ApiResponse(code = 404, message = "Indicates the requested task was not found.") }) @RequestMapping(value = "/runtime/tasks/{taskId}/events", method = RequestMethod.GET, produces = "application/json") public List<EventResponse> getEvents(@ApiParam(name = "taskId", value="The id of the task to get the events for.") @PathVariable String taskId, HttpServletRequest request) { HistoricTaskInstance task = getHistoricTaskFromRequest(taskId); return restResponseFactory.createEventResponseList(taskService.getTaskEvents(task.getId())); } }
@ApiOperation(value = "Get all attachments on a task", tags = {"Tasks"}) @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the task was found and the attachments are returned."), @ApiResponse(code = 404, message = "Indicates the requested task was not found.") }) @RequestMapping(value = "/runtime/tasks/{taskId}/attachments", method = RequestMethod.GET, produces = "application/json") public List<AttachmentResponse> getAttachments(@ApiParam(name = "taskId", value="The id of the task to get the attachments for.") @PathVariable String taskId, HttpServletRequest request) { List<AttachmentResponse> result = new ArrayList<AttachmentResponse>(); HistoricTaskInstance task = getHistoricTaskFromRequest(taskId); for (Attachment attachment : taskService.getTaskAttachments(task.getId())) { result.add(restResponseFactory.createAttachmentResponse(attachment)); } return result; }
@ApiOperation(value = "Get an attachment on a task", tags = {"Tasks"}) @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the task and attachment were found and the attachment is returned."), @ApiResponse(code = 404, message = "Indicates the requested task was not found or the tasks doesn’t have a attachment with the given ID.") }) @RequestMapping(value = "/runtime/tasks/{taskId}/attachments/{attachmentId}", method = RequestMethod.GET, produces = "application/json") public AttachmentResponse getAttachment(@ApiParam(name = "taskId", value="The id of the task to get the attachment for.") @PathVariable("taskId") String taskId,@ApiParam(name = "attachmentId", value="The id of the attachment.") @PathVariable("attachmentId") String attachmentId, HttpServletRequest request) { HistoricTaskInstance task = getHistoricTaskFromRequest(taskId); Attachment attachment = taskService.getAttachment(attachmentId); if (attachment == null || !task.getId().equals(attachment.getTaskId())) { throw new ActivitiObjectNotFoundException("Task '" + task.getId() + "' doesn't have an attachment with id '" + attachmentId + "'.", Comment.class); } return restResponseFactory.createAttachmentResponse(attachment); }
@ApiOperation(value = "Get an event on a task", tags = {"Tasks"}) @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the task and event were found and the event is returned."), @ApiResponse(code = 404, message = "Indicates the requested task was not found or the tasks doesn’t have an event with the given ID.") }) @RequestMapping(value = "/runtime/tasks/{taskId}/events/{eventId}", method = RequestMethod.GET, produces = "application/json") public EventResponse getEvent(@ApiParam(name="taskId", value="The id of the task to get the event for.") @PathVariable("taskId") String taskId,@ApiParam(name="eventId", value="The id of the event.") @PathVariable("eventId") String eventId, HttpServletRequest request) { HistoricTaskInstance task = getHistoricTaskFromRequest(taskId); Event event = taskService.getEvent(eventId); if (event == null || !task.getId().equals(event.getTaskId())) { throw new ActivitiObjectNotFoundException("Task '" + task.getId() + "' doesn't have an event with id '" + eventId + "'.", Event.class); } return restResponseFactory.createEventResponse(event); }
@ApiOperation(value = " Get a comment on a task", tags = {"Tasks"}, nickname = "getTaskComment") @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the task and comment were found and the comment is returned."), @ApiResponse(code = 404, message = "Indicates the requested task was not found or the tasks doesn’t have a comment with the given ID.") }) @RequestMapping(value = "/runtime/tasks/{taskId}/comments/{commentId}", method = RequestMethod.GET, produces = "application/json") public CommentResponse getComment(@ApiParam(name = "taskId", value="The id of the task to get the comment for.") @PathVariable("taskId") String taskId,@ApiParam(name = "commentId", value="The id of the comment.") @PathVariable("commentId") String commentId, HttpServletRequest request) { HistoricTaskInstance task = getHistoricTaskFromRequest(taskId); Comment comment = taskService.getComment(commentId); if (comment == null || !task.getId().equals(comment.getTaskId())) { throw new ActivitiObjectNotFoundException("Task '" + task.getId() + "' doesn't have a comment with id '" + commentId + "'.", Comment.class); } return restResponseFactory.createRestComment(comment); }
public Map<QName, Serializable> getTaskProperties(HistoricTaskInstance task) { // Get the local task variables from the history Map<String, Object> variables = propertyConverter.getHistoricTaskVariables(task.getId()); return propertyConverter.getTaskProperties(task, variables); }
public Map<QName, Serializable> getTaskProperties(HistoricTaskInstance task) { // Get the local task variables from the history Map<String, Object> variables = propertyConverter.getHistoricTaskVariables(task.getId()); return propertyConverter.getTaskProperties(task, variables); }
protected void confirmed(ConfirmationEvent event) { // delete subtask taskService.deleteTask(subTask.getId()); // Refresh UI subTaskComponent.refreshSubTasks(); } });
public void buttonClick(ClickEvent event) { ExplorerApp.get().getViewManager().showTaskPage(subTask.getId()); } });
public void buttonClick(ClickEvent event) { ExplorerApp.get().getViewManager().showTaskPage(subTask.getId()); } });
public TaskListItem(HistoricTaskInstance historicTaskInstance) { addItemProperty("id", new ObjectProperty<String>(historicTaskInstance.getId(), String.class)); addItemProperty("name", new ObjectProperty<String>(historicTaskInstance.getName(), String.class)); }
@Override protected Component createDetailComponent(String id) { HistoryService historyService = ProcessEngines.getDefaultProcessEngine().getHistoryService(); HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(id).singleResult(); taskEventPanel.setTaskId(historicTaskInstance.getId()); return new HistoricTaskDetailPanel(historicTaskInstance, this); }
protected void initSubTasks() { subTasksLayout = new VerticalLayout(); subTasksLayout.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); addComponent(subTasksLayout); initSubTaskTitle(); List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery() .taskParentTaskId(historicTask.getId()) .list(); if (!subTasks.isEmpty()) { initSubTaskGrid(); populateSubTasks(subTasks); } else { initNoSubTasksLabel(); } }
public HistoricTaskWrapper(HistoricTaskInstance historicTaskInstance) { this.id = historicTaskInstance.getId(); setName(historicTaskInstance.getName()); setDescription(historicTaskInstance.getDescription()); setDueDate(historicTaskInstance.getDueDate()); setPriority(historicTaskInstance.getPriority()); setOwner(historicTaskInstance.getOwner()); setAssignee(historicTaskInstance.getAssignee()); setTenantId(historicTaskInstance.getTenantId()); setFormKey(historicTaskInstance.getFormKey()); }