Java Code Examples for org.activiti.engine.history.HistoricTaskInstance#getId()

The following examples show how to use org.activiti.engine.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 activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 2
Source File: TaskEventResource.java    From activiti6-boot2 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 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);
}
 
Example 3
Source File: TaskAttachmentResource.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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);
}
 
Example 4
Source File: ActivitiTypeConverter.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
public WorkflowTask convert(HistoricTaskInstance historicTaskInstance) 
{
    if(historicTaskInstance == null) 
    {
        return null;
    }
   
    WorkflowPath path = getWorkflowPath(historicTaskInstance);
    if(path == null)
    {
        // When path is null, workflow is deleted or cancelled. Task should
        // not be used
        return null;
    }
    
    // Extract node from historic task
    WorkflowNode node = buildHistoricTaskWorkflowNode(historicTaskInstance);
    
    WorkflowTaskState state= WorkflowTaskState.COMPLETED;

    String taskId = historicTaskInstance.getId();
    
    // Get the local task variables from the history
    Map<String, Object> variables = propertyConverter.getHistoricTaskVariables(taskId);
    Map<QName, Serializable> historicTaskProperties = propertyConverter.getTaskProperties(historicTaskInstance, variables);
    
    // Get task definition from historic variable 
    String formKey = (String) variables.get(ActivitiConstants.PROP_TASK_FORM_KEY);
    WorkflowTaskDefinition taskDef = factory.createTaskDefinition(formKey, node, formKey, false);
    String title = historicTaskInstance.getName();
    String description = historicTaskInstance.getDescription();
    String taskName = taskDef.getId();

    return factory.createTask(taskId, taskDef, taskName, 
                title, description, state, path, historicTaskProperties);
}
 
Example 5
Source File: Task.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 5 votes vote down vote up
public Task(HistoricTaskInstance taskInstance)
{
    this.id = taskInstance.getId();
    this.processId = taskInstance.getProcessInstanceId();
    this.processDefinitionId = taskInstance.getProcessDefinitionId();
    this.activityDefinitionId = taskInstance.getTaskDefinitionKey();
    this.name = taskInstance.getName();
    this.description = taskInstance.getDescription();
    this.dueAt = taskInstance.getDueDate();
    this.startedAt = taskInstance.getStartTime();
    this.endedAt = taskInstance.getEndTime();
    this.durationInMs = taskInstance.getDurationInMillis();
    this.priority = taskInstance.getPriority();
    this.owner = taskInstance.getOwner();
    this.assignee = taskInstance.getAssignee();
    this.formResourceKey = taskInstance.getFormKey();
    if (taskInstance.getEndTime() != null)
    {
    	this.state = TaskStateTransition.COMPLETED.name().toLowerCase();
    }
    else if (taskInstance.getAssignee() != null)
    {
    	this.state = TaskStateTransition.CLAIMED.name().toLowerCase();
    }
    else
    {
    	this.state = TaskStateTransition.UNCLAIMED.name().toLowerCase();
    }
}
 
Example 6
Source File: WorkspaceController.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 撤销.
 */
@RequestMapping("workspace-withdraw")
public String withdraw(
        @RequestParam("processInstanceId") String processInstanceId) {
    logger.debug("processInstanceId : {}", processInstanceId);

    ProcessInstance processInstance = processEngine.getRuntimeService()
            .createProcessInstanceQuery()
            .processInstanceId(processInstanceId).singleResult();
    String initiator = "";
    String firstUserTaskActivityId = internalProcessConnector
            .findFirstUserTaskActivityId(
                    processInstance.getProcessDefinitionId(), initiator);
    logger.debug("firstUserTaskActivityId : {}", firstUserTaskActivityId);

    List<HistoricTaskInstance> historicTaskInstances = processEngine
            .getHistoryService().createHistoricTaskInstanceQuery()
            .processInstanceId(processInstanceId)
            .taskDefinitionKey(firstUserTaskActivityId).list();
    HistoricTaskInstance historicTaskInstance = historicTaskInstances
            .get(0);
    String taskId = historicTaskInstance.getId();
    HumanTaskDTO humanTaskDto = humanTaskConnector
            .findHumanTaskByTaskId(taskId);
    String comment = "";
    humanTaskConnector.withdraw(humanTaskDto.getId(), comment);

    return "redirect:/bpm/workspace-listRunningProcessInstances.do";
}