Exemple #1
0
        public virtual BatchDto deleteAsyncHistoricQueryBased(DeleteProcessInstancesDto deleteProcessInstancesDto)
        {
            IList <string> processInstanceIds = new List <string>();

            HistoricProcessInstanceQueryDto queryDto = deleteProcessInstancesDto.HistoricProcessInstanceQuery;

            if (queryDto != null)
            {
                HistoricProcessInstanceQuery    query = queryDto.toQuery(ProcessEngine);
                IList <HistoricProcessInstance> historicProcessInstances = query.list();

                foreach (HistoricProcessInstance historicProcessInstance in historicProcessInstances)
                {
                    processInstanceIds.Add(historicProcessInstance.Id);
                }
            }

            if (deleteProcessInstancesDto.ProcessInstanceIds != null)
            {
                ((IList <string>)processInstanceIds).AddRange(deleteProcessInstancesDto.ProcessInstanceIds);
            }

            try
            {
                RuntimeService runtimeService = ProcessEngine.RuntimeService;
                Batch          batch          = runtimeService.deleteProcessInstancesAsync(processInstanceIds, null, deleteProcessInstancesDto.DeleteReason, deleteProcessInstancesDto.SkipCustomListeners, deleteProcessInstancesDto.SkipSubprocesses);

                return(BatchDto.fromBatch(batch));
            }
            catch (BadUserRequestException e)
            {
                throw new InvalidRequestException(Status.BAD_REQUEST, e.Message);
            }
        }
Exemple #2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldScheduleToNow()
        public virtual void shouldScheduleToNow()
        {
            // given
            engineConfiguration.BatchOperationHistoryTimeToLive = "P5D";
            engineConfiguration.HistoryCleanupBatchSize         = 5;
            engineConfiguration.initHistoryCleanup();

            testRule.deploy(PROCESS);

            testRule.deploy(CALLING_PROCESS);

            runtimeService.startProcessInstanceByKey(CALLING_PROCESS_KEY).Id;

            for (int i = 0; i < 5; i++)
            {
                string processInstanceId = runtimeService.createProcessInstanceQuery().processDefinitionKey(PROCESS_KEY).list().get(0).Id;
                runtimeService.deleteProcessInstancesAsync(Collections.singletonList(processInstanceId), "aDeleteReason");

                ClockUtil.CurrentTime = END_DATE;

                string jobId = managementService.createJobQuery().singleResult().Id;
                managementService.executeJob(jobId);
                jobIds.Add(jobId);

                IList <Job> jobs = managementService.createJobQuery().list();
                foreach (Job job in jobs)
                {
                    managementService.executeJob(job.Id);
                    jobIds.Add(job.Id);
                }
            }

            DateTime removalTime = addDays(END_DATE, 5);

            ClockUtil.CurrentTime = removalTime;

            // when
            runHistoryCleanup();

            Job job = historyService.findHistoryCleanupJobs()[0];

            // then
            assertThat(job.Duedate, @is(removalTime));
        }
Exemple #3
0
        private IList <string> createCancelationBatchList(int cancelationCountBatch)
        {
            IList <string> batchIds = new List <string>();

            for (int i = 0; i < cancelationCountBatch; i++)
            {
                batchIds.Add(runtimeService.deleteProcessInstancesAsync(Arrays.asList("unknownId"), "create-deletion-batch").Id);
            }
            return(batchIds);
        }
Exemple #4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDontWriteDuplicateLogOnBatchDeletionJobExecution()
        public virtual void testDontWriteDuplicateLogOnBatchDeletionJobExecution()
        {
            ProcessDefinition definition      = testHelper.deployAndGetDefinition(ProcessModels.ONE_TASK_PROCESS);
            ProcessInstance   processInstance = runtimeService.startProcessInstanceById(definition.Id);

            batch = runtimeService.deleteProcessInstancesAsync(Arrays.asList(processInstance.Id), null, "test reason");

            Job seedJob = managementService.createJobQuery().singleResult();

            managementService.executeJob(seedJob.Id);

            foreach (Job pending in managementService.createJobQuery().list())
            {
                managementService.executeJob(pending.Id);
            }

            assertEquals(5, userOperationLogQuery().entityTypeIn(EntityTypes.PROCESS_INSTANCE, EntityTypes.DEPLOYMENT).count());
        }
Exemple #5
0
        public virtual BatchDto deleteAsync(DeleteProcessInstancesDto dto)
        {
            RuntimeService runtimeService = ProcessEngine.RuntimeService;

            ProcessInstanceQuery processInstanceQuery = null;

            if (dto.ProcessInstanceQuery != null)
            {
                processInstanceQuery = dto.ProcessInstanceQuery.toQuery(ProcessEngine);
            }

            Batch batch = null;

            try
            {
                batch = runtimeService.deleteProcessInstancesAsync(dto.ProcessInstanceIds, processInstanceQuery, dto.DeleteReason, dto.SkipCustomListeners, dto.SkipSubprocesses);
                return(BatchDto.fromBatch(batch));
            }
            catch (BadUserRequestException e)
            {
                throw new InvalidRequestException(Status.BAD_REQUEST, e.Message);
            }
        }