private CaseStruct findSwitchMatch(FacesContext context, String fromAction,
String outcome, String toFlowDocumentId) {
CaseStruct result = null;
NavigationInfo info = getNavigationInfo(context, toFlowDocumentId, fromAction);
FlowHandler flowHandler = context.getApplication().getFlowHandler();
if (null != flowHandler &&
null != info && null != info.switches && !info.switches.isEmpty()) {
SwitchNode switchNode = info.switches.get(outcome);
if (null != switchNode) {
List<SwitchCase> cases = switchNode.getCases();
for (SwitchCase cur : cases) {
if (cur.getCondition(context)) {
outcome = cur.getFromOutcome();
Flow newFlow = flowHandler.getFlow(context, toFlowDocumentId,
fromAction);
// If this outcome corresponds to an existing flow...
if (null != newFlow) {
result = synthesizeCaseStruct(context, newFlow, fromAction, outcome);
} else {
newFlow = flowHandler.getCurrentFlow(context);
if (null != newFlow) {
result = synthesizeCaseStruct(context, newFlow, fromAction, outcome);
}
}
if (null != result) {
break;
}
}
}
if (null == result) {
outcome = switchNode.getDefaultOutcome(context);
if (null != outcome) {
Flow currentFlow = flowHandler.getCurrentFlow(context);
if (null != currentFlow) {
result = synthesizeCaseStruct(context, currentFlow, fromAction, outcome);
if (null != result) {
result.currentFlow = currentFlow;
result.newFlow = currentFlow;