Package org.activiti.engine.task

Examples of org.activiti.engine.task.Task


        FormTemplateManager formTemplateManager = getFormTemplateManager();
        KeyValue keyValue = getKeyValue();
        String taskId = getParameter(OPERATION_TASK_ID);

        TaskService taskService = processEngine.getTaskService();
        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();

        // 处理抄送任务
        if ("copy".equals(task.getCategory())) {
            new DeleteTaskWithCommentCmd(taskId, "已阅").execute(commandContext);

            return null;
        }

        // 先保存草稿
        new SaveDraftOperation().execute(getParameters());

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

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

        logger.info("{}", task.getDelegationState());

        // 处理委办任务
        if (DelegationState.PENDING == task.getDelegationState()) {
            taskService.resolveTask(taskId);

            return null;
        }

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

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

            if (count > 1) {
                return null;
            }

            taskId = task.getParentTaskId();
        }

        FormService formService = processEngine.getFormService();
        String taskFormKey = formService.getTaskFormKey(
                task.getProcessDefinitionId(), task.getTaskDefinitionKey());
        FormInfo formInfo = new FormInfo();
        formInfo.setTaskId(taskId);
        formInfo.setFormKey(taskFormKey);

        // 尝试根据表单里字段的类型,进行转换
        Map<String, String> formTypeMap = new HashMap<String, String>();

        if (formInfo.isFormExists()) {
            FormTemplate formTemplate = formTemplateManager.findUniqueBy(
                    "code", formInfo.getFormKey());

            String content = formTemplate.getContent();
            formTypeMap = this.fetchFormTypeMap(content);
        }

        String processInstanceId = task.getProcessInstanceId();
        Record record = keyValue.findByRef(processInstanceId);
        Map<String, Object> processParameters = new HashMap<String, Object>();

        if (record == null) {
            new CompleteTaskWithCommentCmd(taskId, processParameters,
View Full Code Here


    @RequestMapping("form-viewTaskForm")
    public String viewTaskForm(@RequestParam("taskId") String taskId,
            Model model, RedirectAttributes redirectAttributes)
            throws Exception {
        TaskService taskService = processEngine.getTaskService();
        Task task = taskService.createTaskQuery().taskId(taskId).singleResult();

        if (task == null) {
            messageHelper.addFlashMessage(redirectAttributes, "任务不存在");

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

        FormService formService = processEngine.getFormService();
        String taskFormKey = formService.getTaskFormKey(
                task.getProcessDefinitionId(), task.getTaskDefinitionKey());

        FormTemplate formTemplate = formTemplateManager.findUniqueBy("code",
                taskFormKey);
        model.addAttribute("formTemplate", formTemplate);

        FormInfo formInfo = new FormInfo();
        formInfo.setTaskId(taskId);
        model.addAttribute("formInfo", formInfo);

        List<BpmConfOperation> bpmConfOperations = bpmConfOperationManager
                .find("from BpmConfOperation where bpmConfNode.bpmConfBase.processDefinitionId=? and bpmConfNode.code=?",
                        task.getProcessDefinitionId(),
                        task.getTaskDefinitionKey());

        for (BpmConfOperation bpmConfOperation : bpmConfOperations) {
            formInfo.getButtons().add(bpmConfOperation.getValue());
        }

        String processDefinitionId = task.getProcessDefinitionId();
        String activityId = task.getTaskDefinitionKey();
        formInfo.setProcessDefinitionId(processDefinitionId);
        formInfo.setActivityId(activityId);

        List<BpmConfForm> bpmConfForms = bpmConfFormManager
                .find("from BpmConfForm where bpmConfNode.bpmConfBase.processDefinitionId=? and bpmConfNode.code=?",
                        processDefinitionId, activityId);

        if (!bpmConfForms.isEmpty()) {
            if (Integer.valueOf(1).equals(bpmConfForms.get(0).getType())) {
                String redirectUrl = bpmConfForms.get(0).getValue()
                        + "?taskId=" + taskId;

                return "redirect:" + redirectUrl;
            }
        }

        if ((formTemplate != null)
                && Integer.valueOf(1).equals(formTemplate.getType())) {
            String redirectUrl = formTemplate.getContent() + "?taskId="
                    + taskId;

            return "redirect:" + redirectUrl;
        }

        if ((taskId != null) && (!"".equals(taskId))) {
            // 如果是任务草稿,直接通过processInstanceId获得record,更新数据
            // TODO: 分支肯定有问题
            String processInstanceId = task.getProcessInstanceId();
            Record record = keyValue.findByRef(processInstanceId);

            if (record != null) {
                Map map = new HashMap();
View Full Code Here

    List<HistoricDetail> list = historyService.createHistoricDetailQuery().formProperties().list();
    assertEquals(1, list.size());
   
    // 获取第一个节点
    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    assertEquals("First Step", task.getName());
   
    TaskFormData taskFormData = formService.getTaskFormData(task.getId());
    assertNotNull(taskFormData);
    assertNull(taskFormData.getFormKey());
    List<FormProperty> taskFormProperties = taskFormData.getFormProperties();
    assertNotNull(taskFormProperties);
    for (FormProperty formProperty : taskFormProperties) {
      System.out.println(ToStringBuilder.reflectionToString(formProperty));
    }
    formProperties = new HashMap<String, String>();
    formProperties.put("setInFirstStep", "01/12/2012");
    formService.submitTaskFormData(task.getId(), formProperties);
   
    // 获取第二个节点
    task = taskService.createTaskQuery().taskName("Second Step").singleResult();
    assertNotNull(task);
    taskFormData = formService.getTaskFormData(task.getId());
    assertNotNull(taskFormData);
    List<FormProperty> formProperties2 = taskFormData.getFormProperties();
    assertNotNull(formProperties2);
    assertEquals(1, formProperties2.size());
    assertNotNull(formProperties2.get(0).getValue());
View Full Code Here

    }

    private Map.Entry<Task, TaskFormData> checkTask(final String taskId, final String username)
            throws NotFoundException {

        Task task;
        try {
            task = taskService.createTaskQuery().taskId(taskId).singleResult();
        } catch (ActivitiException e) {
            throw new NotFoundException("Activiti Task " + taskId, e);
        }

        TaskFormData formData;
        try {
            formData = formService.getTaskFormData(task.getId());
        } catch (ActivitiException e) {
            throw new NotFoundException("Form for Activiti Task " + taskId, e);
        }

        if (!adminUser.equals(username)) {
View Full Code Here

            if (tasksForUser.isEmpty()) {
                throw new WorkflowException(new RuntimeException(username + " is not candidate for task " + taskId));
            }
        }

        Task task;
        try {
            taskService.setOwner(taskId, username);
            task = taskService.createTaskQuery().taskId(taskId).singleResult();
        } catch (ActivitiException e) {
            throw new WorkflowException(e);
View Full Code Here

    }

    @Override
    public WorkflowFormTO getForm(final String workflowId) throws NotFoundException, WorkflowException {

        Task task;
        try {
            task = taskService.createTaskQuery().processInstanceId(workflowId).singleResult();
        } catch (ActivitiException e) {
            throw new WorkflowException(e);
        }

        TaskFormData formData;
        try {
            formData = formService.getTaskFormData(task.getId());
        } catch (ActivitiException e) {
            LOG.debug("No form found for task {}", task.getId(), e);
            formData = null;
        }

        WorkflowFormTO result = null;
        if (formData != null && !formData.getFormProperties().isEmpty()) {
View Full Code Here

    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " "
        + processInstance.getProcessDefinitionId());
   
    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
   
    HashMap<String, Object> properties = new HashMap<String, Object>();
    Calendar ca = Calendar.getInstance();
    ca.add(Calendar.SECOND, 5);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    SimpleDateFormat sdft = new SimpleDateFormat("HH:mm:ss");
    properties.put("dateTime", sdf.format(ca.getTime()) + "T" + sdft.format(ca.getTime()));
    taskService.complete(task.getId(), properties);
  }
View Full Code Here

    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " "
        + processInstance.getProcessDefinitionId());
   
    TaskService taskService = processEngine.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    assertNotNull(task);
   
    HashMap<String, Object> properties = new HashMap<String, Object>();
    Calendar ca = Calendar.getInstance();
    ca.add(Calendar.SECOND, 1);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    SimpleDateFormat sdft = new SimpleDateFormat("HH:mm:ss");
    properties.put("dateTime", sdf.format(ca.getTime()) + "T" + sdft.format(ca.getTime()));
    taskService.complete(task.getId(), properties);
    Thread.sleep(2000);
    System.exit(0);
  }
View Full Code Here

    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("DefaultFlow", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());
   
    TaskService taskService = activitiRule.getTaskService();
    Task task = taskService.createTaskQuery().singleResult();
    assertEquals("usertask2", task.getTaskDefinitionKey());
  }
View Full Code Here

    variableMap.put("name", "Activiti");
    ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("process1", variableMap);
    assertNotNull(processInstance.getId());
    System.out.println("id " + processInstance.getId() + " " + processInstance.getProcessDefinitionId());

    Task singleResult = taskService.createTaskQuery().taskCandidateUser("henryyan").singleResult();
    String url = "http://labs.mop.com/apache-mirror//ant/binaries/apache-ant-1.8.3-bin.zip";
    String attachmentDescription = "ant bin package";
    taskService.createAttachment("zip", singleResult.getId(), processInstance.getId(), "apache-ant-1.8.3-bin.zip", attachmentDescription, url);
    taskService.complete(singleResult.getId());

    List<Attachment> taskAttachments = taskService.getTaskAttachments(singleResult.getId());
    assertEquals(1, taskAttachments.size());

    HistoryService historyService = activitiRule.getHistoryService();
    List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery().finished().list();
    assertEquals(false, list.isEmpty());
View Full Code Here

TOP

Related Classes of org.activiti.engine.task.Task

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.