Search in sources :

Example 61 with HistoricTaskInstance

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;
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) ArrayList(java.util.ArrayList) AttachmentResponse(org.activiti.rest.service.api.engine.AttachmentResponse) Attachment(org.activiti.engine.task.Attachment) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 62 with HistoricTaskInstance

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);
    }
}
Also used : HttpHeaders(org.springframework.http.HttpHeaders) ResponseEntity(org.springframework.http.ResponseEntity) ActivitiException(org.activiti.engine.ActivitiException) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) InputStream(java.io.InputStream) MediaType(org.springframework.http.MediaType) Attachment(org.activiti.engine.task.Attachment) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) ActivitiException(org.activiti.engine.ActivitiException) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 63 with HistoricTaskInstance

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);
}
Also used : Comment(org.activiti.engine.task.Comment) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 64 with HistoricTaskInstance

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());
    }
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) HistoryService(org.activiti.engine.HistoryService) Test(org.junit.Test)

Aggregations

HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)64 Task (org.activiti.engine.task.Task)27 Deployment (org.activiti.engine.test.Deployment)26 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)16 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)9 ArrayList (java.util.ArrayList)7 Date (java.util.Date)6 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)6 HistoricActivityInstance (org.activiti.engine.history.HistoricActivityInstance)6 HistoricTaskInstanceQuery (org.activiti.engine.history.HistoricTaskInstanceQuery)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)4 Label (com.vaadin.ui.Label)4 SimpleDateFormat (java.text.SimpleDateFormat)4 Attachment (org.activiti.engine.task.Attachment)4 Button (com.vaadin.ui.Button)3 ClickEvent (com.vaadin.ui.Button.ClickEvent)3 ClickListener (com.vaadin.ui.Button.ClickListener)3