예제 #1
0
 /** 这个结束并不会去推动令牌向下。例如用在退回的时候。 */
 public void end(TaskCommand taskCommand, String taskComment) {
   if (this.isSuspended()) {
     throw ExceptionUtil.getException("10303001");
   }
   end();
   setTaskComment(taskComment);
   if (taskCommand != null
       && taskCommand.getTaskCommandType() != null
       && !taskCommand.getTaskCommandType().equals("")) {
     String taskCommandType = taskCommand.getTaskCommandType();
     String taskCommandName = taskCommand.getName();
     // 设置流程自动结束信息 autoEnd
     this.setCommandId(taskCommand.getId());
     this.setCommandType(taskCommandType);
     if (taskCommandName == null) {
       TaskCommandDefinition taskCommandDef =
           Context.getProcessEngineConfiguration().getTaskCommandDefinition(taskCommandType);
       if (taskCommandDef != null) {
         this.setCommandMessage(taskCommandDef.getName());
       }
     } else {
       this.setCommandMessage(taskCommandName);
     }
   } else {
     this.setCommandId(TaskCommandSystemType.AUTOEND);
     this.setCommandType(TaskCommandSystemType.AUTOEND);
     TaskCommandDefinition taskCommandDef =
         Context.getProcessEngineConfiguration()
             .getTaskCommandDefinition(TaskCommandSystemType.AUTOEND);
     if (taskCommandDef != null) {
       this.setCommandMessage(taskCommandDef.getName());
     }
   }
 }
예제 #2
0
  public TokenEntity getToken() {

    if ((token == null) && (tokenId != null)) {
      this.token = Context.getCommandContext().getTokenManager().findTokenById(tokenId);
    }
    return token;
  }
예제 #3
0
 public void insert(ProcessInstanceEntity processInstance) {
   CommandContext commandContext = Context.getCommandContext();
   commandContext.getTaskManager().insert(this);
   if (processInstance != null) {
     processInstance.addTask(this);
     processInstance.setLocationChange(true);
   }
 }
예제 #4
0
  public List<IdentityLinkEntity> getIdentityLinks() {
    if (!isIdentityLinksInitialized) {
      taskIdentityLinks =
          Context.getCommandContext().getIdentityLinkManager().findIdentityLinksByTaskId(id);
      isIdentityLinksInitialized = true;
    }

    return taskIdentityLinks;
  }
예제 #5
0
  protected void ensureProcessDefinitionInitialized() {

    if (processDefinition == null && processDefinitionId != null) {
      ProcessDefinitionEntity processDefinition =
          Context.getProcessEngineConfiguration()
              .getDeploymentManager()
              .findDeployedProcessDefinitionById(processDefinitionId);
      setProcessDefinition(processDefinition);
    }
  }
예제 #6
0
 protected void ensureProcessInstanceInitialized() {
   if ((processInstance == null) && (processInstanceId != null)) {
     processInstance =
         Context.getCommandContext()
             .getProcessInstanceManager()
             .findProcessInstanceById(processInstanceId);
     if (processInstance != null) {
       processInstanceId = processInstance.getId();
     }
   }
 }
예제 #7
0
 /**
  * 递归查询经过指定节点的父令牌
  *
  * @param token
  * @param nodeId
  * @return
  */
 private TokenEntity getParentTokenByNodeId(TokenEntity token, String nodeId) {
   if (token == null) {
     return null;
   }
   TaskQuery taskQuery = new TaskQueryImpl(Context.getCommandContext());
   long taskCount = taskQuery.tokenId(token.getId()).nodeId(nodeId).count();
   if (taskCount != 0) {
     return token;
   } else {
     return getParentTokenByNodeId((TokenEntity) token.getParent(), nodeId);
   }
 }
예제 #8
0
 public void update() {
   // task
   setOwner(this.getOwner());
   setAssignee(this.getAssignee());
   setDelegationState(this.getDelegationState());
   setName(this.getName());
   setDescription(this.getDescription());
   setPriority(this.getPriority());
   setCreateTime(this.getCreateTime());
   setDueDate(this.getDueDate());
   Context.getCommandContext().getTaskManager().update(this);
 }
예제 #9
0
  /** 结束任务,并驱动流程向下运转。 指定需要去的节点和指定节点的任务处理者 */
  public void complete(KernelFlowNodeImpl toFlowNode, String assignee) {

    /** 设置任务结束状态 */
    end();
    /** 正常处理任务不能处理已经暂停的任务 */
    if (this.isSuspended) {
      throw ExceptionUtil.getException("10303001");
    }
    /** 获取令牌 */
    if (tokenId != null) {
      TokenEntity token = null;
      token = getToken();
      if (toFlowNode != null) {
        // 如果指定了目标节点,则首先判断本令牌是否走过该节点
        // 如果走过该节点(taskCount != 0)则正常退回
        // 如果未走过该节点,则递归查询父令牌是否经过,如果父令牌走过,则结束父令牌的child,并推动父令牌退回,如果父令牌也未走过,则抛出异常
        String nodeId = toFlowNode.getId();
        TaskQuery taskQuery = new TaskQueryImpl(Context.getCommandContext());
        long taskCount = taskQuery.tokenId(tokenId).nodeId(nodeId).count();
        if (taskCount == 0) {
          token = getParentTokenByNodeId((TokenEntity) token.getParent(), toFlowNode.getId());
          if (token == null) {
            throw ExceptionUtil.getException("10303002");
          }
          token.terminationChildToken();
        }
        token.setToFlowNode(toFlowNode);
      }
      /** 移除令牌上注册任务 */
      token.removeTask(this);
      if (StringUtil.isNotEmpty(assignee)) {
        token.setTaskAssignee(assignee);
      }
      /** 驱动令牌向下 */
      token.signal();
    } else {
      log.warn("任务:" + id + "没有令牌号,仅做结束任务处理,不驱动流程向下。");
    }
  }
예제 #10
0
 private ISqlSession getSqlSession() {
   return Context.getCommandContext().getSqlSession();
 }
 @SuppressWarnings("unchecked")
 public List<CalendarRuleEntity> execute(CommandContext commandContext) {
   return (List<CalendarRuleEntity>)
       Context.getCommandContext().getSqlSession().selectList("selectCalendarRulesByTypeId", id);
 }