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

Examples of com.founder.fix.fixflow.core.task.TaskInstance


  public void testUpadteExternalTask() {

    // 创建一个guid
    String taskIdString = GuidUtil.CreateGuid();
    // 创建一个任务(创建任务的时候createTime时间已经被自动设定)
    TaskInstance taskInstance = taskService.newTask(taskIdString);
    // 设置任务的独占处理者
    taskInstance.setAssignee("testAddExternalTask_admin");
    // 设置任务的表单
    taskInstance.setFormUri("http://www.google.com");
    // 设置任务关联键值
    taskInstance.setBizKey("1234567890");
    // 设置任务的主题
    taskInstance.setDescription("XXX系统的代办任务");
    // 设置任务的优先级
    taskInstance.setPriority(TaskInstance.PRIORITY_NORMAL);
    // 设置任务的类型,其他系统的异构流程引擎
    taskInstance.setTaskInstanceType(TaskInstanceType.OTHERBPMTASK);

    // 保存新创建的任务
    taskService.saveTask(taskInstance);

    // 查询任务
    TaskQuery taskQuery = taskService.createTaskQuery();
    taskQuery.taskAssignee("testAddExternalTask_admin");
    taskQuery.addTaskType(TaskInstanceType.OTHERBPMTASK);

    TaskInstance taskInstanceReturn = taskQuery.singleResult();

    assertNotNull(taskInstanceReturn);

    // 将任务处理者换为testAddExternalTask_test
    taskInstanceReturn.setAssignee("testAddExternalTask_test");
    taskService.saveTask(taskInstanceReturn);

    // 再次查询任务
    taskQuery = taskService.createTaskQuery();
    taskQuery.taskAssignee("testAddExternalTask_test");
View Full Code Here


  public void testAddIdentityLink() {

    // 创建一个guid
    String taskIdString = GuidUtil.CreateGuid();
    // 创建一个任务(创建任务的时候createTime时间已经被自动设定)
    TaskInstance taskInstance = taskService.newTask(taskIdString);

    // 设置任务的表单
    taskInstance.setFormUri("http://www.google.com");
    // 设置任务关联键值
    taskInstance.setBizKey("1234567890");
    // 设置任务的主题
    taskInstance.setDescription("XXX系统的代办任务");
    // 设置任务的优先级
    taskInstance.setPriority(TaskInstance.PRIORITY_NORMAL);
    // 设置任务的类型,其他系统的异构流程引擎
    taskInstance.setTaskInstanceType(TaskInstanceType.OTHERBPMTASK);

    // 保存新创建的任务
    taskService.saveTask(taskInstance);

    // 创建候选用户链接
    IdentityLink identityLink = taskService.newIdentityLink();
    // 设置任务编号
    identityLink.setTaskId(taskIdString);
    // 设置候选用户编号
    identityLink.setUserId("testAddExternalTask_admin");
    // 设置候选 包含 、排除类型
    identityLink.setIncludeExclusion(IncludeExclusion.INCLUDE);
    // 设置候选类型
    identityLink.setType(IdentityLinkType.candidate);
    // 保存候选身份
    taskService.saveIdentityLink(identityLink);

    // 查询任务
    TaskQuery taskQuery = taskService.createTaskQuery();
    // 查询候选任务
    taskQuery.taskCandidateUser("testAddExternalTask_admin");
    taskQuery.addTaskType(TaskInstanceType.OTHERBPMTASK);

    TaskInstance taskInstanceReturn = taskQuery.singleResult();

    assertNotNull(taskInstanceReturn);

  }
View Full Code Here

    TaskService taskService = processEngine.getTaskService();

    TaskQuery taskQuery = taskService.createTaskQuery();

    TaskInstance taskInstance=taskQuery.taskId(taskId).singleResult();
   
        

    return null;
View Full Code Here

    Context.getCommandContext().getTaskManager().saveTaskInstanceEntity((TaskInstanceEntity) taskInstanceCallAct);

   
    List<TaskInstance> taskInstanceQueryTos = (new GetRollBackTaskCmd(taskInstanceCallAct.getId())).execute(commandContext);
   
    TaskInstance taskInstanceQueryRollBack = null;

    for (TaskInstance taskInstanceQueryTo : taskInstanceQueryTos) {
      if (taskInstanceQueryTo.getNodeId().equals(rollBackNodeId)) {
        taskInstanceQueryRollBack = taskInstanceQueryTo;
        break;
      }
    }
    if (taskInstanceQueryRollBack == null) {
      throw new FixFlowException("主流程没有可以退回的任务!");
    }

   
   


    if (taskInstanceQueryRollBack.getTaskGroup() != null) {

      try {
       
        UserTaskBehavior backNodeUserTask = (UserTaskBehavior) parentExecutionContext.getProcessDefinition().getDefinitions().getElement(rollBackNodeId);

        parentExecutionContext.setToFlowNode(backNodeUserTask);
 
        parentToken.signal(parentExecutionContext);

       
        //taskInstance.toFlowNodeEnd(taskCommand, taskComment, backNodeUserTask, null);

      } catch (Exception e) {

        throw new FixFlowException("任务: " + taskId + " 退回失败!", e);
      }

      try {
        Context.getCommandContext().getProcessInstanceManager().saveProcessInstance(parentProcessInstance);
      } catch (Exception e) {
        throw new FixFlowException("流程实例持久化失败!", e);
      }
 

    } else {

      try {
       
        UserTaskBehavior backNodeUserTask = (UserTaskBehavior) parentExecutionContext.getProcessDefinition().getDefinitions().getElement(rollBackNodeId);

        parentExecutionContext.setToFlowNode(backNodeUserTask);
       
        parentExecutionContext.setRollBackAssignee(taskInstanceQueryRollBack.getAssignee());
       
        parentToken.signal(parentExecutionContext);
       
     
       
View Full Code Here

      rollBackNodeId = expressionValue.toString();
    } else {
      throw new FixFlowException("没有在表达式中指定退回节点!");
    }

    TaskInstance taskInstanceQueryRollBack = null;

    for (TaskInstance taskInstanceQueryTo : taskInstanceQueryTos) {
      if (taskInstanceQueryTo.getNodeId().equals(rollBackNodeId)) {
        taskInstanceQueryRollBack = taskInstanceQueryTo;
        break;
      }
    }
    if (taskInstanceQueryRollBack == null) {
      throw new FixFlowException(userTask.getId() + " 节点的退回命令上退回节点设置错误!");
    }

    String taskId = this.taskId;
    String taskComment = this.taskComment;

   
    if (taskInstanceQueryRollBack.getTaskGroup() != null) {

      try {

        UserTaskBehavior backNodeUserTask = (UserTaskBehavior) executionContext.getProcessDefinition().getDefinitions().getElement(rollBackNodeId);

        taskInstance.toFlowNodeEnd(taskCommand, taskComment, backNodeUserTask, null);

      } catch (Exception e) {

        throw new FixFlowException("任务: " + taskId + " 退回失败!", e);
      }

      try {
        saveProcessInstance(commandContext);
      } catch (Exception e) {
        throw new FixFlowException("流程实例持久化失败!", e);
      }
      return null;

    } else {

      try {
        UserTaskBehavior backNodeUserTask = (UserTaskBehavior) executionContext.getProcessDefinition().getDefinitions().getElement(rollBackNodeId);

        taskInstance.toFlowNodeEnd(taskCommand, taskComment, backNodeUserTask, taskInstanceQueryRollBack.getAssignee());

      } catch (Exception e) {

        throw new FixFlowException("任务: " + taskId + " 退回失败!", e);
      }
View Full Code Here

      throw new FixFlowBizException("当前的任务已经结束,无法继续处理!");
    }

    TaskManager taskManager=commandContext.getTaskManager();
   
    TaskInstance taskInstanceQueryRollBack = taskManager.findTaskById(rollBackTaskId);



    String taskId = this.taskId;
    String taskComment = this.taskComment;
    String rollBackNodeId = taskInstanceQueryRollBack.getNodeId();

   
    if (taskInstanceQueryRollBack.getTaskGroup() != null) {

      try {
        UserTaskBehavior backNodeUserTask = (UserTaskBehavior)getProcessInstance().getProcessDefinition().getDefinitions().getElement(rollBackNodeId);
        taskInstance.toFlowNodeEnd(taskCommand, taskComment, backNodeUserTask, null);

      } catch (Exception e) {

        throw new FixFlowException("任务: " + taskId + " 退回失败!", e);
      }

      try {
        saveProcessInstance(commandContext);
      } catch (Exception e) {
        throw new FixFlowException("流程实例持久化失败!", e);
      }
      return null;

    } else {

      try {

        UserTaskBehavior backNodeUserTask = (UserTaskBehavior) getProcessInstance().getProcessDefinition().getDefinitions().getElement(rollBackNodeId);

        taskInstance.toFlowNodeEnd(taskCommand, taskComment, backNodeUserTask, taskInstanceQueryRollBack.getAssignee());

      } catch (Exception e) {

        throw new FixFlowException("任务: " + taskId + " 退回失败!", e);
      }
View Full Code Here

      endTaskInstances = taskService.createTaskQuery().processInstanceId(taskInstanceTemp.getProcessInstanceId()).taskAssignee(userId).taskIsEnd()
          .nodeId(recoverNodeId).list();

    }

    TaskInstance recoverToTask = endTaskInstances.get(0);

    String tokenId = recoverToTask.getTokenId();
    Token recoverToToken = runtimeService.createTokenQuery().tokenId(tokenId).singleResult();
    if (recoverToToken.getEndTime() == null) {

   

 
      ProcessDefinitionBehavior processDefinition = processInstanceImpl.getProcessDefinition();

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

     

      TokenEntity tokenEntity = processInstanceImpl.getTokenMap().get(tokenId);

      tokenEntity.terminationChildTokenWithTask(taskCommand.getTaskCommandType(), taskCommand.getName(), this.taskComment, userId, this.agent, this.admin);

      //TokenEntity token = processInstanceImpl.getTokenMap().get(tokenId);

      ExecutionContext executionContext = ProcessObjectFactory.FACTORYINSTANCE.createExecutionContext(tokenEntity);

      //taskInstanceTemp.setAssigneeWithoutCascade(userId);
      taskInstanceTemp.customEnd(taskCommand, taskComment);

      tokenEntity.removeTaskInstanceSynchronization(taskCommand.getTaskCommandType(), taskCommand.getName(), this.taskComment, userId, this.agent, this.admin);

      if (recoverToTask.getTaskGroup() != null) {

        if (taskCommand != null) {

          userTask.enter(executionContext);

        }

        try {
          saveProcessInstance(commandContext);
        } catch (Exception e) {
          throw new FixFlowException("流程实例持久化失败!", e);
        }
        return null;

      } else {

        if (taskCommand != null) {

          executionContext.setRollBackAssignee(recoverToTask.getAssignee());
          userTask.enter(executionContext);

        }

        try {
          saveProcessInstance(commandContext);
        } catch (Exception e) {
          throw new FixFlowException("流程实例持久化失败!", e);
        }
        return null;

      }

    } else {
     
     
      ProcessDefinitionBehavior processDefinition = processInstanceImpl.getProcessDefinition();

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

     
     

      TokenEntity tokenEntity = processInstanceImpl.getRootToken();

      tokenEntity.terminationChildTokenWithTask(taskCommand.getTaskCommandType(), taskCommand.getName(), this.taskComment, userId, this.agent, this.admin);

      //TokenEntity token = processInstanceImpl.getTokenMap().get(tokenId);

      ExecutionContext executionContext = ProcessObjectFactory.FACTORYINSTANCE.createExecutionContext(tokenEntity);

      //taskInstanceTemp.setAssigneeWithoutCascade(userId);
      taskInstanceTemp.customEnd(taskCommand, taskComment);

      tokenEntity.removeTaskInstanceSynchronization(taskCommand.getTaskCommandType(), taskCommand.getName(), this.taskComment, userId, this.agent, this.admin);

      if (recoverToTask.getTaskGroup() != null) {

        if (taskCommand != null) {

          userTask.enter(executionContext);

        }

        try {
          saveProcessInstance(commandContext);
        } catch (Exception e) {
          throw new FixFlowException("流程实例持久化失败!", e);
        }
        return null;

      } else {

        if (taskCommand != null) {

          executionContext.setRollBackAssignee(recoverToTask.getAssignee());
          userTask.enter(executionContext);

        }

        try {
View Full Code Here

    // 创建任务查询
    TaskQuery taskQuery = taskService.createTaskQuery();
    // 查找 1200119390 的这个流程实例的当前独占任务
    List<TaskInstance> taskInstances = taskQuery.taskAssignee("1200119390").processInstanceId(processInstanceId).taskNotEnd().list();
    // 获取一条任务
    TaskInstance taskInstance = taskInstances.get(0);
    //创建通用命令
    ExpandTaskCommand expandTaskCommandGeneral=new ExpandTaskCommand();
    //设置命令为领取任务
    expandTaskCommandGeneral.setCommandType("general");
    //设置命令的ID,需和节点上配置的按钮编号对应,会执行其中脚本
    expandTaskCommandGeneral.setUserCommandId("HandleCommand_2");
    //设置命令的处理任务号
    expandTaskCommandGeneral.setTaskId(taskInstance.getId());
    //领取任务
    taskService.expandTaskComplete(expandTaskCommandGeneral, null);
   
    //获取流程变量
    variableValue = runtimeService.getProcessInstanceVariable(processInstanceId, "testEvent");
View Full Code Here

    // 创建任务查询
    TaskQuery taskQuery = taskService.createTaskQuery();
    // 查找 1200119390 的这个流程实例的当前独占任务
    List<TaskInstance> taskInstances = taskQuery.taskAssignee("1200119390").processInstanceId(processInstanceId).taskNotEnd().list();
    // 获取一条任务
    TaskInstance taskInstance = taskInstances.get(0);
    //创建通用命令
    ExpandTaskCommand expandTaskCommandGeneral=new ExpandTaskCommand();
    //设置命令为领取任务
    expandTaskCommandGeneral.setCommandType("terminationProcess");
    //设置命令的ID,需和节点上配置的按钮编号对应,会执行其中脚本
    expandTaskCommandGeneral.setUserCommandId("HandleCommand_3");
    //设置命令的处理任务号
    expandTaskCommandGeneral.setTaskId(taskInstance.getId());
    //领取任务
    taskService.expandTaskComplete(expandTaskCommandGeneral, null);
    //获取流程变量的值
    variableValue = runtimeService.getProcessInstanceVariable(processInstanceId, "testEvent");
    //在流程定义的终止事件中会将变量的值设置为“终止”详细请参考processEventTest.bpmn的流程定义
View Full Code Here

    assertNotNull(processInstanceId);

    TaskQuery taskQuery = taskService.createTaskQuery();
    // 查找 1200119390 的这个流程实例的当前独占任务
    List<TaskInstance> taskInstances = taskQuery.taskAssignee("1200119390").processInstanceId(processInstanceId).taskNotEnd().list();
    TaskInstance taskInstance = taskInstances.get(0);
    //启动子流程,并且令牌停留在UserTask_2节点
    assertEquals("UserTask_2", taskInstance.getNodeId());

    //创建一个处理命令
    expandTaskCommand = new ExpandTaskCommand();
    // 设置流程名
    expandTaskCommand.setProcessDefinitionKey("SubProcessTest");
    // 设置流程的业务关联键
    expandTaskCommand.setBusinessKey("1234567890");
    // 命令类型,通用按钮
    expandTaskCommand.setCommandType("general");
    // 设置命令的id,需和节点上配置的按钮编号对应,会执行按钮中的脚本。
    expandTaskCommand.setUserCommandId("HandleCommand_2");
    //设置任务ID
    expandTaskCommand.setTaskId(taskInstance.getId());
    //执行处理命令
    taskService.expandTaskComplete(expandTaskCommand, null);
   
    taskInstances = taskQuery.taskAssignee("1200119390").processInstanceId(processInstanceId).taskNotEnd().list();
    taskInstance = taskInstances.get(0);
    //令牌停留在UserTask_3节点
    assertEquals("UserTask_3", taskInstance.getNodeId());
   
    //创建一个处理命令
    expandTaskCommand = new ExpandTaskCommand();
    // 设置流程名
    expandTaskCommand.setProcessDefinitionKey("SubProcessTest");
    // 设置流程的业务关联键
    expandTaskCommand.setBusinessKey("1234567890");
    // 命令类型,通用按钮
    expandTaskCommand.setCommandType("general");
    // 设置命令的id,需和节点上配置的按钮编号对应,会执行按钮中的脚本。
    expandTaskCommand.setUserCommandId("HandleCommand_2");
    //设置任务ID
    expandTaskCommand.setTaskId(taskInstance.getId());
    //执行处理命令
    taskService.expandTaskComplete(expandTaskCommand, null);
   
    taskInstances = taskQuery.taskAssignee("1200119390").processInstanceId(processInstanceId).taskNotEnd().list();
    taskInstance = taskInstances.get(0);
    //令牌停留在UserTask_4节点
    assertEquals("UserTask_4", taskInstance.getNodeId());
  }
View Full Code Here

TOP

Related Classes of com.founder.fix.fixflow.core.task.TaskInstance

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.