use of org.onebusaway.users.client.model.BookmarkBean in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV2Impl method getUserAsBean.
@Override
public UserBean getUserAsBean(User user, UserBean bean) {
UserPropertiesV2 properties = getProperties(user);
bean.setRememberPreferencesEnabled(properties.isRememberPreferencesEnabled());
bean.setHasDefaultLocation(properties.hasDefaultLocationLat() && properties.hasDefaultLocationLon());
bean.setDefaultLocationName(properties.getDefaultLocationName());
bean.setDefaultLocationLat(properties.getDefaultLocationLat());
bean.setDefaultLocationLon(properties.getDefaultLocationLon());
List<String> stopIds = _lastSelectedStopService.getLastSelectedStopsForUser(user.getId());
bean.setLastSelectedStopIds(stopIds);
for (Bookmark bookmark : properties.getBookmarks()) {
BookmarkBean bookmarkBean = new BookmarkBean();
bookmarkBean.setId(bookmark.getId());
bookmarkBean.setName(bookmark.getName());
bookmarkBean.setStopIds(bookmark.getStopIds());
bookmarkBean.setRouteFilter(getRouteFilterAsBean(bookmark.getRouteFilter()));
bean.addBookmark(bookmarkBean);
}
bean.setMinApiRequestInterval(properties.getMinApiRequestInterval());
Map<String, Long> readServiceAlerts = properties.getReadSituationIdsWithReadTime();
if (readServiceAlerts == null)
readServiceAlerts = Collections.emptyMap();
bean.setReadServiceAlerts(readServiceAlerts);
return bean;
}
use of org.onebusaway.users.client.model.BookmarkBean in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV3Impl method getUserAsBean.
@Override
public UserBean getUserAsBean(User user, UserBean bean) {
UserPropertiesV3 properties = getProperties(user);
bean.setRememberPreferencesEnabled(properties.isRememberPreferencesEnabled());
bean.setHasDefaultLocation(properties.hasDefaultLocationLat() && properties.hasDefaultLocationLon());
bean.setDefaultLocationName(properties.getDefaultLocationName());
bean.setDefaultLocationLat(properties.getDefaultLocationLat());
bean.setDefaultLocationLon(properties.getDefaultLocationLon());
bean.setContactName(properties.getContactName());
bean.setContactCompany(properties.getContactCompany());
bean.setContactEmail(properties.getContactEmail());
bean.setContactDetails(properties.getContactDetails());
List<String> stopIds = _lastSelectedStopService.getLastSelectedStopsForUser(user.getId());
bean.setLastSelectedStopIds(stopIds);
for (Bookmark bookmark : properties.getBookmarks()) {
BookmarkBean bookmarkBean = new BookmarkBean();
bookmarkBean.setId(bookmark.getId());
bookmarkBean.setName(bookmark.getName());
bookmarkBean.setStopIds(bookmark.getStopIds());
bookmarkBean.setRouteFilter(getRouteFilterAsBean(bookmark.getRouteFilter()));
bean.addBookmark(bookmarkBean);
}
bean.setMinApiRequestInterval(properties.getMinApiRequestInterval());
Map<String, Long> readServiceAlerts = properties.getReadSituationIdsWithReadTime();
if (readServiceAlerts == null)
readServiceAlerts = Collections.emptyMap();
bean.setReadServiceAlerts(readServiceAlerts);
return bean;
}
use of org.onebusaway.users.client.model.BookmarkBean in project onebusaway-application-modules by camsys.
the class BookmarkPresentationServiceImpl method getBookmarksWithStops.
@Override
public List<BookmarkWithStopsBean> getBookmarksWithStops(List<BookmarkBean> bookmarks) {
List<BookmarkWithStopsBean> beans = new ArrayList<BookmarkWithStopsBean>(bookmarks.size());
for (BookmarkBean bookmark : bookmarks) {
BookmarkWithStopsBean bean = new BookmarkWithStopsBean();
bean.setId(bookmark.getId());
bean.setName(bookmark.getName());
bean.setStops(getStopsForStopIds(bookmark.getStopIds()));
bean.setRoutes(getRoutesForRouteFilter(bookmark.getRouteFilter()));
beans.add(bean);
}
return beans;
}
use of org.onebusaway.users.client.model.BookmarkBean in project onebusaway-application-modules by camsys.
the class CommandBookmarksAction method execute.
@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());
}
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();
return "arrivals-and-departures";
}
}
_bookmarks = _bookmarkPresentationService.getBookmarksWithStops(currentUser.getBookmarks());
return SUCCESS;
}
use of org.onebusaway.users.client.model.BookmarkBean in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV1Impl method getUserAsBean.
@Override
public UserBean getUserAsBean(User user, UserBean bean) {
UserPropertiesV1 properties = getProperties(user);
bean.setRememberPreferencesEnabled(properties.isRememberPreferencesEnabled());
bean.setHasDefaultLocation(properties.hasDefaultLocationLat() && properties.hasDefaultLocationLon());
bean.setDefaultLocationName(properties.getDefaultLocationName());
bean.setDefaultLocationLat(properties.getDefaultLocationLat());
bean.setDefaultLocationLon(properties.getDefaultLocationLon());
if (properties.getLastSelectedStopId() != null)
bean.setLastSelectedStopIds(Arrays.asList(properties.getLastSelectedStopId()));
int bookmarkIndex = 0;
for (String stopId : properties.getBookmarkedStopIds()) {
BookmarkBean bookmark = new BookmarkBean();
bookmark.setId(bookmarkIndex++);
bookmark.setStopIds(Arrays.asList(stopId));
bean.addBookmark(bookmark);
}
return bean;
}
Aggregations