Package org.onebusaway.users.model

Examples of org.onebusaway.users.model.UserPropertiesV1


  @Override
  public int addStopBookmark(User user, String name, List<String> stopIds,
      RouteFilter filter) {

    UserPropertiesV1 properties = getProperties(user);

    if (!properties.isRememberPreferencesEnabled())
      return -1;

    properties.getBookmarkedStopIds().addAll(stopIds);

    _userDao.saveOrUpdateUser(user);

    return properties.getBookmarkedStopIds().size() - 1;
  }
View Full Code Here


  @Override
  public void updateStopBookmark(User user, int id, String name,
      List<String> stopIds, RouteFilter routeFilter) {

    UserPropertiesV1 properties = getProperties(user);

    if (!properties.isRememberPreferencesEnabled())
      return;

    List<String> bookmarks = properties.getBookmarkedStopIds();
    if (0 <= id && id < bookmarks.size()) {
      bookmarks.set(id, stopIds.get(0));
      _userDao.saveOrUpdateUser(user);
    }
  }
View Full Code Here

    }
  }

  @Override
  public void deleteStopBookmarks(User user, int index) {
    UserPropertiesV1 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());

    List<String> bookmarkedStopIds = properties.getBookmarkedStopIds();
    bookmarkedStopIds.remove(index);
    _userDao.saveOrUpdateUser(user);
  }
View Full Code Here

    if (stopIds.isEmpty())
      return;

    String stopId = stopIds.get(0);

    UserPropertiesV1 properties = getProperties(user);

    if (!properties.isRememberPreferencesEnabled())
      return;

    if (!stopId.equals(properties.getLastSelectedStopId())) {
      properties.setLastSelectedStopId(stopId);
      _userDao.saveOrUpdateUser(user);
    }
  }
View Full Code Here

    }
  }

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

    _service.setDefaultLocation(userB, "here", 47.0, -122.0);
    _service.addStopBookmark(userB, "bookmark b", Arrays.asList("C", "B"),
        new RouteFilter());
    _service.mergeProperties(userA, userB);

    UserPropertiesV1 props = getProperties(userB);
    List<String> bookmarks = props.getBookmarkedStopIds();
    assertEquals(4, bookmarks.size());
    assertEquals("C", bookmarks.get(0));
    assertEquals("B", bookmarks.get(1));
    assertEquals("A", bookmarks.get(2));
    assertEquals("C", bookmarks.get(3));

    assertEquals("here", props.getDefaultLocationName());
    assertEquals(47.0, props.getDefaultLocationLat(), 0.0);
    assertEquals(-122.0, props.getDefaultLocationLon(), 0.0);

    assertEquals("A", props.getLastSelectedStopId());
  }
View Full Code Here

    User userB = createUser();

    _service.mergeProperties(userA, userB);

    UserPropertiesV1 props = getProperties(userB);
    List<String> bookmarks = props.getBookmarkedStopIds();
    assertEquals(2, bookmarks.size());
    assertEquals("A", bookmarks.get(0));
    assertEquals("C", bookmarks.get(1));

    assertEquals("here", props.getDefaultLocationName());
    assertEquals(47.0, props.getDefaultLocationLat(), 0.0);
    assertEquals(-122.0, props.getDefaultLocationLon(), 0.0);

    assertEquals("A", props.getLastSelectedStopId());
  }
View Full Code Here

    _service.addStopBookmark(userB, "bookmark b", Arrays.asList("B", "A"),
        new RouteFilter());

    _service.mergeProperties(userA, userB);

    UserPropertiesV1 props = getProperties(userB);
    List<String> bookmarks = props.getBookmarkedStopIds();
    assertEquals(4, bookmarks.size());
    assertEquals("B", bookmarks.get(0));
    assertEquals("A", bookmarks.get(1));
    assertEquals("A", bookmarks.get(2));
    assertEquals("C", bookmarks.get(3));

    assertEquals("there", props.getDefaultLocationName());
    assertEquals(48.0, props.getDefaultLocationLat(), 0.0);
    assertEquals(-123.0, props.getDefaultLocationLon(), 0.0);

    assertEquals("B", props.getLastSelectedStopId());
  }
View Full Code Here

    assertEquals("B", props.getLastSelectedStopId());
  }

  private User createUser() {
    User user = new User();
    user.setProperties(new UserPropertiesV1());
    return user;
  }
View Full Code Here

    if (userIndex == null) {

      User user = new User();
      user.setCreationTime(new Date());
      user.setTemporary(true);
      user.setProperties(new UserPropertiesV1());
      Set<UserRole> roles = new HashSet<UserRole>();
      if (isAnonymous)
        roles.add(_authoritiesService.getAnonymousRole());
      else
        roles.add(_authoritiesService.getUserRole());
View Full Code Here

TOP

Related Classes of org.onebusaway.users.model.UserPropertiesV1

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.