Search in sources :

Example 1 with Expression

use of org.springframework.binding.expression.Expression in project cas by apereo.

the class AbstractCasWebflowConfigurer method createEvaluateAction.

@Override
public EvaluateAction createEvaluateAction(final String expression) {
    if (this.flowBuilderServices == null) {
        LOGGER.error("Flow builder services is not configured correctly.");
        return null;
    }
    final ParserContext ctx = new FluentParserContext();
    final Expression action = this.flowBuilderServices.getExpressionParser().parseExpression(expression, ctx);
    final EvaluateAction newAction = new EvaluateAction(action, null);
    LOGGER.debug("Created evaluate action for expression [[{}]]", action.getExpressionString());
    return newAction;
}
Also used : FluentParserContext(org.springframework.binding.expression.support.FluentParserContext) Expression(org.springframework.binding.expression.Expression) LiteralExpression(org.springframework.binding.expression.support.LiteralExpression) EvaluateAction(org.springframework.webflow.action.EvaluateAction) FluentParserContext(org.springframework.binding.expression.support.FluentParserContext) ParserContext(org.springframework.binding.expression.ParserContext)

Example 2 with Expression

use of org.springframework.binding.expression.Expression in project cas by apereo.

the class AbstractCasWebflowConfigurer method createDecisionState.

@Override
public DecisionState createDecisionState(final Flow flow, final String id, final String testExpression, final String thenStateId, final String elseStateId) {
    if (containsFlowState(flow, id)) {
        LOGGER.debug("Flow [{}] already contains a definition for state id [[{}]]", flow.getId(), id);
        return (DecisionState) flow.getTransitionableState(id);
    }
    final DecisionState decisionState = new DecisionState(flow, id);
    final Expression expression = createExpression(testExpression, Boolean.class);
    final Transition thenTransition = createTransition(expression, thenStateId);
    decisionState.getTransitionSet().add(thenTransition);
    final Transition elseTransition = createTransition("*", elseStateId);
    decisionState.getTransitionSet().add(elseTransition);
    return decisionState;
}
Also used : Expression(org.springframework.binding.expression.Expression) LiteralExpression(org.springframework.binding.expression.support.LiteralExpression) Transition(org.springframework.webflow.engine.Transition) DecisionState(org.springframework.webflow.engine.DecisionState)

Example 3 with Expression

use of org.springframework.binding.expression.Expression in project cas by apereo.

the class AbstractCasWebflowConfigurer method createMappingToSubflowState.

/**
     * Create mapping to subflow state.
     *
     * @param name     the name
     * @param value    the value
     * @param required the required
     * @param type     the type
     * @return the default mapping
     */
protected DefaultMapping createMappingToSubflowState(final String name, final String value, final boolean required, final Class type) {
    final ExpressionParser parser = this.flowBuilderServices.getExpressionParser();
    final Expression source = parser.parseExpression(value, new FluentParserContext());
    final Expression target = parser.parseExpression(name, new FluentParserContext());
    final DefaultMapping mapping = new DefaultMapping(source, target);
    mapping.setRequired(required);
    final ConversionExecutor typeConverter = new RuntimeBindingConversionExecutor(type, this.flowBuilderServices.getConversionService());
    mapping.setTypeConverter(typeConverter);
    return mapping;
}
Also used : FluentParserContext(org.springframework.binding.expression.support.FluentParserContext) RuntimeBindingConversionExecutor(org.springframework.binding.convert.service.RuntimeBindingConversionExecutor) ConversionExecutor(org.springframework.binding.convert.ConversionExecutor) Expression(org.springframework.binding.expression.Expression) LiteralExpression(org.springframework.binding.expression.support.LiteralExpression) SpringELExpressionParser(org.springframework.binding.expression.spel.SpringELExpressionParser) ExpressionParser(org.springframework.binding.expression.ExpressionParser) SpelExpressionParser(org.springframework.expression.spel.standard.SpelExpressionParser) DefaultMapping(org.springframework.binding.mapping.impl.DefaultMapping) RuntimeBindingConversionExecutor(org.springframework.binding.convert.service.RuntimeBindingConversionExecutor)

Example 4 with Expression

use of org.springframework.binding.expression.Expression in project cas by apereo.

the class AbstractCasWebflowConfigurer method getExpressionStringFromAction.

/**
     * Gets expression string from action.
     *
     * @param act the act
     * @return the expression string from action
     */
protected Expression getExpressionStringFromAction(final EvaluateAction act) {
    final Field field = ReflectionUtils.findField(act.getClass(), "expression");
    ReflectionUtils.makeAccessible(field);
    return (Expression) ReflectionUtils.getField(field, act);
}
Also used : Field(java.lang.reflect.Field) Expression(org.springframework.binding.expression.Expression) LiteralExpression(org.springframework.binding.expression.support.LiteralExpression)

Example 5 with Expression

use of org.springframework.binding.expression.Expression in project cas by apereo.

the class AbstractCasWebflowConfigurer method createEndState.

@Override
public EndState createEndState(final Flow flow, final String id, final String viewId, final boolean redirect) {
    if (!redirect) {
        return createEndState(flow, id, viewId);
    }
    final Expression expression = createExpression(viewId, String.class);
    final ActionExecutingViewFactory viewFactory = new ActionExecutingViewFactory(new ExternalRedirectAction(expression));
    return createEndState(flow, id, viewFactory);
}
Also used : Expression(org.springframework.binding.expression.Expression) LiteralExpression(org.springframework.binding.expression.support.LiteralExpression) ActionExecutingViewFactory(org.springframework.webflow.engine.support.ActionExecutingViewFactory) ExternalRedirectAction(org.springframework.webflow.action.ExternalRedirectAction)

Aggregations

Expression (org.springframework.binding.expression.Expression)5 LiteralExpression (org.springframework.binding.expression.support.LiteralExpression)5 FluentParserContext (org.springframework.binding.expression.support.FluentParserContext)2 Field (java.lang.reflect.Field)1 ConversionExecutor (org.springframework.binding.convert.ConversionExecutor)1 RuntimeBindingConversionExecutor (org.springframework.binding.convert.service.RuntimeBindingConversionExecutor)1 ExpressionParser (org.springframework.binding.expression.ExpressionParser)1 ParserContext (org.springframework.binding.expression.ParserContext)1 SpringELExpressionParser (org.springframework.binding.expression.spel.SpringELExpressionParser)1 DefaultMapping (org.springframework.binding.mapping.impl.DefaultMapping)1 SpelExpressionParser (org.springframework.expression.spel.standard.SpelExpressionParser)1 EvaluateAction (org.springframework.webflow.action.EvaluateAction)1 ExternalRedirectAction (org.springframework.webflow.action.ExternalRedirectAction)1 DecisionState (org.springframework.webflow.engine.DecisionState)1 Transition (org.springframework.webflow.engine.Transition)1 ActionExecutingViewFactory (org.springframework.webflow.engine.support.ActionExecutingViewFactory)1