Examples of UserPropertiesV2


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

   * @return
   */

  private UserPropertiesV2 getV2Properties(UserPropertiesV1 v1) {

    UserPropertiesV2 v2 = new UserPropertiesV2();

    v2.setRememberPreferencesEnabled(v1.isRememberPreferencesEnabled());

    v2.setDefaultLocationLat(v1.getDefaultLocationLat());
    v2.setDefaultLocationLon(v1.getDefaultLocationLon());
    v2.setDefaultLocationName(v1.getDefaultLocationName());

    int index = 0;
    for (String stopId : v1.getBookmarkedStopIds()) {
      Bookmark bookmark = new Bookmark(index++,null,Arrays.asList(stopId),new RouteFilter());
      v2.getBookmarks().add(bookmark);
    }

    return v2;
  }
View Full Code Here

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

    UserPropertiesV1 v1 = new UserPropertiesV1();
    assertFalse(_service.needsMigration(v1, UserPropertiesV1.class));
    assertTrue(_service.needsMigration(v1, UserPropertiesV2.class));

    UserPropertiesV2 v2 = new UserPropertiesV2();
    assertTrue(_service.needsMigration(v2, UserPropertiesV1.class));
    assertFalse(_service.needsMigration(v2, UserPropertiesV2.class));
  }
View Full Code Here

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

    v1.setBookmarkedStopIds(Arrays.asList("1_29214", "1_75403"));

    UserPropertiesV1 result = _service.migrate(v1, UserPropertiesV1.class);
    assertTrue(v1 == result);

    UserPropertiesV2 v2 = _service.migrate(v1, UserPropertiesV2.class);

    assertTrue(v2.isRememberPreferencesEnabled());

    assertEquals(47.0, v2.getDefaultLocationLat(), 0.0);
    assertEquals(-122.0, v2.getDefaultLocationLon(), 0.0);
    assertEquals("Seattle", v2.getDefaultLocationName());

    List<Bookmark> bookmarks = v2.getBookmarks();
    assertEquals(2, bookmarks.size());

    Bookmark bookmark = bookmarks.get(0);
    assertEquals(0,bookmark.getId());
    assertNull(bookmark.getName());
View Full Code Here

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

  }

  @Test
  public void testV2ToV1Migration() {

    UserPropertiesV2 v2 = new UserPropertiesV2();
    v2.setDefaultLocationLat(47.0);
    v2.setDefaultLocationLon(-122.0);
    v2.setDefaultLocationName("Seattle");
    v2.setRememberPreferencesEnabled(true);

    Bookmark b1 = new Bookmark(0,null,Arrays.asList("1_29214"),new RouteFilter());
    Bookmark b2 = new Bookmark(1,null,Arrays.asList("1_75403", "1_75414"), new RouteFilter());
    v2.setBookmarks(Arrays.asList(b1, b2));

    UserPropertiesV2 result = _service.migrate(v2, UserPropertiesV2.class);
    assertTrue(v2 == result);

    UserPropertiesV1 v1 = _service.migrate(v2, UserPropertiesV1.class);

    assertTrue(v1.isRememberPreferencesEnabled());
View Full Code Here

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

  }

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

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

  }

  @Override
  public void setRememberUserPreferencesEnabled(User user,
      boolean rememberPreferencesEnabled) {
    UserPropertiesV2 properties = getProperties(user);
    properties.setRememberPreferencesEnabled(rememberPreferencesEnabled);
    if (!rememberPreferencesEnabled)
      properties.clear();
    _userDao.saveOrUpdateUser(user);
  }
View Full Code Here

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

  @Override
  public void setDefaultLocation(User user, String locationName, double lat,
      double lon) {

    UserPropertiesV2 properties = getProperties(user);

    if (!properties.isRememberPreferencesEnabled())
      return;

    properties.setDefaultLocationName(locationName);
    properties.setDefaultLocationLat(lat);
    properties.setDefaultLocationLon(lon);

    _userDao.saveOrUpdateUser(user);
  }
View Full Code Here

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

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

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

    assertEquals(0, _dao.getNumberOfStaleUsers(oneMonth));

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

    _dao.saveOrUpdateUser(userA);

    assertEquals(1, _dao.getNumberOfStaleUsers(oneMonth));
    assertEquals(0, _dao.getNumberOfStaleUsers(twoMonth));
    assertEquals(0, _dao.getNumberOfStaleUsers(threeMonth));

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

    _dao.saveOrUpdateUser(userB);

    assertEquals(2, _dao.getNumberOfStaleUsers(oneMonth));
    assertEquals(1, _dao.getNumberOfStaleUsers(twoMonth));
View Full Code Here

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

    _dao.saveOrUpdateUserRole(userRole);

    User user = new User();
    user.setCreationTime(new Date());
    user.setProperties(new UserPropertiesV2());
    user.getRoles().add(userRole);

    UserIndexKey key = new UserIndexKey("phone", "2065551234");

    UserIndex index = new UserIndex();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.