lib/flowBuilder.js
/**
 * This method should be called to load the flow definition into the executable constructs in order to run a flow
 * instance. The middleware will dictate whether or not buildFlow is called in between each request to change state of
 * the flow passed in.
 *
 * @param flowInst
 * @param flowSpecImpl   this is the flow specificaton implementation that follows the schema outlined in the
 * README and the example in  ../../test/xoflow.js
 */
This method should be called to load the flow definition into the executable constructs in order to run a flow
instance. The middleware will dictate whether or not buildFlow is called in between each request to change state of
the flow passed in.

@param flowInst
@param flowSpecImpl   this is the flow specificaton implementation that follows the schema outlined in the
README and the example in  ../../test/xoflow.js
This method should be called to load the flow definition into the executable constructs in order to run a flow instance . The middleware will dictate whether or not buildFlow is called in between each request to change state of the flow passed in . @param flowInst @param flowSpecImpl this is the flow specificaton implementation that follows the schema outlined in the README and the example in .. / .. / test / xoflow . js
function buildFlow(flowInst, flowSpecImpl) {
    flowInst.name = flowSpecImpl.flowDefinition.flowName;
    assert(flowInst.name, 'Flow name is mandatory!');
    flowInst._startState = flowSpecImpl.flowDefinition.start_state;
    assert(flowInst._startState, 'Flow start state is mandatory!');
    flowInst._authorizationDelegate = flowSpecImpl.authorizationDelegate;
    if( !flowInst._authorizationDelegate && flowInst._parent) {
        flowInst._authorizationDelegate = flowInst._parent._authorizationDelegate;
    }
    flowInst._secured = flowSpecImpl.flowDefinition.secured;
    flowInst._endStates = flowSpecImpl.flowDefinition.endStates;
    assert(flowInst._endStates, 'Invalid flow def ... At least one flow end state event is mandatory!');
    buildStates(flowInst, flowSpecImpl);
    if( flowSpecImpl.subflows ) {
        buildSubflowStates(flowInst, flowSpecImpl);
        buildSubflows(flowInst, flowSpecImpl.subflows);
    }
    verifyStateTransitions(flowInst);
    flowInst.currentStateName = State.states.INIT;
}
function buildFlow ( flowInst , flowSpecImpl ) { flowInst . name = flowSpecImpl . flowDefinition . flowName ; assert ( flowInst . name , 'Flow name is mandatory!' ) ; flowInst . _startState = flowSpecImpl . flowDefinition . start_state ; assert ( flowInst . _startState , 'Flow start state is mandatory!' ) ; flowInst . _authorizationDelegate = flowSpecImpl . authorizationDelegate ; if ( ! flowInst . _authorizationDelegate && flowInst . _parent ) { flowInst . _authorizationDelegate = flowInst . _parent . _authorizationDelegate ; } flowInst . _secured = flowSpecImpl . flowDefinition . secured ; flowInst . _endStates = flowSpecImpl . flowDefinition . endStates ; assert ( flowInst . _endStates , 'Invalid flow def ... At least one flow end state event is mandatory!' ) ; buildStates ( flowInst , flowSpecImpl ) ; if ( flowSpecImpl . subflows ) { buildSubflowStates ( flowInst , flowSpecImpl ) ; buildSubflows ( flowInst , flowSpecImpl . subflows ) ; } verifyStateTransitions ( flowInst ) ; flowInst . currentStateName = State . states . INIT ; }
This method should be called to load the flow definition into the executable constructs in order to run a flow
 instance.
This method should be called to load the flow definition into the executable constructs in order to run a flow instance .
//        debug('init() using parent authorization delegate since subflow: ' + flowInst.name + '  does NOT have one!'); //    debug(flowInst);