Beispiel #1
0
        public virtual CountResultDto getHistoricBatchesCount(UriInfo uriInfo)
        {
            HistoricBatchQueryDto queryDto = new HistoricBatchQueryDto(objectMapper, uriInfo.QueryParameters);
            HistoricBatchQuery    query    = queryDto.toQuery(processEngine);

            long count = query.count();

            return(new CountResultDto(count));
        }
Beispiel #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUpHistoricBatchQueryMock()
        public virtual void setUpHistoricBatchQueryMock()
        {
            IList <HistoricBatch> mockHistoricBatches = MockProvider.createMockHistoricBatches();

            queryMock = mock(typeof(HistoricBatchQuery));

            when(queryMock.list()).thenReturn(mockHistoricBatches);
            when(queryMock.count()).thenReturn((long)mockHistoricBatches.Count);

            when(processEngine.HistoryService.createHistoricBatchQuery()).thenReturn(queryMock);
        }
Beispiel #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testGetNonExistingHistoricBatch()
        public virtual void testGetNonExistingHistoricBatch()
        {
            string             nonExistingId      = MockProvider.NON_EXISTING_ID;
            HistoricBatchQuery historicBatchQuery = mock(typeof(HistoricBatchQuery));

            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.StatusCode).body("type", equalTo(typeof(InvalidRequestException).Name)).body("message", equalTo("Historic batch with id '" + nonExistingId + "' does not exist")).when().get(HISTORIC_SINGLE_BATCH_RESOURCE_URL);
        }
Beispiel #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setUpHistoricBatchQueryMock()
        public virtual void setUpHistoricBatchQueryMock()
        {
            HistoricBatch historicBatchMock = MockProvider.createMockHistoricBatch();

            queryMock = mock(typeof(HistoricBatchQuery));
            when(queryMock.batchId(eq(MockProvider.EXAMPLE_BATCH_ID))).thenReturn(queryMock);
            when(queryMock.singleResult()).thenReturn(historicBatchMock);

            historyServiceMock = mock(typeof(HistoryService));
            when(historyServiceMock.createHistoricBatchQuery()).thenReturn(queryMock);

            when(processEngine.HistoryService).thenReturn(historyServiceMock);
        }
Beispiel #5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWriteUserOperationLogForBatches_AsyncTrue()
        public virtual void shouldWriteUserOperationLogForBatches_AsyncTrue()
        {
            // given
            createBatch(1);

            identityService.AuthenticatedUserId = "aUserId";

            HistoricBatchQuery historicBatchQuery = historyService.createHistoricBatchQuery();

            // when
            historyService.setRemovalTimeToHistoricBatches().clearedRemovalTime().byQuery(historicBatchQuery).executeAsync();

            UserOperationLogEntry userOperationLogEntry = historyService.createUserOperationLogQuery().property("async").singleResult();

            // then
            assertThat(userOperationLogEntry.OrgValue).Null;
            assertThat(userOperationLogEntry.NewValue).isEqualTo("true");
        }
Beispiel #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWriteUserOperationLogForBatches_ModeAbsoluteRemovalTime()
        public virtual void shouldWriteUserOperationLogForBatches_ModeAbsoluteRemovalTime()
        {
            // given
            createBatch(1);

            identityService.AuthenticatedUserId = "aUserId";

            HistoricBatchQuery historicBatchQuery = historyService.createHistoricBatchQuery();

            // when
            historyService.setRemovalTimeToHistoricBatches().absoluteRemovalTime(DateTime.Now).byQuery(historicBatchQuery).executeAsync();

            UserOperationLogEntry userOperationLogEntry = historyService.createUserOperationLogQuery().property("mode").singleResult();

            // then
            assertThat(userOperationLogEntry.OrgValue).Null;
            assertThat(userOperationLogEntry.NewValue).isEqualTo("ABSOLUTE_REMOVAL_TIME");
        }
Beispiel #7
0
        public virtual void shouldAuthorizeSetRemovalTimeForHistoricBatchesBatch()
        {
            // given
            string batchId = engineRule.HistoryService.deleteHistoricProcessInstancesAsync(Collections.singletonList(processInstance.Id), "aDeleteReason").Id;

            authRule.init(scenario).withUser("userId").bindResource("batchId", "*").start();

            HistoricBatchQuery query = historyService.createHistoricBatchQuery().batchId(batchId);

            // when
            historyService.setRemovalTimeToHistoricBatches().absoluteRemovalTime(DateTime.Now).byQuery(query).executeAsync();

            // then
            authRule.assertScenario(scenario);

            // clear database
            managementService.deleteBatch(batchId, true);
        }
Beispiel #8
0
        public override Batch execute(CommandContext commandContext)
        {
            ISet <string> historicBatchIds = new HashSet <string>();

            IList <string>     instanceIds   = builder.Ids;
            HistoricBatchQuery instanceQuery = builder.Query;

            if (instanceQuery == null && instanceIds == null)
            {
                throw new BadUserRequestException("Either query nor ids provided.");
            }

            if (instanceQuery != null)
            {
                foreach (HistoricBatch historicBatch in instanceQuery.list())
                {
                    historicBatchIds.Add(historicBatch.Id);
                }
            }

            if (instanceIds != null)
            {
                historicBatchIds.addAll(findHistoricInstanceIds(instanceIds, commandContext));
            }

            ensureNotNull(typeof(BadUserRequestException), "removalTime", builder.getMode());
            ensureNotEmpty(typeof(BadUserRequestException), "historicBatches", historicBatchIds);

            checkAuthorizations(commandContext, BatchPermissions.CREATE_BATCH_SET_REMOVAL_TIME);

            writeUserOperationLog(commandContext, historicBatchIds.Count, builder.getMode(), builder.RemovalTime, true);

            BatchEntity batch = createBatch(commandContext, new List <>(historicBatchIds));

            batch.createSeedJobDefinition();
            batch.createMonitorJobDefinition();
            batch.createBatchJobDefinition();

            batch.fireHistoricStartEvent();

            batch.createSeedJob();

            return(batch);
        }
Beispiel #9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWriteUserOperationLogForBatches_RemovalTime()
        public virtual void shouldWriteUserOperationLogForBatches_RemovalTime()
        {
            // given
            DateTime removalTime = DateTime.Now;

            createBatch(1);

            identityService.AuthenticatedUserId = "aUserId";

            HistoricBatchQuery historicBatchQuery = historyService.createHistoricBatchQuery();

            // when
            historyService.setRemovalTimeToHistoricBatches().absoluteRemovalTime(removalTime).byQuery(historicBatchQuery).executeAsync();

            UserOperationLogEntry userOperationLogEntry = historyService.createUserOperationLogQuery().property("removalTime").singleResult();

            // then
            assertThat(userOperationLogEntry.OrgValue).Null;
            assertThat(fromMillis(userOperationLogEntry.NewValue)).isEqualToIgnoringMillis(removalTime);
        }
Beispiel #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldWriteUserOperationLogForBatches()
        public virtual void shouldWriteUserOperationLogForBatches()
        {
            // given
            createBatch(1);

            identityService.AuthenticatedUserId = "aUserId";

            HistoricBatchQuery historicBatchQuery = historyService.createHistoricBatchQuery();

            // when
            historyService.setRemovalTimeToHistoricBatches().calculatedRemovalTime().byQuery(historicBatchQuery).executeAsync();

            IList <UserOperationLogEntry> userOperationLogEntries = historyService.createUserOperationLogQuery().list();

            // then
            assertProperties(userOperationLogEntries, "mode", "removalTime", "nrOfInstances", "async");
            assertOperationType(userOperationLogEntries, "SetRemovalTime");
            assertEntityType(userOperationLogEntries, "Batch");
            assertCategory(userOperationLogEntries, "Operator");
        }
Beispiel #11
0
        public virtual BatchDto setRemovalTimeAsync(SetRemovalTimeToHistoricBatchesDto dto)
        {
            HistoryService historyService = processEngine.HistoryService;

            HistoricBatchQuery historicBatchQuery = null;

            if (dto.HistoricBatchQuery != null)
            {
                historicBatchQuery = dto.HistoricBatchQuery.toQuery(processEngine);
            }

            SetRemovalTimeSelectModeForHistoricBatchesBuilder builder = historyService.setRemovalTimeToHistoricBatches();

            if (dto.CalculatedRemovalTime)
            {
                builder.calculatedRemovalTime();
            }

            DateTime removalTime = dto.AbsoluteRemovalTime;

            if (dto.AbsoluteRemovalTime != null)
            {
                builder.absoluteRemovalTime(removalTime);
            }

            if (dto.ClearedRemovalTime)
            {
                builder.clearedRemovalTime();
            }

            builder.byIds(dto.HistoricBatchIds);
            builder.byQuery(historicBatchQuery);

            Batch batch = builder.executeAsync();

            return(BatchDto.fromBatch(batch));
        }
Beispiel #12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") @Override public java.util.List<org.camunda.bpm.engine.rest.dto.history.batch.HistoricBatchDto> getHistoricBatches(javax.ws.rs.core.UriInfo uriInfo, System.Nullable<int> firstResult, System.Nullable<int> maxResults)
        public virtual IList <HistoricBatchDto> getHistoricBatches(UriInfo uriInfo, int?firstResult, int?maxResults)
        {
            HistoricBatchQueryDto queryDto = new HistoricBatchQueryDto(objectMapper, uriInfo.QueryParameters);
            HistoricBatchQuery    query    = queryDto.toQuery(processEngine);

            IList <HistoricBatch> matchingBatches;

            if (firstResult != null || maxResults != null)
            {
                matchingBatches = (IList <HistoricBatch>)executePaginatedQuery(query, firstResult, maxResults);
            }
            else
            {
                matchingBatches = query.list();
            }

            IList <HistoricBatchDto> batchResults = new List <HistoricBatchDto>();

            foreach (HistoricBatch matchingBatch in matchingBatches)
            {
                batchResults.Add(HistoricBatchDto.fromBatch(matchingBatch));
            }
            return(batchResults);
        }
Beispiel #13
0
 public virtual SetRemovalTimeToHistoricBatchesBuilder byQuery(HistoricBatchQuery query)
 {
     this.query = query;
     return(this);
 }