@Override public void delete(CommentEntity commentEntity) { checkHistoryEnabled(); delete(commentEntity, false); Comment comment = (Comment) commentEntity; if (getEventDispatcher().isEnabled()) { // Forced to fetch the process-instance to associate the right // process definition String processDefinitionId = null; String processInstanceId = comment.getProcessInstanceId(); if (comment.getProcessInstanceId() != null) { ExecutionEntity process = getExecutionEntityManager().findById(comment.getProcessInstanceId()); if (process != null) { processDefinitionId = process.getProcessDefinitionId(); } } getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_DELETED, commentEntity, processInstanceId, processInstanceId, processDefinitionId)); } }
public CommentResponse createRestComment(Comment comment, RestUrlBuilder urlBuilder) { CommentResponse result = new CommentResponse(); result.setAuthor(comment.getUserId()); result.setMessage(comment.getFullMessage()); result.setId(comment.getId()); result.setTime(comment.getTime()); result.setTaskId(comment.getTaskId()); result.setProcessInstanceId(comment.getProcessInstanceId()); if (comment.getTaskId() != null) { result.setTaskUrl(urlBuilder.buildUrl(RestUrls.URL_TASK_COMMENT, comment.getTaskId(), comment.getId())); } if (comment.getProcessInstanceId() != null) { result.setProcessInstanceUrl(urlBuilder.buildUrl(RestUrls.URL_HISTORIC_PROCESS_INSTANCE_COMMENT, comment.getProcessInstanceId(), comment.getId())); } return result; }
if (comment.getProcessInstanceId() != null) { ExecutionEntity execution = (ExecutionEntity) commandContext.getExecutionEntityManager().findById(comment.getProcessInstanceId()); if (execution != null && Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, execution.getProcessDefinitionId())) { Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); } else if (comment.getTaskId() != null) { Task task = commandContext.getTaskEntityManager().findById(comment.getTaskId()); if (task != null && task.getProcessDefinitionId() != null && Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, task.getProcessDefinitionId())) { Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler();
@Override public String getTaskId() { return activit5Comment.getTaskId(); }
@Override public String getId() { return activit5Comment.getId(); }
@Override public String getUserId() { return activit5Comment.getUserId(); }
@Override public String getFullMessage() { return activit5Comment.getFullMessage(); }
@Override public Date getTime() { return activit5Comment.getTime(); }
@Override public String getType() { return activit5Comment.getType(); }
@ApiOperation(value = "Delete a comment on a task", tags = {"Tasks"}, nickname = "deleteTaskComment") @ApiResponses(value = { @ApiResponse(code = 204, message = "Indicates the task and comment were found and the comment is deleted. Response body is left empty intentionally."), @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.DELETE) public void deleteComment(@ApiParam(name = "taskId", value="The id of the task to delete the comment for.") @PathVariable("taskId") String taskId,@ApiParam(name = "commentId", value="The id of the comment.") @PathVariable("commentId") String commentId, HttpServletResponse response) { // Check if task exists Task task = getTaskFromRequest(taskId); Comment comment = taskService.getComment(commentId); if (comment == null || comment.getTaskId() == null || !comment.getTaskId().equals(task.getId())) { throw new ActivitiObjectNotFoundException("Task '" + task.getId() + "' doesn't have a comment with id '" + commentId + "'.", Comment.class); } taskService.deleteComment(commentId); response.setStatus(HttpStatus.NO_CONTENT.value()); } }
@Override public void insert(CommentEntity commentEntity) { checkHistoryEnabled(); insert(commentEntity, false); Comment comment = (Comment) commentEntity; if (getEventDispatcher().isEnabled()) { // Forced to fetch the process-instance to associate the right // process definition String processDefinitionId = null; String processInstanceId = comment.getProcessInstanceId(); if (comment.getProcessInstanceId() != null) { ExecutionEntity process = getExecutionEntityManager().findById(comment.getProcessInstanceId()); if (process != null) { processDefinitionId = process.getProcessDefinitionId(); } } getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_CREATED, commentEntity, processInstanceId, processInstanceId, processDefinitionId)); getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_INITIALIZED, commentEntity, processInstanceId, processInstanceId, processDefinitionId)); } }
@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); }
@Override public String getProcessInstanceId() { return activit5Comment.getProcessInstanceId(); }
@ApiOperation(value = "Delete a comment on a historic process instance", tags = { "History" }, notes = "") @ApiResponses(value = { @ApiResponse(code = 204, message = "Indicates the historic process instance and comment were found and the comment is deleted. Response body is left empty intentionally."), @ApiResponse(code = 404, message = "Indicates the requested historic process instance was not found or the historic process instance doesn’t have a comment with the given ID.") }) @RequestMapping(value = "/history/historic-process-instances/{processInstanceId}/comments/{commentId}", method = RequestMethod.DELETE) public void deleteComment(@ApiParam(name="processInstanceId", value="The id of the historic process instance to delete the comment for.") @PathVariable("processInstanceId") String processInstanceId, @ApiParam(name="commentId", value="The id of the comment.") @PathVariable("commentId") String commentId, HttpServletRequest request, HttpServletResponse response) { HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId); Comment comment = taskService.getComment(commentId); if (comment == null || comment.getProcessInstanceId() == null || !comment.getProcessInstanceId().equals(instance.getId())) { throw new ActivitiObjectNotFoundException("Process instance '" + instance.getId() + "' doesn't have a comment with id '" + commentId + "'.", Comment.class); } taskService.deleteComment(commentId); response.setStatus(HttpStatus.NO_CONTENT.value()); }
@ApiOperation(value = "Get a comment on a historic process instance", tags = { "History" }, notes = "") @ApiResponses(value = { @ApiResponse(code = 200, message = "Indicates the historic process instance and comment were found and the comment is returned."), @ApiResponse(code = 404, message = "Indicates the requested historic process instance was not found or the historic process instance doesn’t have a comment with the given ID.") }) @RequestMapping(value = "/history/historic-process-instances/{processInstanceId}/comments/{commentId}", method = RequestMethod.GET, produces = "application/json") public CommentResponse getComment(@ApiParam(name="processInstanceId", value="The id of the historic process instance to get the comment for.") @PathVariable("processInstanceId") String processInstanceId,@ApiParam(name="commentId", value="The id of the comment.") @PathVariable("commentId") String commentId, HttpServletRequest request) { HistoricProcessInstance instance = getHistoricProcessInstanceFromRequest(processInstanceId); Comment comment = taskService.getComment(commentId); if (comment == null || comment.getProcessInstanceId() == null || !comment.getProcessInstanceId().equals(instance.getId())) { throw new ActivitiObjectNotFoundException("Process instance '" + instance.getId() + "' doesn't have a comment with id '" + commentId + "'.", Comment.class); } return restResponseFactory.createRestComment(comment); }
@Override public void delete(CommentEntity commentEntity) { checkHistoryEnabled(); delete(commentEntity, false); Comment comment = (Comment) commentEntity; if (getEventDispatcher().isEnabled()) { // Forced to fetch the process-instance to associate the right // process definition String processDefinitionId = null; String processInstanceId = comment.getProcessInstanceId(); if (comment.getProcessInstanceId() != null) { ExecutionEntity process = getExecutionEntityManager().findById(comment.getProcessInstanceId()); if (process != null) { processDefinitionId = process.getProcessDefinitionId(); } } getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_DELETED, commentEntity, processInstanceId, processInstanceId, processDefinitionId)); } }
@Override public void delete(PersistentObject persistentObject) { checkHistoryEnabled(); super.delete(persistentObject); Comment comment = (Comment) persistentObject; if (getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { // Forced to fetch the process-instance to associate the right process definition String processDefinitionId = null; String processInstanceId = comment.getProcessInstanceId(); if (comment.getProcessInstanceId() != null) { ExecutionEntity process = getProcessInstanceManager().findExecutionById(comment.getProcessInstanceId()); if (process != null) { processDefinitionId = process.getProcessDefinitionId(); } } getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_DELETED, persistentObject, processInstanceId, processInstanceId, processDefinitionId)); } }
@Override public void insert(CommentEntity commentEntity) { checkHistoryEnabled(); insert(commentEntity, false); Comment comment = (Comment) commentEntity; if (getEventDispatcher().isEnabled()) { // Forced to fetch the process-instance to associate the right // process definition String processDefinitionId = null; String processInstanceId = comment.getProcessInstanceId(); if (comment.getProcessInstanceId() != null) { ExecutionEntity process = getExecutionEntityManager().findById(comment.getProcessInstanceId()); if (process != null) { processDefinitionId = process.getProcessDefinitionId(); } } getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_CREATED, commentEntity, processInstanceId, processInstanceId, processDefinitionId)); getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(ActivitiEventType.ENTITY_INITIALIZED, commentEntity, processInstanceId, processInstanceId, processDefinitionId)); } }
@Override public void insert(PersistentObject persistentObject) { checkHistoryEnabled(); super.insert(persistentObject); Comment comment = (Comment) persistentObject; if (getProcessEngineConfiguration().getEventDispatcher().isEnabled()) { // Forced to fetch the process-instance to associate the right process definition String processDefinitionId = null; String processInstanceId = comment.getProcessInstanceId(); if (comment.getProcessInstanceId() != null) { ExecutionEntity process = getProcessInstanceManager().findExecutionById(comment.getProcessInstanceId()); if (process != null) { processDefinitionId = process.getProcessDefinitionId(); } } getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_CREATED, persistentObject, processInstanceId, processInstanceId, processDefinitionId)); getProcessEngineConfiguration().getEventDispatcher().dispatchEvent( ActivitiEventBuilder.createEntityEvent(FlowableEngineEventType.ENTITY_INITIALIZED, persistentObject, processInstanceId, processInstanceId, processDefinitionId)); } }