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); }