use of org.onebusaway.users.model.properties.Bookmark in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV4Impl method addStopBookmark.
@Override
public int addStopBookmark(User user, String name, List<String> stopIds, RouteFilter filter) {
UserPropertiesV4 properties = getProperties(user);
if (!properties.isRememberPreferencesEnabled())
return -1;
int maxId = 0;
for (Bookmark bookmark : properties.getBookmarks()) maxId = Math.max(maxId, bookmark.getId() + 1);
Bookmark bookmark = new Bookmark(maxId, name, stopIds, filter);
properties.getBookmarks().add(bookmark);
_userDao.saveOrUpdateUser(user);
return bookmark.getId();
}
use of org.onebusaway.users.model.properties.Bookmark in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV4Impl method updateStopBookmark.
@Override
public void updateStopBookmark(User user, int id, String name, List<String> stopIds, RouteFilter routeFilter) {
UserPropertiesV4 properties = getProperties(user);
if (!properties.isRememberPreferencesEnabled())
return;
List<Bookmark> bookmarks = properties.getBookmarks();
for (int index = 0; index < bookmarks.size(); index++) {
Bookmark bookmark = bookmarks.get(index);
if (bookmark.getId() == id) {
bookmark = new Bookmark(id, name, stopIds, routeFilter);
bookmarks.set(index, bookmark);
_userDao.saveOrUpdateUser(user);
return;
}
}
}
use of org.onebusaway.users.model.properties.Bookmark in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV4Impl method getUserAsBean.
@Override
public UserBean getUserAsBean(User user, UserBean bean) {
UserPropertiesV4 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());
bean.setDisabled(properties.isDisabled());
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;
}
Aggregations