use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class TaskAttachmentCollectionResource method getAttachments.
@RequestMapping(value = "/runtime/tasks/{taskId}/attachments", method = RequestMethod.GET, produces = "application/json")
public List<AttachmentResponse> getAttachments(@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;
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class TaskAttachmentContentResource method getAttachmentContent.
@RequestMapping(value = "/runtime/tasks/{taskId}/attachments/{attachmentId}/content", method = RequestMethod.GET)
public ResponseEntity<byte[]> getAttachmentContent(@PathVariable("taskId") String taskId, @PathVariable("attachmentId") String attachmentId, HttpServletResponse response) {
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 + "'.", Attachment.class);
}
InputStream attachmentStream = taskService.getAttachmentContent(attachmentId);
if (attachmentStream == null) {
throw new ActivitiObjectNotFoundException("Attachment with id '" + attachmentId + "' doesn't have content associated with it.", Attachment.class);
}
HttpHeaders responseHeaders = new HttpHeaders();
MediaType mediaType = null;
if (attachment.getType() != null) {
try {
mediaType = MediaType.valueOf(attachment.getType());
responseHeaders.set("Content-Type", attachment.getType());
} catch (Exception e) {
// ignore if unknown media type
}
}
if (mediaType == null) {
responseHeaders.set("Content-Type", "application/octet-stream");
}
try {
return new ResponseEntity<byte[]>(IOUtils.toByteArray(attachmentStream), responseHeaders, HttpStatus.OK);
} catch (Exception e) {
throw new ActivitiException("Error creating attachment data", e);
}
}
use of org.activiti.engine.history.HistoricTaskInstance in project Activiti by Activiti.
the class TaskCommentResource method getComment.
@RequestMapping(value = "/runtime/tasks/{taskId}/comments/{commentId}", method = RequestMethod.GET, produces = "application/json")
public CommentResponse getComment(@PathVariable("taskId") String taskId, @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);
}
use of org.activiti.engine.history.HistoricTaskInstance in project bamboobsc by billchen198318.
the class TestBPMN001 method queryHistory.
@Test
public void queryHistory() throws Exception {
HistoryService historyService = (HistoryService) AppContext.getBean("historyService");
List<HistoricTaskInstance> taskInstances = historyService.createHistoricTaskInstanceQuery().finished().list();
for (HistoricTaskInstance taskInst : taskInstances) {
System.out.println(taskInst.getId() + " , " + taskInst.getName() + " , " + taskInst.getFormKey() + " , " + taskInst.getAssignee());
}
}
Aggregations