Search in sources :

Example 1 with EventSubProcessStartEventActivityBehavior

use of org.activiti.engine.impl.bpmn.behavior.EventSubProcessStartEventActivityBehavior in project Activiti by Activiti.

the class StartEventParseHandler method createScopeStartEvent.

protected void createScopeStartEvent(BpmnParse bpmnParse, ActivityImpl startEventActivity, StartEvent startEvent) {
    ScopeImpl scope = bpmnParse.getCurrentScope();
    Object triggeredByEvent = scope.getProperty("triggeredByEvent");
    boolean isTriggeredByEvent = triggeredByEvent != null && ((Boolean) triggeredByEvent == true);
    if (isTriggeredByEvent) {
        // event subprocess
        // all start events of an event subprocess share common behavior
        EventSubProcessStartEventActivityBehavior activityBehavior = bpmnParse.getActivityBehaviorFactory().createEventSubProcessStartEventActivityBehavior(startEvent, startEventActivity.getId());
        startEventActivity.setActivityBehavior(activityBehavior);
        if (!startEvent.getEventDefinitions().isEmpty()) {
            EventDefinition eventDefinition = startEvent.getEventDefinitions().get(0);
            if (eventDefinition instanceof org.activiti.bpmn.model.ErrorEventDefinition || eventDefinition instanceof MessageEventDefinition || eventDefinition instanceof SignalEventDefinition) {
                bpmnParse.getBpmnParserHandlers().parseElement(bpmnParse, eventDefinition);
            } else {
                logger.warn("start event of event subprocess must be of type 'error', 'message' or 'signal' for start event " + startEvent.getId());
            }
        }
    } else {
        if (!startEvent.getEventDefinitions().isEmpty()) {
            logger.warn("event definitions only allowed on start event if subprocess is an event subprocess " + bpmnParse.getCurrentSubProcess().getId());
        }
        if (scope.getProperty(PROPERTYNAME_INITIAL) == null) {
            scope.setProperty(PROPERTYNAME_INITIAL, startEventActivity);
            startEventActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createNoneStartEventActivityBehavior(startEvent));
        } else {
            logger.warn("multiple start events not supported for subprocess", bpmnParse.getCurrentSubProcess().getId());
        }
    }
}
Also used : EventSubProcessStartEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.EventSubProcessStartEventActivityBehavior) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) EventDefinition(org.activiti.bpmn.model.EventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition)

Example 2 with EventSubProcessStartEventActivityBehavior

use of org.activiti.engine.impl.bpmn.behavior.EventSubProcessStartEventActivityBehavior in project Activiti by Activiti.

the class AbstractEventHandler method handleEvent.

public void handleEvent(EventSubscriptionEntity eventSubscription, Object payload, CommandContext commandContext) {
    ExecutionEntity execution = eventSubscription.getExecution();
    ActivityImpl activity = eventSubscription.getActivity();
    if (activity == null) {
        throw new ActivitiException("Error while sending signal for event subscription '" + eventSubscription.getId() + "': " + "no activity associated with event subscription");
    }
    if (payload instanceof Map) {
        @SuppressWarnings("unchecked") Map<String, Object> processVariables = (Map<String, Object>) payload;
        execution.setVariables(processVariables);
    }
    ActivityBehavior activityBehavior = activity.getActivityBehavior();
    if (activityBehavior instanceof BoundaryEventActivityBehavior || activityBehavior instanceof EventSubProcessStartEventActivityBehavior) {
        try {
            dispatchActivitiesCanceledIfNeeded(eventSubscription, execution, activity, commandContext);
            activityBehavior.execute(execution);
        } catch (RuntimeException e) {
            throw e;
        } catch (Exception e) {
            throw new ActivitiException("exception while sending signal for event subscription '" + eventSubscription + "':" + e.getMessage(), e);
        }
    } else {
        // not boundary
        if (!activity.equals(execution.getActivity())) {
            execution.setActivity(activity);
        }
        execution.signal(eventSubscription.getEventName(), payload);
    }
}
Also used : ActivitiException(org.activiti.engine.ActivitiException) BoundaryEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryEventActivityBehavior) ActivitiException(org.activiti.engine.ActivitiException) ExecutionEntity(org.activiti.engine.impl.persistence.entity.ExecutionEntity) ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) EventSubProcessStartEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.EventSubProcessStartEventActivityBehavior) ActivityBehavior(org.activiti.engine.impl.pvm.delegate.ActivityBehavior) BoundaryEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.BoundaryEventActivityBehavior) EventSubProcessStartEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.EventSubProcessStartEventActivityBehavior) Map(java.util.Map)

Example 3 with EventSubProcessStartEventActivityBehavior

use of org.activiti.engine.impl.bpmn.behavior.EventSubProcessStartEventActivityBehavior in project Activiti by Activiti.

the class ErrorPropagation method executeEventHandler.

private static void executeEventHandler(ActivityImpl borderEventActivity, ActivityExecution leavingExecution, String errorCode) {
    if (Context.getProcessEngineConfiguration() != null && Context.getProcessEngineConfiguration().getEventDispatcher().isEnabled()) {
        Context.getProcessEngineConfiguration().getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createErrorEvent(ActivitiEventType.ACTIVITY_ERROR_RECEIVED, borderEventActivity.getId(), errorCode, leavingExecution.getId(), leavingExecution.getProcessInstanceId(), leavingExecution.getProcessDefinitionId()));
    }
    // The current activity of the execution will be changed in the next lines.
    // So we must make sure the activity is ended correctly here
    // The other executions (for example when doing something parallel in a subprocess, will
    // be destroyed by the destroy scope operation (but this execution will be used to do it and 
    // will have list the original activity by then)
    Context.getCommandContext().getHistoryManager().recordActivityEnd((ExecutionEntity) leavingExecution);
    if (borderEventActivity.getActivityBehavior() instanceof EventSubProcessStartEventActivityBehavior) {
        InterpretableExecution execution = (InterpretableExecution) leavingExecution;
        execution.setActivity(borderEventActivity.getParentActivity());
        // make sure the listeners are invoked!
        execution.performOperation(AtomicOperation.ACTIVITY_START);
    } else {
        leavingExecution.executeActivity(borderEventActivity);
    }
}
Also used : EventSubProcessStartEventActivityBehavior(org.activiti.engine.impl.bpmn.behavior.EventSubProcessStartEventActivityBehavior) InterpretableExecution(org.activiti.engine.impl.pvm.runtime.InterpretableExecution)

Aggregations

EventSubProcessStartEventActivityBehavior (org.activiti.engine.impl.bpmn.behavior.EventSubProcessStartEventActivityBehavior)3 Map (java.util.Map)1 EventDefinition (org.activiti.bpmn.model.EventDefinition)1 MessageEventDefinition (org.activiti.bpmn.model.MessageEventDefinition)1 SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)1 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)1 ActivitiException (org.activiti.engine.ActivitiException)1 BoundaryEventActivityBehavior (org.activiti.engine.impl.bpmn.behavior.BoundaryEventActivityBehavior)1 ExecutionEntity (org.activiti.engine.impl.persistence.entity.ExecutionEntity)1 ActivityBehavior (org.activiti.engine.impl.pvm.delegate.ActivityBehavior)1 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)1 ScopeImpl (org.activiti.engine.impl.pvm.process.ScopeImpl)1 InterpretableExecution (org.activiti.engine.impl.pvm.runtime.InterpretableExecution)1