Ejemplo n.º 1
0
  public FormDTO findStartEventForm(FirstTaskForm firstTaskForm) {
    ProcessDefinition processDefinition =
        processEngine
            .getRepositoryService()
            .createProcessDefinitionQuery()
            .processDefinitionId(firstTaskForm.getProcessDefinitionId())
            .singleResult();
    List<BpmConfForm> bpmConfForms =
        bpmConfFormManager.find(
            "from BpmConfForm where bpmConfNode.bpmConfBase.processDefinitionId=? and bpmConfNode.code=?",
            firstTaskForm.getProcessDefinitionId(),
            firstTaskForm.getActivityId());
    FormDTO formDto = new FormDTO();
    formDto.setProcessDefinitionId(firstTaskForm.getProcessDefinitionId());
    formDto.setActivityId(firstTaskForm.getActivityId());
    formDto.setCode(firstTaskForm.getFormKey());

    if (!bpmConfForms.isEmpty()) {
      BpmConfForm bpmConfForm = bpmConfForms.get(0);

      if (!Integer.valueOf(2).equals(bpmConfForm.getStatus())) {
        if (Integer.valueOf(1).equals(bpmConfForm.getType())) {
          formDto.setRedirect(true);
          formDto.setUrl(bpmConfForm.getValue());
        } else {
          formDto.setCode(bpmConfForm.getValue());
        }
      }
    } else {
      logger.info(
          "cannot find bpmConfForm : {}, {}",
          firstTaskForm.getProcessDefinitionId(),
          formDto.getActivityId());
    }

    FormDTO contentFormDto =
        formConnector.findForm(formDto.getCode(), processDefinition.getTenantId());

    if (contentFormDto == null) {
      logger.error("cannot find form : {}", formDto.getCode());

      return formDto;
    }

    formDto.setRedirect(contentFormDto.isRedirect());
    formDto.setUrl(contentFormDto.getUrl());
    formDto.setContent(contentFormDto.getContent());

    return formDto;
  }
Ejemplo n.º 2
0
  /** 获得启动表单. */
  public FormDTO findStartForm(String processDefinitionId) {
    ProcessDefinition processDefinition =
        processEngine
            .getRepositoryService()
            .createProcessDefinitionQuery()
            .processDefinitionId(processDefinitionId)
            .singleResult();
    FirstTaskForm firstTaskForm =
        processEngine
            .getManagementService()
            .executeCommand(new FindFirstTaskFormCmd(processDefinitionId));

    if ((!firstTaskForm.isExists()) && (firstTaskForm.getActivityId() != null)) {
      // 再从数据库里找一遍配置
      com.mossle.spi.humantask.FormDTO humantaskFormDto =
          taskDefinitionConnector.findForm(firstTaskForm.getActivityId(), processDefinitionId);

      if (humantaskFormDto != null) {
        firstTaskForm.setFormKey(humantaskFormDto.getKey());
      }
    }

    if (!firstTaskForm.isExists()) {
      logger.info("cannot find startForm : {}", processDefinitionId);

      return new FormDTO();
    }

    if (!firstTaskForm.isTaskForm()) {
      logger.info("find startEventForm : {}", processDefinitionId);

      return this.findStartEventForm(firstTaskForm);
    }

    List<TaskUserDTO> taskUserDtos =
        taskDefinitionConnector.findTaskUsers(
            firstTaskForm.getActivityId(), firstTaskForm.getProcessDefinitionId());
    String assignee = firstTaskForm.getAssignee();
    logger.debug("assignee : {}", assignee);

    for (TaskUserDTO taskUserDto : taskUserDtos) {
      logger.debug("catalog : {}, user : {}", taskUserDto.getCatalog(), taskUserDto.getValue());

      if ("assignee".equals(taskUserDto.getCatalog())) {
        assignee = taskUserDto.getValue();

        break;
      }
    }

    logger.debug("assignee : {}", assignee);

    boolean exists = assignee != null;

    if ((("${" + firstTaskForm.getInitiatorName() + "}").equals(assignee))
        || "流程发起人".equals(assignee)
        || ((assignee != null) && assignee.equals(Authentication.getAuthenticatedUserId()))) {
      exists = true;
    }

    if (!exists) {
      logger.info(
          "cannot find taskForm : {}, {}", processDefinitionId, firstTaskForm.getActivityId());

      return new FormDTO();
    }

    com.mossle.spi.humantask.FormDTO taskFormDto =
        taskDefinitionConnector.findForm(
            firstTaskForm.getActivityId(), firstTaskForm.getProcessDefinitionId());

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

    if (taskFormDto == null) {
      logger.info(
          "cannot find bpmConfForm : {}, {}", processDefinitionId, firstTaskForm.getActivityId());

      return new FormDTO();
    }

    FormDTO formDto = new FormDTO();
    formDto.setProcessDefinitionId(firstTaskForm.getProcessDefinitionId());
    formDto.setActivityId(firstTaskForm.getActivityId());

    FormDTO contentFormDto =
        formConnector.findForm(taskFormDto.getKey(), processDefinition.getTenantId());

    if (contentFormDto == null) {
      logger.error("cannot find form : {}", formDto.getCode());

      return formDto;
    }

    formDto.setCode(taskFormDto.getKey());
    formDto.setRedirect(contentFormDto.isRedirect());
    formDto.setUrl(contentFormDto.getUrl());
    formDto.setContent(contentFormDto.getContent());

    return formDto;
  }