Package com.founder.fix.fixflow.core.runtime

Examples of com.founder.fix.fixflow.core.runtime.ProcessInstanceQuery


   
    //将已经结束的流程归档
    historyService.archiveAll();
   
    //创建流程实例查询
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询运行表的流程实例
    List<ProcessInstance> processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").list();
    //验证运行表剩3条
    assertEquals(3, processInstances.size());
   
    //重置流程查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询历史表数据
    processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").his().list();
    //验证历史表中有2条
    assertEquals(2, processInstances.size());
   
  }
View Full Code Here


   
    //将归档集合中的流程实例归档
    historyService.archiveByProcessInstanceIds(processInstanceIds);
   
    //创建流程实例查询
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询运行表的流程实例
    List<ProcessInstance> processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").list();
    //验证运行表剩3条
    assertEquals(3, processInstances.size());
   
    //重置流程查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询历史表数据
    processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").his().list();
    //验证历史表中有2条
    assertEquals(2, processInstances.size());
  }
View Full Code Here

    //设置命令的处理任务号
    expandTaskCommandSuspendProcessInstance.setTaskId(taskInstance.getId());
    //执行这个暂停实例的命令
    taskService.expandTaskComplete(expandTaskCommandSuspendProcessInstance, null);
    //创建流程实例查询
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //获取TaskServiceNewTest的流程实例
    List<ProcessInstance> list = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").list();
    //验证是否为2
    assertEquals(2, list.size());
   
    /**********************本例子通过扩展查询的方法获取TaskServiceNewTest流程的INSTANCE_STATUS = RUNNING的流程实例***************************/
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //创建扩展查询
    QueryExpandTo queryExpandTo = new QueryExpandTo();
    //常见扩展查询的参数列表
    List<Object> whereSqlObj = new ArrayList<Object>();
    //添加扩展wheresql语句    (本例子扩展方法查询正在运行的流程实例)
    queryExpandTo.setWhereSql("INSTANCE_STATUS = ?");
    //增加扩展wheresql的参数
    whereSqlObj.add("RUNNING");
    queryExpandTo.setWhereSqlObj(whereSqlObj);
    //增加扩展查询
    processInstanceQuery.queryExpandTo(queryExpandTo);
    //查询TaskServiceNewTest经过扩展查询后的结果
    processInstanceQuery.processDefinitionKey("TaskServiceNewTest");
    list = processInstanceQuery.list();
    //验证是否为1个
    assertEquals(1, list.size());
   
    /**********************本例子通过扩展查询的方法获取流程定义表中的procecss_name和resource_name字段***************************/
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //创建扩展查询
    queryExpandTo = new QueryExpandTo();
    //添加扩展的字段
    queryExpandTo.setFieldSql("fixflow_def_processdefinition.PROCESS_NAME,fixflow_def_processdefinition.RESOURCE_NAME");
    //增加扩展查询的left join语句
    queryExpandTo.setLeftJoinSql("left join fixflow_def_processdefinition on processdefinition_id = fixflow_def_processdefinition.process_id");
    //增加扩展查询
    processInstanceQuery.queryExpandTo(queryExpandTo);
    //查询TaskServiceNewTest经过扩展查询后的结果
    processInstanceQuery.processDefinitionKey("TaskServiceNewTest");
    list = processInstanceQuery.list();
    //获取第一个流程实例结果
    ProcessInstance  processInstance = list.get(0);
    //获取扩展查询的字段
    String process_name = (String)processInstance.getExtensionField("PROCESS_NAME");
    String RESOURCE_NAME = (String)processInstance.getExtensionField("RESOURCE_NAME");
View Full Code Here

      //验证是否成功启动
      assertNotNull(processInstanceId);
    }
   
    //重置流程实例查询
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询ProcessVariablesTest查询变量值等于"查询变量"的流程实例
    List<ProcessInstance> processInstances = processInstanceQuery.processDefinitionKey("ProcessVariablesTest").processInstanceVariableData("查询变量", false).list();
    //验证是否为0
    assertEquals(0, processInstances.size());
   
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询ProcessVariablesTest查询变量值等于"查询变量1"的流程实例
    processInstances = processInstanceQuery.processDefinitionKey("ProcessVariablesTest").processInstanceVariableData("查询变量1", false).list();
    //验证是否为5
    assertEquals(5, processInstances.size());
   
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询ProcessVariablesTest查询变量值 like "查询变量"的流程实例
    processInstances = processInstanceQuery.processDefinitionKey("ProcessVariablesTest").processInstanceVariableData("查询变量", true).list();
    //验证是否为5
    assertEquals(5, processInstances.size());
   
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询ProcessVariablesTest查询变量"queryVariable"值 like "查询变量"的流程实例
    processInstances = processInstanceQuery.processDefinitionKey("ProcessVariablesTest").processInstanceVariableData("queryVariable","查询变量1",false).list();
    //验证是否为5
    assertEquals(5, processInstances.size());
   
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询ProcessVariablesTest查询变量"queryVariable"值 like "查询变量"的流程实例
    processInstances = processInstanceQuery.processDefinitionKey("ProcessVariablesTest").processInstanceVariableData("queryVariable","查询变量",true).list();
    //验证是否为5
    assertEquals(5, processInstances.size());
   
    /**********************本例子通过扩展查询的方法获取ProcessVariablesTest流程的查询变量queryVariable =查询变量1 的流程实例***************************/
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //创建扩展查询
    QueryExpandTo queryExpandTo = new QueryExpandTo();
    //常见扩展查询的参数列表
    List<Object> whereSqlObj = new ArrayList<Object>();
    //添加扩展wheresql语句    (本例子扩展方法查询正在运行的流程实例)
    queryExpandTo.setWhereSql("PROCESSINSTANCE_ID  IN (SELECT PROCESSINSTANCE_ID FROM "+QueryTableUtil.getDefaultTableName("fixflow_run_variable")+" WHERE VARIABLE_KEY = ? AND BIZ_DATA = ?)");
    //增加扩展wheresql的参数
    whereSqlObj.add("queryVariable");
    whereSqlObj.add("查询变量1");
    queryExpandTo.setWhereSqlObj(whereSqlObj);
    //增加扩展查询
    processInstanceQuery.queryExpandTo(queryExpandTo);
    //查询TaskServiceNewTest经过扩展查询后的结果
    processInstanceQuery.processDefinitionKey("ProcessVariablesTest");
    processInstances = processInstanceQuery.list();
    //验证是否为5个
    assertEquals(5, processInstances.size());
  }
View Full Code Here

    expandTaskCommandGeneral.setTaskId(taskInstance.getId());
    //领取任务
    taskService.expandTaskComplete(expandTaskCommandGeneral, null);
   
    //创建流程实例查询
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //获得上面的流程实例
    ProcessInstance process = processInstanceQuery.processInstanceId(processInstanceId).singleResult();
    //验证流程实例是否已经结束,结束说明通用按钮已经驱动流程离开当前节点。
    assertTrue(process.hasEnded());
  }
View Full Code Here

    // 拿到流程实例ID
    String mainProcessInstanceId = processInstance.getId();
    // 验证是否成功启动
    assertNotNull(mainProcessInstanceId);
    //创建流程实例查询
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //拿到子流程实例
    ProcessInstance subProcessInstance = processInstanceQuery.processDefinitionKey("SubProcessTest").singleResult();
    //验证是否为设置的子流程
    assertEquals("SubProcessTest", subProcessInstance.getProcessDefinitionKey());
    //主流程的任务应该没有了,查询子流程中的任务
    TaskQuery taskQuery = taskService.createTaskQuery();
    // 查找 1200119390 的这个流程实例的当前独占任务
View Full Code Here

    expandTaskCommandGeneral.setTaskId(taskInstance.getId());
    //领取任务
    taskService.expandTaskComplete(expandTaskCommandGeneral, null);
   
    //创建流程实例查询
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //获得上面的流程实例
    ProcessInstance process = processInstanceQuery.processInstanceId(processInstanceId).singleResult();
    //验证流程实例是否已经结束,结束说明通用按钮已经驱动流程离开当前节点。
    assertTrue(process.hasEnded());
   
    /*********8.流程结束,查询流程追踪。***********************/
   
    //重置任务实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询1200119390参与的流程(流程追踪)
    List<ProcessInstance> processInstances = processInstanceQuery.taskParticipants("1200119390").processDefinitionKey("TaskServiceNewTest").list();
    //验证是否查询正确
    assertNotNull(processInstances);
   
  }
View Full Code Here

      assertNotNull(processInstanceId);
      //暂停1000毫秒,用来验证order by
      Thread.sleep(1000);
    }
    //流程实例查询
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //根据流程定义key查询
    List<ProcessInstance> processInstances = processInstanceQuery.processDefinitionKey("Process_TaskServiceTest").list();
    //验证是10条流程实例
    assertEquals(10, processInstances.size());
   
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //流程实例key的集合
    List<String> definitionKeys = new ArrayList<String>();
    definitionKeys.add("Process_TaskServiceTest");
    //根据key的集合查询实例
    processInstances = processInstanceQuery.processDefinitionKey(definitionKeys).list();
    //验证10条查询结果
    assertEquals(10, processInstances.size());
   
    //根据开始时间降序查询
    processInstanceQuery.orderByStartTime().desc();
    //获取第一页的0-5条结果
    processInstances = processInstanceQuery.listPage(1, 5);
    //获取第二页5-10条结果
    List<ProcessInstance> tmpProcessInstances = processInstanceQuery.listPage(6, 10);
    //取得第一条结果
    Date firstStartTime = processInstances.get(0).getStartTime();
    //验证比本页所有的时间都大,表示降序排序正确
    for(int i = 1;i < processInstances.size();i++){
      Date tmpStartTime = processInstances.get(i).getStartTime();
      assertTrue(firstStartTime.after(tmpStartTime));
    }
    //验证比第二页所有的时间都大,表示降序排序正确
    for(int i = 0;i<tmpProcessInstances.size();i++){
      Date tmpStartTime = tmpProcessInstances.get(i).getStartTime();
      assertTrue(firstStartTime.after(tmpStartTime));
    }
   
    //需要重置查询,因为order by 有叠加效果
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    processInstanceQuery.processDefinitionKey(definitionKeys);
    //根据开始时间升序排序
    processInstanceQuery.orderByStartTime().asc();
    //获取第一页的0-5条结果
    processInstances = processInstanceQuery.listPage(1, 5);
    //获取第二页5-10条结果
    tmpProcessInstances = processInstanceQuery.listPage(6, 10);
    //取得第一条结果
    firstStartTime = processInstances.get(0).getStartTime();
    //验证比本页所有的时间都小,表示升序正确
    for(int i = 1;i < processInstances.size();i++){
      Date tmpStartTime = processInstances.get(i).getStartTime();
      assertTrue(firstStartTime.before(tmpStartTime));
    }
    //验证比第二页所有的时间都小,表示升序正确
    for(int i = 0;i<tmpProcessInstances.size();i++){
      Date tmpStartTime = tmpProcessInstances.get(i).getStartTime();
      assertTrue(firstStartTime.before(tmpStartTime));
    }
   
   
    //需要重置查询,因为order by 有叠加效果
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    processInstanceQuery.processDefinitionKey(definitionKeys);
    //根据更新时间升序排序
    processInstanceQuery.orderByUpdateTime().asc();
    //获取第一页的0-5条结果
    processInstances = processInstanceQuery.listPage(1, 5);
    //获取第二页5-10条结果
    tmpProcessInstances = processInstanceQuery.listPage(6, 10);
    //取得第一条结果
    firstStartTime = processInstances.get(0).getUpdateTime();
    //验证比本页所有的时间都小,表示升序正确
    for(int i = 1;i < processInstances.size();i++){
      Date tmpStartTime = processInstances.get(i).getUpdateTime();
      assertTrue(firstStartTime.before(tmpStartTime));
    }
    //验证比第二页所有的时间都小,表示升序正确
    for(int i = 0;i<tmpProcessInstances.size();i++){
      Date tmpStartTime = tmpProcessInstances.get(i).getUpdateTime();
      assertTrue(firstStartTime.before(tmpStartTime));
    }
   
   
   
    //需要重置查询,因为order by 有叠加效果
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    processInstanceQuery.processDefinitionKey(definitionKeys);
    //根据更新时间降序序排序
    processInstanceQuery.orderByUpdateTime().desc();
    //获取第一页的0-5条结果
    processInstances = processInstanceQuery.listPage(1, 5);
    //获取第二页5-10条结果
    tmpProcessInstances = processInstanceQuery.listPage(6, 10);
    //取得第一条结果
    firstStartTime = processInstances.get(0).getUpdateTime();
    //验证比本页所有的时间都小,表示降序正确
    for(int i = 1;i < processInstances.size();i++){
      Date tmpStartTime = processInstances.get(i).getUpdateTime();
      assertTrue(firstStartTime.after(tmpStartTime));
    }
    //验证比第二页所有的时间都小,表示降序正确
    for(int i = 0;i<tmpProcessInstances.size();i++){
      Date tmpStartTime = tmpProcessInstances.get(i).getUpdateTime();
      assertTrue(firstStartTime.after(tmpStartTime));
    }
   
   
    //验证小于开始时间的查询
    //重置查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询开始时间小于某个时间的流程实例(时间在方法开始时定义)
    processInstances = processInstanceQuery.processDefinitionKey("Process_TaskServiceTest").startTimeBefore(date).list();
    //验证是否有4个
    assertEquals(4, processInstances.size());
   
    //验证大于开始时间的查询
    //重置查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询开始时间大于某个时间的流程实例(时间在方法开始时定义)
    processInstances = processInstanceQuery.processDefinitionKey("Process_TaskServiceTest").startTimeAfter(date).list();
    //验证是否有6个
    assertEquals(7, processInstances.size());
   
    //重置查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询未结束的流程实例
    processInstances = processInstanceQuery.processDefinitionKey("Process_TaskServiceTest").notEnd().list();
    //验证是否有10个
    assertEquals(10, processInstances.size());
   
    //重置查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询已结束的流程实例
    processInstances = processInstanceQuery.processDefinitionKey("Process_TaskServiceTest").isEnd().list();
    //验证是否有0个
    assertEquals(0, processInstances.size());
   
   
    //重置查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询对应bizKey的流程实例
    processInstances = processInstanceQuery.processDefinitionKey("Process_TaskServiceTest").processInstanceBusinessKey("BK_testStartProcessInstanceByKey").list();
    //验证是否有10个
    assertEquals(10, processInstances.size());
   
    //重置查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询对应bizKey的流程实例
    long count = processInstanceQuery.processDefinitionKey("Process_TaskServiceTest").processInstanceStatus(ProcessInstanceType.RUNNING).count();
    //验证是否有10个
    assertEquals(10, count);
   
    //重置查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询对应bizKey的流程实例(方法2)
    processInstances = processInstanceQuery.processInstanceBusinessKey("BK_testStartProcessInstanceByKey","Process_TaskServiceTest").list();
    //验证是否有10个
    assertEquals(10, processInstances.size());
   
    //重置查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询某人发起的流程实例
    processInstances = processInstanceQuery.processDefinitionKey("Process_TaskServiceTest").initiator("1200119390").list();
    //验证是否有10个
    assertEquals(10, processInstances.size());
   
    //重置查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询流程定义名称like“TaskServiceTes”的流程实例
    processInstances = processInstanceQuery.processDefinitionNameLike("TaskServiceTes").list();
    //验证是否有10个
    assertEquals(10, processInstances.size());
   
    //重置查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询流程定义名称等于“TaskServiceTest”的流程实例
    processInstances = processInstanceQuery.processDefinitionName("TaskServiceTest").list();
    //验证是否有10个
    assertEquals(10, processInstances.size());
   
   
    String processInstanceId = processInstances.get(0).getId();
    TaskQuery taskQuery = taskService.createTaskQuery();
    taskQuery.processInstanceId(processInstanceId).taskNotEnd();
    TaskInstance taskInstance = taskQuery.list().get(0);
   
    Date begin = new Date();
    //创建通用命令
    ExpandTaskCommand expandTaskCommandGeneral=new ExpandTaskCommand();
    //设置命令为处理
    expandTaskCommandGeneral.setCommandType("general");
    //设置命令的ID,需和节点上配置的按钮编号对应,会执行其中脚本
    expandTaskCommandGeneral.setUserCommandId("Normal_1");
    //设置命令的处理任务号
    expandTaskCommandGeneral.setTaskId(taskInstance.getId());
    //领取任务
    taskService.expandTaskComplete(expandTaskCommandGeneral, null);
    Date end = new Date();
   
    //重置查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询流程定义名称等于“TaskServiceTest”的流程实例
    processInstances = processInstanceQuery.processInstanceId(processInstanceId).list();
    //验证是否有10个
    assertTrue(processInstances.get(0).hasEnded());
   
    //重置查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询流程定义名称等于“TaskServiceTest”的流程实例
    processInstances = processInstanceQuery.processDefinitionName("TaskServiceTest").endTimeAfter(end).list();
   
    assertEquals(1, processInstances.size());
   
    //重置查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询流程定义名称等于“TaskServiceTest”的流程实例
    processInstances = processInstanceQuery.processDefinitionName("TaskServiceTest").endTimeAfter(begin).list();
   
    assertEquals(0, processInstances.size());
   
    //重置查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询流程定义名称等于“TaskServiceTest”的流程实例
    processInstances = processInstanceQuery.processDefinitionName("TaskServiceTest").endTimeBefore(begin).list();
   
    assertEquals(1, processInstances.size());
   
    //重置查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询流程定义名称等于“TaskServiceTest”的流程实例
    processInstances = processInstanceQuery.processDefinitionName("TaskServiceTest").endTimeBefore(end).list();
   
    assertEquals(0, processInstances.size());
   
    //重置查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询流程定义名称等于“TaskServiceTest”的流程实例
    processInstances = processInstanceQuery.processDefinitionName("TaskServiceTest").endTimeOn(end).list();
   
    assertEquals(0, processInstances.size());
   
   
  }
View Full Code Here

TOP

Related Classes of com.founder.fix.fixflow.core.runtime.ProcessInstanceQuery

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.