Package org.amplafi.flow

Examples of org.amplafi.flow.FlowState


                    // look for redirect before clearing the flow state
                    // why before cache clearing?
                    URI redirect = fs.getProperty(FSREDIRECT_URL);
                    String returnToFlowId = fs.getProperty(FSRETURN_TO_FLOW);
                    FlowState returnToFlow = getFlowState(returnToFlowId);
                    fs.clearCache();

                    if ( !first ) {
                        // dropped flow was not the current flow
                        // so we return the current flow's page.
View Full Code Here


     * HACK should really have FlowTransitions do the work.
     * @return the now current FlowState.
     */
    @Override
    public FlowState finishFlow(FlowState currentNextFlowState) {
        FlowState nextFlowState = super.finishFlow(currentNextFlowState);
        // maybe check to see if a new flow already exists?
        if (this.getFlowState().getFlowStateLifecycle() == FlowStateLifecycle.successful) {
            String finishType = getFlowState().getFinishKey();
            if (getTransitionType() == TransitionType.normal && finishType == null
                    || getFinishKey().equalsIgnoreCase(finishType)) {
                FlowManagement fm = getFlowManagement();
                if (isNotBlank(getNextFlowId())) {
                    FlowState possibleFlowState = fm.getFlowState(resolveIndirectReference(getNextFlowId()));
                    if ( possibleFlowState != null) {
                        nextFlowState = possibleFlowState;
                        fm.makeAfter(this.getFlowState(), possibleFlowState);
                    }
                } else {
View Full Code Here

    /**
     * @param lookupKey
     * @return the removed {@link FlowState} with the supplied lookupKey.
     */
    public synchronized FlowState removeByLookupKey(String lookupKey) {
        FlowState flowState = activeFlowsMap.remove(lookupKey);
        activeFlows.remove(flowState);
        return flowState;
    }
View Full Code Here

            initPropertyIfNull(FLOWS, l);
        }
    }
    @Override
    public FlowState finishFlow(FlowState currentNextFlowState) {
        FlowState nextFlowState = super.finishFlow(currentNextFlowState);
        List<String> flowStateLookupKeys = getProperty(FLOWS);
        String currentLookupKey = this.getFlowState().getLookupKey();
        for (String lookupKey: flowStateLookupKeys) {
            if ( lookupKey.equals(currentLookupKey) ||
                    nextFlowState != null && lookupKey.equals(nextFlowState.getLookupKey()) ) {
                continue;
            } else {
                getFlowManagement().dropFlowStateByLookupKey(lookupKey);
            }
        }
View Full Code Here

        FlowValidationResult flowValidationResult = null;
        if (verifyValues) {
            flowValidationResult = getFullFlowValidationResult(FlowActivityPhase.finish, FlowStepDirection.forward);
        }
        FlowValidationException.valid(flowValidationResult);
        FlowState currentNextFlowState = getFlowManagement().transitionToFlowState(this, FSFLOW_TRANSITIONS);
        int size = this.size();
        for (int i = 0; i < size; i++) {
            FlowActivity activity = getActivity(i);
            FlowState returned = activity.finishFlow(currentNextFlowState);
            // activity.refresh(); -- commented out because saves default values back to the flowState
            // avoids lose track of FlowState if another FA later in the Flow
            // definition returns a null. ( this means that a FA cannot override a previous decision ).
            if (returned != null && currentNextFlowState != returned) {
                currentNextFlowState = returned;
View Full Code Here

    }

    protected String completeFlow(FlowStateLifecycle nextFlowLifecycleState) {
        String pageName = null;
        if (!isCompleted()) {
            FlowState continueWithFlow = null;
            boolean verifyValues = nextFlowLifecycleState.isVerifyValues();
            FlowValidationResult flowValidationResult = passivate(verifyValues, FlowStepDirection.inPlace);

            if (verifyValues) {
                FlowValidationException.valid(flowValidationResult);
                saveChanges();
            }

            this.setFlowLifecycleState(nextFlowLifecycleState);

            boolean success = false;
            try {
                // getting continueWithFlow should use FlowLauncher more correctly.
                continueWithFlow = finishFlowActivities(verifyValues);
                success = true;
            } finally {
                this.setCurrentActivityByName(null);
                clearCache();
                if (!success) {
                    getFlowManagement().dropFlowState(this);
                }
            }
            // pass on the return flow to the continuation flow.
            // need to set before starting continuation flow because continuation flow may run to completion.
            // HACK : seems like the continueFlow should have picked this up automatically
            String returnToFlow = this.getProperty(FSRETURN_TO_FLOW);
            this.setProperty(FSRETURN_TO_FLOW, null);

            // TODO: THIS block of code should be in the FlowManagement code.
            // TODO: Put this in a FlowPropertyValueProvider !!
            // OLD note but may still be valid:
            // if continueWithFlow is not null then we do not want start
            // any other flows except continueWithFlow. Autorun flows should
            // start only if we have no flow specified by the finishingActivity. This
            // caused bad UI behavior when we used TransitionFlowActivity to start new
            // flow.
            // make sure that don't get into trouble by a finishFlow that
            // returns the current FlowState.
            if (continueWithFlow == null || continueWithFlow == this) {
                if ( nextFlowLifecycleState == successful && isNotBlank(returnToFlow)) {
                    FlowState returnFlow = getFlowManagement().getFlowState(returnToFlow);
                    Map exportedMap = this.getExportedValuesMap().getAsFlattenedStringMap();
                    returnFlow.setAllProperties(exportedMap);
                }
                pageName = getFlowManagement().completeFlowState(this, false, nextFlowLifecycleState);
            } else {
                if ( isNotBlank(returnToFlow)) {
                    continueWithFlow.setProperty(FSRETURN_TO_FLOW, returnToFlow);
View Full Code Here

            flowTestingUtils.addFlowDefinition(flowTypeName, flowActivity);
        }


        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();
        FlowState flowState = flowManagement.startFlowState(flowTypeName, true, initialFlowState, null);

        // now make sure that only the properties allowed to be set externally are set.
        for (PropertyScope propertyScope: PropertyScope.values()) {
            for(PropertyUsage propertyUsage: PropertyUsage.values()) {
                String name= propertyScope+"_"+propertyUsage;
                String externalInitial = "ext_"+name;
                String actual = flowState.getProperty(name);
                if ( !propertyScope.isCacheOnly() && propertyUsage.isExternallySettable()) {
                    assertEquals(actual, externalInitial, "PropertyUsage="+propertyUsage+" flowState="+flowState);
                } else {
                    assertNull(actual, "PropertyUsage="+propertyUsage+" flowState="+flowState);
                }
                String changed = "chg_"+name;
                flowState.setProperty(name, changed);
            }
        }
        flowState.finishFlow();
        FlowValuesMap<FlowValueMapKey, CharSequence> finalMap = flowState.getExportedValuesMap();
        // now make sure that only the properties allowed to be set externally are set.
        for (PropertyScope propertyScope: PropertyScope.values()) {
            for(PropertyUsage propertyUsage: PropertyUsage.values()) {
                String name= propertyScope+"_"+propertyUsage;
                String externalInitial = "ext_"+name;
View Full Code Here

        FlowTestingUtils flowTestingUtils = new FlowTestingUtils();
        FlowPropertyDefinition flowPropertyDefinition = new FlowPropertyDefinitionImpl("testProp", boolean.class).initAccess(propertyScope, propertyUsage);
        FlowActivityImpl flowActivity =newFlowActivity();
        flowActivity.addPropertyDefinitions(flowPropertyDefinition);
        String flowTypeName = flowTestingUtils.addFlowDefinition(flowActivity);
        FlowState flowState = flowTestingUtils.getFlowManagement().startFlowState(flowTypeName, false, null, null);
        flowState.setProperty("not-a-property", true);
        flowState.setProperty("testProp", true);
        flowState.finishFlow();
        FlowValuesMap exportedMap = flowState.getExportedValuesMap();
        assertEquals(exportedMap.get("testProp"), "true");
        assertFalse(exportedMap.containsKey("not-a-property"));
        assertEquals(exportedMap.size(), 1);
    }
View Full Code Here

        flowActivity2.addPropertyDefinitions(globalProperty);

        String flowTypeName = flowTestingUtils.addFlowDefinition(flowActivity0, flowActivity1, flowActivity2);
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();
        Map<String, String> initialFlowState = FlowUtils.INSTANCE.createState(propertyName, "true");
        FlowState flowState = flowManagement.startFlowState(flowTypeName, false, initialFlowState , null);
        assertNotNull(flowState);
        // expect null because
        Boolean propertyValue = flowState.getProperty(propertyName, Boolean.class);
        assertNull(propertyValue, "flowState="+flowState+" propertyValue="+propertyValue);
        flowState.next();
        propertyValue = flowState.getProperty(propertyName, Boolean.class);
        assertNull(propertyValue, "flowState="+flowState+" propertyValue="+propertyValue);
        flowState.next();
        propertyValue = flowState.getProperty(propertyName, Boolean.class);
        assertNotNull(propertyValue, "flowState="+flowState+" propertyValue="+propertyValue);
        assertTrue(propertyValue.booleanValue(), "flowState="+flowState+" propertyValue="+propertyValue);
    }
View Full Code Here

        flowActivity2.addPropertyDefinitions(globalProperty);

        String flowTypeName = flowTestingUtils.addFlowDefinition(flowActivity0, flowActivity1, flowActivity2);
        FlowManagement flowManagement = flowTestingUtils.getFlowManagement();
        Map<String, String> initialFlowState = FlowUtils.INSTANCE.createState(propertyName, "maybe");
        FlowState flowState = flowManagement.startFlowState(flowTypeName, false, initialFlowState , null);
        assertNotNull(flowState);
        String propertyValue = flowState.getProperty(propertyName, String.class);
        assertEquals("true",propertyValue, "flowState="+flowState+" propertyValue="+propertyValue);
        flowState.next();
        propertyValue = flowState.getProperty(propertyName, String.class);
        assertNull(propertyValue, "flowState="+flowState+" propertyValue="+propertyValue);
        flowState.next();
        propertyValue = flowState.getProperty(propertyName, String.class);
        assertNotNull(propertyValue, "flowState="+flowState+" propertyValue="+propertyValue);
        assertEquals("true", propertyValue, "flowState="+flowState+" propertyValue="+propertyValue);
    }
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.