Search in sources :

Example 6 with BookmarkWithStopsBean

use of org.onebusaway.presentation.model.BookmarkWithStopsBean 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)

Aggregations

BookmarkWithStopsBean (org.onebusaway.presentation.model.BookmarkWithStopsBean)6 HashSet (java.util.HashSet)3 ValueStack (com.opensymphony.xwork2.util.ValueStack)2 List (java.util.List)2 AgiActionName (org.onebusaway.probablecalls.AgiActionName)2 ArrayList (java.util.ArrayList)1 StopBean (org.onebusaway.transit_data.model.StopBean)1 BookmarkBean (org.onebusaway.users.client.model.BookmarkBean)1 RouteFilter (org.onebusaway.users.model.properties.RouteFilter)1