use of org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity in project camunda-bpm-platform by camunda.
the class SignalEventReceivedCmd method getProcessDefinitionsOfSubscriptions.
protected Map<String, ProcessDefinitionEntity> getProcessDefinitionsOfSubscriptions(List<EventSubscriptionEntity> startSignalEventSubscriptions) {
DeploymentCache deploymentCache = Context.getProcessEngineConfiguration().getDeploymentCache();
Map<String, ProcessDefinitionEntity> processDefinitions = new HashMap<String, ProcessDefinitionEntity>();
for (EventSubscriptionEntity eventSubscription : startSignalEventSubscriptions) {
String processDefinitionId = eventSubscription.getConfiguration();
ensureNotNull("Configuration of signal start event subscription '" + eventSubscription.getId() + "' contains no process definition id.", processDefinitionId);
ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
if (processDefinition != null && !processDefinition.isSuspended()) {
processDefinitions.put(eventSubscription.getId(), processDefinition);
}
}
return processDefinitions;
}
use of org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity in project camunda-bpm-platform by camunda.
the class GetRenderedStartFormCmd method execute.
public Object execute(CommandContext commandContext) {
ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration();
DeploymentCache deploymentCache = processEngineConfiguration.getDeploymentCache();
ProcessDefinitionEntity processDefinition = deploymentCache.findDeployedProcessDefinitionById(processDefinitionId);
ensureNotNull("Process Definition '" + processDefinitionId + "' not found", "processDefinition", processDefinition);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkReadProcessDefinition(processDefinition);
}
StartFormHandler startFormHandler = processDefinition.getStartFormHandler();
if (startFormHandler == null) {
return null;
}
FormEngine formEngine = Context.getProcessEngineConfiguration().getFormEngines().get(formEngineName);
ensureNotNull("No formEngine '" + formEngineName + "' defined process engine configuration", "formEngine", formEngine);
StartFormData startForm = startFormHandler.createStartFormData(processDefinition);
Object renderedStartForm = null;
try {
renderedStartForm = formEngine.renderStartForm(startForm);
} catch (ScriptEvaluationException e) {
LOG.exceptionWhenStartFormScriptEvaluation(processDefinitionId, e);
}
return renderedStartForm;
}
use of org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity 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.persistence.entity.ProcessDefinitionEntity 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.persistence.entity.ProcessDefinitionEntity in project camunda-bpm-platform by camunda.
the class DefaultHistoryEventProducer method initHistoricVariableUpdateEvt.
protected void initHistoricVariableUpdateEvt(HistoricVariableUpdateEventEntity evt, VariableInstanceEntity variableInstance, HistoryEventType eventType) {
// init properties
evt.setEventType(eventType.getEventName());
evt.setTimestamp(ClockUtil.getCurrentTime());
evt.setVariableInstanceId(variableInstance.getId());
evt.setProcessInstanceId(variableInstance.getProcessInstanceId());
evt.setExecutionId(variableInstance.getExecutionId());
evt.setCaseInstanceId(variableInstance.getCaseInstanceId());
evt.setCaseExecutionId(variableInstance.getCaseExecutionId());
evt.setTaskId(variableInstance.getTaskId());
evt.setRevision(variableInstance.getRevision());
evt.setVariableName(variableInstance.getName());
evt.setSerializerName(variableInstance.getSerializerName());
evt.setTenantId(variableInstance.getTenantId());
evt.setUserOperationId(Context.getCommandContext().getOperationId());
ExecutionEntity execution = variableInstance.getExecution();
if (execution != null) {
ProcessDefinitionEntity definition = execution.getProcessDefinition();
if (definition != null) {
evt.setProcessDefinitionId(definition.getId());
evt.setProcessDefinitionKey(definition.getKey());
}
}
CaseExecutionEntity caseExecution = variableInstance.getCaseExecution();
if (caseExecution != null) {
CaseDefinitionEntity definition = (CaseDefinitionEntity) caseExecution.getCaseDefinition();
if (definition != null) {
evt.setCaseDefinitionId(definition.getId());
evt.setCaseDefinitionKey(definition.getKey());
}
}
// copy value
evt.setTextValue(variableInstance.getTextValue());
evt.setTextValue2(variableInstance.getTextValue2());
evt.setDoubleValue(variableInstance.getDoubleValue());
evt.setLongValue(variableInstance.getLongValue());
if (variableInstance.getByteArrayValueId() != null) {
evt.setByteValue(variableInstance.getByteArrayValue());
}
}
Aggregations