org.activiti.engine.history.HistoricProcessInstanceQuery Java Examples

The following examples show how to use org.activiti.engine.history.HistoricProcessInstanceQuery. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActivitiServiceTest.java    From herd with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetHistoricProcessInstancesByStatusAndProcessDefinitionKeysWhenStatusNotSpecified()
{
    JobStatusEnum jobStatus = null;
    Collection<String> processDefinitionKeys = new ArrayList<>();
    DateTime startTime = new DateTime();
    DateTime endTime = new DateTime();
    HistoricProcessInstanceQuery historicProcessInstanceQuery = mock(HistoricProcessInstanceQuery.class);
    when(activitiHistoryService.createHistoricProcessInstanceQuery()).thenReturn(historicProcessInstanceQuery);
    when(historicProcessInstanceQuery.processDefinitionKeyIn(new ArrayList<>(processDefinitionKeys))).thenReturn(historicProcessInstanceQuery);
    when(historicProcessInstanceQuery.unfinished()).thenReturn(historicProcessInstanceQuery);
    when(historicProcessInstanceQuery.startedAfter(startTime.toDate())).thenReturn(historicProcessInstanceQuery);
    when(historicProcessInstanceQuery.finishedBefore(endTime.toDate())).thenReturn(historicProcessInstanceQuery);
    List<HistoricProcessInstance> expectedHistoricProcessInstances = new ArrayList<>();
    when(historicProcessInstanceQuery.list()).thenReturn(expectedHistoricProcessInstances);
    List<HistoricProcessInstance> actualHistoricProcessInstance =
        activitiService.getHistoricProcessInstancesByStatusAndProcessDefinitionKeys(jobStatus, processDefinitionKeys, startTime, endTime);
    assertSame(expectedHistoricProcessInstances, actualHistoricProcessInstance);
    InOrder inOrder = inOrder(historicProcessInstanceQuery);
    inOrder.verify(historicProcessInstanceQuery).processDefinitionKeyIn(new ArrayList<>(processDefinitionKeys));
    inOrder.verify(historicProcessInstanceQuery).startedAfter(startTime.toDate());
    inOrder.verify(historicProcessInstanceQuery).finishedBefore(endTime.toDate());
    inOrder.verify(historicProcessInstanceQuery).list();
    inOrder.verifyNoMoreInteractions();
}
 
Example #2
Source File: AbstractRelatedContentResource.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
public ResultListDataRepresentation getRelatedProcessInstancesForContent(String source, String sourceId) {
    Page<RelatedContent> relatedContents = contentService.getRelatedContent(source, sourceId, MAX_CONTENT_ITEMS, 0);
    Set<String> processInstanceIds = new HashSet<String>(relatedContents.getSize());
    for(RelatedContent relatedContent : relatedContents)
    {
        processInstanceIds.add(relatedContent.getProcessInstanceId());
    }
    List<HistoricProcessInstance> processInstances;
    if (processInstanceIds.isEmpty()) {
        processInstances = new LinkedList<HistoricProcessInstance>();
    }
    else {
        // todo consider using runtimeService and ProcessInstance queries instead, but then ProcessInstance must return start user id
        HistoricProcessInstanceQuery processInstanceQuery = historyService.createHistoricProcessInstanceQuery();
        User currentUser = SecurityUtils.getCurrentUserObject();
        processInstanceQuery.involvedUser(String.valueOf(currentUser.getId()));
        processInstanceQuery.processInstanceIds(processInstanceIds);
        processInstanceQuery.orderByProcessInstanceId().desc();
        processInstances = processInstanceQuery.listPage(0, MAX_CONTENT_ITEMS);
    }
    ResultListDataRepresentation result = new ResultListDataRepresentation(convertInstanceList(processInstances));
    return result;
}
 
Example #3
Source File: ActivitiServiceTest.java    From herd with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetHistoricProcessInstancesByStatusAndProcessDefinitionKeys()
{
    JobStatusEnum jobStatus = JobStatusEnum.RUNNING;
    Collection<String> processDefinitionKeys = new ArrayList<>();
    DateTime startTime = new DateTime();
    DateTime endTime = new DateTime();
    HistoricProcessInstanceQuery historicProcessInstanceQuery = mock(HistoricProcessInstanceQuery.class);
    when(activitiHistoryService.createHistoricProcessInstanceQuery()).thenReturn(historicProcessInstanceQuery);
    when(historicProcessInstanceQuery.processDefinitionKeyIn(new ArrayList<>(processDefinitionKeys))).thenReturn(historicProcessInstanceQuery);
    when(historicProcessInstanceQuery.unfinished()).thenReturn(historicProcessInstanceQuery);
    when(historicProcessInstanceQuery.startedAfter(startTime.toDate())).thenReturn(historicProcessInstanceQuery);
    when(historicProcessInstanceQuery.finishedBefore(endTime.toDate())).thenReturn(historicProcessInstanceQuery);
    List<HistoricProcessInstance> expectedHistoricProcessInstances = new ArrayList<>();
    when(historicProcessInstanceQuery.list()).thenReturn(expectedHistoricProcessInstances);
    List<HistoricProcessInstance> actualHistoricProcessInstance =
        activitiService.getHistoricProcessInstancesByStatusAndProcessDefinitionKeys(jobStatus, processDefinitionKeys, startTime, endTime);
    assertSame(expectedHistoricProcessInstances, actualHistoricProcessInstance);
    InOrder inOrder = inOrder(historicProcessInstanceQuery);
    inOrder.verify(historicProcessInstanceQuery).processDefinitionKeyIn(new ArrayList<>(processDefinitionKeys));
    inOrder.verify(historicProcessInstanceQuery).unfinished();
    inOrder.verify(historicProcessInstanceQuery).startedAfter(startTime.toDate());
    inOrder.verify(historicProcessInstanceQuery).finishedBefore(endTime.toDate());
    inOrder.verify(historicProcessInstanceQuery).list();
    inOrder.verifyNoMoreInteractions();
}
 
Example #4
Source File: ActivitiServiceTest.java    From herd with Apache License 2.0 6 votes vote down vote up
@Test
public void getHistoricProcessInstancesCountByStatusAndProcessDefinitionKeys()
{
    JobStatusEnum jobStatus = JobStatusEnum.RUNNING;
    Collection<String> processDefinitionKeys = new ArrayList<>();
    DateTime startTime = new DateTime();
    DateTime endTime = new DateTime();
    HistoricProcessInstanceQuery historicProcessInstanceQuery = mock(HistoricProcessInstanceQuery.class);
    when(activitiHistoryService.createHistoricProcessInstanceQuery()).thenReturn(historicProcessInstanceQuery);
    when(historicProcessInstanceQuery.processDefinitionKeyIn(new ArrayList<>(processDefinitionKeys))).thenReturn(historicProcessInstanceQuery);
    when(historicProcessInstanceQuery.unfinished()).thenReturn(historicProcessInstanceQuery);
    when(historicProcessInstanceQuery.startedAfter(startTime.toDate())).thenReturn(historicProcessInstanceQuery);
    when(historicProcessInstanceQuery.finishedBefore(endTime.toDate())).thenReturn(historicProcessInstanceQuery);
    long expectedResult = 1234l;
    when(historicProcessInstanceQuery.count()).thenReturn(expectedResult);
    long actualResult =
        activitiService.getHistoricProcessInstancesCountByStatusAndProcessDefinitionKeys(jobStatus, processDefinitionKeys, startTime, endTime);
    assertEquals(expectedResult, actualResult);
    InOrder inOrder = inOrder(historicProcessInstanceQuery);
    inOrder.verify(historicProcessInstanceQuery).processDefinitionKeyIn(new ArrayList<>(processDefinitionKeys));
    inOrder.verify(historicProcessInstanceQuery).unfinished();
    inOrder.verify(historicProcessInstanceQuery).startedAfter(startTime.toDate());
    inOrder.verify(historicProcessInstanceQuery).finishedBefore(endTime.toDate());
    inOrder.verify(historicProcessInstanceQuery).count();
    inOrder.verifyNoMoreInteractions();
}
 
Example #5
Source File: HistoryServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = { "org/activiti5/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti5/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);
  assertEquals(5, processInstanceQuery.count());

  List<HistoricProcessInstance> processInstances = processInstanceQuery.list();
  assertNotNull(processInstances);
  assertEquals(5, processInstances.size());
  
  deploymentIds = new ArrayList<String>();
  deploymentIds.add("invalid");
  processInstanceQuery = historyService.createHistoricProcessInstanceQuery().deploymentIdIn(deploymentIds);
  assertEquals(0, processInstanceQuery.count());
}
 
Example #6
Source File: HistoryServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@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);
  assertEquals(5, processInstanceQuery.count());

  List<HistoricProcessInstance> processInstances = processInstanceQuery.list();
  assertNotNull(processInstances);
  assertEquals(5, processInstances.size());

  for (HistoricProcessInstance historicProcessInstance : processInstances) {
    assertTrue(processInstanceIds.contains(historicProcessInstance.getId()));
  }
}
 
Example #7
Source File: ActivitiServiceTest.java    From herd with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetHistoricProcessInstanceByProcessInstanceId()
{
    String processInstanceId = "processInstanceId";
    HistoricProcessInstanceQuery historicProcessInstanceQuery = mock(HistoricProcessInstanceQuery.class);
    when(activitiHistoryService.createHistoricProcessInstanceQuery()).thenReturn(historicProcessInstanceQuery);
    when(historicProcessInstanceQuery.processInstanceId(processInstanceId)).thenReturn(historicProcessInstanceQuery);
    when(historicProcessInstanceQuery.includeProcessVariables()).thenReturn(historicProcessInstanceQuery);
    HistoricProcessInstance expectedHistoricProcessInstance = mock(HistoricProcessInstance.class);
    when(historicProcessInstanceQuery.singleResult()).thenReturn(expectedHistoricProcessInstance);
    HistoricProcessInstance actualHistoricProcessInstance = activitiService.getHistoricProcessInstanceByProcessInstanceId(processInstanceId);
    assertSame(expectedHistoricProcessInstance, actualHistoricProcessInstance);
    InOrder inOrder = inOrder(historicProcessInstanceQuery);
    inOrder.verify(historicProcessInstanceQuery).processInstanceId(processInstanceId);
    inOrder.verify(historicProcessInstanceQuery).includeProcessVariables();
    inOrder.verify(historicProcessInstanceQuery).singleResult();
    inOrder.verifyNoMoreInteractions();
}
 
Example #8
Source File: HistoryServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = { "org/activiti5/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti5/engine/test/api/runtime/oneTaskProcess2.bpmn20.xml" })
public void testHistoricProcessInstanceQueryByDeploymentId() {
  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());

  HistoricProcessInstanceQuery processInstanceQuery = historyService.createHistoricProcessInstanceQuery().deploymentId(deployment.getId());
  assertEquals(5, processInstanceQuery.count());
  assertEquals(deployment.getId(), processInstanceQuery.list().get(0).getDeploymentId());

  List<HistoricProcessInstance> processInstances = processInstanceQuery.list();
  assertNotNull(processInstances);
  assertEquals(5, processInstances.size());
  
  processInstanceQuery = historyService.createHistoricProcessInstanceQuery().deploymentId("invalid");
  assertEquals(0, processInstanceQuery.count());
}
 
Example #9
Source File: HistoryServiceTest.java    From activiti6-boot2 with Apache License 2.0 6 votes vote down vote up
@Deployment(resources = { "org/activiti5/engine/test/api/oneTaskProcess.bpmn20.xml", "org/activiti5/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);
  assertEquals(5, processInstanceQuery.count());

  List<HistoricProcessInstance> processInstances = processInstanceQuery.list();
  assertNotNull(processInstances);
  assertEquals(5, processInstances.size());

  for (HistoricProcessInstance historicProcessInstance : processInstances) {
    assertTrue(processInstanceIds.contains(historicProcessInstance.getId()));
  }
}
 
Example #10
Source File: HistoricProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricProcessInstanceQuery processInstanceWithoutTenantId() {
    if (inOrStatement) {
        this.currentOrQueryObject.withoutTenantId = true;
    } else {
        this.withoutTenantId = true;
    }
    return this;
}
 
Example #11
Source File: HistoricProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricProcessInstanceQuery processInstanceName(String name) {
    if (inOrStatement) {
        this.currentOrQueryObject.name = name;
    } else {
        this.name = name;
    }
    return this;
}
 
Example #12
Source File: HistoricProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricProcessInstanceQuery variableValueGreaterThanOrEqual(String name, Object value) {
    if (inOrStatement) {
        currentOrQueryObject.variableValueGreaterThanOrEqual(name, value, true);
        return this;
    } else {
        return variableValueGreaterThanOrEqual(name, value, true);
    }
}
 
Example #13
Source File: HistoricProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricProcessInstanceQuery processInstanceTenantId(String tenantId) {
    if (tenantId == null) {
        throw new ActivitiIllegalArgumentException("process instance tenant id is null");
    }
    if (inOrStatement) {
        this.currentOrQueryObject.tenantId = tenantId;
    } else {
        this.tenantId = tenantId;
    }
    return this;
}
 
Example #14
Source File: HistoricProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricProcessInstanceQuery variableValueGreaterThan(String name, Object value) {
    if (inOrStatement) {
        currentOrQueryObject.variableValueGreaterThan(name, value, true);
        return this;
    } else {
        return variableValueGreaterThan(name, value, true);
    }
}
 
Example #15
Source File: HistoricProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricProcessInstanceQuery processDefinitionKeyNotIn(List<String> processDefinitionKeys) {
    if (inOrStatement) {
        this.currentOrQueryObject.processKeyNotIn = processDefinitionKeys;
    } else {
        this.processKeyNotIn = processDefinitionKeys;
    }
    return this;
}
 
Example #16
Source File: HistoricProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricProcessInstanceQuery notDeleted() {
    if (inOrStatement) {
        this.currentOrQueryObject.notDeleted = true;
    } else {
        this.notDeleted = true;
    }
    return this;
}
 
Example #17
Source File: HistoricProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricProcessInstanceQuery processDefinitionKeyIn(List<String> processDefinitionKeys) {
    if (inOrStatement) {
        currentOrQueryObject.processDefinitionKeyIn = processDefinitionKeys;
    } else {
        this.processDefinitionKeyIn = processDefinitionKeys;
    }
    return this;
}
 
Example #18
Source File: HistoricProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricProcessInstanceQuery processInstanceBusinessKey(String businessKey) {
    if (inOrStatement) {
        this.currentOrQueryObject.businessKey = businessKey;
    } else {
        this.businessKey = businessKey;
    }
    return this;
}
 
Example #19
Source File: HistoricProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricProcessInstanceQuery deploymentIdIn(List<String> deploymentIds) {
    if (inOrStatement) {
        currentOrQueryObject.deploymentIds = deploymentIds;
    } else {
        this.deploymentIds = deploymentIds;
    }
    return this;
}
 
Example #20
Source File: ProcessInstanceResourceRepository.java    From crnk-framework with Apache License 2.0 5 votes vote down vote up
@Override
public <S extends T> S create(S resource) {
	checkFilter(resource, true);

	String processDefinitionKey = resource.getProcessDefinitionKey();
	String businessKey = resource.getBusinessKey();
	String tenantId = resource.getTenantId();
	Map<String, Object> variables = resourceMapper.mapToVariables(resource);

	ProcessInstance processInstance =
			runtimeService.startProcessInstanceByKeyAndTenantId(processDefinitionKey, businessKey, variables, tenantId);

	applyUpdates(processInstance, resource);

	ProcessInstanceQuery processInstanceQuery = runtimeService.createProcessInstanceQuery().processInstanceId(processInstance.getId());
	processInstanceQuery.includeProcessVariables();
	ProcessInstance updatedProcessInstance = processInstanceQuery.singleResult();
	if (updatedProcessInstance != null) {
		return (S) mapResult(updatedProcessInstance);
	}

	// process already terminated, unfortunately no shared interfaces
	HistoricProcessInstanceQuery historicQuery = historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstance.getId());
	historicQuery.includeProcessVariables();
	HistoricProcessInstance historicProcessInstance = historicQuery.singleResult();
	PreconditionUtil.verify(historicProcessInstance != null, "could not found potentially terminated process instance with id %s", processInstance.getId());
	ProcessInstance finishedProcessInstance = new MappedHistoricProcessInstance(historicProcessInstance);
	S result = (S) mapResult(finishedProcessInstance);
	result.setName(resource.getName());
	result.setBusinessKey(resource.getBusinessKey());
	return result;
}
 
Example #21
Source File: ProcessEngineService.java    From open-cloud with MIT License 5 votes vote down vote up
/**
 * 读取已结束的流程
 *
 * @param processDefinitionKey
 * @param startRow
 * @param endRow
 * @return
 */
public List<HistoricProcessInstance> findFinishedProcessInstaces(String processDefinitionKey, int startRow, int endRow) {
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().finished().orderByProcessInstanceEndTime().desc();
    if (org.apache.commons.lang3.StringUtils.isNotEmpty(processDefinitionKey)) {
        query.processDefinitionKey(processDefinitionKey);
    }
    List<HistoricProcessInstance> list = query.listPage(startRow, endRow);
    return list;
}
 
Example #22
Source File: HistoricProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricProcessInstanceQuery deleted() {
    if (inOrStatement) {
        this.currentOrQueryObject.deleted = true;
    } else {
        this.deleted = true;
    }
    return this;
}
 
Example #23
Source File: HistoricProcessInstanceQueryAndWithExceptionTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryWithException() throws InterruptedException{
  ProcessInstance processNoException = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY_NO_EXCEPTION);
  
  HistoricProcessInstanceQuery queryNoException = historyService.createHistoricProcessInstanceQuery();
  assertEquals(1, queryNoException.count());
  assertEquals(1, queryNoException.list().size());
  assertEquals(processNoException.getId(), queryNoException.list().get(0).getId());

  HistoricProcessInstanceQuery queryWithException = historyService.createHistoricProcessInstanceQuery();
  assertEquals(0, queryWithException.withJobException().count());
  assertEquals(0, queryWithException.withJobException().list().size());
  
  ProcessInstance processWithException1 = startProcessInstanceWithFailingJob(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_1);
  TimerJobQuery jobQuery1 = managementService.createTimerJobQuery().processInstanceId(processWithException1.getId());
  assertEquals(1, jobQuery1.withException().count());
  assertEquals(1, jobQuery1.withException().list().size());
  assertEquals(1, queryWithException.withJobException().count());
  assertEquals(1, queryWithException.withJobException().list().size());
  assertEquals(processWithException1.getId(), queryWithException.withJobException().list().get(0).getId());

  ProcessInstance processWithException2 = startProcessInstanceWithFailingJob(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_2);
  TimerJobQuery jobQuery2 = managementService.createTimerJobQuery().processInstanceId(processWithException2.getId());
  assertEquals(2, jobQuery2.withException().count());
  assertEquals(2, jobQuery2.withException().list().size());

  assertEquals(2, queryWithException.withJobException().count());
  assertEquals(2, queryWithException.withJobException().list().size());
  assertEquals(processWithException1.getId(), queryWithException.withJobException().processDefinitionKey(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_1).list().get(0).getId());
  assertEquals(processWithException2.getId(), queryWithException.withJobException().processDefinitionKey(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_2).list().get(0).getId());
}
 
Example #24
Source File: HistoricProcessInstanceQueryAndWithExceptionTest.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public void testQueryWithException() throws InterruptedException {
  if (processEngineConfiguration.getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
    ProcessInstance processNoException = runtimeService.startProcessInstanceByKey(PROCESS_DEFINITION_KEY_NO_EXCEPTION);
    
    HistoricProcessInstanceQuery queryNoException = historyService.createHistoricProcessInstanceQuery();
    assertEquals(1, queryNoException.count());
    assertEquals(1, queryNoException.list().size());
    assertEquals(processNoException.getId(), queryNoException.list().get(0).getId());

    HistoricProcessInstanceQuery queryWithException = historyService.createHistoricProcessInstanceQuery();
    assertEquals(0, queryWithException.withJobException().count());
    assertEquals(0, queryWithException.withJobException().list().size());
    
    ProcessInstance processWithException1 = startProcessInstanceWithFailingJob(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_1);
    TimerJobQuery jobQuery1 = managementService.createTimerJobQuery().processInstanceId(processWithException1.getId());
    assertEquals(1, jobQuery1.withException().count());
    assertEquals(1, jobQuery1.withException().list().size());
    assertEquals(1, queryWithException.withJobException().count());
    assertEquals(1, queryWithException.withJobException().list().size());
    assertEquals(processWithException1.getId(), queryWithException.withJobException().list().get(0).getId());

    ProcessInstance processWithException2 = startProcessInstanceWithFailingJob(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_2);
    TimerJobQuery jobQuery2 = managementService.createTimerJobQuery().processInstanceId(processWithException2.getId());
    assertEquals(2, jobQuery2.withException().count());
    assertEquals(2, jobQuery2.withException().list().size());

    assertEquals(2, queryWithException.withJobException().count());
    assertEquals(2, queryWithException.withJobException().list().size());
    assertEquals(processWithException1.getId(), queryWithException.withJobException().processDefinitionKey(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_1).list().get(0).getId());
    assertEquals(processWithException2.getId(), queryWithException.withJobException().processDefinitionKey(PROCESS_DEFINITION_KEY_WITH_EXCEPTION_2).list().get(0).getId());
  }
}
 
Example #25
Source File: HistoricProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricProcessInstanceQuery variableValueEquals(String variableName, Object variableValue) {
    if (inOrStatement) {
        currentOrQueryObject.variableValueEquals(variableName, variableValue, true);
        return this;
    } else {
        return variableValueEquals(variableName, variableValue, true);
    }
}
 
Example #26
Source File: AbstractServiceTest.java    From herd with Apache License 2.0 5 votes vote down vote up
/**
 * Deletes all Activiti jobs from the history table.
 */
protected void deleteAllHistoricJobs()
{
    HistoricProcessInstanceQuery query = activitiHistoryService.createHistoricProcessInstanceQuery();
    List<HistoricProcessInstance> historicProcessInstances = query.list();
    for (HistoricProcessInstance historicProcessInstance : historicProcessInstances)
    {
        activitiHistoryService.deleteHistoricProcessInstance(historicProcessInstance.getId());
    }
}
 
Example #27
Source File: HistoricProcessInstanceQueryImpl.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricProcessInstanceQuery processInstanceNameLikeIgnoreCase(String nameLikeIgnoreCase) {
    if (inOrStatement) {
        this.currentOrQueryObject.nameLikeIgnoreCase = nameLikeIgnoreCase.toLowerCase();
    } else {
        this.nameLikeIgnoreCase = nameLikeIgnoreCase.toLowerCase();
    }
    return this;
}
 
Example #28
Source File: HistoricProcessInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public HistoricProcessInstanceQuery endOr() {
  if (!inOrStatement) {
    throw new ActivitiException("endOr() can only be called after calling or()");
  }
  
  inOrStatement = false;
  currentOrQueryObject = null;
  return this;
}
 
Example #29
Source File: HistoricProcessInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
public HistoricProcessInstanceQuery or() {
  if (inOrStatement) {
    throw new ActivitiException("the query is already in an or statement");
  }
  
  inOrStatement = true;
  currentOrQueryObject = new HistoricProcessInstanceQueryImpl();
  orQueryObjects.add(currentOrQueryObject);
  return this;
}
 
Example #30
Source File: HistoricProcessInstanceQueryImpl.java    From activiti6-boot2 with Apache License 2.0 5 votes vote down vote up
@Override
public HistoricProcessInstanceQuery variableValueLikeIgnoreCase(String name, String value) {
  if (inOrStatement) {
    currentOrQueryObject.variableValueLikeIgnoreCase(name, value, true);
    return this;
  } else {
    return variableValueLikeIgnoreCase(name, value, true);
  }
}