Search in sources :

Example 1 with SignalEventDefinition

use of org.activiti.bpmn.model.SignalEventDefinition 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 SignalEventDefinition

use of org.activiti.bpmn.model.SignalEventDefinition in project Activiti by Activiti.

the class IntermediateCatchEventParseHandler method executeParse.

protected void executeParse(BpmnParse bpmnParse, IntermediateCatchEvent event) {
    ActivityImpl nestedActivity = null;
    EventDefinition eventDefinition = null;
    if (!event.getEventDefinitions().isEmpty()) {
        eventDefinition = event.getEventDefinitions().get(0);
    }
    if (eventDefinition == null) {
        nestedActivity = createActivityOnCurrentScope(bpmnParse, event, BpmnXMLConstants.ELEMENT_EVENT_CATCH);
        nestedActivity.setAsync(event.isAsynchronous());
        nestedActivity.setExclusive(!event.isNotExclusive());
    } else {
        ScopeImpl scope = bpmnParse.getCurrentScope();
        String eventBasedGatewayId = getPrecedingEventBasedGateway(bpmnParse, event);
        if (eventBasedGatewayId != null) {
            ActivityImpl gatewayActivity = scope.findActivity(eventBasedGatewayId);
            nestedActivity = createActivityOnScope(bpmnParse, event, BpmnXMLConstants.ELEMENT_EVENT_CATCH, gatewayActivity);
        } else {
            nestedActivity = createActivityOnScope(bpmnParse, event, BpmnXMLConstants.ELEMENT_EVENT_CATCH, scope);
        }
        nestedActivity.setAsync(event.isAsynchronous());
        nestedActivity.setExclusive(!event.isNotExclusive());
        // Catch event behavior is the same for all types
        nestedActivity.setActivityBehavior(bpmnParse.getActivityBehaviorFactory().createIntermediateCatchEventActivityBehavior(event));
        if (eventDefinition instanceof TimerEventDefinition || eventDefinition instanceof SignalEventDefinition || eventDefinition instanceof MessageEventDefinition) {
            bpmnParse.getBpmnParserHandlers().parseElement(bpmnParse, eventDefinition);
        } else {
            logger.warn("Unsupported intermediate catch event type for event " + event.getId());
        }
    }
}
Also used : ActivityImpl(org.activiti.engine.impl.pvm.process.ActivityImpl) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) EventDefinition(org.activiti.bpmn.model.EventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition) ScopeImpl(org.activiti.engine.impl.pvm.process.ScopeImpl) TimerEventDefinition(org.activiti.bpmn.model.TimerEventDefinition)

Example 3 with SignalEventDefinition

use of org.activiti.bpmn.model.SignalEventDefinition in project Activiti by Activiti.

the class FeedbackStepDefinitionConverter method createBoundarySignalCatch.

protected BoundaryEvent createBoundarySignalCatch(WorkflowDefinitionConversion conversion, Signal signal, UserTask feedbackTask) {
    BoundaryEvent boundarySignalCatch = new BoundaryEvent();
    boundarySignalCatch.setId(conversion.getUniqueNumberedId(ConversionConstants.BOUNDARY_ID_PREFIX));
    boundarySignalCatch.setAttachedToRef(feedbackTask);
    boundarySignalCatch.setAttachedToRefId(feedbackTask.getId());
    boundarySignalCatch.setCancelActivity(true);
    addFlowElement(conversion, boundarySignalCatch);
    SignalEventDefinition signalCatchEventDefinition = new SignalEventDefinition();
    signalCatchEventDefinition.setSignalRef(signal.getId());
    boundarySignalCatch.addEventDefinition(signalCatchEventDefinition);
    return boundarySignalCatch;
}
Also used : BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition)

Example 4 with SignalEventDefinition

use of org.activiti.bpmn.model.SignalEventDefinition in project Activiti by Activiti.

the class BpmnModelUtil method createSignalBoundaryEvent.

public static BoundaryEvent createSignalBoundaryEvent(WorkflowDefinitionConversion conversion, Signal signal, Activity activity, boolean cancelActivity) {
    BoundaryEvent signalBoundaryEvent = new BoundaryEvent();
    signalBoundaryEvent.setId(conversion.getUniqueNumberedId(SIGNAL_BOUNDARY_EVENT));
    signalBoundaryEvent.setCancelActivity(cancelActivity);
    signalBoundaryEvent.setAttachedToRef(activity);
    SignalEventDefinition boundarySignalEventDefinition = new SignalEventDefinition();
    boundarySignalEventDefinition.setSignalRef(signal.getId());
    signalBoundaryEvent.addEventDefinition(boundarySignalEventDefinition);
    return signalBoundaryEvent;
}
Also used : BoundaryEvent(org.activiti.bpmn.model.BoundaryEvent) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition)

Example 5 with SignalEventDefinition

use of org.activiti.bpmn.model.SignalEventDefinition in project Activiti by Activiti.

the class EventSubscriptionManager method addSignalEventSubscriptions.

protected void addSignalEventSubscriptions(CommandContext commandContext, ProcessDefinitionEntity processDefinition, Process process, BpmnModel bpmnModel) {
    if (CollectionUtil.isNotEmpty(process.getFlowElements())) {
        for (FlowElement element : process.getFlowElements()) {
            if (element instanceof StartEvent) {
                StartEvent startEvent = (StartEvent) element;
                if (CollectionUtil.isNotEmpty(startEvent.getEventDefinitions())) {
                    EventDefinition eventDefinition = startEvent.getEventDefinitions().get(0);
                    if (eventDefinition instanceof SignalEventDefinition) {
                        SignalEventDefinition signalEventDefinition = (SignalEventDefinition) eventDefinition;
                        SignalEventSubscriptionEntity subscriptionEntity = commandContext.getEventSubscriptionEntityManager().createSignalEventSubscription();
                        Signal signal = bpmnModel.getSignal(signalEventDefinition.getSignalRef());
                        if (signal != null) {
                            subscriptionEntity.setEventName(signal.getName());
                        } else {
                            subscriptionEntity.setEventName(signalEventDefinition.getSignalRef());
                        }
                        subscriptionEntity.setActivityId(startEvent.getId());
                        subscriptionEntity.setProcessDefinitionId(processDefinition.getId());
                        if (processDefinition.getTenantId() != null) {
                            subscriptionEntity.setTenantId(processDefinition.getTenantId());
                        }
                        Context.getCommandContext().getEventSubscriptionEntityManager().insert(subscriptionEntity);
                    }
                }
            }
        }
    }
}
Also used : Signal(org.activiti.bpmn.model.Signal) FlowElement(org.activiti.bpmn.model.FlowElement) StartEvent(org.activiti.bpmn.model.StartEvent) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) SignalEventDefinition(org.activiti.bpmn.model.SignalEventDefinition) EventDefinition(org.activiti.bpmn.model.EventDefinition) MessageEventDefinition(org.activiti.bpmn.model.MessageEventDefinition) SignalEventSubscriptionEntity(org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity)

Aggregations

SignalEventDefinition (org.activiti.bpmn.model.SignalEventDefinition)26 EventDefinition (org.activiti.bpmn.model.EventDefinition)15 MessageEventDefinition (org.activiti.bpmn.model.MessageEventDefinition)14 TimerEventDefinition (org.activiti.bpmn.model.TimerEventDefinition)9 FlowElement (org.activiti.bpmn.model.FlowElement)8 BoundaryEvent (org.activiti.bpmn.model.BoundaryEvent)6 ErrorEventDefinition (org.activiti.bpmn.model.ErrorEventDefinition)4 Event (org.activiti.bpmn.model.Event)4 Signal (org.activiti.bpmn.model.Signal)4 CancelEventDefinition (org.activiti.bpmn.model.CancelEventDefinition)3 CompensateEventDefinition (org.activiti.bpmn.model.CompensateEventDefinition)3 IntermediateCatchEvent (org.activiti.bpmn.model.IntermediateCatchEvent)3 Message (org.activiti.bpmn.model.Message)3 SubProcess (org.activiti.bpmn.model.SubProcess)3 ThrowEvent (org.activiti.bpmn.model.ThrowEvent)3 BpmnModel (org.activiti.bpmn.model.BpmnModel)2 FlowNode (org.activiti.bpmn.model.FlowNode)2 StartEvent (org.activiti.bpmn.model.StartEvent)2 ActivityImpl (org.activiti.engine.impl.pvm.process.ActivityImpl)2 ScopeImpl (org.activiti.engine.impl.pvm.process.ScopeImpl)2