コード例 #1
0
  public void notify(DelegateExecution execution) throws Exception {
    this.logger.debug("enter the node event listener.." + execution.getId());

    ExecutionEntity ent = (ExecutionEntity) execution;

    if (ent.getActivityId() == null) return;

    String actDefId = ent.getProcessDefinitionId();
    String nodeId = ent.getActivityId();

    execute(execution, actDefId, nodeId);

    String scriptType = getScriptType();

    exeEventScript(execution, scriptType, actDefId, nodeId);
  }
コード例 #2
0
  public TimerEntity prepareTimerEntity(ExecutionEntity executionEntity) {
    BusinessCalendar businessCalendar =
        Context.getProcessEngineConfiguration()
            .getBusinessCalendarManager()
            .getBusinessCalendar(type.calendarName);

    if (description == null) {
      // Prevent NPE from happening in the next line
      throw new ActivitiIllegalArgumentException(
          "Timer '"
              + executionEntity.getActivityId()
              + "' was not configured with a valid duration/time");
    }

    String endDateString = null;
    String dueDateString = null;
    Date duedate = null;
    Date endDate = null;

    // ACT-1415: timer-declaration on start-event may contain expressions NOT
    // evaluating variables but other context, evaluating should happen nevertheless
    VariableScope scopeForExpression = executionEntity;
    if (scopeForExpression == null) {
      scopeForExpression = NoExecutionVariableScope.getSharedInstance();
    }

    if (endDateExpression != null && !(scopeForExpression instanceof NoExecutionVariableScope)) {
      Object endDateValue = endDateExpression.getValue(scopeForExpression);
      if (endDateValue instanceof String) {
        endDateString = (String) endDateValue;
      } else if (endDateValue instanceof Date) {
        endDate = (Date) endDateValue;
      } else if (endDateValue instanceof DateTime) {
        // Joda DateTime support
        duedate = ((DateTime) endDateValue).toDate();
      } else {
        throw new ActivitiException(
            "Timer '"
                + executionEntity.getActivityId()
                + "' was not configured with a valid duration/time, either hand in a java.util.Date or a String in format 'yyyy-MM-dd'T'hh:mm:ss'");
      }

      if (endDate == null) {
        endDate = businessCalendar.resolveEndDate(endDateString);
      }
    }

    Object dueDateValue = description.getValue(scopeForExpression);
    if (dueDateValue instanceof String) {
      dueDateString = (String) dueDateValue;
    } else if (dueDateValue instanceof Date) {
      duedate = (Date) dueDateValue;
    } else if (dueDateValue instanceof DateTime) {
      // Joda DateTime support
      duedate = ((DateTime) dueDateValue).toDate();
    } else if (dueDateValue != null) {
      // dueDateValue==null is OK - but unexpected class type must throw an error.
      throw new ActivitiException(
          "Timer '"
              + executionEntity.getActivityId()
              + "' was not configured with a valid duration/time, either hand in a java.util.Date or a String in format 'yyyy-MM-dd'T'hh:mm:ss'");
    }

    if (duedate == null && dueDateString != null) {
      duedate = businessCalendar.resolveDuedate(dueDateString);
    }

    TimerEntity timer = null;
    // if dueDateValue is null -> this is OK - timer will be null and job not scheduled
    if (duedate != null) {
      timer = new TimerEntity(this);
      timer.setDuedate(duedate);
      timer.setEndDate(endDate);

      if (executionEntity != null) {
        timer.setExecution(executionEntity);
        timer.setProcessDefinitionId(executionEntity.getProcessDefinitionId());
        timer.setProcessInstanceId(executionEntity.getProcessInstanceId());

        // Inherit tenant identifier (if applicable)
        if (executionEntity != null && executionEntity.getTenantId() != null) {
          timer.setTenantId(executionEntity.getTenantId());
        }
      }

      if (type == TimerDeclarationType.CYCLE) {

        // See ACT-1427: A boundary timer with a cancelActivity='true', doesn't need to repeat
        // itself
        boolean repeat = !isInterruptingTimer;

        // ACT-1951: intermediate catching timer events shouldn't repeat according to spec
        if (TimerCatchIntermediateEventJobHandler.TYPE.equals(jobHandlerType)) {
          repeat = false;
          if (endDate != null) {
            long endDateMiliss = endDate.getTime();
            long dueDateMiliss = duedate.getTime();
            long dueDate = Math.min(endDateMiliss, dueDateMiliss);
            timer.setDuedate(new Date(dueDate));
          }
        }

        if (repeat) {
          String prepared = prepareRepeat(dueDateString);
          timer.setRepeat(prepared);
        }
      }
    }
    return timer;
  }
コード例 #3
0
ファイル: ActivitiAction.java プロジェクト: magicgis/ea
  /**
   * 打开任务 传入的request必须有以下参数 taskId:task的Id taskPage:处理task的页面路径 model:业务表类名 formId:业务表id
   * formProperties:控制表单的名称
   *
   * @return
   * @throws Exception
   */
  public String open_task() throws Exception {
    log.debug("open_task()");
    List<String> nextTaskList = new ArrayList<String>();
    String taskId = getpara("taskId");
    String taskPage = getpara("taskPage");
    String modelStr = getpara("model");
    // add by hb for only query user task
    String readonly = getpara("readonly");
    // end
    String formId = (String) infActiviti.getVariableByTaskId(taskId, "formId");
    if (formId == null || formId.equals("") || modelStr == null || "".equals(modelStr)) {
      rhs.put("model", null);
    } else {
      BaseModel model = (BaseModel) baseDao.loadById(modelStr, Long.parseLong(formId));
      rhs.put("model", model);
    }

    /* add by chenzhijian 20130419 -s */
    // 获取 formProperties 配置文件
    String formProperties = getpara("formProperties");
    HashMap<String, String> formPro = new HashMap<String, String>();
    Properties p = new Properties();
    try {
      // String filepath = System.getProperty("webroot", "./src/main/webapp/");
      String filepath = getWebroot();
      // eg: app/manager/wo/wo.properties
      filepath +=
          "/app/manager/" + modelStr.toLowerCase() + "/" + modelStr.toLowerCase() + ".properties";
      FileInputStream in = new FileInputStream(filepath);
      p.load(in);
      in.close();
      Set<String> set = p.stringPropertyNames();
      for (String s : set) {
        if (s.startsWith("default")) {
          formPro.put(s.replace("default.", ""), p.getProperty(s));
        }
      }
      for (String s : set) {
        if (s.startsWith(formProperties)) {
          formPro.put(s.replace(formProperties + ".", ""), p.getProperty(s));
        }
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    rhs.put("formPro", formPro);
    /* add by chenzhijian 20130419 -e */

    Task task = infActiviti.getTaskById(taskId);
    /*add by hb for get next task 20140128 start*/
    String nextTask = "";
    String initiator = (String) infActiviti.getVariableByTaskId(task.getId(), "initiator");
    // 当前任务获取当前流程的流程定义,然后根据流程定义获得所有的节点
    ProcessDefinitionEntity def =
        (ProcessDefinitionEntity)
            ((RepositoryServiceImpl) repositoryService)
                .getDeployedProcessDefinition(task.getProcessDefinitionId());
    List<ActivityImpl> activitiList = def.getActivities();
    // 根据任务获取当前流程执行ID,执行实例以及当前流程节点的ID
    String excId = task.getExecutionId();
    ExecutionEntity execution =
        (ExecutionEntity) runtimeService.createExecutionQuery().executionId(excId).singleResult();
    String activitiId = execution.getActivityId();
    // 循环activitiList 并判断出当前流程所处节点,然后得到当前节点实例,
    // 根据节点实例获取所有从当前节点出发的路径,然后根据路径获得下一个节点实例
    for (ActivityImpl activityImpl : activitiList) {
      String id = activityImpl.getId();
      if (activitiId.equals(id)) {
        log.debug("当前任务:" + activityImpl.getProperty("name"));
        List<PvmTransition> outTransitions =
            activityImpl.getOutgoingTransitions(); // 获取从某个节点出来的所有线路
        for (PvmTransition tr : outTransitions) {
          PvmActivity ac = tr.getDestination(); // 获取线路的终点节点,在这里应该还要加个判断,如果是并行或者相容关口,则需要继续往下找下一个任务。
          if (ac.getProperty("type").equals("parallelGateway")
              || ac.getProperty("type")
                  .equals(
                      "inclusiveGateway")) { // 不能包括互斥关口
                                             // ac.getProperty("type").equals("exclusiveGateway")
            List<PvmTransition> outTransitions2 = ac.getOutgoingTransitions(); // 因为是关口,所以继续往下找任务
            for (PvmTransition pvmTransition : outTransitions2) {
              PvmActivity ac2 = pvmTransition.getDestination();
              nextTask = (String) ac2.getId();
              log.debug("下一个任务----->:" + nextTask);
              nextTaskList.add(nextTask);
            }
          } else {
            nextTask = (String) ac.getId();
            log.debug("下一个任务++++>:" + nextTask);
            nextTaskList.add(nextTask);
          }
        }
        break;
      }
    }

    /*end*/
    rhs.put("task", task);
    rhs.put("initiator", initiator);
    rhs.put("nextTaskList", nextTaskList);
    rhs.put("taskPage", taskPage);
    rhs.put("readonly", readonly);
    getAllUserAndGroupInfo();

    return "success";
  }