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());
}
}
}
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);
}
}
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);
}
}
Aggregations