Search in sources :

Example 1 with Bookmark

use of org.onebusaway.users.model.properties.Bookmark in project onebusaway-application-modules by camsys.

the class UserPropertiesMigrationImpl method getV1Properties.

private UserPropertiesV1 getV1Properties(UserPropertiesV2 v2) {
    UserPropertiesV1 v1 = new UserPropertiesV1();
    v1.setRememberPreferencesEnabled(v2.isRememberPreferencesEnabled());
    v1.setDefaultLocationLat(v2.getDefaultLocationLat());
    v1.setDefaultLocationLon(v2.getDefaultLocationLon());
    v1.setDefaultLocationName(v2.getDefaultLocationName());
    for (Bookmark bookmark : v2.getBookmarks()) v1.getBookmarkedStopIds().addAll(bookmark.getStopIds());
    return v1;
}
Also used : Bookmark(org.onebusaway.users.model.properties.Bookmark) UserPropertiesV1(org.onebusaway.users.model.UserPropertiesV1)

Example 2 with Bookmark

use of org.onebusaway.users.model.properties.Bookmark in project onebusaway-application-modules by camsys.

the class UserPropertiesServiceV2Impl method addStopBookmark.

@Override
public int addStopBookmark(User user, String name, List<String> stopIds, RouteFilter filter) {
    UserPropertiesV2 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();
}
Also used : Bookmark(org.onebusaway.users.model.properties.Bookmark) UserPropertiesV2(org.onebusaway.users.model.properties.UserPropertiesV2)

Example 3 with Bookmark

use of org.onebusaway.users.model.properties.Bookmark 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;
}
Also used : Bookmark(org.onebusaway.users.model.properties.Bookmark) BookmarkBean(org.onebusaway.users.client.model.BookmarkBean) UserPropertiesV2(org.onebusaway.users.model.properties.UserPropertiesV2)

Example 4 with Bookmark

use of org.onebusaway.users.model.properties.Bookmark 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;
}
Also used : Bookmark(org.onebusaway.users.model.properties.Bookmark) BookmarkBean(org.onebusaway.users.client.model.BookmarkBean) UserPropertiesV3(org.onebusaway.users.model.properties.UserPropertiesV3)

Example 5 with Bookmark

use of org.onebusaway.users.model.properties.Bookmark in project onebusaway-application-modules by camsys.

the class UserPropertiesServiceV3Impl method addStopBookmark.

@Override
public int addStopBookmark(User user, String name, List<String> stopIds, RouteFilter filter) {
    UserPropertiesV3 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();
}
Also used : Bookmark(org.onebusaway.users.model.properties.Bookmark) UserPropertiesV3(org.onebusaway.users.model.properties.UserPropertiesV3)

Aggregations

Bookmark (org.onebusaway.users.model.properties.Bookmark)18 UserPropertiesV2 (org.onebusaway.users.model.properties.UserPropertiesV2)9 UserPropertiesV3 (org.onebusaway.users.model.properties.UserPropertiesV3)6 Test (org.junit.Test)4 RouteFilter (org.onebusaway.users.model.properties.RouteFilter)4 UserPropertiesV4 (org.onebusaway.users.model.properties.UserPropertiesV4)4 BookmarkBean (org.onebusaway.users.client.model.BookmarkBean)3 UserPropertiesV1 (org.onebusaway.users.model.UserPropertiesV1)3