use of io.camunda.zeebe.engine.processing.bpmn.BpmnProcessingException in project zeebe by camunda.
the class BpmnStateBehavior method canBeCompleted.
public boolean canBeCompleted(final BpmnElementContext context) {
final ElementInstance flowScopeInstance = getFlowScopeInstance(context);
if (flowScopeInstance == null) {
return false;
}
final long activePaths = flowScopeInstance.getNumberOfActiveElementInstances() + flowScopeInstance.getActiveSequenceFlows();
if (activePaths < 0) {
throw new BpmnProcessingException(context, String.format("Expected number of active paths to be positive but got %d for instance %s", activePaths, flowScopeInstance));
}
return activePaths == 0;
}
use of io.camunda.zeebe.engine.processing.bpmn.BpmnProcessingException in project zeebe by camunda.
the class SubProcessProcessor method onActivate.
@Override
public void onActivate(final ExecutableFlowElementContainer element, final BpmnElementContext activating) {
variableMappingBehavior.applyInputMappings(activating, element).flatMap(ok -> eventSubscriptionBehavior.subscribeToEvents(element, activating)).ifRightOrLeft(ok -> {
final var activated = stateTransitionBehavior.transitionToActivated(activating);
final ExecutableStartEvent startEvent = element.getNoneStartEvent();
if (startEvent == null) {
throw new BpmnProcessingException(activated, NO_NONE_START_EVENT_ERROR_MSG);
}
stateTransitionBehavior.activateChildInstance(activated, startEvent);
}, failure -> incidentBehavior.createIncident(failure, activating));
}
use of io.camunda.zeebe.engine.processing.bpmn.BpmnProcessingException in project zeebe by camunda.
the class EventBasedGatewayProcessor method onComplete.
@Override
public void onComplete(final ExecutableEventBasedGateway element, final BpmnElementContext context) {
eventSubscriptionBehavior.unsubscribeFromEvents(context);
final var eventTrigger = eventSubscriptionBehavior.findEventTrigger(context).orElseThrow(() -> new BpmnProcessingException(context, "Expected an event trigger to complete the event-based gateway but not found."));
// transition to completed and continue on the event of the gateway that was triggered
// - according to the BPMN specification, the sequence flow to this event is not taken
stateTransitionBehavior.transitionToCompleted(element, context).ifRightOrLeft(completed -> eventSubscriptionBehavior.activateTriggeredEvent(context.getElementInstanceKey(), completed.getFlowScopeKey(), eventTrigger, completed), failure -> incidentBehavior.createIncident(failure, context));
}
use of io.camunda.zeebe.engine.processing.bpmn.BpmnProcessingException in project zeebe by zeebe-io.
the class EventBasedGatewayProcessor method onComplete.
@Override
public void onComplete(final ExecutableEventBasedGateway element, final BpmnElementContext context) {
eventSubscriptionBehavior.unsubscribeFromEvents(context);
final var eventTrigger = eventSubscriptionBehavior.findEventTrigger(context).orElseThrow(() -> new BpmnProcessingException(context, "Expected an event trigger to complete the event-based gateway but not found."));
// transition to completed and continue on the event of the gateway that was triggered
// - according to the BPMN specification, the sequence flow to this event is not taken
stateTransitionBehavior.transitionToCompleted(element, context).ifRightOrLeft(completed -> eventSubscriptionBehavior.activateTriggeredEvent(context.getElementInstanceKey(), completed.getFlowScopeKey(), eventTrigger, completed), failure -> incidentBehavior.createIncident(failure, context));
}
use of io.camunda.zeebe.engine.processing.bpmn.BpmnProcessingException in project zeebe by zeebe-io.
the class BpmnStateBehavior method canBeTerminated.
// used by canceling, since we don't care about active sequence flows
public boolean canBeTerminated(final BpmnElementContext context) {
final ElementInstance flowScopeInstance = getFlowScopeInstance(context);
if (flowScopeInstance == null) {
return false;
}
final long activePaths = flowScopeInstance.getNumberOfActiveElementInstances();
if (activePaths < 0) {
throw new BpmnProcessingException(context, String.format("Expected number of active paths to be positive but got %d for instance %s", activePaths, flowScopeInstance));
}
return activePaths == 0;
}
Aggregations