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

The following examples show how to use org.activiti.engine.history.HistoricTaskInstance#getTaskDefinitionKey() . 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: 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 2
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查看已结束任务
 */
@RequestMapping(value = "task/archived/{taskId}")
public ModelAndView viewHistoryTask(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form-archived";
    ModelAndView mav = new ModelAndView(viewName);
    HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
    if (task.getParentTaskId() != null) {
        HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getParentTaskId()).singleResult();
        mav.addObject("parentTask", parentTask);
    }
    mav.addObject("task", task);

    // 读取子任务
    List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(taskId).list();
    mav.addObject("subTasks", subTasks);

    // 读取附件
    List<Attachment> attachments = null;
    if (task.getTaskDefinitionKey() != null) {
        attachments = taskService.getTaskAttachments(taskId);
    } else {
        attachments = taskService.getProcessInstanceAttachments(task.getProcessInstanceId());
    }
    mav.addObject("attachments", attachments);

    return mav;
}
 
Example 3
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查看已结束任务
 */
@RequestMapping(value = "task/archived/{taskId}")
public ModelAndView viewHistoryTask(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form-archived";
    ModelAndView mav = new ModelAndView(viewName);
    HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
    if (task.getParentTaskId() != null) {
        HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getParentTaskId()).singleResult();
        mav.addObject("parentTask", parentTask);
    }
    mav.addObject("task", task);

    // 读取子任务
    List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(taskId).list();
    mav.addObject("subTasks", subTasks);

    // 读取附件
    List<Attachment> attachments = null;
    if (task.getTaskDefinitionKey() != null) {
        attachments = taskService.getTaskAttachments(taskId);
    } else {
        attachments = taskService.getProcessInstanceAttachments(task.getProcessInstanceId());
    }
    mav.addObject("attachments", attachments);

    return mav;
}
 
Example 4
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查看已结束任务
 */
@RequestMapping(value = "task/archived/{taskId}")
public ModelAndView viewHistoryTask(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form-archived";
    ModelAndView mav = new ModelAndView(viewName);
    HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
    if (task.getParentTaskId() != null) {
        HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getParentTaskId()).singleResult();
        mav.addObject("parentTask", parentTask);
    }
    mav.addObject("task", task);

    // 读取子任务
    List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(taskId).list();
    mav.addObject("subTasks", subTasks);

    // 读取附件
    List<Attachment> attachments = null;
    if (task.getTaskDefinitionKey() != null) {
        attachments = taskService.getTaskAttachments(taskId);
    } else {
        attachments = taskService.getProcessInstanceAttachments(task.getProcessInstanceId());
    }
    mav.addObject("attachments", attachments);

    return mav;
}
 
Example 5
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查看已结束任务
 */
@RequestMapping(value = "task/archived/{taskId}")
public ModelAndView viewHistoryTask(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form-archived";
    ModelAndView mav = new ModelAndView(viewName);
    HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
    if (task.getParentTaskId() != null) {
        HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getParentTaskId()).singleResult();
        mav.addObject("parentTask", parentTask);
    }
    mav.addObject("task", task);

    // 读取子任务
    List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(taskId).list();
    mav.addObject("subTasks", subTasks);

    // 读取附件
    List<Attachment> attachments = null;
    if (task.getTaskDefinitionKey() != null) {
        attachments = taskService.getTaskAttachments(taskId);
    } else {
        attachments = taskService.getProcessInstanceAttachments(task.getProcessInstanceId());
    }
    mav.addObject("attachments", attachments);

    return mav;
}
 
Example 6
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查看已结束任务
 */
@RequestMapping(value = "task/archived/{taskId}")
public ModelAndView viewHistoryTask(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form-archived";
    ModelAndView mav = new ModelAndView(viewName);
    HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
    if (task.getParentTaskId() != null) {
        HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getParentTaskId()).singleResult();
        mav.addObject("parentTask", parentTask);
    }
    mav.addObject("task", task);

    // 读取子任务
    List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(taskId).list();
    mav.addObject("subTasks", subTasks);

    // 读取附件
    List<Attachment> attachments = null;
    if (task.getTaskDefinitionKey() != null) {
        attachments = taskService.getTaskAttachments(taskId);
    } else {
        attachments = taskService.getProcessInstanceAttachments(task.getProcessInstanceId());
    }
    mav.addObject("attachments", attachments);

    return mav;
}
 
Example 7
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 5 votes vote down vote up
/**
 * 查看已结束任务
 */
@RequestMapping(value = "task/archived/{taskId}")
public ModelAndView viewHistoryTask(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form-archived";
    ModelAndView mav = new ModelAndView(viewName);
    HistoricTaskInstance task = historyService.createHistoricTaskInstanceQuery().taskId(taskId).singleResult();
    if (task.getParentTaskId() != null) {
        HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getParentTaskId()).singleResult();
        mav.addObject("parentTask", parentTask);
    }
    mav.addObject("task", task);

    // 读取子任务
    List<HistoricTaskInstance> subTasks = historyService.createHistoricTaskInstanceQuery().taskParentTaskId(taskId).list();
    mav.addObject("subTasks", subTasks);

    // 读取附件
    List<Attachment> attachments = null;
    if (task.getTaskDefinitionKey() != null) {
        attachments = taskService.getTaskAttachments(taskId);
    } else {
        attachments = taskService.getProcessInstanceAttachments(task.getProcessInstanceId());
    }
    mav.addObject("attachments", attachments);

    return mav;
}
 
Example 8
Source File: ActivitiTaskFormService.java    From activiti6-boot2 with Apache License 2.0 4 votes vote down vote up
public FormDefinition getTaskForm(String taskId) {
  HistoricTaskInstance task = permissionService.validateReadPermissionOnTask(SecurityUtils.getCurrentUserObject(), taskId);
  
  Map<String, Object> variables = new HashMap<String, Object>();
  if (task.getProcessInstanceId() != null) {
    List<HistoricVariableInstance> variableInstances = historyService.createHistoricVariableInstanceQuery()
        .processInstanceId(task.getProcessInstanceId())
        .list();
    
    for (HistoricVariableInstance historicVariableInstance : variableInstances) {
      variables.put(historicVariableInstance.getVariableName(), historicVariableInstance.getValue());
    }
  }
  
  String parentDeploymentId = null;
  if (StringUtils.isNotEmpty(task.getProcessDefinitionId())) {
    try {
      ProcessDefinition processDefinition = repositoryService.getProcessDefinition(task.getProcessDefinitionId());
      parentDeploymentId = processDefinition.getDeploymentId();
      
    } catch (ActivitiException e) {
      logger.error("Error getting process definition " + task.getProcessDefinitionId(), e);
    }
  }
  
  FormDefinition formDefinition = null;
  if (task.getEndTime() != null) {
    formDefinition = formService.getCompletedTaskFormDefinitionByKeyAndParentDeploymentId(task.getFormKey(), parentDeploymentId, 
        taskId, task.getProcessInstanceId(), variables, task.getTenantId());
    
  } else {
    formDefinition = formService.getTaskFormDefinitionByKeyAndParentDeploymentId(task.getFormKey(), parentDeploymentId, 
        task.getProcessInstanceId(), variables, task.getTenantId());
  }

  // If form does not exists, we don't want to leak out this info to just anyone
  if (formDefinition == null) {
    throw new NotFoundException("Form definition for task " + task.getTaskDefinitionKey() + " cannot be found for form key " + task.getFormKey());
  }

  return formDefinition;
}