/** * Configure common properties for a transitionable state. */ private void configureCommonProperties(TransitionableState state, Action[] entryActions, Transition[] transitions, FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap<?> attributes) { configureCommonProperties(state, entryActions, exceptionHandlers, attributes); state.getTransitionSet().addAll(transitions); state.getExitActionList().addAll(exitActions); }
/** * Get a transition in this state for given flow execution request context. Throws and exception when there is no * corresponding transition. * @throws NoMatchingTransitionException when a matching transition cannot be found */ public Transition getRequiredTransition(RequestContext context) throws NoMatchingTransitionException { Transition transition = getTransitionSet().getTransition(context); if (transition == null) { throw new NoMatchingTransitionException(getFlow().getId(), getId(), context.getCurrentEvent(), "No transition found on occurence of event '" + context.getCurrentEvent() + "' in state '" + getId() + "' of flow '" + getFlow().getId() + "' -- valid transitional criteria are " + StylerUtils.style(getTransitionSet().getTransitionCriterias()) + " -- likely programmer error, check the set of TransitionCriteria for this state"); } return transition; }
public TransitionDefinition[] getTransitions() { return getTransitionSet().toArray(); }
/** * Add a default transition to a given state. * @param state the state to include the default transition * @param targetState the id of the destination state to which the flow should transfer */ protected static void addDefaultTransitionToState(final TransitionableState state, final String targetState) { if (state == null) { LOGGER.debug("Cant add default transition of [{}] to the given state is null and cannot be found in the flow.", targetState); return; } final Transition transition = createTransition(targetState); state.getTransitionSet().add(transition); }
/** * Returns whether or not this list has a transition that will fire for given flow execution request context. * @param context a flow execution context */ public boolean hasMatchingTransition(RequestContext context) { return getTransition(context) != null; }
/** * Add transition to action state. * * @param state the action state * @param criteriaOutcome the criteria outcome * @param targetState the target state * @param removeExisting the remove existing * @return the transition */ public Transition createTransitionForState(final TransitionableState state, final String criteriaOutcome, final String targetState, final boolean removeExisting) { try { if (removeExisting) { val success = (Transition) state.getTransition(criteriaOutcome); if (success != null) { state.getTransitionSet().remove(success); } } val transition = createTransition(criteriaOutcome, targetState); state.getTransitionSet().add(transition); LOGGER.trace("Added transition [{}] to the state [{}]", transition.getId(), state.getId()); return transition; } catch (final Exception e) { LOGGER.error(e.getMessage(), e); } return null; }
+ StylerUtils.style(eventIds) + "', while the supported set of transitional criteria for this action state is '" + StylerUtils.style(getTransitionSet().getTransitionCriterias()) + "'"); } else { throw new IllegalStateException(
/** * Clone action state. * * @param source the source * @param target the target */ public void cloneActionState(final ActionState source, final ActionState target) { source.getActionList().forEach(a -> target.getActionList().add(a)); source.getExitActionList().forEach(a -> target.getExitActionList().add(a)); source.getAttributes().asMap().forEach((k, v) -> target.getAttributes().put(k, v)); source.getTransitionSet().forEach(t -> target.getTransitionSet().addAll(t)); val field = ReflectionUtils.findField(target.getExceptionHandlerSet().getClass(), "exceptionHandlers"); ReflectionUtils.makeAccessible(field); val list = (List<FlowExecutionExceptionHandler>) ReflectionUtils.getField(field, target.getExceptionHandlerSet()); list.forEach(h -> source.getExceptionHandlerSet().add(h)); target.setDescription(source.getDescription()); target.setCaption(source.getCaption()); }
/** * Add a transition to this set. * @param transition the transition to add * @return true if this set's contents changed as a result of the add operation */ public boolean add(Transition transition) { if (contains(transition)) { return false; } return transitions.add(transition); }
/** * Add a default transition to a given state. * * @param state the state to include the default transition * @param targetState the id of the destination state to which the flow should transfer */ public void createStateDefaultTransition(final TransitionableState state, final String targetState) { if (state == null) { LOGGER.trace("Cannot add default transition of [{}] to the given state is null and cannot be found in the flow.", targetState); return; } val transition = createTransition(targetState); state.getTransitionSet().add(transition); }
public Transition getRequiredTransition(RequestContext context) throws NoMatchingTransitionException { Transition transition = getTransitionSet().getTransition(context); if (transition == null) { throw new NoMatchingActionResultTransitionException(this, context.getCurrentEvent()); } return transition; }
+ StylerUtils.style(eventIds) + "', while the supported set of transitional criteria for this action state is '" + StylerUtils.style(getTransitionSet().getTransitionCriterias()) + "'"); } else { throw new IllegalStateException(
/** * Add a transition to this set. * @param transition the transition to add * @return true if this set's contents changed as a result of the add operation */ public boolean add(Transition transition) { if (contains(transition)) { return false; } return transitions.add(transition); }
/** * Add a default transition to a given state. * * @param state the state to include the default transition * @param targetState the id of the destination state to which the flow should transfer */ protected void createStateDefaultTransition(final TransitionableState state, final String targetState) { if (state == null) { logger.debug("Cannot add default transition of [{}] to the given state is null and cannot be found in the flow.", targetState); return; } final Transition transition = createTransition(targetState); state.getTransitionSet().add(transition); }
/** * Get a transition in this state for given flow execution request context. Throws and exception when there is no * corresponding transition. * @throws NoMatchingTransitionException when a matching transition cannot be found */ public Transition getRequiredTransition(RequestContext context) throws NoMatchingTransitionException { Transition transition = getTransitionSet().getTransition(context); if (transition == null) { throw new NoMatchingTransitionException(getFlow().getId(), getId(), context.getCurrentEvent(), "No transition found on occurence of event '" + context.getCurrentEvent() + "' in state '" + getId() + "' of flow '" + getFlow().getId() + "' -- valid transitional criteria are " + StylerUtils.style(getTransitionSet().getTransitionCriterias()) + " -- likely programmer error, check the set of TransitionCriteria for this state"); } return transition; }
/** * Handle the last event that occurred against an active session of this flow. * @param context the flow execution control context */ public boolean handleEvent(RequestControlContext context) { TransitionableState currentState = getCurrentTransitionableState(context); try { return currentState.handleEvent(context); } catch (NoMatchingTransitionException e) { // try the flow level transition set for a match Transition transition = globalTransitionSet.getTransition(context); if (transition != null) { return context.execute(transition); // return transition.execute(currentState, context); } else { // no matching global transition => let the original exception // propagate throw e; } } }
/** * Builds any transitions shared by all states of the flow. * @throws FlowBuilderException an exception occurred building the flow */ public void buildGlobalTransitions() throws FlowBuilderException { getFlow().getGlobalTransitionSet().addAll(parseTransitions(flowModel.getGlobalTransitions())); }
public TransitionDefinition[] getTransitions() { return getTransitionSet().toArray(); }
+ StylerUtils.style(eventIds) + "', while the supported set of transitional criteria for this action state is '" + StylerUtils.style(getTransitionSet().getTransitionCriterias()) + "'"); } else { throw new IllegalStateException(