Search in sources :

Example 6 with UserPropertiesV4

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

the class UserPropertiesMigrationImpl method getV4Properties.

/**
 **
 *
 * param UserPropertiesVersion
 * return
 */
private UserPropertiesV4 getV4Properties(UserPropertiesV3 v3) {
    UserPropertiesV4 v4 = new UserPropertiesV4();
    v4.setRememberPreferencesEnabled(v3.isRememberPreferencesEnabled());
    v4.setDefaultLocationLat(v3.getDefaultLocationLat());
    v4.setDefaultLocationLon(v3.getDefaultLocationLon());
    v4.setDefaultLocationName(v3.getDefaultLocationName());
    v4.setBookmarks(v3.getBookmarks());
    v4.setMinApiRequestInterval(v3.getMinApiRequestInterval());
    v4.setReadSituationIdsWithReadTime(v3.getReadSituationIdsWithReadTime());
    v4.setContactCompany(v3.getContactCompany());
    v4.setContactDetails(v3.getContactDetails());
    v4.setContactName(v3.getContactName());
    v4.setContactEmail(v3.getContactEmail());
    return v4;
}
Also used : UserPropertiesV4(org.onebusaway.users.model.properties.UserPropertiesV4)

Example 7 with UserPropertiesV4

use of org.onebusaway.users.model.properties.UserPropertiesV4 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)

Example 8 with UserPropertiesV4

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

Example 9 with UserPropertiesV4

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

the class UserPropertiesServiceV4Impl method setRememberUserPreferencesEnabled.

@Override
public void setRememberUserPreferencesEnabled(User user, boolean rememberPreferencesEnabled) {
    UserPropertiesV4 properties = getProperties(user);
    properties.setRememberPreferencesEnabled(rememberPreferencesEnabled);
    if (!rememberPreferencesEnabled)
        properties.clear();
    _userDao.saveOrUpdateUser(user);
}
Also used : UserPropertiesV4(org.onebusaway.users.model.properties.UserPropertiesV4)

Example 10 with UserPropertiesV4

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

Aggregations

UserPropertiesV4 (org.onebusaway.users.model.properties.UserPropertiesV4)16 Bookmark (org.onebusaway.users.model.properties.Bookmark)4 UserProperties (org.onebusaway.users.model.UserProperties)2 Date (java.util.Date)1 HashSet (java.util.HashSet)1 BookmarkBean (org.onebusaway.users.client.model.BookmarkBean)1 User (org.onebusaway.users.model.User)1 UserIndex (org.onebusaway.users.model.UserIndex)1 UserPropertiesV1 (org.onebusaway.users.model.UserPropertiesV1)1 UserRole (org.onebusaway.users.model.UserRole)1 UserPropertiesV2 (org.onebusaway.users.model.properties.UserPropertiesV2)1 UserPropertiesV3 (org.onebusaway.users.model.properties.UserPropertiesV3)1