Search in sources :

Example 36 with ExecutionEntity

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;
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) CommandChecker(org.camunda.bpm.engine.impl.cfg.CommandChecker)

Example 37 with ExecutionEntity

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);
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)

Example 38 with ExecutionEntity

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);
        }
    }
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) ActivityImpl(org.camunda.bpm.engine.impl.pvm.process.ActivityImpl) CompositeActivityBehavior(org.camunda.bpm.engine.impl.pvm.delegate.CompositeActivityBehavior) EventSubscriptionEntity(org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException) ProcessEngineException(org.camunda.bpm.engine.ProcessEngineException)

Example 39 with ExecutionEntity

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;
}
Also used : ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)

Example 40 with ExecutionEntity

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());
    }
}
Also used : CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) ExecutionEntity(org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity) CaseExecutionEntity(org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)

Aggregations

ExecutionEntity (org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity)170 Deployment (org.camunda.bpm.engine.test.Deployment)42 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)18 TaskEntity (org.camunda.bpm.engine.impl.persistence.entity.TaskEntity)17 CaseExecutionEntity (org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity)16 Execution (org.camunda.bpm.engine.runtime.Execution)14 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)13 ActivityImpl (org.camunda.bpm.engine.impl.pvm.process.ActivityImpl)12 Task (org.camunda.bpm.engine.task.Task)12 ScopeImpl (org.camunda.bpm.engine.impl.pvm.process.ScopeImpl)10 ArrayList (java.util.ArrayList)9 VariableInstanceEntity (org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity)9 Test (org.junit.Test)9 CommandChecker (org.camunda.bpm.engine.impl.cfg.CommandChecker)7 EventSubscriptionEntity (org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity)7 PvmExecutionImpl (org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl)7 ProcessDefinitionImpl (org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl)6 ActivityInstance (org.camunda.bpm.engine.runtime.ActivityInstance)6 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)5 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)5