use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.
the class AbstractBpmnActivityBehavior method signalCompensationDone.
protected void signalCompensationDone(ActivityExecution execution) {
if (((PvmExecutionImpl) execution).getNonEventScopeExecutions().isEmpty()) {
if (execution.getParent() != null) {
ActivityExecution parent = execution.getParent();
execution.remove();
parent.signal(SIGNAL_COMPENSATION_DONE, null);
}
} else {
((ExecutionEntity) execution).forceUpdate();
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.
the class SetProcessDefinitionVersionCmd method execute.
public Void execute(CommandContext commandContext) {
ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration();
// check that the new process definition is just another version of the same
// process definition that the process instance is using
ExecutionManager executionManager = commandContext.getExecutionManager();
final ExecutionEntity processInstance = executionManager.findExecutionById(processInstanceId);
if (processInstance == null) {
throw new ProcessEngineException("No process instance found for id = '" + processInstanceId + "'.");
} else if (!processInstance.isProcessInstanceExecution()) {
throw new ProcessEngineException("A process instance id is required, but the provided id " + "'" + processInstanceId + "' " + "points to a child execution of process instance " + "'" + processInstance.getProcessInstanceId() + "'. " + "Please invoke the " + getClass().getSimpleName() + " with a root execution id.");
}
ProcessDefinitionImpl currentProcessDefinitionImpl = processInstance.getProcessDefinition();
DeploymentCache deploymentCache = configuration.getDeploymentCache();
ProcessDefinitionEntity currentProcessDefinition;
if (currentProcessDefinitionImpl instanceof ProcessDefinitionEntity) {
currentProcessDefinition = (ProcessDefinitionEntity) currentProcessDefinitionImpl;
} else {
currentProcessDefinition = deploymentCache.findDeployedProcessDefinitionById(currentProcessDefinitionImpl.getId());
}
ProcessDefinitionEntity newProcessDefinition = deploymentCache.findDeployedProcessDefinitionByKeyVersionAndTenantId(currentProcessDefinition.getKey(), processDefinitionVersion, currentProcessDefinition.getTenantId());
validateAndSwitchVersionOfExecution(commandContext, processInstance, newProcessDefinition);
HistoryLevel historyLevel = configuration.getHistoryLevel();
if (historyLevel.isHistoryEventProduced(HistoryEventTypes.PROCESS_INSTANCE_UPDATE, processInstance)) {
HistoryEventProcessor.processHistoryEvents(new HistoryEventProcessor.HistoryEventCreator() {
@Override
public HistoryEvent createHistoryEvent(HistoryEventProducer producer) {
return producer.createProcessInstanceUpdateEvt(processInstance);
}
});
}
// switch all sub-executions of the process instance to the new process definition version
List<ExecutionEntity> childExecutions = executionManager.findExecutionsByProcessInstanceId(processInstanceId);
for (ExecutionEntity executionEntity : childExecutions) {
validateAndSwitchVersionOfExecution(commandContext, executionEntity, newProcessDefinition);
}
// switch all jobs to the new process definition version
List<JobEntity> jobs = commandContext.getJobManager().findJobsByProcessInstanceId(processInstanceId);
List<JobDefinitionEntity> currentJobDefinitions = commandContext.getJobDefinitionManager().findByProcessDefinitionId(currentProcessDefinition.getId());
List<JobDefinitionEntity> newVersionJobDefinitions = commandContext.getJobDefinitionManager().findByProcessDefinitionId(newProcessDefinition.getId());
Map<String, String> jobDefinitionMapping = getJobDefinitionMapping(currentJobDefinitions, newVersionJobDefinitions);
for (JobEntity jobEntity : jobs) {
switchVersionOfJob(jobEntity, newProcessDefinition, jobDefinitionMapping);
}
// switch all incidents to the new process definition version
List<IncidentEntity> incidents = commandContext.getIncidentManager().findIncidentsByProcessInstance(processInstanceId);
for (IncidentEntity incidentEntity : incidents) {
switchVersionOfIncident(commandContext, incidentEntity, newProcessDefinition);
}
// add an entry to the op log
PropertyChange change = new PropertyChange("processDefinitionVersion", currentProcessDefinition.getVersion(), processDefinitionVersion);
commandContext.getOperationLogManager().logProcessInstanceOperation(UserOperationLogEntry.OPERATION_TYPE_MODIFY_PROCESS_INSTANCE, processInstanceId, null, null, Collections.singletonList(change));
return null;
}
use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.
the class SignalEventReceivedCmd method sendSignalToExecution.
protected void sendSignalToExecution(CommandContext commandContext, String signalName, String executionId) {
ExecutionManager executionManager = commandContext.getExecutionManager();
ExecutionEntity execution = executionManager.findExecutionById(executionId);
ensureNotNull("Cannot find execution with id '" + executionId + "'", "execution", execution);
EventSubscriptionManager eventSubscriptionManager = commandContext.getEventSubscriptionManager();
List<EventSubscriptionEntity> signalEvents = eventSubscriptionManager.findSignalEventSubscriptionsByNameAndExecution(signalName, executionId);
ensureNotEmpty("Execution '" + executionId + "' has not subscribed to a signal event with name '" + signalName + "'.", signalEvents);
checkAuthorizationOfCatchSignals(commandContext, signalEvents);
notifyExecutions(signalEvents);
}
use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.
the class StartProcessInstanceCmd method execute.
public ProcessInstanceWithVariables execute(CommandContext commandContext) {
ProcessDefinitionEntity processDefinition = new GetDeployedProcessDefinitionCmd(instantiationBuilder, false).execute(commandContext);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkCreateProcessInstance(processDefinition);
}
// Start the process instance
ExecutionEntity processInstance = processDefinition.createProcessInstance(instantiationBuilder.getBusinessKey(), instantiationBuilder.getCaseInstanceId());
if (instantiationBuilder.getTenantId() != null) {
processInstance.setTenantId(instantiationBuilder.getTenantId());
}
final ExecutionVariableSnapshotObserver variablesListener = new ExecutionVariableSnapshotObserver(processInstance);
processInstance.start(instantiationBuilder.getVariables());
return new ProcessInstanceWithVariablesImpl(processInstance, variablesListener.getVariables());
}
use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.
the class GetExecutionVariableTypedCmd method execute.
public T execute(CommandContext commandContext) {
ensureNotNull("executionId", executionId);
ensureNotNull("variableName", variableName);
ExecutionEntity execution = commandContext.getExecutionManager().findExecutionById(executionId);
ensureNotNull("execution " + executionId + " doesn't exist", "execution", execution);
checkGetExecutionVariableTyped(execution, commandContext);
T value;
if (isLocal) {
value = execution.getVariableLocalTyped(variableName, deserializeValue);
} else {
value = execution.getVariableTyped(variableName, deserializeValue);
}
return value;
}
Aggregations