Package org.activiti.engine.history

Examples of org.activiti.engine.history.HistoricProcessInstanceQuery


    Calendar oneYearAgo = Calendar.getInstance();
    oneYearAgo.add(Calendar.YEAR, -1);

    // Query on single short variable, should result in 2 matches
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().variableValueEquals("dateVar", date1);
    List<HistoricProcessInstance> processInstances = query.list();
    Assert.assertNotNull(processInstances);
    Assert.assertEquals(2, processInstances.size());

    // Query on two short variables, should result in single value
    query = historyService.createHistoricProcessInstanceQuery().variableValueEquals("dateVar", date1).variableValueEquals("dateVar2", date2);
    HistoricProcessInstance resultInstance = query.singleResult();
    Assert.assertNotNull(resultInstance);
    Assert.assertEquals(processInstance2.getId(), resultInstance.getId());

    // Query with unexisting variable value
    Date unexistingDate = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss").parse("01/01/1989 12:00:00");
View Full Code Here


     * @return
     */
    @Transactional(readOnly = true)
    public List<Leave> findFinishedProcessInstaces(Page<Leave> page, int[] pageParams) {
        List<Leave> results = new ArrayList<Leave>();
        HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("leave").finished().orderByProcessInstanceEndTime().desc();
        List<HistoricProcessInstance> list = query.listPage(pageParams[0], pageParams[1]);

        // 关联业务实体
        for (HistoricProcessInstance historicProcessInstance : list) {
            String businessKey = historicProcessInstance.getBusinessKey();
            Leave leave = leaveManager.getLeave(new Long(businessKey));
            leave.setProcessDefinition(getProcessDefinition(historicProcessInstance.getProcessDefinitionId()));
            leave.setHistoricProcessInstance(historicProcessInstance);
            results.add(leave);
        }
        page.setTotalCount(query.count());
        page.setResult(results);
        return results;
    }
View Full Code Here

        ModelAndView mav = new ModelAndView("/form/finished-list", Collections.singletonMap("processType", processType));
        Page<HistoricProcessInstance> page = new Page<HistoricProcessInstance>(PageUtil.PAGE_SIZE);
        int[] pageParams = PageUtil.init(page, request);

        if (!StringUtils.equals(processType, "all")) {
            HistoricProcessInstanceQuery leaveDynamicQuery = historyService.createHistoricProcessInstanceQuery()
                    .processDefinitionKey("leave-dynamic-from").finished().orderByProcessInstanceEndTime().desc();
            List<HistoricProcessInstance> list = leaveDynamicQuery.listPage(pageParams[0], pageParams[1]);

            HistoricProcessInstanceQuery dispatchQuery = historyService.createHistoricProcessInstanceQuery()
                    .processDefinitionKey("dispatch").finished().orderByProcessInstanceEndTime().desc();
            List<HistoricProcessInstance> list2 = dispatchQuery.listPage(pageParams[0], pageParams[1]);

            HistoricProcessInstanceQuery leaveJpaQuery = historyService.createHistoricProcessInstanceQuery()
                    .processDefinitionKey("leave-jpa").finished().orderByProcessInstanceEndTime().desc();
            List<HistoricProcessInstance> list3 = leaveJpaQuery.listPage(pageParams[0], pageParams[1]);

            list.addAll(list2);
            list.addAll(list3);

            page.setResult(list);
            page.setTotalCount(leaveDynamicQuery.count() + dispatchQuery.count());
        } else {
            HistoricProcessInstanceQuery dynamicQuery = historyService.createHistoricProcessInstanceQuery()
                    .finished().orderByProcessInstanceEndTime().desc();
            List<HistoricProcessInstance> list = dynamicQuery.listPage(pageParams[0], pageParams[1]);
            page.setResult(list);
            page.setTotalCount(dynamicQuery.count());
        }

        mav.addObject("page", page);
        return mav;
    }
View Full Code Here

    @RequestMapping(value = "process-instance/finished/list")
    public ModelAndView finished(Model model, HttpServletRequest request) {
        ModelAndView mav = new ModelAndView("/form/finished-list");
        Page<HistoricProcessInstance> page = new Page<HistoricProcessInstance>(PageUtil.PAGE_SIZE);
        int[] pageParams = PageUtil.init(page, request);
        HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processDefinitionKey("leave-formkey").orderByProcessInstanceEndTime().desc().finished();
        List<HistoricProcessInstance> list = query.listPage(pageParams[0], pageParams[1]);

        page.setResult(list);
        page.setTotalCount(query.count());
        mav.addObject("page", page);
        return mav;
    }
View Full Code Here

TOP

Related Classes of org.activiti.engine.history.HistoricProcessInstanceQuery

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.