Java Code Examples for org.flowable.task.api.history.HistoricTaskInstance#getId()

The following examples show how to use org.flowable.task.api.history.HistoricTaskInstance#getId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TaskCommentResource.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = " Get a comment on a task", tags = { "Task Comments" }, 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 does not have a comment with the given ID.")
})
@GetMapping(value = "/runtime/tasks/{taskId}/comments/{commentId}", produces = "application/json")
public CommentResponse getComment(@ApiParam(name = "taskId") @PathVariable("taskId") String taskId, @ApiParam(name = "commentId") @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 FlowableObjectNotFoundException("Task '" + task.getId() + "' does not have a comment with id '" + commentId + "'.", Comment.class);
    }

    return restResponseFactory.createRestComment(comment);
}
 
Example 2
Source File: TaskEventResource.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@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 does not have an event with the given ID.")
})
@GetMapping(value = "/runtime/tasks/{taskId}/events/{eventId}", produces = "application/json")
public EventResponse getEvent(@ApiParam(name = "taskId") @PathVariable("taskId") String taskId, @ApiParam(name = "eventId") @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 FlowableObjectNotFoundException("Task '" + task.getId() + "' does not have an event with id '" + eventId + "'.", Event.class);
    }

    return restResponseFactory.createEventResponse(event);
}
 
Example 3
Source File: TaskAttachmentResource.java    From flowable-engine with Apache License 2.0 6 votes vote down vote up
@ApiOperation(value = "Get an attachment on a task", tags = { "Task Attachments" })
@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 does not have a attachment with the given ID.")
})
@GetMapping(value = "/runtime/tasks/{taskId}/attachments/{attachmentId}", produces = "application/json")
public AttachmentResponse getAttachment(@ApiParam(name = "taskId") @PathVariable("taskId") String taskId, @ApiParam(name = "attachmentId") @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 FlowableObjectNotFoundException("Task '" + task.getId() + "' does not have an attachment with id '" + attachmentId + "'.", Comment.class);
    }

    return restResponseFactory.createAttachmentResponse(attachment);
}
 
Example 4
Source File: CacheTaskListener.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
    CmmnEngineConfiguration cmmnEngineConfiguration = CommandContextUtil.getCmmnEngineConfiguration();
    CmmnTaskService taskService = cmmnEngineConfiguration.getCmmnTaskService();
    Task task = taskService.createTaskQuery().taskId(delegateTask.getId()).singleResult();
    if (task != null && task.getId().equals(delegateTask.getId())) {
        taskId = task.getId();
    }
    
    CmmnHistoryService historyService = cmmnEngineConfiguration.getCmmnHistoryService();
    HistoricTaskInstance historicTask = historyService.createHistoricTaskInstanceQuery().taskId(delegateTask.getId()).singleResult();
    if (historicTask != null && historicTask.getId().equals(delegateTask.getId())) {
        historicTaskId = historicTask.getId();
    }
}
 
Example 5
Source File: TestCacheTaskListener.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public void notify(DelegateTask delegateTask) {
    ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration();
    TaskService taskService = processEngineConfiguration.getTaskService();
    Task task = taskService.createTaskQuery().taskId(delegateTask.getId()).singleResult();
    if (task != null && task.getId().equals(delegateTask.getId())) {
        TASK_ID = task.getId();
    }
    
    HistoryService historyService = processEngineConfiguration.getHistoryService();
    HistoricTaskInstance historicTask = historyService.createHistoricTaskInstanceQuery().taskId(delegateTask.getId()).singleResult();
    if (historicTask != null && historicTask.getId().equals(delegateTask.getId())) {
        HISTORIC_TASK_ID = historicTask.getId();
    }

    delegateTask.setVariable("varFromTheListener", "valueFromTheListener");
    delegateTask.setVariableLocal("localVar", "localValue");

    // Used in CacheTaskTest#testTaskQueryWithIncludeVariables
    ProcessInstance processInstance = processEngineConfiguration.getRuntimeService().createProcessInstanceQuery()
        .processInstanceId(task.getProcessInstanceId())
        .includeProcessVariables()
        .singleResult();
    PROCESS_VARIABLES = processInstance.getProcessVariables();

    HistoricProcessInstance historicProcessInstance = processEngineConfiguration.getHistoryService().createHistoricProcessInstanceQuery()
        .processInstanceId(task.getProcessInstanceId())
        .includeProcessVariables()
        .singleResult();
    HISTORIC_PROCESS_VARIABLES = historicProcessInstance.getProcessVariables();

    // Used in CacheTaskTest#testTaskQueryWithIncludeVariables
    Task taskFromQuery = processEngineConfiguration.getTaskService().createTaskQuery()
        .taskId(delegateTask.getId())
        .includeProcessVariables()
        .includeTaskLocalVariables()
        .singleResult();
    TASK_PROCESS_VARIABLES = taskFromQuery.getProcessVariables();
    TASK_LOCAL_VARIABLES = taskFromQuery.getTaskLocalVariables();

    HistoricTaskInstance historicTaskFromQuery = processEngineConfiguration.getHistoryService().createHistoricTaskInstanceQuery()
        .taskId(delegateTask.getId())
        .includeProcessVariables()
        .includeTaskLocalVariables()
        .singleResult();
    HISTORIC_TASK_PROCESS_VARIABLES = historicTaskFromQuery.getProcessVariables();
    HISTORIC_TASK_LOCAL_VARIABLES = historicTaskFromQuery.getTaskLocalVariables();

}