use of org.camunda.bpm.engine.impl.cfg.CommandChecker 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());
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class SubmitStartFormCmd method execute.
@Override
public ProcessInstance execute(CommandContext commandContext) {
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();
ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
ensureNotNull("No process definition found for id = '" + processDefinitionId + "'", "processDefinition", processDefinition);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkCreateProcessInstance(processDefinition);
}
ExecutionEntity processInstance = null;
if (businessKey != null) {
processInstance = processDefinition.createProcessInstance(businessKey);
} else {
processInstance = processDefinition.createProcessInstance();
}
// see CAM-2828
if (processDefinition.getInitial().isAsyncBefore()) {
// avoid firing history events
processInstance.setStartContext(new ProcessInstanceStartContext(processInstance.getActivity()));
FormPropertyHelper.initFormPropertiesOnScope(variables, processInstance);
processInstance.start();
} else {
processInstance.startWithFormProperties(variables);
}
return processInstance;
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class CreateCaseInstanceCmd method execute.
public CaseInstance execute(CommandContext commandContext) {
ensureAtLeastOneNotNull("caseDefinitionId and caseDefinitionKey are null", caseDefinitionId, caseDefinitionKey);
CaseDefinitionEntity caseDefinition = find(commandContext);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkCreateCaseInstance(caseDefinition);
}
// Start the case instance
CaseExecutionEntity caseInstance = (CaseExecutionEntity) caseDefinition.createCaseInstance(businessKey);
caseInstance.create(variables);
return caseInstance;
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class GetDeploymentCmmnModelInstanceCmd method execute.
public CmmnModelInstance execute(CommandContext commandContext) {
ensureNotNull("caseDefinitionId", caseDefinitionId);
ProcessEngineConfigurationImpl configuration = Context.getProcessEngineConfiguration();
final DeploymentCache deploymentCache = configuration.getDeploymentCache();
CaseDefinitionEntity caseDefinition = deploymentCache.findDeployedCaseDefinitionById(caseDefinitionId);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkReadCaseDefinition(caseDefinition);
}
CmmnModelInstance modelInstance = Context.getProcessEngineConfiguration().getDeploymentCache().findCmmnModelInstanceForCaseDefinition(caseDefinitionId);
ensureNotNull(CmmnModelInstanceNotFoundException.class, "No CMMN model instance found for case definition id " + caseDefinitionId, "modelInstance", modelInstance);
return modelInstance;
}
use of org.camunda.bpm.engine.impl.cfg.CommandChecker in project camunda-bpm-platform by camunda.
the class CaseExecutionVariableCmd method execute.
public Void execute(CommandContext commandContext) {
ensureNotNull("caseExecutionId", caseExecutionId);
caseExecution = commandContext.getCaseExecutionManager().findCaseExecutionById(caseExecutionId);
ensureNotNull(CaseExecutionNotFoundException.class, "There does not exist any case execution with id: '" + caseExecutionId + "'", "caseExecution", caseExecution);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkUpdateCaseInstance(caseExecution);
}
if (variablesDeletions != null && !variablesDeletions.isEmpty()) {
caseExecution.removeVariables(variablesDeletions);
}
if (variablesLocalDeletions != null && !variablesLocalDeletions.isEmpty()) {
caseExecution.removeVariablesLocal(variablesLocalDeletions);
}
if (variables != null && !variables.isEmpty()) {
caseExecution.setVariables(variables);
}
if (variablesLocal != null && !variablesLocal.isEmpty()) {
caseExecution.setVariablesLocal(variablesLocal);
}
return null;
}
Aggregations