Search in sources :

Example 1 with AbstractProcessInstanceModificationCommand

use of org.camunda.bpm.engine.impl.cmd.AbstractProcessInstanceModificationCommand in project camunda-bpm-platform by camunda.

the class RestartProcessInstancesBatchCmd method execute.

@Override
public Batch execute(CommandContext commandContext) {
    List<AbstractProcessInstanceModificationCommand> instructions = builder.getInstructions();
    Collection<String> processInstanceIds = collectProcessInstanceIds();
    ensureNotEmpty(BadUserRequestException.class, "Restart instructions cannot be empty", "instructions", instructions);
    ensureNotEmpty(BadUserRequestException.class, "Process instance ids cannot be empty", "processInstanceIds", processInstanceIds);
    ensureNotContainsNull(BadUserRequestException.class, "Process instance ids cannot be null", "processInstanceIds", processInstanceIds);
    commandContext.getAuthorizationManager().checkAuthorization(Permissions.CREATE, Resources.BATCH);
    ProcessDefinitionEntity processDefinition = getProcessDefinition(commandContext, builder.getProcessDefinitionId());
    ;
    ensureNotNull(BadUserRequestException.class, "Process definition cannot be null", processDefinition);
    ensureTenantAuthorized(commandContext, processDefinition);
    writeUserOperationLog(commandContext, processDefinition, processInstanceIds.size(), true);
    ArrayList<String> ids = new ArrayList<String>();
    ids.addAll(processInstanceIds);
    BatchEntity batch = createBatch(commandContext, instructions, ids, processDefinition);
    batch.createSeedJobDefinition();
    batch.createMonitorJobDefinition();
    batch.createBatchJobDefinition();
    batch.fireHistoricStartEvent();
    batch.createSeedJob();
    return batch;
}
Also used : AbstractProcessInstanceModificationCommand(org.camunda.bpm.engine.impl.cmd.AbstractProcessInstanceModificationCommand) ArrayList(java.util.ArrayList) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)

Aggregations

ArrayList (java.util.ArrayList)1 AbstractProcessInstanceModificationCommand (org.camunda.bpm.engine.impl.cmd.AbstractProcessInstanceModificationCommand)1 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)1