}
@Override
public String execute() throws ServiceException, BookmarkException {
UserBean currentUser = _currentUserService.getCurrentUser();
if (_arg != null && _arg.length() > 0) {
if (_arg.startsWith("add")) {
if( currentUser == null)
return "noUser";
List<String> lastSelectedStopIds = currentUser.getLastSelectedStopIds();
if (!lastSelectedStopIds.isEmpty()) {
String name = _bookmarkPresentationService.getNameForStopIds(lastSelectedStopIds);
_currentUserService.addStopBookmark(name, lastSelectedStopIds,
new RouteFilter());
}
logUserInteraction("bookmark","added","stopIds",lastSelectedStopIds);
return "added";
}
if (_arg.startsWith("delete")) {
int index = _arg.indexOf(' ');
if (index == -1)
return INPUT;
int bookmarkIndex = Integer.parseInt(_arg.substring(index + 1).trim()) - 1;
_currentUserService.deleteStopBookmarks(bookmarkIndex);
return "deleted";
}
if (_arg.matches("\\d+")) {
int index = Integer.parseInt(_arg) - 1;
List<BookmarkBean> bookmarks = currentUser.getBookmarks();
if (index < 0 || index >= bookmarks.size())
return INPUT;
BookmarkBean bookmark = bookmarks.get(index);
_stopIds = bookmark.getStopIds();
_routeFilter = bookmark.getRouteFilter().getRouteIds();
logUserInteraction("stopIds",_stopIds,"routeIds",_routeFilter);
return "arrivals-and-departures";
}
}
_bookmarks = _bookmarkPresentationService.getBookmarksWithStops(currentUser.getBookmarks());
logUserInteraction();
return SUCCESS;
}