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