Package org.amplafi.flow

Examples of org.amplafi.flow.FlowState


        FlowTestingUtils flowTestingUtils = new FlowTestingUtils();
        flowTestingUtils.getFlowTranslatorResolver().resolveFlow(flow);
        flowTestingUtils.getFlowDefinitionsManager().addDefinition(FLOW_TYPE, flow);
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();
        String returnToFlowLookupKey = null;
        FlowState flowState = flowManagement.startFlowState(FLOW_TYPE, true, initialFlowState, returnToFlowLookupKey);
        SampleEnum type =flowState.getCurrentActivity().getProperty("foo");
        assertEquals(type, SampleEnum.EXTERNAL, "(looking for property 'foo') FlowState="+flowState);
        type =flowState.getProperty("fa1fp", SampleEnum.class);
        assertEquals(type, SampleEnum.EMAIL);
    }
View Full Code Here


        flowActivity0.setFlowPropertyProviderName("activity0");
        flowActivity0.addPropertyDefinitions(flowLocalProperty);
        String flowTypeName = flowTestingUtils.addFlowDefinition(flowActivity0);
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();
        Map<String, String> initialFlowState = FlowUtils.INSTANCE.createState(propertyName, "maybe");
        FlowState flowState = flowManagement.startFlowState(flowTypeName, false, initialFlowState , null);
        assertNotNull(flowState);
        Boolean propertyValue = flowState.getProperty(propertyName, Boolean.class);
        assertEquals(Boolean.TRUE,propertyValue, "flowState="+flowState+" propertyValue="+propertyValue);
    }
View Full Code Here

    }

    protected Object getFlowStateProperty(Class<?> expected) {
        Object result = null;
        // Determine if there is a flow state to get the value from, if not just return defaultValue
        FlowState flowState = getFlowState();
        if (flowState != null) {
            addValidation(flowState.getCurrentActivity(), cycle.renderStackPeek());
            try {
                result = flowState.getProperty(key, expected);
            } catch (RuntimeException e) {
                if (e.getCause() instanceof ValidatorException) {
                    throw new BindingException(e.getMessage(), this, e.getCause());
                } else {
                    throw new BindingException(e.getMessage(), this, e);
View Full Code Here

     */
    @SuppressWarnings("null")
    @Override
    public void setObject(Object value) {
        // Check that we have a flow to set the value to
        FlowState flowState = getFlowState();
        ApplicationIllegalStateException.checkState(flowState != null, this,": no attached flow - cannot set value");
        flowState.setProperty(key, value);
    }
View Full Code Here

     */
    public abstract void describeService(IRequestCycle cycle, String flowType) throws IOException;

    // TODO look at eliminating passing of cycle so that calls will be less tapestry specific.
    protected FlowState getFlowState(String flowType, String flowId, String renderResult, Map<String, String> initial, Writer writer, boolean currentFlow) throws IOException {
        FlowState flowState = null;
        if ( isNotBlank(flowId)) {
            flowState = getFlowManagement().getFlowState(flowId);
        }
        if ( flowState == null && isNotBlank(flowType)) {

            if(!getFlowManager().isFlowDefined(flowType)) {
                renderError(writer, flowType+": no such flow type", renderResult, null, new PageNotFoundException(flowType));
                return null;
            }

            if (USE_CURRENT.equals(flowId)) {
                flowState = getFlowManagement().getFirstFlowStateByType(flowType);
            }

            if (flowState==null) {
                String returnToFlowLookupKey = null;
                flowState = getFlowManagement().startFlowState(flowType, currentFlow, initial, returnToFlowLookupKey );
                if ( flowState == null || flowState.getFlowStateLifecycle() == FlowStateLifecycle.failed) {
                    renderError(writer, flowType+": could not start flow type", renderResult, flowState, null);
                    return null;
                }
            }
        } else {
View Full Code Here

        }
    }

    // TODO -- this should not be necessary any more.
    public void continueFlowState(String flowLookupKey, Map<String, String> propertyChanges) throws PageRedirectException {
        FlowState flowState = getFlowManagement().continueFlowState(flowLookupKey, true, propertyChanges);
        if (flowState != null) {
            throw new PageRedirectException(flowState.getCurrentPage());
        }
    }
View Full Code Here

public class BaseFlowResultHandlerImpl implements FlowResultHandler {

    @Override
    public void handleFlowResult(FlowValidationResult result, BaseFlowComponent component) {
        FlowState currentFlowState = component.getAttachedFlowState();
        component.getFlowManagement().getLog().warn(
                currentFlowState+" could not complete "+currentFlowState.getCurrentActivityByName()+ " (activity #"+currentFlowState.getCurrentActivityIndex()+ ") flowValidationResult="+result);
        handleValidationTrackings(result.getTrackings(), component);
    }
View Full Code Here

        return (FlowBorder)this.getComponent(FLOW_BORDER_COMPONENT_NAME);
    }

    // cancel handling needed due to TAPESTRY-1673
    public void doCancelForm() {
        FlowState state = getFlowState();
        if (state!=null) {
            String page = state.cancelFlow();
            FlowWebUtils.activatePageIfNotNull(getPage().getRequestCycle(), page, state);
        }
    }
View Full Code Here

     * note: this method name is used in {@link org.amplafi.flow.web.resolvers.FlowAwareTemplateSourceDelegate}.
     * @return the flow attached to this FullFlow instance
     */
    @Override
    public FlowState getFlowState() {
        FlowState flow = getAttachedFlowState();
        if ( flow == null && getFlowId() != null ) {
            flow = getFlowManagement().getFlowState(getFlowId());
        }
        if ( flow != null ) {
            if (flow.getFlowStateLifecycle() != FlowStateLifecycle.started) {
                // this situation arises if the user clears
                // an flow autostarted
                flow = null;
            } else if(!flow.getFlowTypeName().equals(getFlowName())) {
                // another flow component on the page should be handling this.
                return null;
            }
        }
        if ( flow == null ) {
            // HACK: what happens if 2 different flows of same type are active?
            List<String> expectedFlows = getExpectedFlows();
            flow = getFlowManagement().getFirstFlowStateByType(expectedFlows);
            if ( flow != null && !flow.getFlowTypeName().equals(getFlowName())) {
                // only display this FullFlowComponent if handling the flow that is the 'first' flow of the flows displayed on the current page.
                // however, another FullFlowComponent is handling displaying this flow. So this FullFlowComponent should
                // quietly do nothing.
                flow = null;
            } else if ( flow == null && isShouldAutoStart() ) {
View Full Code Here

    /**
     * note: this method name is used in {@link org.amplafi.flow.web.resolvers.FlowAwareTemplateSourceDelegate}.
     * @return true if this component should be rendered.
     */
    public boolean isVisibleFlow() {
        FlowState flowToUse = getFlowState();
        return flowToUse != null;
    }
View Full Code Here

TOP

Related Classes of org.amplafi.flow.FlowState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.