本文整理汇总了Java中org.activiti.engine.history.HistoricProcessInstanceQuery.listPage方法的典型用法代码示例。如果您正苦于以下问题:Java HistoricProcessInstanceQuery.listPage方法的具体用法?Java HistoricProcessInstanceQuery.listPage怎么用?Java HistoricProcessInstanceQuery.listPage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.activiti.engine.history.HistoricProcessInstanceQuery
的用法示例。
在下文中一共展示了HistoricProcessInstanceQuery.listPage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPaginatedHistoryInstances
import org.activiti.engine.history.HistoricProcessInstanceQuery; //导入方法依赖的package包/类
/**
* Get paginated history instances
*
* @param start
* @param size
* @return list of BPMNInstances
*/
public BPMNInstance[] getPaginatedHistoryInstances(int start, int size){
BPMNInstance bpmnInstance;
Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
List<BPMNInstance> bpmnInstances = new ArrayList<>();
HistoryService historyService = BPMNServerHolder.getInstance().getEngine().getHistoryService();
HistoricProcessInstanceQuery query =
historyService.createHistoricProcessInstanceQuery().processInstanceTenantId(tenantId.toString())
.finished().includeProcessVariables();
historyInstanceCount = (int) query.count();
List<HistoricProcessInstance> historicProcessInstances = query.listPage(start, size);
for(HistoricProcessInstance instance: historicProcessInstances){
bpmnInstance = new BPMNInstance();
bpmnInstance.setInstanceId(instance.getId());
bpmnInstance.setProcessId(instance.getProcessDefinitionId());
bpmnInstance.setStartTime(instance.getStartTime());
bpmnInstance.setEndTime(instance.getEndTime());
bpmnInstance.setVariables(formatVariables(instance.getProcessVariables()));
bpmnInstances.add(bpmnInstance);
}
return bpmnInstances.toArray(new BPMNInstance[bpmnInstances.size()]);
}
示例2: findRunningProcessInstances
import org.activiti.engine.history.HistoricProcessInstanceQuery; //导入方法依赖的package包/类
/**
* 未结流程.
*/
public Page findRunningProcessInstances(String userId, String tenantId,
Page page) {
HistoryService historyService = processEngine.getHistoryService();
// TODO: 改成通过runtime表搜索,提高效率
long count = historyService.createHistoricProcessInstanceQuery()
.processInstanceTenantId(tenantId).startedBy(userId)
.unfinished().count();
HistoricProcessInstanceQuery query = historyService
.createHistoricProcessInstanceQuery()
.processInstanceTenantId(tenantId).startedBy(userId)
.unfinished();
if (page.getOrderBy() != null) {
String orderBy = page.getOrderBy();
if ("processInstanceStartTime".equals(orderBy)) {
query.orderByProcessInstanceStartTime();
}
if (page.isAsc()) {
query.asc();
} else {
query.desc();
}
}
List<HistoricProcessInstance> historicProcessInstances = query
.listPage((int) page.getStart(), page.getPageSize());
page.setResult(historicProcessInstances);
page.setTotalCount(count);
return page;
}
示例3: constructBPMNInstancesByProcessID
import org.activiti.engine.history.HistoricProcessInstanceQuery; //导入方法依赖的package包/类
private boolean constructBPMNInstancesByProcessID(BPMNDeletableInstances bpmnDeletableInstances, String processId, Integer
tenantId, ProcessEngine processEngine){
//first going to get the instances list of unfinished instances
HistoricProcessInstanceQuery runtimeQuery = processEngine.getHistoryService()
.createHistoricProcessInstanceQuery().processInstanceTenantId(tenantId.toString())
.includeProcessVariables().unfinished().processDefinitionId(processId);
int processInstanceCount = (int) runtimeQuery.count();
bpmnDeletableInstances.setActiveInstanceCount(processInstanceCount);
if(bpmnDeletableInstances.getActiveInstanceCount() > maximumDeleteCount){
return false;
}
if(log.isDebugEnabled()){
log.debug("Process ID has un completed instances count : " + processInstanceCount);
}
if(processInstanceCount > 0){
List<HistoricProcessInstance> instances = runtimeQuery.listPage(0, processInstanceCount + 1);
bpmnDeletableInstances.setActiveProcessInstance(instances);
}
//next get the count of finished instance for the same process id
runtimeQuery = processEngine.getHistoryService()
.createHistoricProcessInstanceQuery().processInstanceTenantId(tenantId.toString())
.includeProcessVariables().finished().processDefinitionId(processId);
int completedProcessInstanceCount = (int) runtimeQuery.count();
if((completedProcessInstanceCount + bpmnDeletableInstances.getActiveInstanceCount()) > maximumDeleteCount){
return false;
}
bpmnDeletableInstances.setCompletedInstanceCount(completedProcessInstanceCount);
bpmnDeletableInstances.addCompletedProcessDefinitionIds(processId);
if(log.isDebugEnabled()){
log.debug("Process ID has completed instances count : " + completedProcessInstanceCount);
}
return true;
}