use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.
the class ProcessInstanceModificationCmd method execute.
@Override
public Void execute(final CommandContext commandContext) {
List<AbstractProcessInstanceModificationCommand> instructions = builder.getInstructions();
final Collection<String> processInstanceIds = collectProcessInstanceIds(commandContext);
ensureNotEmpty(BadUserRequestException.class, "Modification instructions cannot be empty", instructions);
ensureNotEmpty(BadUserRequestException.class, "Process instance ids cannot be empty", "Process instance ids", processInstanceIds);
ensureNotContainsNull(BadUserRequestException.class, "Process instance ids cannot be null", "Process instance ids", processInstanceIds);
ProcessDefinitionEntity processDefinition = getProcessDefinition(commandContext, builder.getProcessDefinitionId());
ensureNotNull(BadUserRequestException.class, "Process definition id cannot be null", processDefinition);
if (writeUserOperationLog) {
writeUserOperationLog(commandContext, processDefinition, processInstanceIds.size(), false);
}
boolean skipCustomListeners = builder.isSkipCustomListeners();
boolean skipIoMappings = builder.isSkipIoMappings();
for (String processInstanceId : processInstanceIds) {
ExecutionEntity processInstance = commandContext.getExecutionManager().findExecutionById(processInstanceId);
ensureProcessInstanceExist(processInstanceId, processInstance);
ensureSameProcessDefinition(processInstance, processDefinition.getId());
ProcessInstanceModificationBuilderImpl builder = createProcessInstanceModificationBuilder(processInstanceId, commandContext);
builder.execute(false, skipCustomListeners, skipIoMappings);
}
return null;
}
use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.
the class RemoveExecutionVariablesCmd method getEntity.
protected ExecutionEntity getEntity() {
ensureNotNull("executionId", entityId);
ExecutionEntity execution = commandContext.getExecutionManager().findExecutionById(entityId);
ensureNotNull("execution " + entityId + " doesn't exist", "execution", execution);
checkRemoveExecutionVariables(execution);
return execution;
}
use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.
the class GetActivityInstanceCmd method loadFromDb.
protected List<ExecutionEntity> loadFromDb(final String processInstanceId, final CommandContext commandContext) {
List<ExecutionEntity> executions = commandContext.getExecutionManager().findExecutionsByProcessInstanceId(processInstanceId);
ExecutionEntity processInstance = commandContext.getExecutionManager().findExecutionById(processInstanceId);
// initialize parent/child sets
if (processInstance != null) {
processInstance.restoreProcessInstance(executions, null, null, null, null, null, null);
}
return executions;
}
use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.
the class SetExecutionVariablesCmd method getEntity.
protected ExecutionEntity getEntity() {
ensureNotNull("executionId", entityId);
ExecutionEntity execution = commandContext.getExecutionManager().findExecutionById(entityId);
ensureNotNull("execution " + entityId + " doesn't exist", "execution", execution);
checkSetExecutionVariables(execution);
return execution;
}
use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.
the class StartProcessInstanceAtActivitiesCmd method execute.
public ProcessInstanceWithVariables execute(CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = new GetDeployedProcessDefinitionCmd(instantiationBuilder, false).execute(commandContext);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkCreateProcessInstance(processDefinition);
}
ProcessInstanceModificationBuilderImpl modificationBuilder = instantiationBuilder.getModificationBuilder();
ensureNotEmpty("At least one instantiation instruction required (e.g. by invoking startBefore(..), startAfter(..) or startTransition(..))", "instructions", modificationBuilder.getModificationOperations());
// instantiate the process
ActivityImpl initialActivity = determineFirstActivity(processDefinition, modificationBuilder);
ExecutionEntity processInstance = processDefinition.createProcessInstance(instantiationBuilder.getBusinessKey(), instantiationBuilder.getCaseInstanceId(), initialActivity);
if (instantiationBuilder.getTenantId() != null) {
processInstance.setTenantId(instantiationBuilder.getTenantId());
}
processInstance.setSkipCustomListeners(modificationBuilder.isSkipCustomListeners());
VariableMap variables = modificationBuilder.getProcessVariables();
final ExecutionVariableSnapshotObserver variablesListener = new ExecutionVariableSnapshotObserver(processInstance);
processInstance.startWithoutExecuting(variables);
// prevent ending of the process instance between instructions
processInstance.setPreserveScope(true);
// apply modifications
List<AbstractProcessInstanceModificationCommand> instructions = modificationBuilder.getModificationOperations();
for (int i = 0; i < instructions.size(); i++) {
AbstractProcessInstanceModificationCommand instruction = instructions.get(i);
LOG.debugStartingInstruction(processInstance.getId(), i, instruction.describe());
instruction.setProcessInstanceId(processInstance.getId());
instruction.setSkipCustomListeners(modificationBuilder.isSkipCustomListeners());
instruction.setSkipIoMappings(modificationBuilder.isSkipIoMappings());
instruction.execute(commandContext);
}
if (!processInstance.hasChildren() && processInstance.isEnded()) {
// process instance has ended regularly but this has not been propagated yet
// due to preserveScope setting
processInstance.propagateEnd();
}
return new ProcessInstanceWithVariablesImpl(processInstance, variablesListener.getVariables());
}
Aggregations