use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.
the class SignalCmd method execute.
public Object execute(CommandContext commandContext) {
ensureNotNull(BadUserRequestException.class, "executionId is null", "executionId", executionId);
ExecutionEntity execution = commandContext.getExecutionManager().findExecutionById(executionId);
ensureNotNull(BadUserRequestException.class, "execution " + executionId + " doesn't exist", "execution", execution);
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkUpdateProcessInstance(execution);
}
if (processVariables != null) {
execution.setVariables(processVariables);
}
execution.signal(signalName, signalData);
return null;
}
use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.
the class VariableListenerInvocationListener method addEventToScopeExecution.
protected void addEventToScopeExecution(ExecutionEntity sourceScope, VariableEvent event) {
// ignore events of variables that are not set in an execution
ExecutionEntity sourceExecution = sourceScope;
ExecutionEntity scopeExecution = sourceExecution.isScope() ? sourceExecution : sourceExecution.getParent();
scopeExecution.delayEvent((ExecutionEntity) targetScope, event);
}
use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.
the class CompensationEventHandler method handleEvent.
@Override
public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, String businessKey, CommandContext commandContext) {
eventSubscription.delete();
String configuration = eventSubscription.getConfiguration();
ensureNotNull("Compensating execution not set for compensate event subscription with id " + eventSubscription.getId(), "configuration", configuration);
ExecutionEntity compensatingExecution = commandContext.getExecutionManager().findExecutionById(configuration);
ActivityImpl compensationHandler = eventSubscription.getActivity();
// activate execution
compensatingExecution.setActive(true);
if (compensatingExecution.getActivity().getActivityBehavior() instanceof CompositeActivityBehavior) {
compensatingExecution.getParent().setActivityInstanceId(compensatingExecution.getActivityInstanceId());
}
if (compensationHandler.isScope() && !compensationHandler.isCompensationHandler()) {
// descend into scope:
List<EventSubscriptionEntity> eventsForThisScope = compensatingExecution.getCompensateEventSubscriptions();
CompensationUtil.throwCompensationEvent(eventsForThisScope, compensatingExecution, false);
} else {
try {
if (compensationHandler.isSubProcessScope() && compensationHandler.isTriggeredByEvent()) {
compensatingExecution.executeActivity(compensationHandler);
} else {
// since we already have a scope execution, we don't need to create another one
// for a simple scoped compensation handler
compensatingExecution.setActivity(compensationHandler);
compensatingExecution.performOperation(PvmAtomicOperation.ACTIVITY_START);
}
} catch (Exception e) {
throw new ProcessEngineException("Error while handling compensation event " + eventSubscription, e);
}
}
}
use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.
the class DefaultHistoryEventProducer method createProcessInstanceStartEvt.
// Implementation ////////////////////////////////
public HistoryEvent createProcessInstanceStartEvt(DelegateExecution execution) {
final ExecutionEntity executionEntity = (ExecutionEntity) execution;
// create event instance
HistoricProcessInstanceEventEntity evt = newProcessInstanceEventEntity(executionEntity);
// initialize event
initProcessInstanceEvent(evt, executionEntity, HistoryEventTypes.PROCESS_INSTANCE_START);
evt.setStartActivityId(executionEntity.getActivityId());
evt.setStartTime(ClockUtil.getCurrentTime());
// set super process instance id
ExecutionEntity superExecution = executionEntity.getSuperExecution();
if (superExecution != null) {
evt.setSuperProcessInstanceId(superExecution.getProcessInstanceId());
}
// state
evt.setState(HistoricProcessInstance.STATE_ACTIVE);
// set start user Id
evt.setStartUserId(Context.getCommandContext().getAuthenticatedUserId());
return evt;
}
use of org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity in project camunda-bpm-platform by camunda.
the class DefaultHistoryEventProducer method initActivityInstanceEvent.
protected void initActivityInstanceEvent(HistoricActivityInstanceEventEntity evt, ExecutionEntity execution, PvmScope eventSource, String activityInstanceId, String parentActivityInstanceId, HistoryEventType eventType) {
evt.setId(activityInstanceId);
evt.setEventType(eventType.getEventName());
evt.setActivityInstanceId(activityInstanceId);
evt.setParentActivityInstanceId(parentActivityInstanceId);
evt.setProcessDefinitionId(execution.getProcessDefinitionId());
evt.setProcessInstanceId(execution.getProcessInstanceId());
evt.setExecutionId(execution.getId());
evt.setTenantId(execution.getTenantId());
ProcessDefinitionEntity definition = execution.getProcessDefinition();
if (definition != null) {
evt.setProcessDefinitionKey(definition.getKey());
}
evt.setActivityId(eventSource.getId());
evt.setActivityName((String) eventSource.getProperty("name"));
evt.setActivityType((String) eventSource.getProperty("type"));
// update sub process reference
ExecutionEntity subProcessInstance = execution.getSubProcessInstance();
if (subProcessInstance != null) {
evt.setCalledProcessInstanceId(subProcessInstance.getId());
}
// update sub case reference
CaseExecutionEntity subCaseInstance = execution.getSubCaseInstance();
if (subCaseInstance != null) {
evt.setCalledCaseInstanceId(subCaseInstance.getId());
}
}
Aggregations