use of org.activiti.engine.history.HistoricProcessInstanceQuery in project Activiti by Activiti.
the class HistoryServiceTest method testHistoricProcessInstanceQueryByDeploymentIdIn.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricProcessInstanceQueryByDeploymentIdIn() {
org.activiti.engine.repository.Deployment deployment = repositoryService.createDeploymentQuery().singleResult();
HashSet<String> processInstanceIds = new HashSet<String>();
for (int i = 0; i < 4; i++) {
processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
}
processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());
List<String> deploymentIds = new ArrayList<String>();
deploymentIds.add(deployment.getId());
deploymentIds.add("invalid");
HistoricProcessInstanceQuery processInstanceQuery = historyService.createHistoricProcessInstanceQuery().deploymentIdIn(deploymentIds);
assertThat(processInstanceQuery.count()).isEqualTo(5);
List<HistoricProcessInstance> processInstances = processInstanceQuery.list();
assertThat(processInstances).isNotNull();
assertThat(processInstances).hasSize(5);
deploymentIds = new ArrayList<String>();
deploymentIds.add("invalid");
processInstanceQuery = historyService.createHistoricProcessInstanceQuery().deploymentIdIn(deploymentIds);
assertThat(processInstanceQuery.count()).isEqualTo(0);
}
use of org.activiti.engine.history.HistoricProcessInstanceQuery in project Activiti by Activiti.
the class HistoryServiceTest method testHistoricProcessInstanceQueryByProcessInstanceIds.
@Deployment(resources = { "org/activiti/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricProcessInstanceQueryByProcessInstanceIds() {
HashSet<String> processInstanceIds = new HashSet<String>();
for (int i = 0; i < 4; i++) {
processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess", i + "").getId());
}
processInstanceIds.add(runtimeService.startProcessInstanceByKey("oneTaskProcess2", "1").getId());
// start an instance that will not be part of the query
runtimeService.startProcessInstanceByKey("oneTaskProcess2", "2");
HistoricProcessInstanceQuery processInstanceQuery = historyService.createHistoricProcessInstanceQuery().processInstanceIds(processInstanceIds);
assertThat(processInstanceQuery.count()).isEqualTo(5);
List<HistoricProcessInstance> processInstances = processInstanceQuery.list();
assertThat(processInstances).isNotNull();
assertThat(processInstances).hasSize(5);
for (HistoricProcessInstance historicProcessInstance : processInstances) {
assertThat(processInstanceIds.contains(historicProcessInstance.getId())).isTrue();
}
}
use of org.activiti.engine.history.HistoricProcessInstanceQuery in project alfresco-repository by Alfresco.
the class ActivitiWorkflowEngine method getWorkflowsInternal.
@SuppressWarnings("unchecked")
private List<WorkflowInstance> getWorkflowsInternal(WorkflowInstanceQuery workflowInstanceQuery, boolean isActive, int maxItems, int skipCount) {
// MNT-9074 My Tasks fails to render if tasks quantity is excessive
HistoricProcessInstanceQuery query = createQuery(workflowInstanceQuery, isActive);
LinkedList<WorkflowInstance> results = new LinkedList<WorkflowInstance>();
List<HistoricProcessInstance> completedInstances;
if (maxItems > 0) {
completedInstances = query.orderByProcessInstanceDuration().desc().listPage(skipCount, maxItems);
} else {
completedInstances = query.list();
}
List<WorkflowInstance> completedResults = typeConverter.doSpecialTenantFilterAndSafeConvert(completedInstances, new Function<HistoricProcessInstance, String>() {
public String apply(HistoricProcessInstance historicProcessInstance) {
ProcessDefinition procDef = activitiUtil.getProcessDefinition(historicProcessInstance.getProcessDefinitionId());
return procDef.getKey();
}
});
results.addAll(completedResults);
return results;
}
Aggregations