コード例 #1
0
        public override Batch execute(CommandContext commandContext)
        {
            IList <AbstractProcessInstanceModificationCommand> instructions = builder.Instructions;
            ICollection <string> processInstanceIds = collectProcessInstanceIds();

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

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

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

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

            List <string> ids = new List <string>();

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

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

            batch.fireHistoricStartEvent();

            batch.createSeedJob();
            return(batch);
        }
コード例 #2
0
 protected internal virtual void checkAccess(CommandContext commandContext, BatchEntity batch)
 {
     foreach (CommandChecker checker in commandContext.ProcessEngineConfiguration.CommandCheckers)
     {
         checker.checkDeleteBatch(batch);
     }
 }
コード例 #3
0
        public virtual void deleteJobs(BatchEntity batch)
        {
            IList <JobEntity> jobs = Context.CommandContext.JobManager.findJobsByJobDefinitionId(batch.BatchJobDefinitionId);

            foreach (JobEntity job in jobs)
            {
                job.delete();
            }
        }
コード例 #4
0
        public virtual Void execute(CommandContext commandContext)
        {
            ensureNotNull(typeof(BadUserRequestException), "Batch id must not be null", "batch id", batchId);

            BatchEntity batchEntity = commandContext.BatchManager.findBatchById(batchId);

            ensureNotNull(typeof(BadUserRequestException), "Batch for id '" + batchId + "' cannot be found", "batch", batchEntity);

            checkAccess(commandContext, batchEntity);
            writeUserOperationLog(commandContext);
            batchEntity.delete(cascadeToHistory);

            return(null);
        }
コード例 #5
0
        public virtual void execute(BatchMonitorJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId)
        {
            string      batchId = configuration.BatchId;
            BatchEntity batch   = commandContext.BatchManager.findBatchById(configuration.BatchId);

            ensureNotNull("Batch with id '" + batchId + "' cannot be found", "batch", batch);

            bool completed = batch.Completed;

            if (!completed)
            {
                batch.createMonitorJob(true);
            }
            else
            {
                batch.delete(false);
            }
        }
コード例 #6
0
        protected internal virtual BatchEntity createBatch(CommandContext commandContext, IList <AbstractProcessInstanceModificationCommand> instructions, IList <string> processInstanceIds, ProcessDefinitionEntity processDefinition)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration = commandContext.ProcessEngineConfiguration;
            BatchJobHandler <RestartProcessInstancesBatchConfiguration> batchJobHandler = getBatchJobHandler(processEngineConfiguration);

            RestartProcessInstancesBatchConfiguration configuration = new RestartProcessInstancesBatchConfiguration(processInstanceIds, instructions, builder.ProcessDefinitionId, builder.InitialVariables, builder.SkipCustomListeners, builder.SkipIoMappings, builder.WithoutBusinessKey);

            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               = processDefinition.TenantId;
            commandContext.BatchManager.insertBatch(batch);

            return(batch);
        }
コード例 #7
0
        public virtual bool createJobs(BatchEntity batch)
        {
            CommandContext   commandContext   = Context.CommandContext;
            ByteArrayManager byteArrayManager = commandContext.ByteArrayManager;
            JobManager       jobManager       = commandContext.JobManager;

            T configuration = readConfiguration(batch.ConfigurationBytes);

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

            IList <string> ids = configuration.Ids;
            int            numberOfItemsToProcess = Math.Min(invocationsPerBatchJob * batchJobsPerSeed, ids.Count);
            // view of process instances to process
            IList <string> processIds = ids.subList(0, numberOfItemsToProcess);

            int createdJobs = 0;

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

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

                JobEntity job = createBatchJob(batch, configurationEntity);
                postProcessJob(configuration, job);
                jobManager.insertAndHintJobExecutor(job);

                idsForJob.Clear();
                createdJobs++;
            }

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

            // update batch configuration
            batch.ConfigurationBytes = writeConfiguration(configuration);

            return(ids.Count == 0);
        }
コード例 #8
0
        public virtual void execute(BatchSeedJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, string tenantId)
        {
            string      batchId = configuration.BatchId;
            BatchEntity batch   = commandContext.BatchManager.findBatchById(batchId);

            ensureNotNull("Batch with id '" + batchId + "' cannot be found", "batch", batch);

//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: BatchJobHandler<?> batchJobHandler = commandContext.getProcessEngineConfiguration().getBatchHandlers().get(batch.getType());
            BatchJobHandler <object> batchJobHandler = commandContext.ProcessEngineConfiguration.BatchHandlers[batch.Type];

            bool done = batchJobHandler.createJobs(batch);

            if (!done)
            {
                batch.createSeedJob();
            }
            else
            {
                // create monitor job initially without due date to
                // enable rapid completion of simple batches
                batch.createMonitorJob(false);
            }
        }
コード例 #9
0
 public BatchJobContext(BatchEntity batchEntity, ByteArrayEntity configuration)
 {
     this.batch         = batchEntity;
     this.configuration = configuration;
 }
コード例 #10
0
        protected internal virtual JobEntity createBatchJob(BatchEntity batch, ByteArrayEntity configuration)
        {
            BatchJobContext creationContext = new BatchJobContext(batch, configuration);

            return(JobDeclaration.createJobInstance(creationContext));
        }