Esempio n. 1
0
        public virtual BatchDto setRetriesByProcessHistoricQueryBased(SetJobRetriesByProcessDto setJobRetriesDto)
        {
            IList <string> processInstanceIds = new List <string>();

            HistoricProcessInstanceQueryDto queryDto = setJobRetriesDto.HistoricProcessInstanceQuery;

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

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

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

            try
            {
                ManagementService managementService = ProcessEngine.ManagementService;
                Batch             batch             = managementService.setJobRetriesAsync(processInstanceIds, (ProcessInstanceQuery)null, setJobRetriesDto.Retries.Value);

                return(BatchDto.fromBatch(batch));
            }
            catch (BadUserRequestException e)
            {
                throw new InvalidRequestException(Status.BAD_REQUEST, e.Message);
            }
        }
Esempio n. 2
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);
            }
        }
Esempio n. 3
0
        public virtual IList <HistoricProcessInstanceDto> queryHistoricProcessInstances(HistoricProcessInstanceQueryDto queryDto, int?firstResult, int?maxResults)
        {
            queryDto.ObjectMapper = objectMapper;
            HistoricProcessInstanceQuery query = queryDto.toQuery(processEngine);

            IList <HistoricProcessInstance> matchingHistoricProcessInstances;

            if (firstResult != null || maxResults != null)
            {
                matchingHistoricProcessInstances = executePaginatedQuery(query, firstResult, maxResults);
            }
            else
            {
                matchingHistoricProcessInstances = query.list();
            }

            IList <HistoricProcessInstanceDto> historicProcessInstanceDtoResults = new List <HistoricProcessInstanceDto>();

            foreach (HistoricProcessInstance historicProcessInstance in matchingHistoricProcessInstances)
            {
                HistoricProcessInstanceDto resultHistoricProcessInstanceDto = HistoricProcessInstanceDto.fromHistoricProcessInstance(historicProcessInstance);
                historicProcessInstanceDtoResults.Add(resultHistoricProcessInstanceDto);
            }
            return(historicProcessInstanceDtoResults);
        }
Esempio n. 4
0
        private void createHistoricProcessInstanceMock()
        {
            IList <HistoricProcessInstance> processes    = new List <HistoricProcessInstance>();
            HistoricProcessInstance         mockInstance = MockProvider.createMockHistoricProcessInstance();

            processes.Add(mockInstance);

            HistoricProcessInstanceQuery mockHistoricProcessInstanceQuery = mock(typeof(HistoricProcessInstanceQuery));

            when(mockHistoricProcessInstanceQuery.list()).thenReturn(processes);
            when(mockHistoryService.createHistoricProcessInstanceQuery()).thenReturn(mockHistoricProcessInstanceQuery);
        }
Esempio n. 5
0
        public override Batch execute(CommandContext commandContext)
        {
            ISet <string> historicProcessInstanceIds = new HashSet <string>();

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

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

            if (instanceQuery != null)
            {
                foreach (HistoricProcessInstance historicDecisionInstance in instanceQuery.list())
                {
                    historicProcessInstanceIds.Add(historicDecisionInstance.Id);
                }
            }

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

            ensureNotNull(typeof(BadUserRequestException), "removalTime", builder.getMode());
            ensureNotEmpty(typeof(BadUserRequestException), "historicProcessInstances", historicProcessInstanceIds);

            checkAuthorizations(commandContext, BatchPermissions.CREATE_BATCH_SET_REMOVAL_TIME);

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

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

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

            batch.fireHistoricStartEvent();

            batch.createSeedJob();

            return(batch);
        }