/** * Factory method that creates a new decision state, a state where a flow routing decision is made. This method is * an atomic operation that returns a fully initialized state. It encapsulates the selection of the decision state * implementation as well as the state assembly. * @param id the identifier to assign to the state, must be unique to its owning flow (required) * @param flow the flow that will own (contain) this state (required) * @param entryActions any state entry actions; may be null * @param transitions any transitions (paths) out of this state * @param exceptionHandlers any exception handlers; may be null * @param exitActions any state exit actions; may be null * @param attributes attributes to assign to the State, which may also be used to affect state construction; may be * null * @return the fully initialized decision state instance */ public State createDecisionState(String id, Flow flow, Action[] entryActions, Transition[] transitions, FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap<?> attributes) { DecisionState decisionState = new DecisionState(flow, id); configureCommonProperties(decisionState, entryActions, transitions, exceptionHandlers, exitActions, attributes); return decisionState; }
private void parseAndAddActionState(ActionStateModel state, Flow flow) { MutableAttributeMap<Object> attributes = parseMetaAttributes(state.getAttributes()); parseAndPutSecured(state.getSecured(), attributes); getLocalContext().getFlowArtifactFactory().createActionState(state.getId(), flow, parseActions(state.getOnEntryActions()), parseActions(state.getActions()), parseTransitions(state.getTransitions()), parseExceptionHandlers(state.getExceptionHandlers(), state.getTransitions()), parseActions(state.getOnExitActions()), attributes); }
private void parseAndAddDecisionState(DecisionStateModel state, Flow flow) { MutableAttributeMap<Object> attributes = parseMetaAttributes(state.getAttributes()); parseAndPutSecured(state.getSecured(), attributes); getLocalContext().getFlowArtifactFactory().createDecisionState(state.getId(), flow, parseActions(state.getOnEntryActions()), parseIfs(state.getIfs()), parseExceptionHandlers(state.getExceptionHandlers(), null), parseActions(state.getOnExitActions()), attributes); }
private Transition parseElse(IfModel ifModel) { TargetStateResolver stateResolver = (TargetStateResolver) fromStringTo(TargetStateResolver.class).execute( ifModel.getElse()); return getLocalContext().getFlowArtifactFactory().createTransition(stateResolver, null, null, null); }
private void parseAndAddViewState(ViewStateModel state, Flow flow) { ViewFactory viewFactory = parseViewFactory(state.getView(), state.getId(), false, state.getBinder()); Boolean redirect = null; if (StringUtils.hasText(state.getRedirect())) { redirect = (Boolean) fromStringTo(Boolean.class).execute(state.getRedirect()); } boolean popup = false; if (StringUtils.hasText(state.getPopup())) { popup = ((Boolean) fromStringTo(Boolean.class).execute(state.getPopup())); } MutableAttributeMap<Object> attributes = parseMetaAttributes(state.getAttributes()); if (state.getModel() != null) { attributes.put( "model", getLocalContext().getExpressionParser().parseExpression(state.getModel(), new FluentParserContext().evaluate(RequestContext.class))); } if (state.getValidationHints() != null) { attributes.put("validationHints", getLocalContext().getExpressionParser().parseExpression(state.getValidationHints(), new FluentParserContext().evaluate(RequestContext.class))); } parseAndPutSecured(state.getSecured(), attributes); getLocalContext().getFlowArtifactFactory().createViewState(state.getId(), flow, parseViewVariables(state.getVars()), parseActions(state.getOnEntryActions()), viewFactory, redirect, popup, parseActions(state.getOnRenderActions()), parseTransitions(state.getTransitions()), parseExceptionHandlers(state.getExceptionHandlers(), state.getTransitions()), parseActions(state.getOnExitActions()), attributes); }
/** * Factory method that initially creates the flow implementation during flow builder initialization. Simply * delegates to the configured flow artifact factory by default. * @return the flow instance, initially created but not yet built */ protected Flow createFlow() { String id = getContext().getFlowId(); AttributeMap<Object> attributes = getContext().getFlowAttributes(); return getContext().getFlowArtifactFactory().createFlow(id, attributes); }
private void parseAndAddEndState(EndStateModel state, Flow flow) { MutableAttributeMap<Object> attributes = parseMetaAttributes(state.getAttributes()); if (StringUtils.hasText(state.getCommit())) { attributes.put("commit", fromStringTo(Boolean.class).execute(state.getCommit())); } parseAndPutSecured(state.getSecured(), attributes); Action finalResponseAction; ViewFactory viewFactory = parseViewFactory(state.getView(), state.getId(), true, null); if (viewFactory != null) { finalResponseAction = new ViewFactoryActionAdapter(viewFactory); } else { finalResponseAction = null; } getLocalContext().getFlowArtifactFactory().createEndState(state.getId(), flow, parseActions(state.getOnEntryActions()), finalResponseAction, parseFlowOutputMapper(state.getOutputs()), parseExceptionHandlers(state.getExceptionHandlers(), null), attributes); }
/** * Adds a decision state to the flow built by this builder. * @param stateId the state identifier * @param decisionCriteria the criteria that defines the decision * @param trueStateId the target state on a "true" decision * @param falseStateId the target state on a "false" decision * @return the fully constructed decision state instance */ protected State addDecisionState(String stateId, TransitionCriteria decisionCriteria, String trueStateId, String falseStateId) { Transition thenTransition = getFlowArtifactFactory().createTransition(to(trueStateId), decisionCriteria, null, null); Transition elseTransition = getFlowArtifactFactory().createTransition(to(falseStateId), null, null, null); return getFlowArtifactFactory().createDecisionState(stateId, getFlow(), null, new Transition[] { thenTransition, elseTransition }, null, null, null); }
private void parseAndAddSubflowState(SubflowStateModel state, Flow flow) { MutableAttributeMap<Object> attributes = parseMetaAttributes(state.getAttributes()); parseAndPutSecured(state.getSecured(), attributes); getLocalContext().getFlowArtifactFactory().createSubflowState(state.getId(), flow, parseActions(state.getOnEntryActions()), parseSubflowExpression(state.getSubflow()), parseSubflowAttributeMapper(state), parseTransitions(state.getTransitions()), parseExceptionHandlers(state.getExceptionHandlers(), state.getTransitions()), parseActions(state.getOnExitActions()), attributes); }
private Transition parseThen(IfModel ifModel) { Expression test = getLocalContext().getExpressionParser().parseExpression(ifModel.getTest(), new FluentParserContext().evaluate(RequestContext.class).expectResult(Boolean.class)); TransitionCriteria matchingCriteria = new DefaultTransitionCriteria(test); TargetStateResolver targetStateResolver = (TargetStateResolver) fromStringTo(TargetStateResolver.class) .execute(ifModel.getThen()); return getLocalContext().getFlowArtifactFactory().createTransition(targetStateResolver, matchingCriteria, null, null); }
/** * Adds a view state to the flow built by this builder. * @param stateId the state identifier * @param entryActions the actions to execute when the state is entered * @param viewSelector the view selector that will make the view selection when the state is entered * @param renderActions any 'render actions' to execute on state entry and refresh; may be null * @param transitions the transitions (path) out of this state * @param exceptionHandlers any exception handlers to attach to the state * @param exitActions the actions to execute when the state exits * @param attributes attributes to assign to the state that may be used to affect state construction and execution * @return the fully constructed view state instance */ protected State addViewState(String stateId, Action[] entryActions, ViewSelector viewSelector, Action[] renderActions, Transition[] transitions, FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap attributes) { return getFlowArtifactFactory().createViewState(stateId, getFlow(), entryActions, viewSelector, renderActions, transitions, exceptionHandlers, exitActions, attributes); }
protected Flow createFlow() { String flowId = getContext().getFlowId(); AttributeMap<Object> flowAttributes = parseFlowMetaAttributes(flowModel); flowAttributes = getContext().getFlowAttributes().union(flowAttributes); if (IS_SPRING_FACES_PRESENT) { flowAttributes.asMap().put(VALIDATOR_FLOW_ATTR, getLocalContext().getValidator()); flowAttributes.asMap().put(VALIDATION_HINT_RESOLVER_FLOW_ATTR, getLocalContext().getValidationHintResolver()); } Flow flow = getLocalContext().getFlowArtifactFactory().createFlow(flowId, flowAttributes); flow.setApplicationContext(getLocalContext().getApplicationContext()); return flow; }
/** * Adds an end state to the flow built by this builder. * @param stateId the state identifier * @return the fully constructed end state instance */ protected State addEndState(String stateId) { return getFlowArtifactFactory().createEndState(stateId, getFlow(), null, null, null, null, null); }
/** * Adds a subflow state to the flow built by this builder. * @param stateId the state identifier * @param subflow the flow that will act as the subflow * @param attributeMapper the mapper to map subflow input and output attributes * @param transitions the transitions (paths) out of the state * @return the fully constructed subflow state instance */ protected State addSubflowState(String stateId, Flow subflow, FlowAttributeMapper attributeMapper, Transition[] transitions) { return getFlowArtifactFactory().createSubflowState(stateId, getFlow(), null, subflow, attributeMapper, transitions, null, null, null); }
/** * Factory method that creates a new subflow state, a state where a parent flow spawns another flow as a subflow. * This method is an atomic operation that returns a fully initialized state. It encapsulates the selection of the * subflow state implementation as well as the state assembly. * @param id the identifier to assign to the state, must be unique to its owning flow (required) * @param flow the flow that will own (contain) this state (required) * @param entryActions any state entry actions; may be null * @param subflow the subflow definition (required) * @param attributeMapper the subflow input and output attribute mapper; may be null * @param transitions any transitions (paths) out of this state * @param exceptionHandlers any exception handlers; may be null * @param exitActions any state exit actions; may be null * @param attributes attributes to assign to the State, which may also be used to affect state construction; may be * null * @return the fully initialized subflow state instance */ public State createSubflowState(String id, Flow flow, Action[] entryActions, Expression subflow, SubflowAttributeMapper attributeMapper, Transition[] transitions, FlowExecutionExceptionHandler[] exceptionHandlers, Action[] exitActions, AttributeMap<?> attributes) { SubflowState subflowState = new SubflowState(flow, id, subflow); if (attributeMapper != null) { subflowState.setAttributeMapper(attributeMapper); } configureCommonProperties(subflowState, entryActions, transitions, exceptionHandlers, exitActions, attributes); return subflowState; }
private Transition parseTransition(TransitionModel transition) { TransitionCriteria matchingCriteria = (TransitionCriteria) fromStringTo(TransitionCriteria.class).execute( transition.getOn()); TargetStateResolver stateResolver = (TargetStateResolver) fromStringTo(TargetStateResolver.class).execute( transition.getTo()); TransitionCriteria executionCriteria = TransitionCriteriaChain.criteriaChainFor(parseActions(transition .getActions())); MutableAttributeMap<Object> attributes = parseMetaAttributes(transition.getAttributes()); if (StringUtils.hasText(transition.getBind())) { attributes.put("bind", fromStringTo(Boolean.class).execute(transition.getBind())); } if (StringUtils.hasText(transition.getValidate())) { attributes.put("validate", fromStringTo(Boolean.class).execute(transition.getValidate())); } if (StringUtils.hasText(transition.getValidationHints())) { attributes.put("validationHints", getLocalContext().getExpressionParser().parseExpression(transition.getValidationHints(), new FluentParserContext().evaluate(RequestContext.class))); } if (StringUtils.hasText(transition.getHistory())) { attributes.put("history", fromStringTo(History.class).execute(transition.getHistory().toUpperCase())); } parseAndPutSecured(transition.getSecured(), attributes); return getLocalContext().getFlowArtifactFactory().createTransition(stateResolver, matchingCriteria, executionCriteria, attributes); }
/** * Adds a view state to the flow built by this builder. * @param stateId the state identifier * @param viewName the string-encoded view selector * @param renderAction the action to execute on state entry and refresh; may be null * @param transition the sole transition (path) out of this state * @return the fully constructed view state instance */ protected State addViewState(String stateId, String viewName, Action renderAction, Transition transition) { return getFlowArtifactFactory().createViewState(stateId, getFlow(), null, viewSelector(viewName), new Action[] { renderAction }, new Transition[] { transition }, null, null, null); }
/** * Adds an action state to the flow built by this builder. * @param stateId the state identifier * @param action the single action to execute when the state is entered * @param transition the single transition (path) out of this state * @return the fully constructed action state instance */ protected State addActionState(String stateId, Action action, Transition transition) { return getFlowArtifactFactory().createActionState(stateId, getFlow(), null, new Action[] { action }, new Transition[] { transition }, null, null, null); }
private Flow parseFlow(String id, AttributeMap attributes, Element flowElement) { if (!isFlowElement(flowElement)) { throw new IllegalStateException("This is not the '" + FLOW_ELEMENT + "' element"); } Flow flow = getFlowArtifactFactory().createFlow(id, parseAttributes(flowElement).union(attributes)); initLocalServiceRegistry(flowElement, flow); return flow; }
/** * Adds an end state to the flow built by this builder. * @param stateId the state identifier * @param entryActions the actions to execute when the state is entered * @param viewSelector the view selector that will make the view selection when the state is entered * @param outputMapper the output mapper to map output attributes for the end state (a flow outcome) * @param exceptionHandlers any exception handlers to attach to the state * @param attributes attributes to assign to the state that may be used to affect state construction and execution * @return the fully constructed end state instance */ protected State addEndState(String stateId, Action[] entryActions, ViewSelector viewSelector, AttributeMapper outputMapper, FlowExecutionExceptionHandler[] exceptionHandlers, AttributeMap attributes) { return getFlowArtifactFactory().createEndState(stateId, getFlow(), entryActions, viewSelector, outputMapper, exceptionHandlers, attributes); }