protected internal virtual HistoryEvent CreateBatchEvent(BatchEntity batch, HistoryEventTypes eventType)
        {
            HistoricBatchEntity @event = new HistoricBatchEntity();

            @event.Id                     = batch.Id;
            @event.Type                   = batch.Type;
            @event.TotalJobs              = batch.TotalJobs;
            @event.BatchJobsPerSeed       = batch.BatchJobsPerSeed;
            @event.InvocationsPerBatchJob = batch.InvocationsPerBatchJob;
            @event.SeedJobDefinitionId    = batch.SeedJobDefinitionId;
            @event.MonitorJobDefinitionId = batch.MonitorJobDefinitionId;
            @event.BatchJobDefinitionId   = batch.BatchJobDefinitionId;
            @event.TenantId               = batch.TenantId;
            @event.EventType              = eventType.EventName;

            if (HistoryEventTypes.BatchStart.Equals(eventType))
            {
                @event.StartTime = ClockUtil.CurrentTime;
            }

            if (HistoryEventTypes.BatchEnd.Equals(eventType))
            {
                @event.EndTime = ClockUtil.CurrentTime;
            }

            return(@event);
        }
        public async Task <BatchEntity> Update(int id, BatchEntity batch)
        {
            try
            {
                if (batch != null)
                {
                    if (batch.FruitId == 0)
                    {
                        throw new ArgumentException("Fruit is invalid.");
                    }

                    _context.Batches.Update(batch);

                    if (!(await _context.SaveChangesAsync() >= 0))
                    {
                        throw new Exception("Creating batch failed on save.");
                    }

                    return(await GetBatchById(batch.Id));
                }

                return(null);
            }
            catch (Exception e)
            {
                _logger.LogError(e.ToString());
                throw;
            }
        }
示例#3
0
        public bool UpdateBatch(int batchId, BatchEntity batchEntity)

        {
            var batch   = _mapper.Map <BatchEntity, Batch>(batchEntity);
            var success = false;

            if (batch != null && batch.Id == batchId)
            {
                //using (var scope = new TransactionScope())
                //{

                if (batch != null)
                {
                    //batch.Batch_Name = batchEntity.Batch_Name;
                    //batch.App_Status = batchEntity.App_Status;
                    //batch.Description = batchEntity.Description;
                    //batch.Del_Status = batchEntity.Del_Status;
                    //batch.Course_Id = batchEntity.Course_Id;
                    //batch.Acedemic_Year = batchEntity.Acedemic_Year;

                    _unitOfWork.BatchRepository.Update(batch);
                    _unitOfWork.Save();
                    // scope.Complete();
                    success = true;
                }
                // }
            }
            return(success);
        }
示例#4
0
        public override Batch execute(CommandContext commandContext)
        {
            MigrationPlan        migrationPlan      = executionBuilder.MigrationPlan;
            ICollection <string> processInstanceIds = collectProcessInstanceIds(commandContext);

            ensureNotNull(typeof(BadUserRequestException), "Migration plan cannot be null", "migration plan", migrationPlan);
            ensureNotEmpty(typeof(BadUserRequestException), "Process instance ids cannot empty", "process instance ids", processInstanceIds);
            ensureNotContainsNull(typeof(BadUserRequestException), "Process instance ids cannot be null", "process instance ids", processInstanceIds);

            ProcessDefinitionEntity sourceProcessDefinition = resolveSourceProcessDefinition(commandContext);
            ProcessDefinitionEntity targetProcessDefinition = resolveTargetProcessDefinition(commandContext);

            checkAuthorizations(commandContext, sourceProcessDefinition, targetProcessDefinition, processInstanceIds);
            writeUserOperationLog(commandContext, sourceProcessDefinition, targetProcessDefinition, processInstanceIds.Count, true);

            BatchEntity batch = createBatch(commandContext, migrationPlan, processInstanceIds, sourceProcessDefinition);

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

            batch.fireHistoricStartEvent();

            batch.createSeedJob();

            return(batch);
        }
示例#5
0
        public virtual Batch execute(CommandContext commandContext)
        {
            string processInstanceId = builder.ProcessInstanceId;

            ExecutionManager executionManager = commandContext.ExecutionManager;
            ExecutionEntity  processInstance  = executionManager.findExecutionById(processInstanceId);

            ensureProcessInstanceExists(processInstanceId, processInstance);

            checkPermissions(commandContext);

            commandContext.OperationLogManager.logProcessInstanceOperation(LogEntryOperation, processInstanceId, null, null, Collections.singletonList(PropertyChange.EMPTY_CHANGE));

            IList <AbstractProcessInstanceModificationCommand> instructions = builder.ModificationOperations;
            BatchEntity batch = createBatch(commandContext, instructions, processInstance);

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

            batch.fireHistoricStartEvent();

            batch.createSeedJob();
            return(batch);
        }
示例#6
0
        public override Batch execute(CommandContext commandContext)
        {
            IList <AbstractProcessInstanceModificationCommand> instructions = builder.Instructions;
            ICollection <string> processInstanceIds = collectProcessInstanceIds(commandContext);

            ensureNotEmpty(typeof(BadUserRequestException), "Modification instructions cannot be empty", instructions);
            ensureNotEmpty(typeof(BadUserRequestException), "Process instance ids cannot be empty", "Process instance ids", processInstanceIds);
            ensureNotContainsNull(typeof(BadUserRequestException), "Process instance ids cannot be null", "Process instance ids", processInstanceIds);

            checkPermissions(commandContext);

            ProcessDefinitionEntity processDefinition = getProcessDefinition(commandContext, builder.ProcessDefinitionId);

            ensureNotNull(typeof(BadUserRequestException), "Process definition id cannot be null", processDefinition);

            writeUserOperationLog(commandContext, processDefinition, processInstanceIds.Count, true);

            BatchEntity batch = createBatch(commandContext, instructions, processInstanceIds, processDefinition);

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

            batch.fireHistoricStartEvent();

            batch.createSeedJob();
            return(batch);
        }
示例#7
0
        public override IBatch Execute(CommandContext commandContext)
        {
            IList <AbstractProcessInstanceModificationCommand> instructions = builder.Instructions;
            ICollection <string> processInstanceIds = CollectProcessInstanceIds(commandContext);

            EnsureUtil.EnsureNotEmpty(typeof(BadUserRequestException), "Modification instructions cannot be empty", instructions);
            EnsureUtil.EnsureNotEmpty(typeof(BadUserRequestException), "Process instance ids cannot be empty", "Process instance ids", processInstanceIds);
            EnsureUtil.EnsureNotContainsNull(typeof(BadUserRequestException), "Process instance ids cannot be null", "Process instance ids", processInstanceIds);

            commandContext.AuthorizationManager.CheckAuthorization(Permissions.Create, Resources.Batch);

            ProcessDefinitionEntity processDefinition = GetProcessDefinition(commandContext, builder.ProcessDefinitionId);

            EnsureUtil.EnsureNotNull(typeof(BadUserRequestException), "Process definition id cannot be null", processDefinition);

            WriteUserOperationLog(commandContext, processDefinition, processInstanceIds.Count, true);

            BatchEntity batch = CreateBatch(commandContext, instructions, processInstanceIds, processDefinition);

            batch.CreateSeedJobDefinition();
            batch.CreateMonitorJobDefinition();
            batch.CreateBatchJobDefinition();

            batch.FireHistoricStartEvent();

            batch.CreateSeedJob();
            return(batch);
        }
示例#8
0
        protected internal virtual void createJobEntities(BatchEntity batch, DeleteProcessInstanceBatchConfiguration configuration, string deploymentId, IList <string> processInstancesToHandle, int invocationsPerBatchJob)
        {
            CommandContext   commandContext   = Context.CommandContext;
            ByteArrayManager byteArrayManager = commandContext.ByteArrayManager;
            JobManager       jobManager       = commandContext.JobManager;

            int createdJobs = 0;

            while (processInstancesToHandle.Count > 0)
            {
                int lastIdIndex = Math.Min(invocationsPerBatchJob, processInstancesToHandle.Count);
                // view of process instances for this job
                IList <string> idsForJob = processInstancesToHandle.subList(0, lastIdIndex);

                DeleteProcessInstanceBatchConfiguration jobConfiguration = createJobConfiguration(configuration, idsForJob);
                ByteArrayEntity configurationEntity = saveConfiguration(byteArrayManager, jobConfiguration);

                JobEntity job = createBatchJob(batch, configurationEntity);
                job.DeploymentId = deploymentId;

                jobManager.insertAndHintJobExecutor(job);
                createdJobs++;

                idsForJob.Clear();
            }

            // update created jobs for batch
            batch.JobsCreated = batch.JobsCreated + createdJobs;

            // update batch configuration
            batch.ConfigurationBytes = writeConfiguration(configuration);
        }
示例#9
0
        private void AddSpan(DwNumber number)
        {
            string[] dmNames = DimensionNumberTypeBiz.Instance.GetEnabledDimensions("12X3");
            List <BatchEntity <DwSpan> > batchEntities = new List <BatchEntity <DwSpan> >(dmNames.Length);

            foreach (string dmName in dmNames)
            {
                string[] numberTypes = DimensionNumberTypeBiz.Instance.GetNumberTypes("12X3", dmName);
                Dictionary <string, int> spanDict = this.DataAccessor.SelectSpansByNumberTypes(number, dmName, numberTypes);
                DwSpan dwSpan = new DwSpan()
                {
                    P = number.P
                };
                foreach (string key in spanDict.Keys)
                {
                    string propertyName = string.Format("{0}Spans", key);
                    dwSpan[propertyName] = spanDict[key];
                }

                string               destTableName = ConfigHelper.GetDwSpanTableName(dmName);
                string[]             columnNames   = numberTypes.Select(x => x + "Spans").Union(new string[] { "P" }).ToArray();
                BatchEntity <DwSpan> batchEntity   = new BatchEntity <DwSpan>(dwSpan, destTableName, columnNames);
                batchEntities.Add(batchEntity);
            }

            DwSpanDAO spanDao = new DwSpanDAO(string.Empty, this.DataAccessor.ConnectionString);

            spanDao.Insert(batchEntities);
        }
示例#10
0
        private List <BatchEntity> GetPrioritizedListOfBatches(string dedicatedBatchId)
        {
            List <BatchEntity> batches = null;

            if (!string.IsNullOrEmpty(dedicatedBatchId))
            {
                batches = _batchRepository.GetBatches().Where(b => b.Status.Equals(BatchStatus.Open) && b.Id.Equals(dedicatedBatchId, StringComparison.CurrentCultureIgnoreCase)).ToList();
            }
            else
            {
                // don't consider batches that require dedicated workers
                // these would have already been assigned to a worker
                batches = _batchRepository.GetBatches().Where(b => b.Status.Equals(BatchStatus.Open) && b.RequiresDedicatedWorker.Equals(false)).OrderBy(b => b.Priority).ToList();
            }
            // there should be a least one batch
            if (batches.Count() <= 0)
            {
                var defaultBatch = new BatchEntity()
                {
                    Id      = GlobalConstants.DEFAULT_BATCH_ID,
                    Name    = GlobalConstants.DEFAULT_BATCH_NAME,
                    Created = DateTime.UtcNow,
                    RequiresDedicatedWorker = false,
                    Priority = 999,
                    Status   = BatchStatus.Open
                };

                _batchRepository.CreateBatch(defaultBatch);

                batches.Add(defaultBatch);
            }

            return(batches);
        }
示例#11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDeleteHistoricIncidentByJobDefinitionId()
        public virtual void testDeleteHistoricIncidentByJobDefinitionId()
        {
            // given
            BatchEntity batch = (BatchEntity)createFailingMigrationBatch();

            migrationHelper.executeSeedJob(batch);

            IList <Job> list = managementService.createJobQuery().list();

            foreach (Job job in list)
            {
                if (((JobEntity)job).JobHandlerType.Equals("instance-migration"))
                {
                    managementService.setJobRetries(job.Id, 1);
                }
            }
            migrationHelper.executeJobs(batch);

            // assume
            if (eventTypes != null)
            {
                HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult();
                assertNotNull(historicIncident);
            }

            // when
            managementService.deleteBatch(batch.Id, true);

            // then
            IList <HistoricIncident> incidents = historyService.createHistoricIncidentQuery().list();

            assertEquals(0, incidents.Count);
        }
示例#12
0
 public static void AddBatch(ModelBuilder modelBuilder, BatchEntity batch)
 {
     modelBuilder.Entity <BatchEntity>().HasData(new BatchEntity
     {
         Id       = batch.Id,
         Quantity = batch.Quantity,
         FruitId  = batch.Fruit.Id
     });
 }
示例#13
0
        public IActionResult Put(int id, [FromBody] BatchEntity batch)
        {
            if (id == batch.Id)
            {
                _batchServices.UpdateBatch(id, batch);

                return(Ok(batch));
            }
            return(NotFound());
        }
示例#14
0
        public int CreateBatch(BatchEntity batchEntity)
        {
            var model = _mapper.Map <BatchEntity, Batch>(batchEntity);


            _unitOfWork.BatchRepository.Insert(model);
            _unitOfWork.Save();

            return(0);
        }
示例#15
0
        //JAVA TO C# CONVERTER WARNING: 'final' parameters are not allowed in .NET:
        //ORIGINAL LINE: public void completeHistoricBatch(final org.camunda.bpm.engine.impl.batch.BatchEntity batch)
        public virtual void CompleteHistoricBatch(BatchEntity batch)
        {
            ProcessEngineConfigurationImpl configuration = context.Impl.Context.ProcessEngineConfiguration;

            IHistoryLevel historyLevel = configuration.HistoryLevel;

            if (historyLevel.IsHistoryEventProduced(HistoryEventTypes.BatchEnd, batch))
            {
                HistoryEventProcessor.ProcessHistoryEvents(new HistoryEventCreatorAnonymousInnerClassHelper2(this, batch));
            }
        }
示例#16
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public void completeHistoricBatch(final org.camunda.bpm.engine.impl.batch.BatchEntity batch)
        public virtual void completeHistoricBatch(BatchEntity batch)
        {
            ProcessEngineConfigurationImpl configuration = Context.ProcessEngineConfiguration;

            HistoryLevel historyLevel = configuration.HistoryLevel;

            if (historyLevel.isHistoryEventProduced(HistoryEventTypes.BATCH_END, batch))
            {
                HistoryEventProcessor.processHistoryEvents(new HistoryEventCreatorAnonymousInnerClass2(this, batch));
            }
        }
示例#17
0
        protected internal override HistoricBatchEntity loadBatchEntity(BatchEntity batch)
        {
            string batchId = batch.Id;

            HistoricBatchEntity cachedEntity = findInCache(typeof(HistoricBatchEntity), batchId);

            if (cachedEntity != null)
            {
                return(cachedEntity);
            }
            else
            {
                return(newBatchEventEntity(batch));
            }
        }
示例#18
0
        protected internal virtual BatchEntity createBatch(CommandContext commandContext, ICollection <string> processInstanceIds)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration      = commandContext.ProcessEngineConfiguration;
            BatchJobHandler <SetRetriesBatchConfiguration> batchJobHandler = getBatchJobHandler(processEngineConfiguration);

            SetRetriesBatchConfiguration configuration = new SetRetriesBatchConfiguration(new List <string>(processInstanceIds), builder.Retries);

            BatchEntity batch = new BatchEntity();

            batch.Type                   = batchJobHandler.Type;
            batch.TotalJobs              = BatchUtil.calculateBatchSize(processEngineConfiguration, configuration);
            batch.BatchJobsPerSeed       = processEngineConfiguration.BatchJobsPerSeed;
            batch.InvocationsPerBatchJob = processEngineConfiguration.InvocationsPerBatchJob;
            batch.ConfigurationBytes     = batchJobHandler.writeConfiguration(configuration);
            commandContext.BatchManager.insertBatch(batch);

            return(batch);
        }
示例#19
0
        protected internal virtual BatchEntity CreateBatch(CommandContext commandContext, IList <string> ids)
        {
            var processEngineConfiguration = commandContext.ProcessEngineConfiguration;
            var batchJobHandler            = GetBatchJobHandler(processEngineConfiguration);

            var configuration = GetAbstractIdsBatchConfiguration(ids);

            var batch = new BatchEntity();

            batch.Type                   = batchJobHandler.Type;
            batch.TotalJobs              = CalculateSize(processEngineConfiguration, configuration);
            batch.BatchJobsPerSeed       = processEngineConfiguration.BatchJobsPerSeed;
            batch.InvocationsPerBatchJob = processEngineConfiguration.InvocationsPerBatchJob;
            batch.ConfigurationBytes     = batchJobHandler.WriteConfiguration(configuration);
            (commandContext.BatchManager as BatchManager).Add(batch);

            return(batch);
        }
示例#20
0
        protected internal virtual BatchEntity createBatch(CommandContext commandContext, IList <string> ids)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration = commandContext.ProcessEngineConfiguration;
            BatchJobHandler batchJobHandler = getBatchJobHandler(processEngineConfiguration);

            BatchConfiguration configuration = getAbstractIdsBatchConfiguration(ids);

            BatchEntity batch = new BatchEntity();

            batch.Type                   = batchJobHandler.Type;
            batch.TotalJobs              = BatchUtil.calculateBatchSize(processEngineConfiguration, configuration);
            batch.BatchJobsPerSeed       = processEngineConfiguration.BatchJobsPerSeed;
            batch.InvocationsPerBatchJob = processEngineConfiguration.InvocationsPerBatchJob;
            batch.ConfigurationBytes     = batchJobHandler.writeConfiguration(configuration);
            commandContext.BatchManager.insertBatch(batch);

            return(batch);
        }
示例#21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testDeleteHistoricIncidentByBatchId()
        public virtual void testDeleteHistoricIncidentByBatchId()
        {
            // given
            initBatchOperationHistoryTimeToLive();
            ClockUtil.CurrentTime = DateUtils.addDays(DateTime.Now, -11);

            BatchEntity batch = (BatchEntity)createFailingMigrationBatch();

            migrationHelper.executeSeedJob(batch);

            IList <Job> list = managementService.createJobQuery().list();

            foreach (Job job in list)
            {
                if (((JobEntity)job).JobHandlerType.Equals("instance-migration"))
                {
                    managementService.setJobRetries(job.Id, 1);
                }
            }
            migrationHelper.executeJobs(batch);

            ClockUtil.CurrentTime = DateUtils.addDays(DateTime.Now, -10);
            managementService.deleteBatch(batch.Id, false);
            ClockUtil.CurrentTime = DateTime.Now;

            // assume
            if (eventTypes != null)
            {
                HistoricIncident historicIncident = historyService.createHistoricIncidentQuery().singleResult();
                assertNotNull(historicIncident);
            }

            // when
            historyService.cleanUpHistoryAsync(true);
            foreach (Job job in historyService.findHistoryCleanupJobs())
            {
                managementService.executeJob(job.Id);
            }

            // then
            IList <HistoricIncident> incidents = historyService.createHistoricIncidentQuery().list();

            assertEquals(0, incidents.Count);
        }
示例#22
0
        public override Batch execute(CommandContext commandContext)
        {
            ISet <string> historicDecisionInstanceIds = new HashSet <string>();

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

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

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

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

            ensureNotNull(typeof(BadUserRequestException), "removalTime", builder.getMode());
            ensureNotEmpty(typeof(BadUserRequestException), "historicDecisionInstances", historicDecisionInstanceIds);

            checkAuthorizations(commandContext, BatchPermissions.CREATE_BATCH_SET_REMOVAL_TIME);

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

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

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

            batch.fireHistoricStartEvent();

            batch.createSeedJob();

            return(batch);
        }
示例#23
0
        protected internal virtual BatchEntity CreateBatch(CommandContext commandContext, IList <AbstractProcessInstanceModificationCommand> instructions, ICollection <string> processInstanceIds, ProcessDefinitionEntity processDefinition)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration = commandContext.ProcessEngineConfiguration;
            IBatchJobHandler batchJobHandler = GetBatchJobHandler(processEngineConfiguration);

            ModificationBatchConfiguration configuration = new ModificationBatchConfiguration(new List <string>(processInstanceIds), builder.ProcessDefinitionId, instructions, builder.SkipCustomListeners, builder.SkipIoMappings);

            BatchEntity batch = new BatchEntity();

            batch.Type                   = batchJobHandler.Type;
            batch.TotalJobs              = CalculateSize(processEngineConfiguration, configuration);
            batch.BatchJobsPerSeed       = processEngineConfiguration.BatchJobsPerSeed;
            batch.InvocationsPerBatchJob = processEngineConfiguration.InvocationsPerBatchJob;
            batch.ConfigurationBytes     = batchJobHandler.WriteConfiguration(configuration);
            batch.TenantId               = processDefinition.TenantId;
            commandContext.BatchManager.Add(batch);

            return(batch);
        }
示例#24
0
        protected internal virtual BatchEntity createBatch(CommandContext commandContext, MigrationPlan migrationPlan, ICollection <string> processInstanceIds, ProcessDefinitionEntity sourceProcessDefinition)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration     = commandContext.ProcessEngineConfiguration;
            BatchJobHandler <MigrationBatchConfiguration> batchJobHandler = getBatchJobHandler(processEngineConfiguration);

            MigrationBatchConfiguration configuration = new MigrationBatchConfiguration(new List <string>(processInstanceIds), migrationPlan, executionBuilder.SkipCustomListeners, executionBuilder.SkipIoMappings);

            BatchEntity batch = new BatchEntity();

            batch.Type                   = batchJobHandler.Type;
            batch.TotalJobs              = BatchUtil.calculateBatchSize(processEngineConfiguration, configuration);
            batch.BatchJobsPerSeed       = processEngineConfiguration.BatchJobsPerSeed;
            batch.InvocationsPerBatchJob = processEngineConfiguration.InvocationsPerBatchJob;
            batch.ConfigurationBytes     = batchJobHandler.writeConfiguration(configuration);
            batch.TenantId               = sourceProcessDefinition.TenantId;
            commandContext.BatchManager.insertBatch(batch);

            return(batch);
        }
示例#25
0
        public override Batch execute(CommandContext commandContext)
        {
            ICollection <string> processInstanceIds = collectProcessInstanceIds();

            EnsureUtil.ensureNotEmpty(typeof(BadUserRequestException), "No process instance ids given", "process Instance Ids", processInstanceIds);
            EnsureUtil.ensureNotContainsNull(typeof(BadUserRequestException), "Cannot be null.", "Process Instance ids", processInstanceIds);
            checkAuthorizations(commandContext);
            writeUserOperationLog(commandContext, processInstanceIds.Count, true);
            BatchEntity batch = createBatch(commandContext, processInstanceIds);

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

            batch.fireHistoricStartEvent();

            batch.createSeedJob();
            return(batch);
        }
示例#26
0
        public override Batch execute(CommandContext commandContext)
        {
            IList <string> processInstanceIds = collectHistoricProcessInstanceIds();

            ensureNotEmpty(typeof(BadUserRequestException), "historicProcessInstanceIds", processInstanceIds);
            checkAuthorizations(commandContext, BatchPermissions.CREATE_BATCH_DELETE_FINISHED_PROCESS_INSTANCES);
            writeUserOperationLog(commandContext, deleteReason, processInstanceIds.Count, true);

            BatchEntity batch = createBatch(commandContext, processInstanceIds);

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

            batch.fireHistoricStartEvent();

            batch.createSeedJob();

            return(batch);
        }
示例#27
0
        public override Batch execute(CommandContext commandContext)
        {
            IList <string> jobIds = collectJobIds(commandContext);

            ensureNotEmpty(typeof(BadUserRequestException), "jobIds", jobIds);
            EnsureUtil.ensureGreaterThanOrEqual("Retries count", retries, 0);
            checkAuthorizations(commandContext, BatchPermissions.CREATE_BATCH_SET_JOB_RETRIES);
            writeUserOperationLog(commandContext, retries, jobIds.Count, true);

            BatchEntity batch = createBatch(commandContext, jobIds);

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

            batch.fireHistoricStartEvent();

            batch.createSeedJob();

            return(batch);
        }
示例#28
0
        public override Batch execute(CommandContext commandContext)
        {
            IList <string> externalTaskIds = collectExternalTaskIds();

            ensureNotEmpty(typeof(BadUserRequestException), "externalTaskIds", externalTaskIds);

            checkPermissions(commandContext);

            writeUserOperationLog(commandContext, builder.Retries, externalTaskIds.Count, true);

            BatchEntity batch = createBatch(commandContext, externalTaskIds);

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

            batch.fireHistoricStartEvent();

            batch.createSeedJob();

            return(batch);
        }
示例#29
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testCleanupHistoricIncident()
        public virtual void testCleanupHistoricIncident()
        {
            initBatchOperationHistoryTimeToLive(DEFAULT_TTL_DAYS);
            ClockUtil.CurrentTime = DateUtils.addDays(DateTime.Now, -11);

            BatchEntity batch = (BatchEntity)createFailingMigrationBatch();

            migrationHelper.executeSeedJob(batch);

            IList <Job> list = managementService.createJobQuery().list();

            foreach (Job job in list)
            {
                if (((JobEntity)job).JobHandlerType.Equals("instance-migration"))
                {
                    managementService.setJobRetries(job.Id, 1);
                }
            }
            migrationHelper.executeJobs(batch);

            IList <string> byteArrayIds = findExceptionByteArrayIds();

            ClockUtil.CurrentTime = DateUtils.addDays(DateTime.Now, -10);
            managementService.deleteBatch(batch.Id, false);
            ClockUtil.CurrentTime = DateTime.Now;

            // given
            HistoricBatch historicBatch = historyService.createHistoricBatchQuery().singleResult();
            string        batchId       = historicBatch.Id;

            // when
            runHistoryCleanup();

            assertEquals(0, historyService.createHistoricBatchQuery().count());
            assertEquals(0, historyService.createHistoricJobLogQuery().jobDefinitionConfiguration(batchId).count());
            assertEquals(0, historyService.createHistoricIncidentQuery().count());
            verifyByteArraysWereRemoved(byteArrayIds.ToArray());
        }
示例#30
0
        public override bool createJobs(BatchEntity batch)
        {
            DeleteProcessInstanceBatchConfiguration configuration = readConfiguration(batch.ConfigurationBytes);

            IList <string> ids = configuration.Ids;
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final org.camunda.bpm.engine.impl.interceptor.CommandContext commandContext = org.camunda.bpm.engine.impl.context.Context.getCommandContext();
            CommandContext commandContext = Context.CommandContext;

            int batchJobsPerSeed       = batch.BatchJobsPerSeed;
            int invocationsPerBatchJob = batch.InvocationsPerBatchJob;

            int numberOfItemsToProcess = Math.Min(invocationsPerBatchJob * batchJobsPerSeed, ids.Count);
            // view of process instances to process
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final java.util.List<String> processIds = ids.subList(0, numberOfItemsToProcess);
            IList <string> processIds = ids.subList(0, numberOfItemsToProcess);

            IList <string> deploymentIds = commandContext.runWithoutAuthorization(new CallableAnonymousInnerClass(this, commandContext, processIds));

            foreach (String deploymentId in deploymentIds)
            {
                IList <String> processIdsPerDeployment = commandContext.runWithoutAuthorization(new CallableAnonymousInnerClass2(this, commandContext, processIds));

//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'removeAll' method:
                processIds.removeAll(processIdsPerDeployment);

                createJobEntities(batch, configuration, deploymentId, processIdsPerDeployment, invocationsPerBatchJob);
            }

            // when there are non existing process instance ids
            if (processIds.Count > 0)
            {
                createJobEntities(batch, configuration, null, processIds, invocationsPerBatchJob);
            }

            return(ids.Count == 0);
        }