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

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


        pageIndex = Integer.valueOf(pageI);
      }
      if(StringUtil.isNotEmpty(rowI)){
        rowNum = Integer.valueOf(rowI);
      }
      ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
      if(StringUtil.isNotEmpty(processDefinitionKey))
        processInstanceQuery.processDefinitionKey(processDefinitionKey);
      if(StringUtil.isNotEmpty(processInstanceId))
        processInstanceQuery.processInstanceId(processInstanceId);
      if(StringUtil.isNotEmpty(title))
        processInstanceQuery.subjectLike(title);
      if(StringUtil.isNotEmpty(bizKey))
        processInstanceQuery.processInstanceBusinessKeyLike(bizKey);
      if(processInstanceStatus !=null){
        processInstanceQuery.processInstanceStatus(processInstanceStatus);
      }
      if(StringUtil.isNotEmpty(initor))
        processInstanceQuery.initiator(initor);
     
     
      if(StringUtil.isNotEmpty(processType)){
        if(processType.equals("initor"))
          processInstanceQuery.initiator(userId);
        else
          processInstanceQuery.taskParticipants(userId);
      }
     
      String processDefinitionName     = StringUtil.getString(filter.get("processDefinitionName"));
      if(StringUtil.isNotEmpty(processDefinitionName))
        processInstanceQuery.processDefinitionNameLike(processDefinitionName);
     
      processInstanceQuery.orderByUpdateTime().desc();
      Date dates = null;
      Date datee = null;
      String dss = StringUtil.getString(filter.get("startTimeS"));
      String dse = StringUtil.getString(filter.get("startTimeE"));
      if(StringUtil.isNotEmpty(dss)){
        dates = DateUtil.stringToDate(dss,"yyyy-MM-dd");
      }
      if(StringUtil.isNotEmpty(dse)){
        String endTime = "235959999";
        dse += endTime;
        datee = DateUtil.stringToDate(dse,"yyyy-MM-ddHHmmssSSS");
      }
      if(dates!=null)
        processInstanceQuery.startTimeBefore(dates);
     
      if(datee!=null)
        processInstanceQuery.startTimeAfter(datee);
     
     
      List<ProcessInstance> processInstances = processInstanceQuery.listPagination(pageIndex, rowNum);
     
      List<Map<String,Object>> instanceMaps = new ArrayList<Map<String,Object>>();
      for(ProcessInstance tmp: processInstances){
        Map<String, Object> persistentState = tmp.getPersistentState();
        String processDefinitionId = tmp.getProcessDefinitionId();
        ProcessDefinitionBehavior processDefinitionBehavior = engine.getModelService().getProcessDefinition(processDefinitionId);
        String processDefinitionName1 = processDefinitionBehavior.getName();
        persistentState.put("processDefinitionName", processDefinitionName1);
        String nowNodeInfo = flowUtil.getShareTaskNowNodeInfo(tmp.getId());
        persistentState.put("nowNodeInfo", nowNodeInfo);
        UserTo user = identityService.getUserTo(tmp.getStartAuthor());
        if(user !=null){
          persistentState.put("startAuthorName", user.getUserName());
        }else{
          persistentState.put("startAuthorName", tmp.getStartAuthor());
        }
        instanceMaps.add(persistentState);
      }
      Long count = processInstanceQuery.count();
      Pagination page = new Pagination(pageIndex,rowNum);
      page.setTotal(count.intValue());
      resultMap.put("dataList", instanceMaps);
      resultMap.put("pageInfo", page);
    }finally{
View Full Code Here


    String userId = (String) filter.get("userId");
    String processType = StringUtil.getString(filter.get("processType"));
   
    ProcessEngine engine = getProcessEngine(userId);
    try{
      ProcessInstanceQuery tq = engine.getRuntimeService()
          .createProcessInstanceQuery();
     
      String bizKey = StringUtil.getString(filter.get("BIZ_KEY"))//业务数据
      if(StringUtil.isNotEmpty(bizKey))
        tq.processInstanceBusinessKey(bizKey);
     
      String initor = StringUtil.getString(filter.get("initor"))//发起人
      if(StringUtil.isNotEmpty(initor))
        tq.initiator(initor);
     
      Date dates = null;
      Date datee = null;
      String dss = StringUtil.getString(filter.get("arrivalTimeS"));
      String dse = StringUtil.getString(filter.get("arrivalTimeE"));
      if(StringUtil.isNotEmpty(dss)){
        dates = DateUtil.stringToDate(dss,"yyyy-MM-dd");
      }
      if(StringUtil.isNotEmpty(dse)){
        String endTime = "235959999";
        dse += endTime;
        datee = DateUtil.stringToDate(dse,"yyyy-MM-ddHHmmssSSS");
      }
      if(dates!=null)
        tq.archiveTimeBefore(dates);
       
     
      if(datee!=null)
        tq.archiveTimeAfter(datee);
     
      String processDefinitionKey = StringUtil.getString(filter.get("processDefinitionKey"))//流程定义
      if(StringUtil.isNotEmpty(processDefinitionKey))
        tq.processDefinitionKey(processDefinitionKey);
     
      String processInstanceId = StringUtil.getString(filter.get("processInstanceId"))//流程实例号
      if(StringUtil.isNotEmpty(processInstanceId))
        tq.processInstanceId(processInstanceId);
     
      String subject = StringUtil.getString(filter.get("subject"))//主题
      if(StringUtil.isNotEmpty(subject))
        tq.subjectLike(subject);
     
      String pageI = StringUtil.getString(filter.get("pageIndex"));
      String rowI = StringUtil.getString(filter.get("pageSize"));
     
      int pageIndex=1;
      int rowNum   =15;
      if(StringUtil.isNotEmpty(pageI)){
        pageIndex = Integer.valueOf(pageI);
      }
      if(StringUtil.isNotEmpty(rowI)){
        rowNum = Integer.valueOf(rowI);
      }
     
      if(filter.get("ended")!=null)
        tq.isEnd();
     
      List<ProcessInstance> instances = null;
      if(StringUtil.isNotEmpty(processType)){
        if(processType.equals("initor"))
          tq.initiator(userId);
        else
          tq.taskParticipants(userId);
      }
      tq.his();
      instances = tq.listPagination(pageIndex, rowNum);

      Long count = tq.count();
      List<Map<String,Object>> instanceMaps = new ArrayList<Map<String,Object>>();
      Pagination page = new Pagination(pageIndex,rowNum);
      page.setTotal(count.intValue());
      IdentityService identityService = engine.getIdentityService();
      for(ProcessInstance tmp:instances){
View Full Code Here

    ExpandClassConfig expandClassConfig=processEngineConfiguration.getExpandClassConfig();
    List<ExpandClass>  expandClasses=expandClassConfig.getExpandClass();
    for (ExpandClass expandClass : expandClasses) {
      if(expandClass.getClassId().equals("ProcessInstanceQuery")){
        Object[] objTemp = new Object[] {commandExecutor}
        ProcessInstanceQuery processInstanceQuery =(ProcessInstanceQuery) ReflectUtil.instantiate(expandClass.getClassImpl(),objTemp);
        return processInstanceQuery;
      }
    }
    throw new FixFlowException("流程引擎扩展配置里的ProcessInstanceQuery实现类指定错误");
  }
View Full Code Here

        pageIndex = Integer.valueOf(pageI);
      }
      if(StringUtil.isNotEmpty(rowI)){
        rowNum = Integer.valueOf(rowI);
      }
      ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
      if(StringUtil.isNotEmpty(processName)){
//        QueryExpandTo queryExpandTo = new QueryExpandTo();
//        //增加扩展查询的left join语句
//        List<Object> paraObjs = new ArrayList<Object>();
//        paraObjs.add("%"+processName+"%");
//        queryExpandTo.setLeftJoinSql("left join fixflow_def_processdefinition pd on PD.process_id = E.processdefinition_id");
//        queryExpandTo.setWhereSql(" PD.process_name like ? ");
//        queryExpandTo.setWhereSqlObj(paraObjs);
//        processInstanceQuery.queryExpandTo(queryExpandTo);
        processInstanceQuery.processDefinitionNameLike(processName);
       
      }
      if(StringUtil.isNotEmpty(processInstanceId))
        processInstanceQuery.processInstanceId(processInstanceId);
      if(StringUtil.isNotEmpty(subject))
        processInstanceQuery.subjectLike(subject);
      if(StringUtil.isNotEmpty(bizKey))
        processInstanceQuery.processInstanceBusinessKeyLike(bizKey);
      if(StringUtil.isNotEmpty(initor))
        processInstanceQuery.initiatorLike(initor);
      if(processInstanceStatus !=null){
        processInstanceQuery.processInstanceStatus(processInstanceStatus);
      }
      processInstanceQuery.orderByUpdateTime().desc();
      List<ProcessInstance> processInstances = processInstanceQuery.listPagination(pageIndex, rowNum);
     
      List<Map<String,Object>> instanceMaps = new ArrayList<Map<String,Object>>();
      for(ProcessInstance tmp: processInstances){
        Map<String, Object> persistentState = tmp.getPersistentState();
        String processDefinitionId = tmp.getProcessDefinitionId();
        ProcessDefinitionBehavior processDefinitionBehavior = engine.getModelService().getProcessDefinition(processDefinitionId);
        String processDefinitionName = processDefinitionBehavior.getName();
        persistentState.put("processDefinitionName", processDefinitionName);
        String nowNodeInfo = flowUtil.getShareTaskNowNodeInfo(tmp.getId());
        persistentState.put("nowNodeInfo", nowNodeInfo);
        UserTo user = identityService.getUserTo(tmp.getStartAuthor());
        if(user !=null){
          persistentState.put("startAuthorName", user.getUserName());
        }else{
          persistentState.put("startAuthorName", tmp.getStartAuthor());
        }
        instanceMaps.add(persistentState);
      }
      Long count = processInstanceQuery.count();
      Pagination page = new Pagination(pageIndex,rowNum);
      page.setTotal(count.intValue());
      resultMap.put("dataList", instanceMaps);
      resultMap.put("pageInfo", page);
    }finally{
View Full Code Here

  /**
   * 测试创建流程查询实例
   */
  public void testCreateProcessInstanceQuery(){
    //创建查询实例
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //验证是否创建成功
    assertNotNull(processInstanceQuery);
  }
View Full Code Here

    String processInstanceId = processInstance.getId();
    //暂停流程实例
    runtimeService.suspendProcessInstance(processInstanceId);
   
    //创建流程实例查询
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询刚才暂停的流程实例
    processInstanceQuery.processInstanceId(processInstanceId);
    //获取流程实例
    processInstance = processInstanceQuery.singleResult();
    //验证流程实例已经暂停
    assertTrue(processInstance.isSuspended());
   
    //恢复流程实例
    runtimeService.continueProcessInstance(processInstanceId);
   
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询刚才的流程实例
    processInstanceQuery.processInstanceId(processInstanceId);
    //获取流程实例
    processInstance = processInstanceQuery.singleResult();
    //验证不是暂停状态
    assertFalse(processInstance.isSuspended());
  }
View Full Code Here

    //获取流程实例号
    String processInstanceId = processInstance.getId();
    runtimeService.terminatProcessInstance(processInstanceId);
   
    //创建流程实例查询
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询刚才暂停的流程实例
    processInstanceQuery.processInstanceId(processInstanceId);
    //获取流程实例
    processInstance = processInstanceQuery.singleResult();
    //验证流程实例为终止状态
    assertEquals(ProcessInstanceType.TERMINATION, processInstance.getInstanceType());
  }
View Full Code Here

    assertNotNull(processInstanceId);
    //测试归档未结束的流程实例
    historyService.archiveByProcessInstanceId(processInstanceId);
   
    //创建流程实例查询
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询刚才启动的流程
    List<ProcessInstance> processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").list();
    //验证运行表已经不存在这条流程
    assertEquals(1, processInstances.size());
    //验证归档时间为null
    assertNull(processInstances.get(0).getArchiveTime());
   
    // 创建任务查询
    TaskQuery taskQuery = taskService.createTaskQuery();
    // 查找 1200119390 的这个流程实例的当前独占任务
    List<TaskInstance> taskInstances = taskQuery.taskAssignee("1200119390").processInstanceId(processInstanceId).taskNotEnd().list();
    // 获取一条任务
    TaskInstance taskInstance = taskInstances.get(0);
    //验证运行表中的归档时间不为空
    assertNull(taskInstance.getArchiveTime());
    //创建通用命令
    ExpandTaskCommand expandTaskCommandGeneral=new ExpandTaskCommand();
    //设置命令为领取任务
    expandTaskCommandGeneral.setCommandType("general");
    //设置命令的ID,需和节点上配置的按钮编号对应,会执行其中脚本
    expandTaskCommandGeneral.setUserCommandId("HandleCommand_2");
    //设置命令的处理任务号
    expandTaskCommandGeneral.setTaskId(taskInstance.getId());
    //执行通用按钮
    taskService.expandTaskComplete(expandTaskCommandGeneral, null);
   
    //将上面结束的流程进行归档
    historyService.archiveByProcessInstanceId(processInstanceId);
   
    //创建流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询刚才启动的流程
    processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").list();
    //验证运行表已经不存在这条流程
    assertEquals(0, processInstances.size());
   
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").his().list();
    //验证历史表存在这条流程
    assertEquals(1, processInstances.size());
    //验证历史表查询出的实例归档时间不为空
    assertNotNull(processInstances.get(0).getArchiveTime());
   
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").run().list();
    //验证运行表已经不存在这条流程
    assertEquals(0, processInstances.size());
   
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").run().his().list();
    //验证运行表和历史表集合中存在这条流程
    assertEquals(1, processInstances.size());
   
    //重置任务查询
    taskQuery = taskService.createTaskQuery();
View Full Code Here

    assertNotNull(processInstanceId);
    //测试归档未结束的流程实例
    historyService.archiveByProcessInstanceId(processInstanceId);
   
    //创建流程实例查询
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
    //查询刚才启动的流程
    List<ProcessInstance> processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").list();
    //验证运行表还存在这条流程,说明未结束的流程是不会被归档的
    assertEquals(1, processInstances.size());
       
    // 创建任务查询
    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);
   
    //将上面结束的流程进行归档
    historyService.archiveByProcessDefinitionKey("TaskServiceNewTest");
   
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").his().list();
    //验证运行表已经不存在这条流程
    assertEquals(1, processInstances.size());
   
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").run().list();
    //验证运行表已经不存在这条流程
    assertEquals(0, processInstances.size());
  }
View Full Code Here

      expandTaskCommandGeneral.setTaskId(taskInstance.getId());
      //执行通用按钮
      taskService.expandTaskComplete(expandTaskCommandGeneral, null);
     
      if(i == 1){
        ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
        processInstance = processInstanceQuery.processInstanceId(processInstanceId).singleResult();
        begin = processInstance.getEndTime();
      }
     
      if(i == 3){
        ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
        processInstance = processInstanceQuery.processInstanceId(processInstanceId).singleResult();
        middle = processInstance.getEndTime();
      }
     
      if(i == 4){
        ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
        processInstance = processInstanceQuery.processInstanceId(processInstanceId).singleResult();
        end = processInstance.getEndTime();
      }
      Thread.sleep(1000);
    }
    //将1和2归档
    historyService.archiveBetweenTime(null, begin);
    ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery();
    List<ProcessInstance> processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").list();
    //run表剩3个
    assertEquals(3, processInstances.size());
   
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").his().list();
    //his表剩2个
    assertEquals(2, processInstances.size());
   
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").his().run().list();
    //run和his表共3个
    assertEquals(5, processInstances.size());
   
    //将大于5归档
    historyService.archiveBetweenTime(end, null);
   
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").list();
    //run表剩2个
    assertEquals(2, processInstances.size());
   
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").his().list();
    //his表剩3个
    assertEquals(3, processInstances.size());
   
    //将3、4、5归档
    historyService.archiveBetweenTime(middle, end);
   
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").list();
    //run表剩1个
    assertEquals(1, processInstances.size());
   
    //重置流程实例查询
    processInstanceQuery = runtimeService.createProcessInstanceQuery();
    processInstances = processInstanceQuery.processDefinitionKey("TaskServiceNewTest").his().list();
    //his表剩4个
    assertEquals(4, 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.