org.camunda.bpm.engine.batch.history.HistoricBatchQuery Java Examples
The following examples show how to use
org.camunda.bpm.engine.batch.history.HistoricBatchQuery.
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: HistoricBatchRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void testGetNonExistingHistoricBatch() { String nonExistingId = MockProvider.NON_EXISTING_ID; HistoricBatchQuery historicBatchQuery = mock(HistoricBatchQuery.class); when(historicBatchQuery.batchId(nonExistingId)).thenReturn(historicBatchQuery); when(historicBatchQuery.singleResult()).thenReturn(null); when(historyServiceMock.createHistoricBatchQuery()).thenReturn(historicBatchQuery); given() .pathParam("id", nonExistingId) .then().expect() .statusCode(Status.NOT_FOUND.getStatusCode()) .body("type", equalTo(InvalidRequestException.class.getSimpleName())) .body("message", equalTo("Historic batch with id '" + nonExistingId + "' does not exist")) .when() .get(HISTORIC_SINGLE_BATCH_RESOURCE_URL); }
Example #2
Source File: BatchSetRemovalTimeTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void shouldThrowBadUserRequestExceptionForBatch() { // given // then thrown.expect(BadUserRequestException.class); thrown.expectMessage("historicBatches is empty"); HistoricBatchQuery query = historyService.createHistoricBatchQuery(); // when historyService.setRemovalTimeToHistoricBatches() .absoluteRemovalTime(REMOVAL_TIME) .byQuery(query) .executeAsync(); }
Example #3
Source File: BatchSetRemovalTimeTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void shouldProduceHistoryForBatch() { // given String processInstanceId = testRule.process().serviceTask().deploy().start(); Batch batch = historyService.deleteHistoricProcessInstancesAsync(Collections.singletonList(processInstanceId), ""); testRule.syncExec(batch); HistoricBatchQuery query = historyService.createHistoricBatchQuery(); // when testRule.syncExec( historyService.setRemovalTimeToHistoricBatches() .calculatedRemovalTime() .byQuery(query) .executeAsync() ); HistoricBatch historicBatch = historyService.createHistoricBatchQuery() .type("batch-set-removal-time") .singleResult(); // then assertThat(historicBatch.getStartTime()).isEqualTo(CURRENT_DATE); assertThat(historicBatch.getEndTime()).isEqualTo(CURRENT_DATE); }
Example #4
Source File: BatchSetRemovalTimeUserOperationLogTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void shouldWriteUserOperationLogForBatches() { // given createBatch(1); identityService.setAuthenticatedUserId("aUserId"); HistoricBatchQuery historicBatchQuery = historyService.createHistoricBatchQuery(); // when historyService.setRemovalTimeToHistoricBatches() .calculatedRemovalTime() .byQuery(historicBatchQuery) .executeAsync(); List<UserOperationLogEntry> userOperationLogEntries = historyService.createUserOperationLogQuery().list(); // then assertProperties(userOperationLogEntries, "mode", "removalTime", "nrOfInstances", "async"); assertOperationType(userOperationLogEntries, "SetRemovalTime"); assertEntityType(userOperationLogEntries, "Batch"); assertCategory(userOperationLogEntries, "Operator"); }
Example #5
Source File: BatchSetRemovalTimeUserOperationLogTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void shouldWriteUserOperationLogForBatches_ModeCalculatedRemovalTime() { // given createBatch(1); identityService.setAuthenticatedUserId("aUserId"); HistoricBatchQuery historicBatchQuery = historyService.createHistoricBatchQuery(); // when historyService.setRemovalTimeToHistoricBatches() .calculatedRemovalTime() .byQuery(historicBatchQuery) .executeAsync(); UserOperationLogEntry userOperationLogEntry = historyService.createUserOperationLogQuery() .property("mode") .singleResult(); // then assertThat(userOperationLogEntry.getOrgValue()).isNull(); assertThat(userOperationLogEntry.getNewValue()).isEqualTo("CALCULATED_REMOVAL_TIME"); }
Example #6
Source File: BatchSetRemovalTimeUserOperationLogTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void shouldWriteUserOperationLogForBatches_ModeAbsoluteRemovalTime() { // given createBatch(1); identityService.setAuthenticatedUserId("aUserId"); HistoricBatchQuery historicBatchQuery = historyService.createHistoricBatchQuery(); // when historyService.setRemovalTimeToHistoricBatches() .absoluteRemovalTime(new Date()) .byQuery(historicBatchQuery) .executeAsync(); UserOperationLogEntry userOperationLogEntry = historyService.createUserOperationLogQuery() .property("mode") .singleResult(); // then assertThat(userOperationLogEntry.getOrgValue()).isNull(); assertThat(userOperationLogEntry.getNewValue()).isEqualTo("ABSOLUTE_REMOVAL_TIME"); }
Example #7
Source File: BatchSetRemovalTimeUserOperationLogTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void shouldWriteUserOperationLogForBatches_RemovalTime() { // given Date removalTime = new Date(); createBatch(1); identityService.setAuthenticatedUserId("aUserId"); HistoricBatchQuery historicBatchQuery = historyService.createHistoricBatchQuery(); // when historyService.setRemovalTimeToHistoricBatches() .absoluteRemovalTime(removalTime) .byQuery(historicBatchQuery) .executeAsync(); UserOperationLogEntry userOperationLogEntry = historyService.createUserOperationLogQuery() .property("removalTime") .singleResult(); // then assertThat(userOperationLogEntry.getOrgValue()).isNull(); assertThat(fromMillis(userOperationLogEntry.getNewValue())).isEqualToIgnoringMillis(removalTime); }
Example #8
Source File: BatchSetRemovalTimeUserOperationLogTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void shouldWriteUserOperationLogForBatches_RemovalTimeNull() { // given createBatch(1); identityService.setAuthenticatedUserId("aUserId"); HistoricBatchQuery historicBatchQuery = historyService.createHistoricBatchQuery(); // when historyService.setRemovalTimeToHistoricBatches() .clearedRemovalTime() .byQuery(historicBatchQuery) .executeAsync(); UserOperationLogEntry userOperationLogEntry = historyService.createUserOperationLogQuery() .property("removalTime") .singleResult(); // then assertThat(userOperationLogEntry.getOrgValue()).isNull(); assertThat(userOperationLogEntry.getNewValue()).isNull(); }
Example #9
Source File: BatchSetRemovalTimeUserOperationLogTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void shouldWriteUserOperationLogForBatches_NrOfInstances() { // given createBatch(2); identityService.setAuthenticatedUserId("aUserId"); HistoricBatchQuery historicBatchQuery = historyService.createHistoricBatchQuery(); // when historyService.setRemovalTimeToHistoricBatches() .clearedRemovalTime() .byQuery(historicBatchQuery) .executeAsync(); UserOperationLogEntry userOperationLogEntry = historyService.createUserOperationLogQuery() .property("nrOfInstances") .singleResult(); // then assertThat(userOperationLogEntry.getOrgValue()).isNull(); assertThat(userOperationLogEntry.getNewValue()).isEqualTo("2"); }
Example #10
Source File: HistoricBatchQueryDto.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
protected void applyFilters(HistoricBatchQuery query) { if (batchId != null) { query.batchId(batchId); } if (type != null) { query.type(type); } if (completed != null) { query.completed(completed); } if (Boolean.TRUE.equals(withoutTenantId)) { query.withoutTenantId(); } if (tenantIds != null && !tenantIds.isEmpty()) { query.tenantIdIn(tenantIds.toArray(new String[tenantIds.size()])); } }
Example #11
Source File: HistoricBatchRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public List<HistoricBatchDto> getHistoricBatches(UriInfo uriInfo, Integer firstResult, Integer maxResults) { HistoricBatchQueryDto queryDto = new HistoricBatchQueryDto(objectMapper, uriInfo.getQueryParameters()); HistoricBatchQuery query = queryDto.toQuery(processEngine); List<HistoricBatch> matchingBatches; if (firstResult != null || maxResults != null) { matchingBatches = (List<HistoricBatch>) executePaginatedQuery(query, firstResult, maxResults); } else { matchingBatches = query.list(); } List<HistoricBatchDto> batchResults = new ArrayList<HistoricBatchDto>(); for (HistoricBatch matchingBatch : matchingBatches) { batchResults.add(HistoricBatchDto.fromBatch(matchingBatch)); } return batchResults; }
Example #12
Source File: BatchSetRemovalTimeUserOperationLogTest.java From camunda-bpm-platform with Apache License 2.0 | 6 votes |
@Test public void shouldWriteUserOperationLogForBatches_AsyncTrue() { // given createBatch(1); identityService.setAuthenticatedUserId("aUserId"); HistoricBatchQuery historicBatchQuery = historyService.createHistoricBatchQuery(); // when historyService.setRemovalTimeToHistoricBatches() .clearedRemovalTime() .byQuery(historicBatchQuery) .executeAsync(); UserOperationLogEntry userOperationLogEntry = historyService.createUserOperationLogQuery() .property("async") .singleResult(); // then assertThat(userOperationLogEntry.getOrgValue()).isNull(); assertThat(userOperationLogEntry.getNewValue()).isEqualTo("true"); }
Example #13
Source File: BatchSetRemovalTimeNonHierarchicalTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void shouldSetRemovalTimeToBatch_Incident() { // given String processInstance = testRule.process().failingCustomListener().deploy().start(); Batch batch = runtimeService.deleteProcessInstancesAsync(Collections.singletonList(processInstance), "aDeleteReason"); String jobId = managementService.createJobQuery().singleResult().getId(); managementService.setJobRetries(jobId, 0); HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult(); // assume assertThat(historicIncident.getRemovalTime()).isNull(); HistoricBatchQuery query = historyService.createHistoricBatchQuery(); // when testRule.syncExec( historyService.setRemovalTimeToHistoricBatches() .absoluteRemovalTime(REMOVAL_TIME) .byQuery(query) .executeAsync() ); historicIncident = historyService.createHistoricIncidentQuery().singleResult(); // then assertThat(historicIncident.getRemovalTime()).isEqualTo(REMOVAL_TIME); // clear database managementService.deleteBatch(batch.getId(), true); runtimeService.deleteProcessInstance(processInstance, "", true); }
Example #14
Source File: BatchSetRemovalTimeTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void shouldSetRemovalTimeForBatch_Null() { // given ProcessEngineConfigurationImpl configuration = testRule.getProcessEngineConfiguration(); configuration.setBatchOperationHistoryTimeToLive("P5D"); configuration.initHistoryCleanup(); String processInstanceId = testRule.process().serviceTask().deploy().start(); Batch batch = historyService.deleteHistoricProcessInstancesAsync(Collections.singletonList(processInstanceId), ""); HistoricBatch historicBatch = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION) .singleResult(); // assume assertThat(historicBatch.getRemovalTime()).isNotNull(); HistoricBatchQuery query = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION); // when testRule.syncExec( historyService.setRemovalTimeToHistoricBatches() .clearedRemovalTime() .byQuery(query) .executeAsync() ); historicBatch = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION) .singleResult(); // then assertThat(historicBatch.getRemovalTime()).isNull(); // clear database managementService.deleteBatch(batch.getId(), true); }
Example #15
Source File: BatchSetRemovalTimeTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void shouldSetRemovalTimeForBatch_Absolute() { // given String processInstanceId = testRule.process().serviceTask().deploy().start(); Batch batch = historyService.deleteHistoricProcessInstancesAsync(Collections.singletonList(processInstanceId), ""); HistoricBatch historicBatch = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION) .singleResult(); // assume assertThat(historicBatch.getRemovalTime()).isNull(); HistoricBatchQuery query = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION); // when testRule.syncExec( historyService.setRemovalTimeToHistoricBatches() .absoluteRemovalTime(REMOVAL_TIME) .byQuery(query) .executeAsync() ); historicBatch = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION) .singleResult(); // then assertThat(historicBatch.getRemovalTime()).isEqualTo(REMOVAL_TIME); // clear database managementService.deleteBatch(batch.getId(), true); }
Example #16
Source File: BatchSetRemovalTimeTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void shouldClearRemovalTimeForBatch_BaseTimeEnd() { // given ProcessEngineConfigurationImpl configuration = testRule.getProcessEngineConfiguration(); configuration.setBatchOperationHistoryTimeToLive("P5D"); configuration.initHistoryCleanup(); String processInstanceId = testRule.process().serviceTask().deploy().start(); Batch batch = historyService.deleteHistoricProcessInstancesAsync(Collections.singletonList(processInstanceId), ""); HistoricBatch historicBatch = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION) .singleResult(); // assume assertThat(historicBatch.getRemovalTime()).isNotNull(); configuration.setHistoryRemovalTimeStrategy(HISTORY_REMOVAL_TIME_STRATEGY_END); HistoricBatchQuery query = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION); // when testRule.syncExec( historyService.setRemovalTimeToHistoricBatches() .calculatedRemovalTime() .byQuery(query) .executeAsync() ); historicBatch = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION) .singleResult(); // then assertThat(historicBatch.getRemovalTime()).isNull(); // clear database managementService.deleteBatch(batch.getId(), true); }
Example #17
Source File: BatchSetRemovalTimeTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void shouldSetRemovalTimeForBatch_BaseTimeStart() { // given String processInstanceId = testRule.process().serviceTask().deploy().start(); Batch batch = historyService.deleteHistoricProcessInstancesAsync(Collections.singletonList(processInstanceId), ""); HistoricBatch historicBatch = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION) .singleResult(); // assume assertThat(historicBatch.getRemovalTime()).isNull(); ProcessEngineConfigurationImpl configuration = testRule.getProcessEngineConfiguration(); configuration.setBatchOperationHistoryTimeToLive("P5D"); configuration.initHistoryCleanup(); HistoricBatchQuery query = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION); // when testRule.syncExec( historyService.setRemovalTimeToHistoricBatches() .calculatedRemovalTime() .byQuery(query) .executeAsync() ); historicBatch = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION) .singleResult(); // then assertThat(historicBatch.getRemovalTime()).isEqualTo(addDays(CURRENT_DATE, 5)); // clear database managementService.deleteBatch(batch.getId(), true); }
Example #18
Source File: HistoricBatchRestServiceInteractionTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Before public void setUpHistoricBatchQueryMock() { HistoricBatch historicBatchMock = MockProvider.createMockHistoricBatch(); queryMock = mock(HistoricBatchQuery.class); when(queryMock.batchId(eq(MockProvider.EXAMPLE_BATCH_ID))).thenReturn(queryMock); when(queryMock.singleResult()).thenReturn(historicBatchMock); historyServiceMock = mock(HistoryService.class); when(historyServiceMock.createHistoricBatchQuery()).thenReturn(queryMock); when(processEngine.getHistoryService()).thenReturn(historyServiceMock); }
Example #19
Source File: BatchSetRemovalTimeTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void shouldThrowExceptionIfNoRemovalTimeSettingDefinedForBatch() { // given HistoricBatchQuery query = historyService.createHistoricBatchQuery(); SetRemovalTimeToHistoricBatchesBuilder batchBuilder = historyService.setRemovalTimeToHistoricBatches() .byQuery(query); // then thrown.expect(BadUserRequestException.class); thrown.expectMessage("removalTime is null"); // when batchBuilder.executeAsync(); }
Example #20
Source File: HistoricBatchRestServiceQueryTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Before public void setUpHistoricBatchQueryMock() { List<HistoricBatch> mockHistoricBatches = MockProvider.createMockHistoricBatches(); queryMock = mock(HistoricBatchQuery.class); when(queryMock.list()).thenReturn(mockHistoricBatches); when(queryMock.count()).thenReturn((long) mockHistoricBatches.size()); when(processEngine.getHistoryService().createHistoricBatchQuery()).thenReturn(queryMock); }
Example #21
Source File: HistoricBatchRestServiceImpl.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public CountResultDto getHistoricBatchesCount(UriInfo uriInfo) { HistoricBatchQueryDto queryDto = new HistoricBatchQueryDto(objectMapper, uriInfo.getQueryParameters()); HistoricBatchQuery query = queryDto.toQuery(processEngine); long count = query.count(); return new CountResultDto(count); }
Example #22
Source File: BatchSetRemovalTimeNonHierarchicalTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void shouldSetRemovalTimeToBatch_JobLog() { // given String processInstanceId = testRule.process().userTask().deploy().start(); Batch batch = runtimeService.deleteProcessInstancesAsync(Collections.singletonList(processInstanceId), "aDeleteReason"); HistoricJobLog historicJobLog = historyService.createHistoricJobLogQuery() .jobDefinitionConfiguration(batch.getId()) .singleResult(); // assume assertThat(historicJobLog.getRemovalTime()).isNull(); HistoricBatchQuery query = historyService.createHistoricBatchQuery(); // when testRule.syncExec( historyService.setRemovalTimeToHistoricBatches() .absoluteRemovalTime(REMOVAL_TIME) .byQuery(query) .executeAsync() ); historicJobLog = historyService.createHistoricJobLogQuery() .jobDefinitionConfiguration(batch.getId()) .singleResult(); // then assertThat(historicJobLog.getRemovalTime()).isEqualTo(REMOVAL_TIME); // clear database managementService.deleteBatch(batch.getId(), true); }
Example #23
Source File: BatchSetRemovalTimeNonHierarchicalTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test public void shouldSetRemovalTimeToBatch() { // given String processInstanceId = testRule.process().userTask().deploy().start(); Batch batch = runtimeService.deleteProcessInstancesAsync(Collections.singletonList(processInstanceId), "aDeleteReason"); HistoricBatch historicBatch = historyService.createHistoricBatchQuery().singleResult(); // assume assertThat(historicBatch.getRemovalTime()).isNull(); HistoricBatchQuery query = historyService.createHistoricBatchQuery(); // when testRule.syncExec( historyService.setRemovalTimeToHistoricBatches() .absoluteRemovalTime(REMOVAL_TIME) .byQuery(query) .executeAsync() ); historicBatch = historyService.createHistoricBatchQuery() .type(Batch.TYPE_PROCESS_INSTANCE_DELETION) .singleResult(); // then assertThat(historicBatch.getRemovalTime()).isEqualTo(REMOVAL_TIME); // clear database managementService.deleteBatch(batch.getId(), true); }
Example #24
Source File: SetRemovalTimeForHistoricBatchesBatchAuthorizationTest.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Test @RequiredHistoryLevel(ProcessEngineConfiguration.HISTORY_FULL) public void shouldAuthorizeSetRemovalTimeForHistoricBatchesBatch() { // given String batchId = engineRule.getHistoryService() .deleteHistoricProcessInstancesAsync(Collections.singletonList(processInstance.getId()), "aDeleteReason").getId(); authRule .init(scenario) .withUser("userId") .bindResource("batchId", "*") .start(); HistoricBatchQuery query = historyService.createHistoricBatchQuery().batchId(batchId); // when historyService.setRemovalTimeToHistoricBatches() .absoluteRemovalTime(new Date()) .byQuery(query) .executeAsync(); // then authRule.assertScenario(scenario); // clear database managementService.deleteBatch(batchId, true); }
Example #25
Source File: HistoricBatchQueryDto.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
protected void applySortBy(HistoricBatchQuery query, String sortBy, Map<String, Object> parameters, ProcessEngine engine) { if (sortBy.equals(SORT_BY_BATCH_ID_VALUE)) { query.orderById(); } if (sortBy.equals(SORT_BY_BATCH_START_TIME_VALUE)) { query.orderByStartTime(); } if (sortBy.equals(SORT_BY_BATCH_END_TIME_VALUE)) { query.orderByEndTime(); } if (sortBy.equals(SORT_BY_TENANT_ID_VALUE)) { query.orderByTenantId(); } }
Example #26
Source File: SetRemovalTimeToHistoricBatchesCmd.java From camunda-bpm-platform with Apache License 2.0 | 5 votes |
@Override public Batch execute(CommandContext commandContext) { List<String> instanceIds = builder.getIds(); HistoricBatchQuery instanceQuery = builder.getQuery(); if (instanceQuery == null && instanceIds == null) { throw new BadUserRequestException("Neither query nor ids provided."); } Collection<String> collectedInstanceIds = new HashSet<>(); if (instanceQuery != null) { for (HistoricBatch historicBatch : instanceQuery.list()) { collectedInstanceIds.add(historicBatch.getId()); } } if (instanceIds != null) { collectedInstanceIds.addAll(findHistoricInstanceIds(instanceIds, commandContext)); } ensureNotNull(BadUserRequestException.class, "removalTime", builder.getMode()); ensureNotEmpty(BadUserRequestException.class, "historicBatches", collectedInstanceIds); return new BatchBuilder(commandContext) .type(Batch.TYPE_BATCH_SET_REMOVAL_TIME) .config(getConfiguration(collectedInstanceIds)) .permission(BatchPermissions.CREATE_BATCH_SET_REMOVAL_TIME) .operationLogHandler(this::writeUserOperationLog) .build(); }
Example #27
Source File: BatchSetRemovalTimeTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Test public void shouldSetRemovalTimeForBatch_BothQueryAndIdsDefined() { // given String processInstanceId = testRule.process().serviceTask().deploy().start(); Batch batchOne = historyService.deleteHistoricProcessInstancesAsync(Collections.singletonList(processInstanceId), ""); Batch batchTwo = historyService.deleteHistoricProcessInstancesAsync(Collections.singletonList(processInstanceId), ""); List<HistoricBatch> historicBatches = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION) .list(); // assume assertThat(historicBatches.get(0).getRemovalTime()).isNull(); assertThat(historicBatches.get(1).getRemovalTime()).isNull(); ProcessEngineConfigurationImpl configuration = testRule.getProcessEngineConfiguration(); configuration.setBatchOperationHistoryTimeToLive("P5D"); configuration.initHistoryCleanup(); HistoricBatchQuery query = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION) .batchId(batchOne.getId()); // when testRule.syncExec( historyService.setRemovalTimeToHistoricBatches() .calculatedRemovalTime() .byQuery(query) .byIds(batchTwo.getId()) .executeAsync() ); historicBatches = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION) .list(); // then assertThat(historicBatches.get(0).getRemovalTime()).isEqualTo(addDays(CURRENT_DATE, 5)); assertThat(historicBatches.get(1).getRemovalTime()).isEqualTo(addDays(CURRENT_DATE, 5)); // clear database managementService.deleteBatch(batchOne.getId(), true); managementService.deleteBatch(batchTwo.getId(), true); }
Example #28
Source File: BatchSetRemovalTimeTest.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
@Test public void shouldNotSetRemovalTimeForBatch_BaseTimeEnd() { // given ProcessEngineConfigurationImpl configuration = testRule.getProcessEngineConfiguration(); configuration .setHistoryRemovalTimeStrategy(HISTORY_REMOVAL_TIME_STRATEGY_END); String processInstanceId = testRule.process().serviceTask().deploy().start(); Batch batch = historyService.deleteHistoricProcessInstancesAsync(Collections.singletonList(processInstanceId), ""); HistoricBatch historicBatch = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION) .singleResult(); // assume assertThat(historicBatch.getRemovalTime()).isNull(); configuration.setBatchOperationHistoryTimeToLive("P5D"); configuration.initHistoryCleanup(); HistoricBatchQuery query = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION); // when testRule.syncExec( historyService.setRemovalTimeToHistoricBatches() .calculatedRemovalTime() .byQuery(query) .executeAsync() ); historicBatch = historyService.createHistoricBatchQuery() .type(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION) .singleResult(); // then assertThat(historicBatch.getRemovalTime()).isNull(); // clear database managementService.deleteBatch(batch.getId(), true); }
Example #29
Source File: HistoricBatchQueryDto.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
protected HistoricBatchQuery createNewQuery(ProcessEngine engine) { return engine.getHistoryService().createHistoricBatchQuery(); }
Example #30
Source File: SetRemovalTimeToHistoricBatchesCmd.java From camunda-bpm-platform with Apache License 2.0 | 4 votes |
protected HistoricBatchQuery createHistoricBatchQuery(CommandContext commandContext) { return commandContext.getProcessEngineConfiguration() .getHistoryService() .createHistoricBatchQuery(); }