Package org.fireflow.model

Examples of org.fireflow.model.WorkflowProcess


    if (taskInstanceCompletionEvaluator != null) {
      return taskInstanceCompletionEvaluator.taskInstanceCanBeCompleted(
          currentSession, runtimeContext, processInstance,
          taskInstance);
    } else {
      WorkflowProcess process = taskInstance.getWorkflowProcess();
      throw new EngineException(taskInstance.getProcessInstanceId(),
          process, taskInstance.getTaskId(),
          "无法获取TaskInstanceCompletionEvaluator,TaskId="
              + task.getId() + ", taskType="
              + taskInstance.getTaskType());
View Full Code Here


    if (taskInstance.getState() == ITaskInstance.COMPLETED
        || taskInstance.getState() == ITaskInstance.CANCELED) {
      return;
    }
    if (taskInstance.getState() == ITaskInstance.INITIALIZED) {
      WorkflowProcess process = taskInstance.getWorkflowProcess();
      throw new EngineException(taskInstance.getProcessInstanceId(),
          process, taskInstance.getTaskId(),
          "Complete task insatance failed.The state of the task insatnce[id="
              + taskInstance.getId() + "] is "
              + taskInstance.getState());
    }
    if (taskInstance.isSuspended()) {
      WorkflowProcess process = taskInstance.getWorkflowProcess();
      throw new EngineException(taskInstance.getProcessInstanceId(),
          process, taskInstance.getTaskId(),
          "Complete task insatance failed. The task instance [id="
              + taskInstance.getId() + "] is suspended");
    }

    if (targetActivityInstance != null) {
      ((TaskInstance) taskInstance)
          .setTargetActivityId(targetActivityInstance.getActivity()
              .getId());
    }

    IPersistenceService persistenceService = this.rtCtx
        .getPersistenceService();

    // 第一步,首先结束当前taskInstance
    if (!this.taskInstanceCanBeCompleted(currentSession, this.rtCtx,
        processInstance, taskInstance)) {
      return;
    }
    ((TaskInstance) taskInstance).setState(ITaskInstance.COMPLETED);
    ((TaskInstance) taskInstance).setCanBeWithdrawn(Boolean.FALSE);
    ((TaskInstance) taskInstance).setEndTime(rtCtx.getCalendarService()
        .getSysDate());
    persistenceService.saveOrUpdateTaskInstance(taskInstance);
    // 触发相应的事件
    TaskInstanceEvent e = new TaskInstanceEvent();
    e.setSource(taskInstance);
    e.setWorkflowSession(currentSession);
    e.setProcessInstance(processInstance);
    e.setEventType(TaskInstanceEvent.AFTER_TASK_INSTANCE_COMPLETE);
    if (this.defaultTaskInstanceEventListener != null) {
      this.defaultTaskInstanceEventListener.onTaskInstanceEventFired(e);
    }

    this.fireTaskInstanceEvent(taskInstance, e);

    // 第二步,检查ActivityInstance是否可以结束
    if (!activityInstanceCanBeCompleted(taskInstance)) {
      return;
    }

    // 第三步,尝试结束对应的activityInstance
    List<IToken> tokens = persistenceService.findTokensForProcessInstance(
        taskInstance.getProcessInstanceId(), taskInstance
            .getActivityId());
    // System.out.println("Inside TaskInstance.complete(targetActivityInstance):: tokens.size is "+tokens.size());
    if (tokens == null || tokens.size() == 0) {
      return;// 表明activityInstance已经结束了。
    }
    if (tokens.size() > 1) {
      WorkflowProcess process = taskInstance.getWorkflowProcess();
      throw new EngineException(taskInstance.getProcessInstanceId(),
          process, taskInstance.getTaskId(), "与activityId="
              + taskInstance.getActivityId() + "对应的token数量(="
              + tokens.size() + ")不正确,正确只能为1,因此无法完成complete操作");
    }
    IToken token = tokens.get(0);
    // stepNumber不相等,不允许执行结束操作。
    if (token.getStepNumber().intValue() != taskInstance.getStepNumber()
        .intValue()) {
      return;
    }
    if (token.isAlive() == false) {
      WorkflowProcess process = taskInstance.getWorkflowProcess();
      throw new EngineException(taskInstance.getProcessInstanceId(),
          process, taskInstance.getTaskId(), "与activityId="
              + taskInstance.getActivityId()
              + "对应的token.alive=false,因此无法完成complete操作");
    }

    INetInstance netInstance = rtCtx.getKernelManager().getNetInstance(
        taskInstance.getProcessId(), taskInstance.getVersion());
    Object obj = netInstance.getWFElementInstance(taskInstance
        .getActivityId());
    if (obj == null) {
      WorkflowProcess process = taskInstance.getWorkflowProcess();
      throw new EngineException(taskInstance.getProcessInstanceId(),
          process, taskInstance.getTaskId(), "系统没有找到与activityId="
              + taskInstance.getActivityId()
              + "对应activityInstance,无法执行complete操作。");
    }
View Full Code Here

    // taskInstance.getTaskId(),
    // "Complete task insatance failed.The state of the task insatnce[id=" +
    // taskInstance.getId() + "] is " + taskInstance.getState());
    // }
    if (taskInstance.isSuspended()) {
      WorkflowProcess process = taskInstance.getWorkflowProcess();
      throw new EngineException(taskInstance.getProcessInstanceId(),
          process, taskInstance.getTaskId(),
          "Abort task insatance failed. The task instance [id="
              + taskInstance.getId() + "] is suspended");
    }

    // 1)检查是否在同一个“执行线”上

    WorkflowProcess workflowProcess = taskInstance.getWorkflowProcess();
    if (targetActivityId != null) {
      String thisActivityId = taskInstance.getActivityId();
      boolean isInSameLine = workflowProcess.isInSameLine(thisActivityId,
          targetActivityId);
      if (!isInSameLine) {
        throw new EngineException(
            taskInstance.getProcessInstanceId(),
            taskInstance.getWorkflowProcess(),
            taskInstance.getTaskId(),
            "Jumpto refused because of the current activitgy and the target activity are NOT in the same 'Execution Thread'.");
      }
    }

    INetInstance netInstance = rtCtx.getKernelManager().getNetInstance(
        workflowProcess.getId(), taskInstance.getVersion());
    IActivityInstance targetActivityInstance = (IActivityInstance) netInstance
        .getWFElementInstance(targetActivityId);

    IActivityInstance thisActivityInstance = (IActivityInstance) netInstance
        .getWFElementInstance(taskInstance.getActivityId());
    if (thisActivityInstance == null) {
      WorkflowProcess process = taskInstance.getWorkflowProcess();
      throw new EngineException(taskInstance.getProcessInstanceId(),
          process, taskInstance.getTaskId(), "系统没有找到与activityId="
              + taskInstance.getActivityId()
              + "对应activityInstance,无法执行abort操作。");
    }

    if (targetActivityInstance != null) {
      ((TaskInstance) taskInstance)
          .setTargetActivityId(targetActivityInstance.getActivity()
              .getId());
    }

    IPersistenceService persistenceService = this.rtCtx
        .getPersistenceService();

    // 第一步,首先Abort当前taskInstance
    persistenceService.abortTaskInstance((TaskInstance) taskInstance);

    // 触发相应的事件
    TaskInstanceEvent e = new TaskInstanceEvent();
    e.setSource(taskInstance);
    e.setWorkflowSession(currentSession);
    e.setProcessInstance(processInstance);
    e.setEventType(TaskInstanceEvent.AFTER_TASK_INSTANCE_COMPLETE);
    if (this.defaultTaskInstanceEventListener != null) {
      this.defaultTaskInstanceEventListener.onTaskInstanceEventFired(e);
    }

    this.fireTaskInstanceEvent(taskInstance, e);

    // 第二步,检查ActivityInstance是否可以结束
    if (!activityInstanceCanBeCompleted(taskInstance)) {
      return;
    }

    // 第三步,尝试结束对应的activityInstance
    List<IToken> tokens = persistenceService.findTokensForProcessInstance(
        taskInstance.getProcessInstanceId(), taskInstance
            .getActivityId());
    // System.out.println("Inside TaskInstance.complete(targetActivityInstance):: tokens.size is "+tokens.size());
    if (tokens == null || tokens.size() == 0) {
      return;// 表明activityInstance已经结束了。
    }
    if (tokens.size() > 1) {
      WorkflowProcess process = taskInstance.getWorkflowProcess();
      throw new EngineException(taskInstance.getProcessInstanceId(),
          process, taskInstance.getTaskId(), "与activityId="
              + taskInstance.getActivityId() + "对应的token数量(="
              + tokens.size() + ")不正确,正确只能为1,因此无法完成complete操作");
    }
    IToken token = tokens.get(0);
    // stepNumber不相等,不允许执行结束操作。
    if (token.getStepNumber().intValue() != taskInstance.getStepNumber()
        .intValue()) {
      return;
    }
    if (token.isAlive() == false) {
      WorkflowProcess process = taskInstance.getWorkflowProcess();
      throw new EngineException(taskInstance.getProcessInstanceId(),
          process, taskInstance.getTaskId(), "与activityId="
              + taskInstance.getActivityId()
              + "对应的token.alive=false,因此无法完成complete操作");
    }
View Full Code Here

    // taskInstance.getTaskId(),
    // "Complete task insatance failed.The state of the task insatnce[id=" +
    // taskInstance.getId() + "] is " + taskInstance.getState());
    // }
    if (thisTaskInst.isSuspended()) {
      WorkflowProcess process = thisTaskInst.getWorkflowProcess();
      throw new EngineException(thisTaskInst.getProcessInstanceId(),
          process, thisTaskInst.getTaskId(),
          "Abort task insatance failed. The task instance [id="
              + thisTaskInst.getId() + "] is suspended");
    }

    //
    IPersistenceService persistenceService = this.rtCtx.getPersistenceService();
    WorkflowProcess workflowProcess = thisTaskInst.getWorkflowProcess();
    List<IToken> allTokens = null;
    List<String> aliveActivityIdsAfterJump = new ArrayList<String>();
    if (targetActivityId != null) {     
      String thisActivityId = thisTaskInst.getActivityId();
      boolean isInSameLine = workflowProcess.isInSameLine(thisActivityId,
          targetActivityId);
     
      if (isInSameLine){
        this.abortTaskInstance(currentSession, processInstance, thisTaskInst, targetActivityId);
      }
     
      //合法性检查
      allTokens = persistenceService.findTokensForProcessInstance(thisTaskInst.getProcessInstanceId(), null);

      aliveActivityIdsAfterJump.add(targetActivityId);
     
      for (int i=0;allTokens!=null && i<allTokens.size();i++){
        IToken tokenTmp = allTokens.get(i);
        IWFElement workflowElement = workflowProcess.findWFElementById(tokenTmp.getNodeId());
        if ((workflowElement instanceof Activity) && !workflowElement.getId().equals(thisActivityId)){
         
          aliveActivityIdsAfterJump.add(workflowElement.getId());
         
          if (workflowProcess.isReachable(targetActivityId, workflowElement.getId())
            || workflowProcess.isReachable(workflowElement.getId(), targetActivityId)){
            throw new EngineException(
                thisTaskInst.getProcessInstanceId(),
                thisTaskInst.getWorkflowProcess(),
                thisTaskInst.getTaskId(),
                "Abort refused because of the business-logic conflict!");

          }
        }
      }     
     
      //1)检查是否在同一个“执行线”上(不做该检查,20091008) 
//      if (!isInSameLine) {
//        throw new EngineException(
//            taskInstance.getProcessInstanceId(),
//            taskInstance.getWorkflowProcess(),
//            taskInstance.getTaskId(),
//            "Jumpto refused because of the current activitgy and the target activity are NOT in the same 'Execution Thread'.");
//      }
    }

    INetInstance netInstance = rtCtx.getKernelManager().getNetInstance(
        workflowProcess.getId(), thisTaskInst.getVersion());
    IActivityInstance targetActivityInstance = null;
    if (targetActivityId!=null){
      targetActivityInstance = (IActivityInstance) netInstance
        .getWFElementInstance(targetActivityId);
    }

    IActivityInstance thisActivityInstance = (IActivityInstance) netInstance
        .getWFElementInstance(thisTaskInst.getActivityId());
    if (thisActivityInstance == null) {
      WorkflowProcess process = thisTaskInst.getWorkflowProcess();
      throw new EngineException(thisTaskInst.getProcessInstanceId(),
          process, thisTaskInst.getTaskId(), "系统没有找到与activityId="
              + thisTaskInst.getActivityId()
              + "对应activityInstance,无法执行abort操作。");
    }

    if (targetActivityInstance != null) {
      ((TaskInstance) thisTaskInst)
          .setTargetActivityId(targetActivityInstance.getActivity()
              .getId());
    }


    // 第一步,首先Abort当前taskInstance
    persistenceService.abortTaskInstance((TaskInstance) thisTaskInst);

    // 触发相应的事件
    TaskInstanceEvent e = new TaskInstanceEvent();
    e.setSource(thisTaskInst);
    e.setWorkflowSession(currentSession);
    e.setProcessInstance(processInstance);
    e.setEventType(TaskInstanceEvent.AFTER_TASK_INSTANCE_COMPLETE);
    if (this.defaultTaskInstanceEventListener != null) {
      this.defaultTaskInstanceEventListener.onTaskInstanceEventFired(e);
    }

    this.fireTaskInstanceEvent(thisTaskInst, e);

    // 第二步,检查ActivityInstance是否可以结束
    if (!activityInstanceCanBeCompleted(thisTaskInst)) {
      return;
    }

    // 第三步,尝试结束对应的activityInstance
    List<IToken> tokens = persistenceService.findTokensForProcessInstance(
        thisTaskInst.getProcessInstanceId(), thisTaskInst
            .getActivityId());
    // System.out.println("Inside TaskInstance.complete(targetActivityInstance):: tokens.size is "+tokens.size());
    if (tokens == null || tokens.size() == 0) {
      return;// 表明activityInstance已经结束了。
    }
    if (tokens.size() > 1) {
      WorkflowProcess process = thisTaskInst.getWorkflowProcess();
      throw new EngineException(thisTaskInst.getProcessInstanceId(),
          process, thisTaskInst.getTaskId(), "与activityId="
              + thisTaskInst.getActivityId() + "对应的token数量(="
              + tokens.size() + ")不正确,正确只能为1,因此无法完成complete操作");
    }
    IToken token = tokens.get(0);
    // stepNumber不相等,不允许执行结束操作。
    if (token.getStepNumber().intValue() != thisTaskInst.getStepNumber()
        .intValue()) {
      return;
    }
    if (token.isAlive() == false) {
      WorkflowProcess process = thisTaskInst.getWorkflowProcess();
      throw new EngineException(thisTaskInst.getProcessInstanceId(),
          process, thisTaskInst.getTaskId(), "与activityId="
              + thisTaskInst.getActivityId()
              + "对应的token.alive=false,因此无法完成complete操作");
    }
View Full Code Here

    }

    if (workItem.getTaskInstance().isSuspended()) {
      TaskInstance thisTaskInst = (TaskInstance) workItem
          .getTaskInstance();
      WorkflowProcess process = thisTaskInst.getWorkflowProcess();
      throw new EngineException(thisTaskInst.getProcessInstanceId(),
          process, thisTaskInst.getTaskId(),
          "Complete work item failed. The correspond task instance [id="
              + thisTaskInst.getId() + "] is suspended");
    }
View Full Code Here

  public void completeWorkItemAndJumpTo(IWorkItem workItem,
      String targetActivityId, String comments) throws EngineException,
      KernelException {
    // 首先检查是否可以正确跳转
    // 1)检查是否在同一个“执行线”上
    WorkflowProcess workflowProcess = workItem.getTaskInstance()
        .getWorkflowProcess();
    String thisActivityId = workItem.getTaskInstance().getActivityId();
    boolean isInSameLine = workflowProcess.isInSameLine(thisActivityId,
        targetActivityId);
    TaskInstance thisTaskInst = (TaskInstance) workItem.getTaskInstance();
    if (!isInSameLine) {
      throw new EngineException(
          thisTaskInst.getProcessInstanceId(),
          thisTaskInst.getWorkflowProcess(),
          thisTaskInst.getTaskId(),
          "Jumpto refused because of the current activitgy and the target activity are NOT in the same 'Execution Thread'.");
    }

    // 2)检查目标Activity Form Task的数量(暂时关闭该检查项目)
    // Activity targetActivity =
    // (Activity)workflowProcess.findWFElementById(activityId);
    // int count = getFormTaskCount(targetActivity);
    // if (count!=1){
    // if (!isInSameLine) throw new
    // EngineException("Jumpto refused because of the  FORM-type-task count of the target activitgy  is NOT 1; the count is "+count);
    // }

    // 3)检查当前的 taskinstance是否可以结束
    IPersistenceService persistenceService = rtCtx.getPersistenceService();

    Integer aliveWorkItemCount = persistenceService
        .getAliveWorkItemCountForTaskInstance(thisTaskInst.getId());
    if (aliveWorkItemCount != null && aliveWorkItemCount > 1) {
      throw new EngineException(
          thisTaskInst.getProcessInstanceId(),
          thisTaskInst.getWorkflowProcess(),
          thisTaskInst.getTaskId(),
          "Jumpto refused because of current taskinstance can NOT be completed. some workitem of this taskinstance is in runing state or initialized state");

    }

    // 4)检查当前的activity instance是否可以结束
    if (Activity.ALL.equals(workItem.getTaskInstance().getActivity()
        .getCompletionStrategy())) {

      Integer aliveTaskInstanceCount4ThisActivity = persistenceService
          .getAliveTaskInstanceCountForActivity(workItem
              .getTaskInstance().getProcessInstanceId(), workItem
              .getTaskInstance().getActivityId());
      if (aliveTaskInstanceCount4ThisActivity.intValue() > 1) {// 大于2表明当前Activity不可以complete
        throw new EngineException(
            thisTaskInst.getProcessInstanceId(),
            thisTaskInst.getWorkflowProcess(),
            thisTaskInst.getTaskId(),
            "Jumpto refused because of current activity instance can NOT be completed. some task instance of this activity instance is in runing state or initialized state");
      }
    }

    INetInstance netInstance = rtCtx.getKernelManager().getNetInstance(
        workflowProcess.getId(),
        workItem.getTaskInstance().getVersion());
    if (netInstance == null) {
      throw new EngineException(thisTaskInst.getProcessInstanceId(),
          thisTaskInst.getWorkflowProcess(),
          thisTaskInst.getTaskId(),
          "Not find the net instance for workflow process [id="
              + workflowProcess.getId() + ", version="
              + workItem.getTaskInstance().getVersion() + "]");
    }
    Object obj = netInstance.getWFElementInstance(targetActivityId);
    IActivityInstance targetActivityInstance = (IActivityInstance) obj;
    if (targetActivityInstance == null) {
      throw new EngineException(thisTaskInst.getProcessInstanceId(),
          thisTaskInst.getWorkflowProcess(),
          thisTaskInst.getTaskId(),
          "Not find the activity instance  for activity[process id="
              + workflowProcess.getId() + ", version="
              + workItem.getTaskInstance().getVersion()
              + ",activity id=" + targetActivityId + "]");
    }

    if (rtCtx.isEnableTrace()) {
View Full Code Here

      String targetActivityId, String comments) throws EngineException,
      KernelException {
   
    // 首先检查是否可以正确跳转 

    WorkflowProcess workflowProcess = workItem.getTaskInstance().getWorkflowProcess();
    String thisActivityId = workItem.getTaskInstance().getActivityId();
    TaskInstance thisTaskInst = (TaskInstance) workItem.getTaskInstance();
    //如果是在同一条执行线上,那么可以直接跳过去,只是重复判断了是否在同一条执行线上
    boolean isInSameLine = workflowProcess.isInSameLine(thisActivityId,targetActivityId)
    if (isInSameLine){
      this.completeWorkItemAndJumpTo(workItem, targetActivityId, comments);
      return;
    }
   
    // 1)检查是否在同一个“执行线”上(关闭该检查,20091002)   
//    if (!isInSameLine) {
//      throw new EngineException(
//          thisTaskInst.getProcessInstanceId(),
//          thisTaskInst.getWorkflowProcess(),
//          thisTaskInst.getTaskId(),
//          "Jumpto refused because of the current activitgy and the target activity are NOT in the same 'Execution Thread'.");
//    }

    // 2)检查目标Activity Form Task的数量(暂时关闭该检查项目)
    // Activity targetActivity =
    // (Activity)workflowProcess.findWFElementById(activityId);
    // int count = getFormTaskCount(targetActivity);
    // if (count!=1){
    // if (!isInSameLine) throw new
    // EngineException("Jumpto refused because of the  FORM-type-task count of the target activitgy  is NOT 1; the count is "+count);
    // }

    // 3)检查当前的 taskinstance是否可以结束
    IPersistenceService persistenceService = rtCtx.getPersistenceService();

    Integer aliveWorkItemCount = persistenceService
        .getAliveWorkItemCountForTaskInstance(thisTaskInst.getId());
    if (aliveWorkItemCount != null && aliveWorkItemCount > 1) {
      throw new EngineException(
          thisTaskInst.getProcessInstanceId(),
          thisTaskInst.getWorkflowProcess(),
          thisTaskInst.getTaskId(),
          "Jumpto refused because of current taskinstance can NOT be completed. some workitem of this taskinstance is in runing state or initialized state");

    }

    // 4)检查当前的activity instance是否可以结束
    if (Activity.ALL.equals(workItem.getTaskInstance().getActivity().getCompletionStrategy())) {

      Integer aliveTaskInstanceCount4ThisActivity = persistenceService
          .getAliveTaskInstanceCountForActivity(workItem
              .getTaskInstance().getProcessInstanceId(), workItem
              .getTaskInstance().getActivityId());
      if (aliveTaskInstanceCount4ThisActivity.intValue() > 1) {// 大于1表明当前Activity不可以complete
        throw new EngineException(
            thisTaskInst.getProcessInstanceId(),
            thisTaskInst.getWorkflowProcess(),
            thisTaskInst.getTaskId(),
            "Jumpto refused because of current activity instance can NOT be completed. some task instance of this activity instance is in runing state or initialized state");
      }
    }
   
    //4)首先检查目标状态M是否存在冲突,如果存在冲突则不允许跳转;如果不存在冲突,则需要调整token
    List<IToken> allTokens = persistenceService.findTokensForProcessInstance(thisTaskInst.getProcessInstanceId(), null);
    WorkflowProcess thisProcess = thisTaskInst.getWorkflowProcess();//找到当前的工作里模型
    List<String> aliveActivityIdsAfterJump = new ArrayList<String>();//计算跳转后,哪些activity节点复活
    aliveActivityIdsAfterJump.add(targetActivityId);
   
    for (int i=0;allTokens!=null && i<allTokens.size();i++){
      IToken tokenTmp = allTokens.get(i);
      IWFElement workflowElement = thisProcess.findWFElementById(tokenTmp.getNodeId()); //找到拥有此token的工作流元素
      if ((workflowElement instanceof Activity) && !workflowElement.getId().equals(thisActivityId)){
        //注意:不能自己跳转到自己,同时此工作流元素是activity类型
        aliveActivityIdsAfterJump.add(workflowElement.getId());
       
        if (thisProcess.isReachable(targetActivityId, workflowElement.getId())
          || thisProcess.isReachable(workflowElement.getId(), targetActivityId)){
          throw new EngineException(
              thisTaskInst.getProcessInstanceId(),
              thisTaskInst.getWorkflowProcess(),
              thisTaskInst.getTaskId(),
              "Jumpto refused because of the business-logic conflict!");

        }
      }
    }

    //所有检查结束,开始执行跳转操作
   
    INetInstance netInstance = rtCtx.getKernelManager().getNetInstance(
        workflowProcess.getId(),
        workItem.getTaskInstance().getVersion());
    if (netInstance == null) {
      throw new EngineException(thisTaskInst.getProcessInstanceId(),
          thisTaskInst.getWorkflowProcess(),
          thisTaskInst.getTaskId(),
          "Not find the net instance for workflow process [id="
              + workflowProcess.getId() + ", version="
              + workItem.getTaskInstance().getVersion() + "]");
    }
    Object obj = netInstance.getWFElementInstance(targetActivityId);
    IActivityInstance targetActivityInstance = (IActivityInstance) obj;
    if (targetActivityInstance == null) {
      throw new EngineException(thisTaskInst.getProcessInstanceId(),
          thisTaskInst.getWorkflowProcess(),
          thisTaskInst.getTaskId(),
          "Not find the activity instance  for activity[process id="
              + workflowProcess.getId() + ", version="
              + workItem.getTaskInstance().getVersion()
              + ",activity id=" + targetActivityId + "]");
    }

    if (rtCtx.isEnableTrace()) {

      ProcessInstanceTrace trace = new ProcessInstanceTrace();
      trace.setProcessInstanceId(workItem.getTaskInstance()
          .getProcessInstanceId());
      trace.setStepNumber(workItem.getTaskInstance().getStepNumber() + 1);
      trace.setType(ProcessInstanceTrace.JUMPTO_TYPE);
      trace.setFromNodeId(workItem.getTaskInstance().getActivityId());
      trace.setToNodeId(targetActivityId);
      trace.setEdgeId("");
      rtCtx.getPersistenceService().saveOrUpdateProcessInstanceTrace(
          trace);
    }

    //调整token布局
    List<Synchronizer> allSynchronizersAndEnds = new ArrayList<Synchronizer>();
    allSynchronizersAndEnds.addAll(thisProcess.getSynchronizers());
    allSynchronizersAndEnds.addAll(thisProcess.getEndNodes());
    for (int i=0;i<allSynchronizersAndEnds.size();i++){
      Synchronizer synchronizer = allSynchronizersAndEnds.get(i);

      int volumn = 0;
      if (synchronizer instanceof EndNode){
        volumn = synchronizer.getEnteringTransitions().size();
      }else{
        volumn = synchronizer.getEnteringTransitions().size()*synchronizer.getLeavingTransitions().size();
      }     
      IToken tokenTmp =  new Token();
      tokenTmp.setNodeId(synchronizer.getId());
      tokenTmp.setAlive(false);
      tokenTmp.setProcessInstanceId(thisTaskInst.getProcessInstanceId());
      tokenTmp.setStepNumber(-1);

      List<String> incomingTransitionIds = new ArrayList<String>();
      boolean reachable = false;
      List<Transition> enteringTrans = synchronizer.getEnteringTransitions();   
      for (int m=0;m<aliveActivityIdsAfterJump.size();m++){
        String aliveActivityId = aliveActivityIdsAfterJump.get(m);
        if (thisProcess.isReachable(aliveActivityId, synchronizer.getId())){         
          Transition trans = null;
          reachable = true;
          for (int j=0;j<enteringTrans.size();j++){
            trans = enteringTrans.get(j);
            Node fromNode = trans.getFromNode();
            if (thisProcess.isReachable(aliveActivityId, fromNode.getId())){
              if (!incomingTransitionIds.contains(trans.getId())){
                incomingTransitionIds.add(trans.getId());
              }
            }
          }     
View Full Code Here

    StringTokenizer tokenizer = new StringTokenizer(thisTaskInstance
        .getFromActivityId(), IToken.FROM_ACTIVITY_ID_SEPARATOR);
    while (tokenizer.hasMoreTokens()) {
      fromActivityIdList.add(tokenizer.nextToken());
    }
    WorkflowProcess workflowProcess = workItem.getTaskInstance()
        .getWorkflowProcess();
    for (int i = 0; i < fromActivityIdList.size(); i++) {
      String fromActivityId = (String) fromActivityIdList.get(i);
      Activity fromActivity = (Activity) workflowProcess
          .findWFElementById(fromActivityId);
      List<Task> fromTaskList = fromActivity.getTasks();
      for (int j = 0; j < fromTaskList.size(); j++) {
        Task task =  fromTaskList.get(j);
        if (Task.TOOL.equals(task.getType())
            || Task.SUBFLOW.equals(task.getType())) {
          throw new EngineException(
              thisTaskInstance.getProcessInstanceId(),
              thisTaskInstance.getWorkflowProcess(),
              thisTaskInstance.getTaskId(),
              "Reject operation refused!The previous activity contains tool-task or subflow-task");

        }
      }
    }
    // 恢复所有的FromTaskInstance
    INetInstance netInstance = rtCtx.getKernelManager().getNetInstance(
        workflowProcess.getId(),
        workItem.getTaskInstance().getVersion());
    if (netInstance == null) {
      throw new EngineException(thisTaskInstance.getProcessInstanceId(),
          thisTaskInstance.getWorkflowProcess(), thisTaskInstance
              .getTaskId(),
          "Not find the net instance for workflow process [id="
              + workflowProcess.getId() + ", version="
              + workItem.getTaskInstance().getVersion() + "]");
    }

    // 执行reject操作。
View Full Code Here

TOP

Related Classes of org.fireflow.model.WorkflowProcess

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.