Search in sources :

Example 11 with Bookmark

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

the class UserPropertiesServiceV2Impl method updateStopBookmark.

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

Example 12 with Bookmark

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

the class UserPropertiesServiceV2Impl method deleteStopBookmarks.

@Override
public void deleteStopBookmarks(User user, int id) {
    UserPropertiesV2 properties = getProperties(user);
    // either way.
    if (!properties.isRememberPreferencesEnabled())
        _log.warn("Attempt to delete bookmark for stateless user.  They shouldn't have bookmarks in the first place.  User=" + user.getId());
    boolean modified = false;
    for (Iterator<Bookmark> it = properties.getBookmarks().iterator(); it.hasNext(); ) {
        Bookmark bookmark = it.next();
        if (bookmark.getId() == id) {
            it.remove();
            modified = true;
        }
    }
    if (modified)
        _userDao.saveOrUpdateUser(user);
}
Also used : Bookmark(org.onebusaway.users.model.properties.Bookmark) UserPropertiesV2(org.onebusaway.users.model.properties.UserPropertiesV2)

Example 13 with Bookmark

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

the class UserPropertiesServiceV3Impl method updateStopBookmark.

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

Example 14 with Bookmark

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

the class UserPropertiesServiceV3Impl method deleteStopBookmarks.

@Override
public void deleteStopBookmarks(User user, int id) {
    UserPropertiesV3 properties = getProperties(user);
    // either way.
    if (!properties.isRememberPreferencesEnabled())
        _log.warn("Attempt to delete bookmark for stateless user.  They shouldn't have bookmarks in the first place.  User=" + user.getId());
    boolean modified = false;
    for (Iterator<Bookmark> it = properties.getBookmarks().iterator(); it.hasNext(); ) {
        Bookmark bookmark = it.next();
        if (bookmark.getId() == id) {
            it.remove();
            modified = true;
        }
    }
    if (modified)
        _userDao.saveOrUpdateUser(user);
}
Also used : Bookmark(org.onebusaway.users.model.properties.Bookmark) UserPropertiesV3(org.onebusaway.users.model.properties.UserPropertiesV3)

Example 15 with Bookmark

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

the class UserPropertiesServiceV4Impl method deleteStopBookmarks.

@Override
public void deleteStopBookmarks(User user, int id) {
    UserPropertiesV4 properties = getProperties(user);
    if (!properties.isRememberPreferencesEnabled())
        _log.warn("Attempt to delete bookmark for stateless user.  They shouldn't have bookmarks in the first place.  User=" + user.getId());
    boolean modified = false;
    for (Iterator<Bookmark> it = properties.getBookmarks().iterator(); it.hasNext(); ) {
        Bookmark bookmark = it.next();
        if (bookmark.getId() == id) {
            it.remove();
            modified = true;
        }
    }
    if (modified)
        _userDao.saveOrUpdateUser(user);
}
Also used : Bookmark(org.onebusaway.users.model.properties.Bookmark) UserPropertiesV4(org.onebusaway.users.model.properties.UserPropertiesV4)

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