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

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


 
  @SuppressWarnings({ "unchecked", "rawtypes" })
  public List<TaskInstance> execute(CommandContext commandContext) {
    TaskManager taskManager = commandContext.getTaskManager();

    TaskInstance taskInstanceQuery = taskManager.findTaskById(taskId);
   
   
    String tokenId = taskInstanceQuery.getTokenId();
    String processDefinitionId = taskInstanceQuery.getProcessDefinitionId();
    ProcessInstanceManager processInstanceManager = commandContext.getProcessInstanceManager();

    String processInstanceId = taskInstanceQuery.getProcessInstanceId();

    ProcessDefinitionManager processDefinitionManager = commandContext.getProcessDefinitionManager();

    ProcessDefinitionBehavior processDefinition = processDefinitionManager.findLatestProcessDefinitionById(processDefinitionId);
View Full Code Here


  public List<TaskInstance> execute(CommandContext commandContext) {
   
   
    TaskManager taskManager = commandContext.getTaskManager();

    TaskInstance taskInstanceQuery = taskManager.findTaskById(taskId);
   
    if(taskId==null||taskId.equals("")){
      throw new FixFlowException("taskId不能为空");
    }

   
    if(taskInstanceQuery==null){
      throw new FixFlowException("没有查询到相关任务");
    }
   


   

    ProcessEngine processEngine = ProcessEngineManagement.getDefaultProcessEngine();
    TaskQuery taskQuery = processEngine.getTaskService().createTaskQuery();
    List<TaskInstance> taskInstancesEnd = taskQuery.processInstanceId(taskInstanceQuery.getProcessInstanceId())
        .taskAssignee(Authentication.getAuthenticatedUserId()).addTaskType(TaskInstanceType.FIXFLOWTASK).addTaskType(TaskInstanceType.FIXNOTICETASK).taskIsEnd().list();

    String tokenId = taskInstanceQuery.getTokenId();
    String nodeId = taskInstanceQuery.getNodeId();
    String processDefinitionId = taskInstanceQuery.getProcessDefinitionId();
    ProcessInstanceManager processInstanceManager = Context.getCommandContext().getProcessInstanceManager();

    String processInstanceId = taskInstanceQuery.getProcessInstanceId();

    ProcessDefinitionManager processDefinitionManager = Context.getCommandContext().getProcessDefinitionManager();

    ProcessDefinitionBehavior processDefinition = processDefinitionManager.findLatestProcessDefinitionById(processDefinitionId);
View Full Code Here

   
    TaskManager taskManager = commandContext.getTaskManager();
    if(taskId==null||taskId.equals("")){
      throw new FixFlowBizException("taskId 不能为空");
    }
    TaskInstance taskInstanceQuery = taskManager.findTaskById(taskId);
   
   
   
    String tokenId = taskInstanceQuery.getTokenId();
    String processDefinitionId = taskInstanceQuery.getProcessDefinitionId();
    ProcessInstanceManager processInstanceManager = commandContext.getProcessInstanceManager();

    String processInstanceId = taskInstanceQuery.getProcessInstanceId();

    ProcessDefinitionManager processDefinitionManager = commandContext.getProcessDefinitionManager();

    ProcessDefinitionBehavior processDefinition = processDefinitionManager.findLatestProcessDefinitionById(processDefinitionId);

    ProcessInstanceEntity processInstanceImpl = processInstanceManager.findProcessInstanceById(processInstanceId, processDefinition);

    TokenEntity token=processInstanceImpl.getTokenMap().get(tokenId);
   
   
   
    List<String> tokenIdList=new ArrayList<String>();
   

    addTokenParent(token, tokenIdList);
   
    //获取这个节点关系上之前的所有人工任务(UserTask)
    Map<String,FlowNode> flowNodes=CoreUtil.getBeforeFlowNode(token.getFlowNode());
   
    //获取这个令牌自己和爸爸相关的所有任务

   
    TaskQuery taskQuery=new TaskQueryImpl(Context.getCommandContext());


    List<TaskInstance> taskInstanceQueryToList = new ArrayList<TaskInstance>();


    taskQuery.processInstanceId(processInstanceId);
    taskQuery.taskIsEnd().orderByEndTime().asc().orderByTaskCreateTime().asc();
    taskInstanceQueryToList = taskQuery.list();
   
   
   
    List<String> processInstanceIdList=new ArrayList<String>();
    processInstanceIdList.add(token.getProcessInstanceId());
    taskManager.getTaskStatusByByProcessInstanceIdList(processInstanceIdList);
   
    //List<TaskInstance> taskInstanceQueryToList=(List)taskManager.findTasksByTokenIdList(tokenIdList);
    List<TaskInstance> taskInstanceQueryToListNew=new ArrayList<TaskInstance>();
    //Map<String, TaskInstance> taskMap=new HashMap<String, TaskInstance>();
   
    //TaskInstance previousTaskInstance=null;
   
    Map<String, String> pcNodeMap= new HashMap<String, String>();
    String tempString=taskInstanceQuery.getNodeId()+Authentication.getAuthenticatedUserId();
   
   
    for (int i = 0; i < taskInstanceQueryToList.size(); i++) {
      TaskInstance taskInstance=taskInstanceQueryToList.get(i);
     
      if(flowNodes.get(taskInstance.getNodeId())!=null&&!taskInstance.getId().equals(this.taskId)){
       
       
       
        if(!tempString.equals(taskInstance.getNodeId()+taskInstance.getAssignee())){
          //taskInstanceQueryToListNew.add(taskInstance);
          if(pcNodeMap.get(taskInstance.getNodeId()+taskInstance.getAssignee())==null){
            taskInstanceQueryToListNew.add(taskInstance);
            pcNodeMap.put(taskInstance.getNodeId()+taskInstance.getAssignee(), "");
          }
          //taskMap.put(taskInstance.getNodeId(), taskInstance);
        }
       
       
View Full Code Here

    // 获取任务管理器
    ProcessInstanceManager processInstanceManager = commandContext.getProcessInstanceManager();

    // 根据指定id查询出任务的TO 不能做改变操作
    TaskInstance taskInstanceQuery = taskManager.findTaskById(taskId);

    if (taskInstanceQuery == null) {
      throw new FixFlowBizException("未查询到指定的任务");
    }

    String processInstanceId = taskInstanceQuery.getProcessInstanceId();

    String tokenId = taskInstanceQuery.getTokenId();

    String nodeId = taskInstanceQuery.getNodeId();

    this.processInstanceAbstract = processInstanceManager.findProcessInstanceById(processInstanceId);

    TokenEntity tokenEntity = this.processInstanceAbstract.getTokenMap().get(tokenId);
View Full Code Here

    TaskInstanceType newTaskTaskInstanceType = TaskInstanceType.INTERMEDIATECATCHEVENT;
    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

    taskQuery.processDefinitionKey("TaskServiceNewTest");
    List<TaskInstance> list = taskQuery.list();
    //验证是否为1个
    assertEquals(1, list.size());
    //获取得到的任务实例
    TaskInstance taskInstance = list.get(0);
    //验证得到的任务实例nodeid是否正确
    assertEquals("UserTask_1", taskInstance.getNodeId());
   
    /**********************本例子通过扩展查询的方法获取流程定义表中的procecss_name和resource_name字段***************************/
    //重置流程实例查询
    taskQuery = taskService.createTaskQuery();
    //创建扩展查询
    queryExpandTo = new QueryExpandTo();
    //添加扩展的字段
    queryExpandTo.setFieldSql("fixflow_def_processdefinition.PROCESS_NAME,fixflow_def_processdefinition.RESOURCE_NAME");
    //增加扩展查询的left join语句(taskinstance持久化层的别名是“T”所以连接时需要加上,否则可能出现“未明确定义列”)
    queryExpandTo.setLeftJoinSql("left join fixflow_def_processdefinition on T.processdefinition_id = fixflow_def_processdefinition.process_id");
    //增加扩展查询
    taskQuery.queryExpandTo(queryExpandTo);
    //查询TaskServiceNewTest经过扩展查询后的结果
    taskQuery.processDefinitionKey("TaskServiceNewTest");
    list = taskQuery.list();
    //获取第一个流程实例结果
    taskInstance = list.get(0);
    //获取扩展查询的字段
    String process_name = (String)taskInstance.getExtensionField("PROCESS_NAME");
    String RESOURCE_NAME = (String)taskInstance.getExtensionField("RESOURCE_NAME");
    //验证获得的扩展字段是否正确
    assertEquals("流程名称", process_name);
    assertEquals("com/founder/fix/fixflow/test/engine/api/task/TaskServiceNewTest.bpmn", RESOURCE_NAME);
  }
View Full Code Here

   */
  public void testVariableData(){
    // 创建一个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);
   
    // 为任务创建变量
    taskService.setVariable(taskInstance.getId(), "变量", "变量值");
    //创建任务查询
    TaskQuery taskQuery = taskService.createTaskQuery();
    //查询变量等于“变量”的任务实例
    List<TaskInstance> taskInstances = taskQuery.variableData("变量", false).list();
    assertEquals(0, taskInstances.size());
View Full Code Here

  public void testAddExternalTask() {

    // 创建一个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);

  }
View Full Code Here

  public void testTaskVariable() {

    // 创建一个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);

    /* 任务变量 */

    // 为任务创建变量
    taskService.setVariable(taskInstanceReturn.getId(), "变量", "变量值");
    // 查询任务的变量
    Object returnValue = taskService.getVariable(taskInstanceReturn.getId(), "变量");
    // 将取回的变量值比较
    assertEquals(returnValue, "变量值");

    /* 流程实例变量 */

 
View Full Code Here

   */
  public void testDeleteExternalTask() {
    // 创建一个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);

    // 级联删除任务信息
    taskService.deleteTask(taskInstanceReturn.getId(), true);

    // 再次查询任务

    // 查询任务
    taskQuery = taskService.createTaskQuery();
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.