Search in sources :

Example 6 with AgiActionName

use of org.onebusaway.probablecalls.AgiActionName in project onebusaway-application-modules by camsys.

the class StopsForRouteNavigationTemplate method buildTemplate.

@Override
public void buildTemplate(ActionContext context) {
    ValueStack vs = context.getValueStack();
    NavigationBean navigation = (NavigationBean) vs.findValue("navigation");
    List<NameBean> names = navigation.getNames();
    int index = navigation.getCurrentIndex();
    if (index < 0)
        index = 0;
    /**
     * We always listen for the key-press for the previous name in case it takes
     * the user a second to press
     */
    if (index > 0)
        addNavigationSelectionActionForIndex(navigation, index - 1);
    /**
     * If we're at the first entry and there is a second, we allow the user to
     * jump ahead
     */
    if (index == 0 && names.size() > 1) {
        addNavigationSelectionActionForIndex(navigation, index + 1);
    }
    if (index >= names.size()) {
        AgiActionName action = setNextAction("/search/navigate-to");
        action.putParam("navigation", navigation);
        action.putParam("index", 0);
        action.setExcludeFromHistory(true);
        // Add an extra pause so the user has a chance to make a selection from
        // the previous entry
        addPause(1000);
        addMessage(Messages.TO_REPEAT);
    } else {
        String key = addNavigationSelectionActionForIndex(navigation, index);
        NameBean name = names.get(index);
        handleName(name, key);
        addNavigateToAction(navigation, "4", first(index - 1));
        addNavigateToAction(navigation, "6", index + 1);
        addNavigateToAction(navigation, "7", first(index - 10));
        addNavigateToAction(navigation, "9", index + 10);
        AgiActionName action = setNextAction("/search/navigate-to");
        action.putParam("navigation", navigation);
        action.putParam("index", index + 1);
        action.setExcludeFromHistory(true);
    }
    addAction("\\*", "/back");
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack) NavigationBean(org.onebusaway.phone.actions.search.NavigationBean) NameBean(org.onebusaway.transit_data.model.NameBean) AgiActionName(org.onebusaway.probablecalls.AgiActionName)

Example 7 with AgiActionName

use of org.onebusaway.probablecalls.AgiActionName in project onebusaway-application-modules by camsys.

the class IndexTemplate method buildTemplate.

@SuppressWarnings("unchecked")
@Override
public void buildTemplate(ActionContext context) {
    ValueStack stack = context.getValueStack();
    List<BookmarkWithStopsBean> bookmarks = (List<BookmarkWithStopsBean>) stack.findValue("bookmarks");
    if (bookmarks.isEmpty()) {
        addMessage(Messages.BOOKMARKS_EMPTY);
    } else {
        int index = 1;
        for (BookmarkWithStopsBean bookmark : bookmarks) {
            String toPress = Integer.toString(index);
            addMessage(Messages.FOR);
            AgiActionName stopAction = addAction(toPress, "/stop/arrivalsAndDeparturesForStopId");
            List<String> stopIds = MappingLibrary.map(bookmark.getStops(), "id");
            Set<String> routeIds = new HashSet<String>(MappingLibrary.map(bookmark.getRoutes(), "id", String.class));
            stopAction.putParam("stopIds", stopIds);
            stopAction.putParam("routeIds", routeIds);
            addBookmarkDescription(bookmark);
            addMessage(Messages.PLEASE_PRESS);
            addText(toPress);
            index++;
        }
    }
    addAction("(#|0|.+\\*)", "/repeat");
    addMessage(Messages.HOW_TO_GO_BACK);
    addAction("\\*", "/back");
    addMessage(Messages.TO_REPEAT);
}
Also used : ValueStack(com.opensymphony.xwork2.util.ValueStack) BookmarkWithStopsBean(org.onebusaway.presentation.model.BookmarkWithStopsBean) List(java.util.List) AgiActionName(org.onebusaway.probablecalls.AgiActionName) HashSet(java.util.HashSet)

Example 8 with AgiActionName

use of org.onebusaway.probablecalls.AgiActionName in project onebusaway-application-modules by camsys.

the class MultipleRoutesFoundTemplate method buildTemplate.

@SuppressWarnings("unchecked")
@Override
public void buildTemplate(ActionContext context) {
    ValueStack vs = context.getValueStack();
    List<RouteBean> routes = (List<RouteBean>) vs.findValue("routes");
    int index = 1;
    addMessage(Messages.MULTIPLE_ROUTES_WERE_FOUND);
    for (RouteBean route : routes) {
        addMessage(Messages.FOR);
        addMessage(Messages.ROUTE);
        String routeNumber = route.getShortName();
        addText(_routeNumberPronunciation.modify(routeNumber));
        addMessage(Messages.OPERATED_BY);
        addText(route.getAgency().getName());
        addMessage(Messages.PLEASE_PRESS);
        String key = Integer.toString(index++);
        addText(key);
        AgiActionName action = addAction(key, "/search/tree");
        action.putParam("route", route);
    }
    addMessage(Messages.HOW_TO_GO_BACK);
    addAction("\\*", "/back");
    addMessage(Messages.TO_REPEAT);
}
Also used : RouteBean(org.onebusaway.transit_data.model.RouteBean) ValueStack(com.opensymphony.xwork2.util.ValueStack) List(java.util.List) AgiActionName(org.onebusaway.probablecalls.AgiActionName)

Example 9 with AgiActionName

use of org.onebusaway.probablecalls.AgiActionName in project onebusaway-application-modules by camsys.

the class StopsForRouteNavigationTemplate method addNavigateToAction.

private void addNavigateToAction(NavigationBean navigation, String key, int index) {
    AgiActionName action = addAction(key, "/search/navigate-to");
    action.putParam("navigation", navigation);
    action.putParam("index", index);
    action.setExcludeFromHistory(true);
}
Also used : AgiActionName(org.onebusaway.probablecalls.AgiActionName)

Example 10 with AgiActionName

use of org.onebusaway.probablecalls.AgiActionName in project onebusaway-application-modules by camsys.

the class StopsForRouteNavigationTemplate method addNavigationSelectionActionForIndex.

private String addNavigationSelectionActionForIndex(NavigationBean navigation, int index) {
    int keyIndex = (index % 2) + 1;
    String key = Integer.toString(keyIndex);
    AgiActionName action = addAction(key, "/search/navigate-down");
    action.putParam("navigation", navigation);
    action.putParam("index", index);
    return key;
}
Also used : AgiActionName(org.onebusaway.probablecalls.AgiActionName)

Aggregations

AgiActionName (org.onebusaway.probablecalls.AgiActionName)10 ValueStack (com.opensymphony.xwork2.util.ValueStack)7 List (java.util.List)4 BookmarkWithStopsBean (org.onebusaway.presentation.model.BookmarkWithStopsBean)2 StopBean (org.onebusaway.transit_data.model.StopBean)2 HashSet (java.util.HashSet)1 NavigationBean (org.onebusaway.phone.actions.search.NavigationBean)1 PhoneArrivalsAndDeparturesModel (org.onebusaway.phone.impl.PhoneArrivalsAndDeparturesModel)1 NameBean (org.onebusaway.transit_data.model.NameBean)1 RouteBean (org.onebusaway.transit_data.model.RouteBean)1 StopsWithArrivalsAndDeparturesBean (org.onebusaway.transit_data.model.StopsWithArrivalsAndDeparturesBean)1