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");
}
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);
}
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);
}
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);
}
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;
}
Aggregations