Java Code Examples for org.activiti.engine.task.Task#getParentTaskId()

The following examples show how to use org.activiti.engine.task.Task#getParentTaskId() . 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: ActivitiInternalProcessConnector.java    From lemon with Apache License 2.0 5 votes vote down vote up
/**
 * 完成任务.
 */
public void completeTask(String taskId, String userId,
        Map<String, Object> variables) {
    TaskService taskService = processEngine.getTaskService();
    Task task = taskService.createTaskQuery().taskId(taskId).singleResult();

    if (task == null) {
        throw new IllegalStateException("任务不存在");
    }

    // 先设置登录用户
    IdentityService identityService = processEngine.getIdentityService();
    identityService.setAuthenticatedUserId(userId);

    // 处理子任务
    if ("subtask".equals(task.getCategory())) {
        processEngine.getManagementService().executeCommand(
                new DeleteTaskWithCommentCmd(taskId, "完成"));

        int count = jdbcTemplate.queryForObject(
                "select count(*) from ACT_RU_TASK where PARENT_TASK_ID_=?",
                Integer.class, task.getParentTaskId());

        if (count > 1) {
            return;
        }

        taskId = task.getParentTaskId();
    }

    processEngine.getManagementService().executeCommand(
            new CompleteTaskWithCommentCmd(taskId, variables, "完成"));
}
 
Example 2
Source File: TaskController.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
/**
 * 读取用户任务的表单字段
 */
@RequestMapping(value = "task/getform/{taskId}")
public ModelAndView readTaskForm(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form";
    ModelAndView mav = new ModelAndView(viewName);
    TaskFormData taskFormData = formService.getTaskFormData(taskId);
    Task task = null;

    // 外置表单
    if (taskFormData != null && taskFormData.getFormKey() != null) {
        Object renderedTaskForm = formService.getRenderedTaskForm(taskId);
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("taskFormData", renderedTaskForm);
        mav.addObject("hasFormKey", true);
    } else if (taskFormData != null) { // 动态表单
        mav.addObject("taskFormData", taskFormData);
        task = taskFormData.getTask();
    } else { // 手动创建的任务(包括子任务)
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("manualTask", true);
    }
    mav.addObject("task", task);

    // 读取任务参与人列表
    List<IdentityLink> identityLinksForTask = taskService.getIdentityLinksForTask(taskId);
    mav.addObject("identityLinksForTask", identityLinksForTask);

    // 读取所有人员
    List<User> users = identityService.createUserQuery().list();
    mav.addObject("users", users);

    // 读取所有组
    List<Group> groups = identityService.createGroupQuery().list();
    mav.addObject("groups", groups);

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

    // 读取上级任务
    if (task != null && task.getParentTaskId() != null) {
        HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getParentTaskId()).singleResult();
        mav.addObject("parentTask", parentTask);
    }

    // 读取附件
    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 4 votes vote down vote up
/**
 * 读取用户任务的表单字段
 */
@RequestMapping(value = "task/getform/{taskId}")
public ModelAndView readTaskForm(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form";
    ModelAndView mav = new ModelAndView(viewName);
    TaskFormData taskFormData = formService.getTaskFormData(taskId);
    Task task = null;

    // 外置表单
    if (taskFormData != null && taskFormData.getFormKey() != null) {
        Object renderedTaskForm = formService.getRenderedTaskForm(taskId);
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("taskFormData", renderedTaskForm);
        mav.addObject("hasFormKey", true);
    } else if (taskFormData != null) { // 动态表单
        mav.addObject("taskFormData", taskFormData);
        task = taskFormData.getTask();
    } else { // 手动创建的任务(包括子任务)
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("manualTask", true);
    }
    mav.addObject("task", task);

    // 读取任务参与人列表
    List<IdentityLink> identityLinksForTask = taskService.getIdentityLinksForTask(taskId);
    mav.addObject("identityLinksForTask", identityLinksForTask);

    // 读取所有人员
    List<User> users = identityService.createUserQuery().list();
    mav.addObject("users", users);

    // 读取所有组
    List<Group> groups = identityService.createGroupQuery().list();
    mav.addObject("groups", groups);

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

    // 读取上级任务
    if (task != null && task.getParentTaskId() != null) {
        HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getParentTaskId()).singleResult();
        mav.addObject("parentTask", parentTask);
    }

    // 读取附件
    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 4 votes vote down vote up
/**
 * 读取用户任务的表单字段
 */
@RequestMapping(value = "task/getform/{taskId}")
public ModelAndView readTaskForm(@PathVariable("taskId") String taskId) throws Exception {
    String viewName = "chapter6/task-form";
    ModelAndView mav = new ModelAndView(viewName);
    TaskFormData taskFormData = formService.getTaskFormData(taskId);
    Task task = null;

    // 外置表单
    if (taskFormData != null && taskFormData.getFormKey() != null) {
        Object renderedTaskForm = formService.getRenderedTaskForm(taskId);
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("taskFormData", renderedTaskForm);
        mav.addObject("hasFormKey", true);
    } else if (taskFormData != null) { // 动态表单
        mav.addObject("taskFormData", taskFormData);
        task = taskFormData.getTask();
    } else { // 手动创建的任务(包括子任务)
        task = taskService.createTaskQuery().taskId(taskId).singleResult();
        mav.addObject("manualTask", true);
    }
    mav.addObject("task", task);

    // 读取任务参与人列表
    List<IdentityLink> identityLinksForTask = taskService.getIdentityLinksForTask(taskId);
    mav.addObject("identityLinksForTask", identityLinksForTask);

    // 读取所有人员
    List<User> users = identityService.createUserQuery().list();
    mav.addObject("users", users);

    // 读取所有组
    List<Group> groups = identityService.createGroupQuery().list();
    mav.addObject("groups", groups);

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

    // 读取上级任务
    if (task != null && task.getParentTaskId() != null) {
        HistoricTaskInstance parentTask = historyService.createHistoricTaskInstanceQuery().taskId(task.getParentTaskId()).singleResult();
        mav.addObject("parentTask", parentTask);
    }

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

    return mav;
}