Package com.founder.fix.fixflow.core.impl.task

Examples of com.founder.fix.fixflow.core.impl.task.TaskInstanceEntity


    if (taskId == null) {
      throw new FixFlowException("任务编号为空!");
    }

    TaskInstanceEntity taskInstance = Context.getCommandContext().getTaskManager().findTaskById(taskId);

    if (taskInstance == null) {
      throw new FixFlowException("无法找到编号为: " + taskId + " 的任务!");
    }
    if (transferUserId != null) {
      if (taskInstance.getAssignee() == null) {

        throw new FixFlowException("任务 " + taskId + " 无代理人!");

      } else {

        String nodeId = taskInstance.getNodeId();
        String processDefinitionId = taskInstance.getProcessDefinitionId();

        ProcessDefinitionManager processDefinitionManager = commandContext.getProcessDefinitionManager();

        ProcessDefinitionBehavior processDefinition = processDefinitionManager.findLatestProcessDefinitionById(processDefinitionId);

        UserTaskBehavior userTask = (UserTaskBehavior) processDefinition.getDefinitions().getElement(nodeId);

        TaskCommandInst taskCommand = userTask.getTaskCommandsMap().get(userCommandId);

        taskInstance.setEndTime(ClockUtil.getCurrentTime());
        taskInstance.setCommandId(taskCommand.getId());
        taskInstance.setCommandType(StringUtil.getString(taskCommand.getTaskCommandType()));
        taskInstance.setCommandMessage(taskCommand.getName());
        taskInstance.setTaskComment(taskComment);

        Context.getCommandContext().getTaskManager().saveTaskInstanceEntity(taskInstance);

        taskInstance.setId(GuidUtil.CreateGuid());
        taskInstance.setAssignee(transferUserId);
        taskInstance.setCreateTime(ClockUtil.getCurrentTime());
        taskInstance.setEndTime(null);
        taskInstance.setCommandType(null);
        taskInstance.setCommandMessage(null);
        taskInstance.setTaskComment(null);
        Context.getCommandContext().getTaskManager().saveTaskInstanceEntity(taskInstance);
      }
    } else {
      throw new FixFlowException("转发人不能为空!");
    }
View Full Code Here


 
  public List<TaskCommandInst> execute(CommandContext commandContext) {
    // TODO 自动生成的方法存根
    List<TaskCommandInst> taskCommandInsts=new ArrayList<TaskCommandInst>();
   
    TaskInstanceEntity taskInstance=commandContext.getTaskManager().findTaskById(taskId);
   
    if(isProcessTracking){
      //流程追踪查询
      if(taskInstance!=null){
        if(taskInstance.getTaskInstanceType()==TaskInstanceType.FIXFLOWTASK){
          taskCommandInsts= CoreUtil.getTaskCommandInst(taskInstance,this.isProcessTracking);
        }
       
      }
    }
    else{

      //非流程追踪查询
      if(taskInstance!=null){
        if(taskInstance.getTaskInstanceType()==TaskInstanceType.FIXFLOWTASK||taskInstance.getTaskInstanceType()==TaskInstanceType.FIXNOTICETASK){
          taskCommandInsts= CoreUtil.getTaskCommandInst(taskInstance,this.isProcessTracking);
        }
       
      }
    }
View Full Code Here

        .getTaskMgmtInstance().getTaskInstanceEntitys();

    for (TaskInstanceEntity taskInstance : taskInstances) {
      if (taskInstance.getId().equals(taskId)) {

        TaskInstanceEntity taskInstanceImpl = taskInstance;
        taskInstanceImpl.end();
        if (taskCommand != null) {
          taskInstanceImpl.setCommandId(taskCommand.getId());
          taskInstanceImpl.setCommandType(StringUtil
              .getString(taskCommand.getTaskCommandType()));

          taskInstanceImpl.setCommandMessage(taskCommand.getName());
        }

        taskInstanceImpl.setTaskComment(this.taskComment);

      }
    }

    return processInstanceImpl;
View Full Code Here

      for (TaskInstanceEntity taskInstance : taskInstances) {
        if (taskInstance.getId().equals(taskId)) {
       
         
          TaskInstanceEntity taskInstanceImpl= taskInstance;
            taskInstanceImpl.setTaskComment(this.taskComment);
           
        }
      }

      try {
View Full Code Here

        throw new FixFlowException("节点: " + this.getId() + " 没有定义处理者,请重新检查节点定义!");
      }
    }

    // 创建并分配任务
    TaskInstanceEntity taskInstance = null;

    if (executionContext.getGroupID() != null) {
      taskInstance = tmi.createTaskInstanceEntity(getTaskDefinition(), executionContext, executionContext.getGroupID());
    } else {
      taskInstance = tmi.createTaskInstanceEntity(getTaskDefinition(), executionContext);
    }

    // 是否启用验证
    // if (!executionContext.getProcessDefinition().isVerification()) {
    // return;
    //

    // 当独占任务和候选任务都没有的时候则直接弹出异常消息.
    if (taskInstance.getAssignee() == null && taskInstance.getTaskIdentityLinks().size() == 0) {
      throw new FixFlowException("节点: " + this.getId() + " 无对应处理者,请重新检查节点定义!");
    } else {
      // 检查分配的用户或者组是否存在,不存在则抛出异常
      if (taskInstance.getAssignee() != null) {
        if (taskInstance.getAssignee().equals("fixflow_allusers")) {
          throw new FixFlowException("独占处理者不能是所有人");
          // return;
        }
        UserTo userTo = Authentication.findUserInfoByUserId(taskInstance.getAssignee());
        if (userTo == null) {
          throw new FixFlowException("节点: " + this.getId() + " 指定的处理者 " + taskInstance.getAssignee() + " 不存在,请重新检查节点定义!");
        }
      }

      if (taskInstance.getTaskIdentityLinks().size() > 0) {
        for (IdentityLink identityLink : taskInstance.getTaskIdentityLinks()) {

          if (identityLink.getUserId() != null) {
            if (identityLink.getUserId().equals("fixflow_allusers")) {
              return;
            }
View Full Code Here

      }
    }

    TokenEntity token = executionContext.getToken();

    TaskInstanceEntity newTask = TaskInstanceEntity.create();
    newTask.setId(GuidUtil.CreateGuid());
    newTask.setCreateTime(new Date());
    newTask.setNodeId(this.getId());

    if (skipAssigneeString != null && !skipAssigneeString.equals("")) {
      newTask.setAssignee(skipAssigneeString);
    }

    newTask.setDraft(false);

    Date date = new Date();

    Calendar cal = Calendar.getInstance();
    cal.setTime(date);
    cal.add(Calendar.MILLISECOND, 1);
    date = cal.getTime();

    newTask.setEndTime(date);
    newTask.setPriority(50);

    ProcessDefinitionBehavior processDefinition = token.getProcessInstance().getProcessDefinition();
    String processDefinitionId = processDefinition.getProcessDefinitionId();
    newTask.setProcessDefinitionId(processDefinitionId);
    newTask.setProcessDefinitionKey(processDefinition.getProcessDefinitionKey());
    newTask.setName(this.getName());
    newTask.setNodeName(this.getName());
    newTask.setProcessInstanceId(token.getProcessInstance().getId());
    newTask.setTokenId(token.getId());
    newTask.setProcessDefinitionName(processDefinition.getName());
    newTask.setTaskInstanceType(TaskInstanceType.FIXBPMTASK);
    String bizKey = token.getProcessInstance().getBizKey();
    newTask.setBizKey(bizKey);
    newTask.setCommandId(TaskCommandType.SKIPNODE);
    newTask.setCommandType(TaskCommandType.SKIPNODE);

    TaskCommandDef taskCommandDef = Context.getProcessEngineConfiguration().getTaskCommandDefMap().get("skipNode");

    if (taskCommandDef.getName() != null) {
      newTask.setCommandMessage(taskCommandDef.getName());
    }

    if (skipCommentString != null && !skipCommentString.equals("")) {
      newTask.setTaskComment(skipCommentString);
    }

    Context.getCommandContext().getTaskManager().saveTaskInstanceEntity(newTask);

  }
View Full Code Here

   
    ExecutionContext executionContext=ProcessObjectFactory.FACTORYINSTANCE.createExecutionContext(token);
   
   
    if(this.taskId!=null&&!this.taskId.equals("")){
      TaskInstanceEntity taskInstanceEntity=processInstance.getTaskMgmtInstance().getTaskInstanceEntitys(taskId);
      executionContext.setTaskInstance(taskInstanceEntity);
    }
   
    if(this.connectorId!=null&&!this.connectorId.equals("")){
     
View Full Code Here

    boolean isDraft=false;
       
   
       
    //创建任务
    TaskInstanceEntity taskInstance=new TaskInstanceEntity();
    taskInstance.setId(newTaskId);
    taskInstance.setNodeName(newTaskNodeName);
    taskInstance.setProcessInstanceId(newTaskProcessInstanceId);
    taskInstance.setProcessDefinitionId(newTaskProcessDefinitionId);
    taskInstance.setTokenId(newTaskTokenId);
    taskInstance.setNodeId(newTaskNodeId);
    taskInstance.setName(newTaskNodeName);
    taskInstance.setDescription(newTaskDescription);
    taskInstance.setCreateTime(newTaskCreateTime);
    taskInstance.setPriority(newTaskPriority);
    taskInstance.setProcessDefinitionKey(newTaskProcessDefinitionKey);
    taskInstance.setTaskInstanceType(newTaskTaskInstanceType);
    taskInstance.setProcessDefinitionName(newTaskProcessDefinitionName);
    taskInstance.setDraft(isDraft);
   
 
    taskInstance.setAssignee(Authentication.getAuthenticatedUserId());
    //taskInstance.setEndTime(newTaskEndTime);
    taskInstance.setCommandId(TaskCommandType.STARTEVENT);
    taskInstance.setCommandType(TaskCommandType.STARTEVENT);
    //taskInstance.setCommandMessage("流程启动");
    TaskCommandDef taskCommandDef=Context.getProcessEngineConfiguration().getTaskCommandDefMap().get(TaskCommandType.STARTEVENT);
    if(taskCommandDef!=null){
      taskInstance.setCommandMessage(taskCommandDef.getName());
    }
   
   
    taskInstance.setEndTime(ClockUtil.getCurrentTime());
    //taskInstance.setCallActivityInstanceId(subProcessInstanceId);
    executionContext.getProcessInstance().getTaskMgmtInstance().addTaskInstanceEntity(taskInstance);
    //Context.getCommandContext().getTaskManager().saveTaskInstanceEntity((TaskInstanceEntity)taskInstance);
   
  }
View Full Code Here

    TaskInstanceType newTaskTaskInstanceType = TaskInstanceType.FIXRECEIVETASK;
    String newTaskProcessDefinitionName = executionContext.getProcessDefinition().getName();
    boolean isDraft = false;

    // 创建任务
    TaskInstance taskInstance = new TaskInstanceEntity();
    taskInstance.setId(newTaskId);
    taskInstance.setNodeName(newTaskNodeName);
    taskInstance.setProcessInstanceId(newTaskProcessInstanceId);
    taskInstance.setProcessDefinitionId(newTaskProcessDefinitionId);
    taskInstance.setTokenId(newTaskTokenId);
    taskInstance.setNodeId(newTaskNodeId);
    taskInstance.setName(newTaskNodeName);
    taskInstance.setDescription(newTaskDescription);
    taskInstance.setCreateTime(newTaskCreateTime);
    taskInstance.setPriority(newTaskPriority);
    taskInstance.setProcessDefinitionKey(newTaskProcessDefinitionKey);
    taskInstance.setTaskInstanceType(newTaskTaskInstanceType);
    taskInstance.setProcessDefinitionName(newTaskProcessDefinitionName);
    taskInstance.setDraft(isDraft);
    //taskInstance.setCallActivityInstanceId(subProcessInstanceId);
    Context.getCommandContext().getTaskManager().saveTaskInstanceEntity((TaskInstanceEntity) taskInstance);

  }
View Full Code Here

  @Override
  public void leaveClearData(ExecutionContext executionContext){

    ProcessEngine processEngine=ProcessEngineManagement.getDefaultProcessEngine();
    TaskInstanceEntity taskInstance=(TaskInstanceEntity)processEngine.getTaskService().createTaskQuery().tokenId(executionContext.getToken().getId()).addTaskType(TaskInstanceType.FIXRECEIVETASK).taskNotEnd().singleResult();
    //当发现老任务,并没有创建等待接收任务的时候,不需要清理
    if(taskInstance==null){
      return;
    }
   
   
    Date newTaskEndTime=ClockUtil.getCurrentTime();
    //taskInstance.setAssigneeId("1200119390");
    taskInstance.setEndTime(newTaskEndTime);
    taskInstance.setCommandId(TaskCommandType.RECEIVEEND);
    taskInstance.setCommandType(TaskCommandType.RECEIVEEND);
    TaskCommandDef taskCommandDef=Context.getProcessEngineConfiguration().getTaskCommandDefMap().get(TaskCommandType.RECEIVEEND);
    if(taskCommandDef!=null){
      taskInstance.setCommandMessage(taskCommandDef.getName());
    }

    Context.getCommandContext().getTaskManager().saveTaskInstanceEntity(taskInstance);
   
View Full Code Here

TOP

Related Classes of com.founder.fix.fixflow.core.impl.task.TaskInstanceEntity

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.