Package org.onebusaway.users.model.properties

Examples of org.onebusaway.users.model.properties.UserPropertiesV2


  @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);
View Full Code Here


  @Test
  public void testTransitionUserIndex() {

    User userA = new User();
    userA.setCreationTime(new Date());
    userA.setProperties(new UserPropertiesV2());

    UserIndex index = new UserIndex();
    index.setId(new UserIndexKey("test", "A"));
    index.setUser(userA);
    userA.getUserIndices().add(index);

    _dao.saveOrUpdateUser(userA);

    User userB = new User();
    userB.setCreationTime(new Date());
    userB.setProperties(new UserPropertiesV2());

    _dao.saveOrUpdateUser(userB);

    assertEquals(1, _dao.getUserForId(userA.getId()).getUserIndices().size());
    assertEquals(0, _dao.getUserForId(userB.getId()).getUserIndices().size());
View Full Code Here

    }
  }

  @Override
  public void resetUser(User user) {
    user.setProperties(new UserPropertiesV2());
    _userDao.saveOrUpdateUser(user);
    _lastSelectedStopService.clearLastSelectedStopForUser(user.getId());
  }
View Full Code Here

    _lastSelectedStopService.clearLastSelectedStopForUser(user.getId());
  }

  @Override
  public void deleteStopBookmarks(User user, int id) {
    UserPropertiesV2 properties = getProperties(user);

    // Why don't we have a check for stateless user here? If the user wants to
    // remove information, that's ok. Still not sure why this would be called
    // 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;
      }
View Full Code Here

    _lastSelectedStopService.setLastSelectedStopsForUser(user.getId(), stopIds);
  }

  @Override
  public void authorizeApi(User user, long minApiRequestInterval) {
    UserPropertiesV2 properties = getProperties(user);
    properties.setMinApiRequestInterval(minApiRequestInterval);
    _userDao.saveOrUpdateUser(user);
  }
View Full Code Here

  @Override
  public void markServiceAlertAsRead(User user, String situationId, long time,
      boolean isRead) {

    UserPropertiesV2 properties = getProperties(user);
    Map<String, Long> readSituationIdsWithReadTime = properties.getReadSituationIdsWithReadTime();

    if (isRead) {

      if (readSituationIdsWithReadTime == null) {
        readSituationIdsWithReadTime = new HashMap<String, Long>();
        properties.setReadSituationIdsWithReadTime(readSituationIdsWithReadTime);
      }
      readSituationIdsWithReadTime.put(situationId, time);
      _userDao.saveOrUpdateUser(user);
    } else {
      if (readSituationIdsWithReadTime == null)
View Full Code Here

   * Private Methods
   ****/

  private UserPropertiesV2 getProperties(User user) {
    UserProperties props = user.getProperties();
    UserPropertiesV2 v2 = _userPropertiesMigration.migrate(props,
        UserPropertiesV2.class);
    if (props != v2)
      user.setProperties(v2);
    return v2;
  }
View Full Code Here

TOP

Related Classes of org.onebusaway.users.model.properties.UserPropertiesV2

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.