Package org.amplafi.flow

Examples of org.amplafi.flow.FlowState


    public String getFlowName() {
        return getSpecification().getDescription();
    }

    public IComponent getCurrentBlock() {
        FlowState flow = getFlowState();
        if ( flow != null ) {
            if ( flow.getFlowStateLifecycle() != FlowStateLifecycle.started) {
                String message = getStartErrorMessage(flow) + "' but flow is not in the 'started' state. Flow state: " + flow.getFlowStateLifecycle() + "; Values: " + flow.getFlowValuesMap();
                throw new IllegalStateException(message);
            }
            int activity = flow.getCurrentActivityIndex();
            String blockName = FlowWebUtils.getBlockName(activity);
            IComponent comp = getComponentSafe(blockName);
            if(comp==null) {
                FlowActivity flowActivity = flow.getCurrentActivity();
                if(flowActivity == null){
                    String message = getStartErrorMessage(flow) + "' but current activity (#" + activity + ") is null. Flow state: " + flow.getFlowStateLifecycle() + "; Values: " + flow.getFlowValuesMap() ;
                    throw new IllegalStateException(message);
                } else {
                    String message = getStartErrorMessage(flow) + "' but there is no component named '" + blockName + "'. This should be the block containing the FlowActivity named '" + flowActivity.getFlowPropertyProviderName() + "' (activity #" + activity + ") ";
                    if ( flowActivity.isInvisible() ) {
                        throw new IllegalStateException(message+" -- this is an invisible activity");
View Full Code Here


        return getFlowStateProperty(null);
    }
    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 ValidationException) {
                    throw new TapestryException(e.getMessage(), this.getLocation(), e.getCause());
                } else {
                    throw new TapestryException(e.getMessage(), this.getLocation(), e);
View Full Code Here

     * @see org.apache.tapestry5.Binding#set(java.lang.Object)
     */
    @Override
    public void set(Object value) {
        // Check that we have a flow to set the value to
        FlowState flowState = getFlowState();
        if (flowState == null) {
            throw new IllegalStateException("no attached flow - cannot set value");
        }
        flowState.setProperty(key, value);
    }
View Full Code Here

        IRequestCycle cycle = field.getPage().getRequestCycle();
        FlowAware border = FlowBorder.get(cycle);
        if (border==null) {
            return;
        }
        FlowState flowState = border.getAttachedFlowState();
        if (!flowState.getCurrentActivityFlowValidationResult().isValid()) {
            throw new ValidatorException("Cannot complete activity",
                    new ValidationJSONRender(field.getName(), "Cannot complete activity"),
                    ValidationConstraint.CONSISTENCY);
        }
    }
View Full Code Here

    private String getReturnFlowLookupKey() {
        String returnFlowLookupKey = getReturnToFlow();
        if ( isBlank(returnFlowLookupKey) ) {
            Boolean finishCurrentFlow = getFinishCurrentFlow();
            Boolean returnToCurrentFlow = getReturnToCurrentFlow();
            FlowState attachedFlow = getFlowManagement().getCurrentFlowState();
            if ( attachedFlow != null ) {
                if ( finishCurrentFlow == null || !finishCurrentFlow) {
                    if (returnToCurrentFlow != null && returnToCurrentFlow) {
                        returnFlowLookupKey = attachedFlow.getLookupKey();
                    }
                }
            }
        }
        return returnFlowLookupKey;
View Full Code Here

                return showValue;
            }
        }
    }
    public String getActivePage() {
        FlowState flowState = getFlowManagement().getCurrentFlowState();
        return flowState.getCurrentPage();
    }
View Full Code Here

     * is the same type as the flow that this entry point is to launch.
     * @return true if the current flow has the same flow type as the flow that this entry point would launch
     */
    @Cached
    public Boolean isSameAsActive() {
        FlowState flowState = getFlowManagement().getCurrentFlowState();
        FlowLauncher actualFlowLauncher = getActualFlowLauncher();
        if (flowState != null && actualFlowLauncher != null && flowState.getFlowTypeName().equals(actualFlowLauncher.getFlowTypeName())) {
            return true;
        } else {
            return false;
        }
    }
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    public ILink doEnterFlow(FlowLauncher flowLauncher, String finishFlowId, Iterable<String> initialValues) {
        String pageName = null;
        // grab FlowState now because the flow may be finished and no longer be available.
        FlowState currentFlowState = getFlowManagement().getCurrentFlowState();
        FlowState flowState = null;
        boolean success = false;
        try {
            // should this be a force situation and ignore any errors? seems unlikely as Amplafi would want user to be able to save any half-finished changes.
            if (finishFlowId != null ) {
                flowState = getFlowManagement().getFlowState(finishFlowId);
                if ( flowState != null && !flowState.isCompleted()) {
                    pageName = flowState.finishFlow();
                }
            }
            if ( flowLauncher != null) {
                flowLauncher.setFlowManagement(getFlowManagement());
                if (flowLauncher instanceof StartFromDefinitionFlowLauncher) {
                    // if currentFlowState was just finished, we want the final flow state.
                    if(currentFlowState != null){
                        Map<String, String> initialFlowState = currentFlowState.getExportedValuesMap().getAsFlattenedStringMap();
                        flowLauncher.putAll(initialFlowState);
                    }
                    if ( initialValues != null) {
                        ((StartFromDefinitionFlowLauncher)flowLauncher).setPropertyRoot(getContainer());
                        ((StartFromDefinitionFlowLauncher)flowLauncher).addInitialValues(initialValues);
                    }
                }
            }
            success = true;
        } catch (FlowValidationException e) {
            getFlowResultHandler().handleValidationTrackings(e.getTrackings(), this);
        }
        if (success) {
            try {
                if ( flowLauncher != null ) {
                    flowState  = flowLauncher.call();
                    pageName = (flowState != null) ? flowState.getCurrentPage() : null;
                }
                if ( isBlank(pageName) ) {
                    // stay on current page if the finishFlow failed.
                    pageName = getPageName();
                }

            } catch (FlowValidationException e) {
                getFlowResultHandler().handleValidationTrackings(e.getTrackings(), this);
                // HACK: cleanup - this seems really wrong - we should only clean up flow if was the flow started
                // not just any random flow. - we are relying on luck that the failed flow is the current flow.
                // the FlowValidationException should have a reference to the flowState.
                FlowState current = getFlowManagement().getCurrentFlowState();
                if (current!=null) {
                    getFlowManagement().dropFlowState(current);
                }
                pageName = null;
            } finally {
                if ( pageName == null || pageName.equals(this.getPage().getPageName()) || isDynamic()) {
                    List<String> findComponentsToUpdate = findComponentsToUpdate(getUpdateComponents());
                    this.updateComponents(findComponentsToUpdate);
                }
            }
        }

        FlowState newCurrentFlow = getFlowManagement().getCurrentFlowState();
        if ( newCurrentFlow != null && newCurrentFlow != flowState ) {
            pageName = newCurrentFlow.getCurrentPage();
        } else {
            newCurrentFlow = flowState;
        }
        FlowWebUtils.activatePageIfNotNull(getRequestCycle(), pageName, newCurrentFlow);
        return null;
View Full Code Here

        return "form".equals(getTemplateTagName());
    }
    private String getFlowToFinish() {
        String lookupKeyOfFlowToFinish = getFinishFlowId();
        Boolean finishCurrentFlow = getFinishCurrentFlow();
        FlowState attachedFlowState = getFlowManagement().getCurrentFlowState();
        if ( isBlank(lookupKeyOfFlowToFinish) && finishCurrentFlow != null && finishCurrentFlow && attachedFlowState !=null) {
            lookupKeyOfFlowToFinish = attachedFlowState.getLookupKey();
        }
        return lookupKeyOfFlowToFinish;
    }
View Full Code Here

    public abstract FlowResultHandler getFlowResultHandler();

    @Cached(resetAfterRewind=true)
    public List<FlowActivity> getActivities() {
        FlowState attachedFlowState = getAttachedFlowState();
        if (attachedFlowState == null) {
            // under some error conditions (don't believe this happens otherwise), there may be no attachedFlowState.
            return Collections.emptyList();
        } else {
            return attachedFlowState.getVisibleActivities();
        }
    }
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.