public void execute(
      JobEntity job,
      String configuration,
      ExecutionEntity execution,
      CommandContext commandContext) {
    ActivityImpl borderEventActivity = execution.getProcessDefinition().findActivity(configuration);

    if (borderEventActivity == null) {
      throw new ActivitiException(
          "Error while firing timer: border event activity " + configuration + " not found");
    }

    try {

      borderEventActivity.getActivityBehavior().execute(execution);

      if (commandContext.getEventDispatcher().isEnabled()) {
        commandContext
            .getEventDispatcher()
            .dispatchEvent(
                ActivitiEventBuilder.createEntityEvent(ActivitiEventType.TIMER_FIRED, job));
      }

    } catch (RuntimeException e) {
      log.error("exception during timer execution", e);
      throw e;

    } catch (Exception e) {
      log.error("exception during timer execution", e);
      throw new ActivitiException("exception during timer execution: " + e.getMessage(), e);
    }
  }
예제 #2
0
  /**
   * 根据流入任务集合,查询最近一次的流入任务节点
   *
   * @param procInst 流程实例
   * @param tempList 流入任务集合
   * @return
   */
  private ActivityImpl filterNewestActivity(ProcessInstance procInst, List<ActivityImpl> tempList) {
    while (tempList.size() > 0) {
      ActivityImpl activity_ = tempList.get(0);
      HistoricActivityInstance activityInstance_ =
          findHistoricUserTask(procInst, activity_.getId());
      if (activityInstance_ == null) {
        tempList.remove(activity_);
        continue;
      }

      if (tempList.size() > 0) {
        ActivityImpl activity_0 = tempList.get(0);
        HistoricActivityInstance activityInstance_0 =
            findHistoricUserTask(procInst, activity_0.getId());
        if (activityInstance_ == null) {
          tempList.remove(activity_);
          continue;
        }

        if (activityInstance_0.getEndTime().before(activityInstance_0.getEndTime())) {
          tempList.remove(activity_);
        } else {
          tempList.remove(activity_);
        }
      } else {
        break;
      }
    }
    if (tempList.size() > 0) {
      return tempList.get(0);
    }
    return null;
  }
예제 #3
0
 public static String getActivityName(String processDefinitionId, String activityId) {
   ActivityImpl activity = getActivity(processDefinitionId, activityId);
   if (activity != null) {
     return ObjectUtils.toString(activity.getProperty("name"));
   }
   return null;
 }
  @Override
  public void execute(ActivityExecution execution) throws Exception {

    // find cancel boundary event:
    ActivityImpl cancelBoundaryEvent =
        ScopeUtil.findInParentScopesByBehaviorType(
            (ActivityImpl) execution.getActivity(), CancelBoundaryEventActivityBehavior.class);

    if (cancelBoundaryEvent == null) {
      throw new ActivitiException(
          "Could not find cancel boundary event for cancel end event " + execution.getActivity());
    }

    ActivityExecution scopeExecution =
        ScopeUtil.findScopeExecutionForScope(
            (ExecutionEntity) execution, cancelBoundaryEvent.getParentActivity());

    // end all executions and process instances in the scope of the transaction
    scopeExecution.destroyScope("cancel end event fired");

    // the scope execution executes the boundary event
    InterpretableExecution outgoingExecution = (InterpretableExecution) scopeExecution;
    outgoingExecution.setActivity(cancelBoundaryEvent);
    outgoingExecution.setActive(true);

    // execute the boundary
    cancelBoundaryEvent.getActivityBehavior().execute(outgoingExecution);
  }
예제 #5
0
 public static void put(String processDefinitionId, ProcessDefinition processDefinition) {
   map.put(processDefinitionId, processDefinition);
   ProcessDefinitionEntity pde = (ProcessDefinitionEntity) processDefinition;
   activities.put(processDefinitionId, pde.getActivities());
   for (ActivityImpl activityImpl : pde.getActivities()) {
     singleActivity.put(processDefinitionId + "_" + activityImpl.getId(), activityImpl);
   }
 }
  protected void executeParse(BpmnParse bpmnParse, UserTask userTask) {

    // Do the regular stuff
    super.executeParse(bpmnParse, userTask);

    // Make user tasks always async
    ActivityImpl activity = findActivity(bpmnParse, userTask.getId());
    activity.setAsync(true);
  }
예제 #7
0
  /**
   * 封装输出信息,包括:当前节点的X、Y坐标、变量信息、任务类型、任务描述
   *
   * @param activity
   * @param processInstance
   * @param currentActiviti
   * @return
   */
  private Map<String, Object> packageSingleActivitiInfo(
      ActivityImpl activity, ProcessInstance processInstance, boolean currentActiviti)
      throws Exception {
    Map<String, Object> vars = new HashMap<String, Object>();
    Map<String, Object> activityInfo = new HashMap<String, Object>();
    activityInfo.put("currentActiviti", currentActiviti);
    setPosition(activity, activityInfo);
    setWidthAndHeight(activity, activityInfo);

    Map<String, Object> properties = activity.getProperties();
    vars.put("任务类型", WorkflowUtils.parseToZhType(properties.get("type").toString()));

    ActivityBehavior activityBehavior = activity.getActivityBehavior();
    logger.debug("activityBehavior={}", activityBehavior);
    if (activityBehavior instanceof UserTaskActivityBehavior) {

      Task currentTask = null;

      /*
       * 当前节点的task
       */
      if (currentActiviti) {
        currentTask = getCurrentTaskInfo(processInstance);
      }

      /*
       * 当前任务的分配角色
       */
      UserTaskActivityBehavior userTaskActivityBehavior =
          (UserTaskActivityBehavior) activityBehavior;
      TaskDefinition taskDefinition = userTaskActivityBehavior.getTaskDefinition();
      Set<Expression> candidateGroupIdExpressions = taskDefinition.getCandidateGroupIdExpressions();
      if (!candidateGroupIdExpressions.isEmpty()) {

        // 任务的处理角色
        setTaskGroup(vars, candidateGroupIdExpressions);

        // 当前处理人
        if (currentTask != null) {
          setCurrentTaskAssignee(vars, currentTask);
        }
      }
    }

    vars.put("节点说明", properties.get("documentation"));

    String description = activity.getProcessDefinition().getDescription();
    vars.put("描述", description);

    logger.debug("trace variables: {}", vars);
    activityInfo.put("vars", vars);
    return activityInfo;
  }
예제 #8
0
 public String process_definition_activity() {
   String processDefinitionId = getpara("processDefinitionId");
   ProcessDefinitionEntity processDefinition =
       (ProcessDefinitionEntity)
           ((RepositoryServiceImpl) repositoryService)
               .getDeployedProcessDefinition(processDefinitionId);
   List<ActivityImpl> activityImplList = processDefinition.getActivities();
   for (ActivityImpl a : activityImplList) {
     log.debug(a.getProperties().toString());
   }
   rhs.put("list", activityImplList);
   return "success";
 }
  public void handleEvent(
      EventSubscriptionEntity eventSubscription, Object payload, CommandContext commandContext) {

    String configuration = eventSubscription.getConfiguration();
    if (configuration == null) {
      throw new ActivitiException(
          "Compensating execution not set for compensate event subscription with id "
              + eventSubscription.getId());
    }

    ExecutionEntity compensatingExecution =
        commandContext.getExecutionEntityManager().findExecutionById(configuration);

    ActivityImpl compensationHandler = eventSubscription.getActivity();

    if ((compensationHandler.getProperty(BpmnParse.PROPERTYNAME_IS_FOR_COMPENSATION) == null
            || !(Boolean)
                compensationHandler.getProperty(BpmnParse.PROPERTYNAME_IS_FOR_COMPENSATION))
        && compensationHandler.isScope()) {

      // descend into scope:
      List<CompensateEventSubscriptionEntity> eventsForThisScope =
          compensatingExecution.getCompensateEventSubscriptions();
      ScopeUtil.throwCompensationEvent(eventsForThisScope, compensatingExecution, false);

    } else {
      try {

        if (commandContext.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
          commandContext
              .getProcessEngineConfiguration()
              .getEventDispatcher()
              .dispatchEvent(
                  ActivitiEventBuilder.createActivityEvent(
                      ActivitiEventType.ACTIVITY_COMPENSATE,
                      compensationHandler.getId(),
                      compensatingExecution.getId(),
                      compensatingExecution.getProcessInstanceId(),
                      compensatingExecution.getProcessDefinitionId()));
        }
        compensatingExecution.setActivity(compensationHandler);

        // executing the atomic operation makes sure activity start events are fired
        compensatingExecution.performOperation(AtomicOperation.ACTIVITY_START);

      } catch (Exception e) {
        throw new ActivitiException(
            "Error while handling compensation event " + eventSubscription, e);
      }
    }
  }
예제 #10
0
 /**
  * 获取可以驳回的节点。
  *
  * @param wfTaskId String
  * @return List<Map<String,Object>>
  * @throws Exception 异常
  */
 @ResponseBody
 @RequestMapping(value = "taskManage.do", params = "queryBackActivitiNodes")
 public List<Map<String, Object>> queryBackActivitiNodes(String wfTaskId) throws Exception {
   List<Map<String, Object>> returnList = new ArrayList<Map<String, Object>>();
   // 获取可以驳回的节点
   List<ActivityImpl> backActivitiNodes = this.taskManageService.findBackAvtivity(wfTaskId);
   for (ActivityImpl a : backActivitiNodes) {
     Map<String, Object> map = new HashMap<String, Object>();
     map.put("value", a.getId());
     map.put("label", a.getProperties().get("name"));
     returnList.add(map);
   }
   return returnList;
 }
예제 #11
0
  /**
   * 判断是否为第一个初始节点
   *
   * @return
   */
  public boolean isFirstTask() {
    ActivityImpl rootActivity = execution.getProcessDefinition().getInitial();
    List<PvmTransition> transitions = rootActivity.getOutgoingTransitions();

    for (PvmTransition transition : transitions) {
      TransitionImpl transitionImpl = (TransitionImpl) transition;
      ActivityImpl destinationActivity = transitionImpl.getDestination();
      String firstTaskActivityname = destinationActivity.getId();
      String currentActivityName = execution.getActivity().getId();

      return currentActivityName.equals(firstTaskActivityname);
    }

    return false;
  }
예제 #12
0
 /**
  * 根据当前节点,查询输出流向是否为并行终点,如果为并行终点,则拼装对应的并行起点ID
  *
  * @param activityImpl 当前节点
  * @return
  */
 private String findParallelGatewayId(ActivityImpl activityImpl) {
   List<PvmTransition> incomingTransitions = activityImpl.getOutgoingTransitions();
   for (PvmTransition pvmTransition : incomingTransitions) {
     TransitionImpl transitionImpl = (TransitionImpl) pvmTransition;
     activityImpl = transitionImpl.getDestination();
     String type = (String) activityImpl.getProperty("type");
     if ("parallelGateway".equals(type)) { // 并行路线
       String gatewayId = activityImpl.getId();
       String gatewayType = gatewayId.substring(gatewayId.lastIndexOf("_") + 0);
       if ("END".equals(gatewayType.toUpperCase())) {
         return gatewayId.substring(0, gatewayId.lastIndexOf("_")) + "_start";
       }
     }
   }
   return null;
 }
예제 #13
0
 /**
  * 还原指定活动节点流向
  *
  * @param activityImpl 活动节点
  * @param oriPvmTransitionList 原有节点流向集合
  */
 private void restoreTransition(
     ActivityImpl activityImpl, List<PvmTransition> oriPvmTransitionList) {
   // 清空现有流向
   List<PvmTransition> pvmTransitionList = activityImpl.getOutgoingTransitions();
   pvmTransitionList.clear();
   // 还原以前流向
   for (PvmTransition pvmTransition : oriPvmTransitionList) {
     pvmTransitionList.add(pvmTransition);
   }
 }
예제 #14
0
  /**
   * 清空指定活动节点流向
   *
   * @param activityImpl 活动节点
   * @return 节点流向集合
   */
  private List<PvmTransition> clearTransition(ActivityImpl activityImpl) {
    // 存储当前节点所有流向临时变量
    List<PvmTransition> oriPvmTransitionList = new ArrayList<PvmTransition>();
    // 获取当前节点所有流向,存储到临时变量,然后清空
    List<PvmTransition> pvmTransitionList = activityImpl.getOutgoingTransitions();
    for (PvmTransition pvmTransition : pvmTransitionList) {
      oriPvmTransitionList.add(pvmTransition);
    }
    pvmTransitionList.clear();

    return oriPvmTransitionList;
  }
예제 #15
0
  /**
   * 流程转向操作
   *
   * @param taskId 当前任务ID
   * @param activityId 目标节点任务ID
   * @param variables 流程变量
   * @throws Exception
   */
  private void turnTransition(String taskId, String activityId, Map<String, Object> variables)
      throws Exception {
    // 当前节点
    ActivityImpl currActivity = this.findActivitiImpl(taskId, null);
    // 清空当前流向
    List<PvmTransition> oriPvmTransitionList = this.clearTransition(currActivity);

    // 创建新流向
    TransitionImpl newTransition = currActivity.createOutgoingTransition();
    // 目标节点
    ActivityImpl pointActivity = this.findActivitiImpl(taskId, activityId);
    // 设置新流向的目标节点
    newTransition.setDestination(pointActivity);

    // 执行转向任务
    taskService.complete(taskId, variables);
    // 删除目标节点新流入
    pointActivity.getIncomingTransitions().remove(newTransition);

    // 还原以前流向
    this.restoreTransition(currActivity, oriPvmTransitionList);
  }
예제 #16
0
  /**
   * 流程跟踪图
   *
   * @param processInstanceId 流程实例ID
   * @return 封装了各种节点信息
   */
  public List<Map<String, Object>> traceProcess(String processInstanceId) throws Exception {
    Execution execution =
        runtimeService.createExecutionQuery().executionId(processInstanceId).singleResult(); // 执行实例
    Object property = PropertyUtils.getProperty(execution, "activityId");
    String activityId = "";
    if (property != null) {
      activityId = property.toString();
    }
    ProcessInstance processInstance =
        runtimeService
            .createProcessInstanceQuery()
            .processInstanceId(processInstanceId)
            .singleResult();
    ProcessDefinitionEntity processDefinition =
        (ProcessDefinitionEntity)
            ((RepositoryServiceImpl) repositoryService)
                .getDeployedProcessDefinition(processInstance.getProcessDefinitionId());
    List<ActivityImpl> activitiList = processDefinition.getActivities(); // 获得当前任务的所有节点

    List<Map<String, Object>> activityInfos = new ArrayList<Map<String, Object>>();
    for (ActivityImpl activity : activitiList) {

      boolean currentActiviti = false;
      String id = activity.getId();

      // 当前节点
      if (id.equals(activityId)) {
        currentActiviti = true;
      }

      Map<String, Object> activityImageInfo =
          packageSingleActivitiInfo(activity, processInstance, currentActiviti);

      activityInfos.add(activityImageInfo);
    }

    return activityInfos;
  }
예제 #17
0
  /**
   * 根据任务ID和节点ID获取活动节点 <br>
   *
   * @param taskId 任务ID
   * @param activityId 活动节点ID <br>
   *     如果为null或"",则默认查询当前活动节点 <br>
   *     如果为"end",则查询结束节点 <br>
   * @return
   * @throws Exception
   */
  private ActivityImpl findActivitiImpl(String taskId, String activityId) throws Exception {
    // 取得流程定义
    ProcessDefinitionEntity procDef = this.findProcDefEntityByTaskId(taskId);

    // 获取当前活动节点ID
    if (StringUtil.isStrEmpty(activityId)) {
      activityId = this.findTaskById(taskId).getTaskDefinitionKey();
    }

    // 根据流程定义,获取该流程实例的结束节点
    if (activityId.toUpperCase().equals("END")) {
      for (ActivityImpl activityImpl : procDef.getActivities()) {
        List<PvmTransition> pvmTransitionList = activityImpl.getOutgoingTransitions();
        if (pvmTransitionList.isEmpty()) {
          return activityImpl;
        }
      }
    }

    // 根据节点ID,获取对应的活动节点
    ActivityImpl activityImpl = ((ProcessDefinitionImpl) procDef).findActivity(activityId);

    return activityImpl;
  }
 /** * 获取跟踪信息 * * @return * @throws Exception */
 public String getProcessMap() throws Exception {
   String procDefId = ""; // request.getParameter("procDefId");
   String proInstId = ""; // request.getParameter("procInstId");
   ProcessDefinition processDefinition =
       repositoryService
           .createProcessDefinitionQuery()
           .processDefinitionId(procDefId)
           .singleResult();
   ProcessDefinitionImpl pdImpl = (ProcessDefinitionImpl) processDefinition;
   String processDefinitionId = pdImpl.getId(); // 流程标识
   ProcessDefinitionEntity def =
       (ProcessDefinitionEntity)
           ((RepositoryServiceImpl) repositoryService)
               .getDeployedProcessDefinition(processDefinitionId);
   List<ActivityImpl> activitiList = def.getActivities();
   // 获得当前任务的所有节点 /****/
   List<String> ActiveActivityIds = runtimeService.getActiveActivityIds(proInstId);
   for (String activeId : ActiveActivityIds) {
     for (ActivityImpl activityImpl : activitiList) {
       String id = activityImpl.getId();
       if (activityImpl.isScope()) {
         if (activityImpl.getActivities().size() > 1) {
           List<ActivityImpl> subAcList = activityImpl.getActivities();
           for (ActivityImpl subActImpl : subAcList) {
             String subid = subActImpl.getId();
             System.out.println("subImpl:" + subid);
             if (activeId.equals(subid)) { // 获得执行到那个节点
               actImpls.add(subActImpl);
               break;
             }
           }
         }
       }
       if (activeId.equals(id)) { // 获得执行到那个节点
         actImpls.add(activityImpl);
         System.out.println(id);
       }
     }
   }
   /** * */
   return "SUCCESS";
 }
 public BoundaryEventActivityBehavior createBoundaryEventActivityBehavior(
     BoundaryEvent boundaryEvent, boolean interrupting, ActivityImpl activity) {
   return new BoundaryEventActivityBehavior(interrupting, activity.getId());
 }
예제 #20
0
 /**
  * 中止流程(特权人直接审批通过等)
  *
  * @param taskId
  */
 @Override
 public void endProcess(String taskId) throws Exception {
   ActivityImpl endActivity = findActivitiImpl(taskId, "end");
   commitProcess(taskId, null, endActivity.getId());
 }
예제 #21
0
  public void validateExclusiveGateway(ActivityImpl activity, ExclusiveGateway exclusiveGateway) {
    if (activity.getOutgoingTransitions().size() == 0) {
      // TODO: double check if this is valid (I think in Activiti yes, since we need start events we
      // will need an end event as well)
      bpmnModel.addProblem(
          "Exclusive Gateway '" + activity.getId() + "' has no outgoing sequence flows.",
          exclusiveGateway);
    } else if (activity.getOutgoingTransitions().size() == 1) {
      PvmTransition flow = activity.getOutgoingTransitions().get(0);
      Condition condition = (Condition) flow.getProperty(BpmnParse.PROPERTYNAME_CONDITION);
      if (condition != null) {
        bpmnModel.addProblem(
            "Exclusive Gateway '"
                + activity.getId()
                + "' has only one outgoing sequence flow ('"
                + flow.getId()
                + "'). This is not allowed to have a condition.",
            exclusiveGateway);
      }
    } else {
      String defaultSequenceFlow = (String) activity.getProperty("default");
      boolean hasDefaultFlow = StringUtils.isNotEmpty(defaultSequenceFlow);

      ArrayList<PvmTransition> flowsWithoutCondition = new ArrayList<PvmTransition>();
      for (PvmTransition flow : activity.getOutgoingTransitions()) {
        Condition condition = (Condition) flow.getProperty(BpmnParse.PROPERTYNAME_CONDITION);
        boolean isDefaultFlow = flow.getId() != null && flow.getId().equals(defaultSequenceFlow);
        boolean hasConditon = condition != null;

        if (!hasConditon && !isDefaultFlow) {
          flowsWithoutCondition.add(flow);
        }
        if (hasConditon && isDefaultFlow) {
          bpmnModel.addProblem(
              "Exclusive Gateway '"
                  + activity.getId()
                  + "' has outgoing sequence flow '"
                  + flow.getId()
                  + "' which is the default flow but has a condition too.",
              exclusiveGateway);
        }
      }
      if (hasDefaultFlow || flowsWithoutCondition.size() > 1) {
        // if we either have a default flow (then no flows without conditions are valid at all) or
        // if we have more than one flow without condition this is an error
        for (PvmTransition flow : flowsWithoutCondition) {
          bpmnModel.addProblem(
              "Exclusive Gateway '"
                  + activity.getId()
                  + "' has outgoing sequence flow '"
                  + flow.getId()
                  + "' without condition which is not the default flow.",
              exclusiveGateway);
        }
      } else if (flowsWithoutCondition.size() == 1) {
        // Havinf no default and exactly one flow without condition this is considered the default
        // one now (to not break backward compatibility)
        PvmTransition flow = flowsWithoutCondition.get(0);
        bpmnModel.addWarning(
            "Exclusive Gateway '"
                + activity.getId()
                + "' has outgoing sequence flow '"
                + flow.getId()
                + "' without condition which is not the default flow. We assume it to be the default flow, but it is bad modeling practice, better set the default flow in your gateway.",
            exclusiveGateway);
      }
    }
  }
 /** @return */
 @Override
 public String getProcessDefinitionId() {
   return activityImpl.getProcessDefinition().getId();
 }
 /** @return */
 @Override
 public String getTaskDefinitionKey() {
   return activityImpl.getId();
 }
 /** @return */
 @Override
 public String getName() {
   return (String) activityImpl.getProperty("name");
 }
 /** @return */
 @Override
 public String getDescription() {
   return (String) activityImpl.getProperty("description");
 }
예제 #26
0
  /**
   * 迭代循环流程树结构,查询当前节点可驳回的任务节点
   *
   * @param taskId 当前任务ID
   * @param currActivity 当前活动节点
   * @param rtnList 存储回退节点集合
   * @param tempList 临时存储节点集合(存储一次迭代过程中的同级userTask节点)
   * @return 回退节点集合
   */
  private List<ActivityImpl> iteratorBackActivity(
      String taskId,
      ActivityImpl currActivity,
      List<ActivityImpl> rtnList,
      List<ActivityImpl> tempList)
      throws Exception {
    // 查询流程定义,生成流程树结构
    ProcessInstance procInst = this.findProcInsByTaskId(taskId);

    // 当前节点的流入来源
    List<PvmTransition> incomingTransitions = currActivity.getIncomingTransitions();
    // 条件分支节点集合,userTask节点遍历完毕,迭代遍历此集合,查询条件分支对应的userTask节点
    List<ActivityImpl> exclusiveGateways = new ArrayList<ActivityImpl>();
    // 并行节点集合,userTask节点遍历完毕,迭代遍历此集合,查询并行节点对应的userTask节点
    List<ActivityImpl> parallelGateways = new ArrayList<ActivityImpl>();
    // 遍历当前节点所有流入路径
    for (PvmTransition pvmTransition : incomingTransitions) {
      TransitionImpl transitionImpl = (TransitionImpl) pvmTransition;
      ActivityImpl activityImpl = transitionImpl.getSource();
      String type = (String) activityImpl.getProperty("type");
      /**
       * 并行节点配置要求:<br>
       * 必须成对出现,且要求分别配置节点ID为:XXX_start(开始),XXX_end(结束)
       */
      if ("parallelGateway".equals(type)) { // 并行路线
        String gatewayId = activityImpl.getId();
        String gatewayType = gatewayId.substring(gatewayId.lastIndexOf("_") + 0);
        if ("START".equals(gatewayType.toUpperCase())) { // 并行起点,停止递归
          return rtnList;
        } else { // 并行终点,临时存储此节点,本次循环结束,迭代集合,查询对应的userTask节点
          parallelGateways.add(activityImpl);
        }
      } else if ("startEvent".equals(type)) { // 开始节点,停止递归
        return rtnList;
      } else if ("userTask".equals(type)) { // 用户任务
        tempList.add(activityImpl);
      } else if ("exclusiveGateway".equals(type)) { // 分支路线,临时存储此节点,本次循环结束,迭代集合,查询对应的userTask节点
        currActivity = transitionImpl.getSource();
        exclusiveGateways.add(currActivity);
      }
    }

    /** 迭代条件分支集合,查询对应的userTask节点 */
    for (ActivityImpl activityImpl : exclusiveGateways) {
      iteratorBackActivity(taskId, activityImpl, rtnList, tempList);
    }

    /** 迭代并行集合,查询对应的userTask节点 */
    for (ActivityImpl activityImpl : parallelGateways) {
      iteratorBackActivity(taskId, activityImpl, rtnList, tempList);
    }

    /** 根据同级userTask集合,过滤最近发生的节点 */
    currActivity = filterNewestActivity(procInst, tempList);
    if (currActivity != null) {
      // 查询当前节点的流向是否为并行终点,并获取并行起点ID
      String id = findParallelGatewayId(currActivity);
      if (StringUtil.isStrEmpty(id)) { // 并行起点ID为空,此节点流向不是并行终点,符合驳回条件,存储此节点
        rtnList.add(currActivity);
      } else { // 根据并行起点ID查询当前节点,然后迭代查询其对应的userTask任务节点
        currActivity = findActivitiImpl(taskId, id);
      }

      // 清空本次迭代临时集合
      tempList.clear();
      // 执行下次迭代
      iteratorBackActivity(taskId, currActivity, rtnList, tempList);
    }
    return rtnList;
  }
예제 #27
0
  /**
   * 打开任务 传入的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";
  }
 protected void executeParse(BpmnParse bpmnParse, ParallelGateway gateway) {
   ActivityImpl activity =
       createActivityOnCurrentScope(bpmnParse, gateway, BpmnXMLConstants.ELEMENT_GATEWAY_PARALLEL);
   activity.setActivityBehavior(
       bpmnParse.getActivityBehaviorFactory().createParallelGatewayActivityBehavior(gateway));
 }
예제 #29
0
 /**
  * 设置宽度、高度属性
  *
  * @param activity
  * @param activityInfo
  */
 private void setWidthAndHeight(ActivityImpl activity, Map<String, Object> activityInfo) {
   activityInfo.put("width", activity.getWidth());
   activityInfo.put("height", activity.getHeight());
 }
예제 #30
0
 /**
  * 设置坐标位置
  *
  * @param activity
  * @param activityInfo
  */
 private void setPosition(ActivityImpl activity, Map<String, Object> activityInfo) {
   activityInfo.put("x", activity.getX());
   activityInfo.put("y", activity.getY());
 }