/** * 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; }
/** * Sets start state. * * @param flow the flow * @param state the state */ protected void setStartState(final Flow flow, final TransitionableState state) { setStartState(flow, state.getId()); }
@Override public void setStartState(final Flow flow, final TransitionableState state) { setStartState(flow, state.getId()); }
/** * Sets start state. * * @param flow the flow * @param state the state */ protected void setStartState(final Flow flow, final String state) { flow.setStartState(state); final TransitionableState startState = getStartState(flow); logger.debug("Start state is now set to {}", startState.getId()); }
@Override public void setStartState(final Flow flow, final String state) { flow.setStartState(state); val startState = getStartState(flow); LOGGER.trace("Start state is now set to [{}]", startState.getId()); }
/** * Create transition. * * @param criteriaOutcome the criteria outcome * @param targetState the target state * @return the transition */ protected Transition createTransition(final String criteriaOutcome, final TransitionableState targetState) { return createTransition(new LiteralExpression(criteriaOutcome), targetState.getId()); }
@Override public Transition createTransition(final String criteriaOutcome, final TransitionableState targetState) { return createTransition(new LiteralExpression(criteriaOutcome), targetState.getId()); }
/** * Add transition to action state. * * @param state the action state * @param criteriaOutcome the criteria outcome * @param targetState the target state */ protected void createTransitionForState(final TransitionableState state, final String criteriaOutcome, final String targetState) { try { final Transition transition = createTransition(criteriaOutcome, targetState); state.getTransitionSet().add(transition); logger.debug("Added transition {} to the state {}", transition.getId(), state.getId()); } catch (final Exception e) { logger.error(e.getMessage(), e); } }
actionState.getId(), currentStartState.getId()); addTransitionToActionState(actionState, "requireTgt", currentStartState.getId()); if (!STATE_DEFINITION_ID_TGT_EXISTS_CHECK.equals(currentStartState.getId())) { LOGGER.debug("Found a custom existing start state [{}]. Will add a default transition to " + "[{}] so the flow can resume normally.", STATE_DEFINITION_ID_TGT_EXISTS_CHECK, currentStartState.getId()); addDefaultTransitionToState(currentStartState, STATE_DEFINITION_ID_TGT_EXISTS_CHECK);
/** * 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; }
/** * 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; }
/** * 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; }
/** * 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.getLastEvent(), "No transition found on occurence of event '" + context.getLastEvent() + "' 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 void testTransitionExecutorHandlesExceptionExactMatch() { TransitionExecutingFlowExecutionExceptionHandler handler = new TransitionExecutingFlowExecutionExceptionHandler(); handler.add(TestException.class, "state"); FlowExecutionException e = new FlowExecutionException(state.getOwner().getId(), state.getId(), "Oops", new TestException()); assertTrue("Doesn't handle state exception", handler.canHandle(e)); e = new FlowExecutionException(state.getOwner().getId(), state.getId(), "Oops", new Exception()); assertFalse("Shouldn't handle exception", handler.canHandle(e)); }
public void testTransitionExecutorHandlesExceptionSuperclassMatch() { TransitionExecutingFlowExecutionExceptionHandler handler = new TransitionExecutingFlowExecutionExceptionHandler(); handler.add(Exception.class, "state"); FlowExecutionException e = new FlowExecutionException(state.getOwner().getId(), state.getId(), "Oops", new TestException()); assertTrue("Doesn't handle state exception", handler.canHandle(e)); e = new FlowExecutionException(state.getOwner().getId(), state.getId(), "Oops", new RuntimeException()); assertTrue("Doesn't handle state exception", handler.canHandle(e)); }
public void testGetTransitionableState() { assertEquals("Wrong state:", "myState1", flow.getTransitionableState("myState1").getId()); assertEquals("Wrong state:", "myState1", flow.getState("myState1").getId()); }
transitionSet.add(createTransition(CasWebflowConstants.TRANSITION_ID_CANCEL, CasWebflowConstants.STATE_ID_INIT_LOGIN_FORM)); LOGGER.trace("Creating transition [{}] for state [{}]", subflowId, actionState.getId()); createTransitionForState(actionState, subflowId, subflowId);