Package org.onebusaway.users.model

Examples of org.onebusaway.users.model.User


  }

  @Test
  public void testMergeUsers02() throws BookmarkException {

    User userA = createUser();

    _service.setLastSelectedStopIds(userA, Arrays.asList("A"));
    _service.setDefaultLocation(userA, "here", 47.0, -122.0);
    _service.addStopBookmark(userA, "bookmark A", Arrays.asList("A", "C"),
        new RouteFilter());

    User userB = createUser();

    _service.mergeProperties(userA, userB);

    UserPropertiesV1 props = getProperties(userB);
    List<String> bookmarks = props.getBookmarkedStopIds();
View Full Code Here


  }

  @Test
  public void testMergeUsers03() throws BookmarkException {

    User userA = createUser();

    _service.setLastSelectedStopIds(userA, Arrays.asList("A"));
    _service.setDefaultLocation(userA, "here", 47.0, -122.0);
    _service.addStopBookmark(userA, "bookmark a", Arrays.asList("A", "C"),
        new RouteFilter());

    User userB = createUser();

    _service.setLastSelectedStopIds(userB, Arrays.asList("B"));
    _service.setDefaultLocation(userB, "there", 48.0, -123.0);
    _service.addStopBookmark(userB, "bookmark b", Arrays.asList("B", "A"),
        new RouteFilter());
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

  }

  public void handleAccessForUser(int userId, long accessTime) {
    Element element = _cache.get(userId);
    if (element == null) {
      User user = _userDao.getUserForId(userId);
      user.setLastAccessTime(new Date(accessTime));
      _userDao.saveOrUpdateUser(user);
      if (_log.isDebugEnabled())
        _log.debug("user last access set " + userId);
      element = new Element(userId, accessTime);
      _cache.put(element);
View Full Code Here

    UserIndex userIndex = _userDao.getUserIndexForId(key);

    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());
      user.setRoles(roles);

      userIndex = new UserIndex();
      userIndex.setId(key);
      userIndex.setCredentials(credentials);
      userIndex.setUser(user);

      user.getUserIndices().add(userIndex);

      _userDao.saveOrUpdateUser(user);
    }

    return userIndex;
View Full Code Here

     * At this point, we have a valid registration code. We may safely clear the
     * registration
     */
    _userIndexRegistrationService.clearRegistrationForUserIndexKey(userIndex.getId());

    User targetUser = _userDao.getUserForId(registration.getUserId());
    if (targetUser == null)
      return null;

    User phoneUser = userIndex.getUser();

    /**
     * If the user index is already registered, our work is done
     */
    if (phoneUser.equals(targetUser))
      return userIndex;

    /**
     * If the phone user only has one index (the phoneNumber index), we merge
     * the phone user with the registration target user. Otherwise, we keep the
     * phone user, but just transfer the phone index
     */
    if (phoneUser.getUserIndices().size() == 1) {
      mergeUsers(userIndex.getUser(), targetUser);
    } else {
      userIndex.setUser(targetUser);
      targetUser.getUserIndices().add(userIndex);
      phoneUser.getUserIndices().remove(userIndex);
      _userDao.saveOrUpdateUsers(phoneUser, targetUser);
    }

    // Refresh the user index
    return getUserIndexForId(userIndex.getId());
View Full Code Here

    if (userIndex == null) {
      return null;
    }

    User user = userIndex.getUser();
    UserBean bean = getUserAsBean(user);
    return bean.getMinApiRequestInterval();
  }
View Full Code Here

      for (int userId : userIds) {
        if (Thread.interrupted() ) {
          return;
        }
        User user = _userDao.getUserForId(userId);
        if (user != null) {
          _userDao.deleteUser(user);
        }
        Thread.yield();
      }
View Full Code Here

   
    return new IndexedUserDetailsImpl(_authoritiesService, userIndex);
  }

  private void setLastAccessTimeForUser(UserIndex userIndex) {
    User user = userIndex.getUser();
    _userLastAccessTimeService.handleAccessForUser(user.getId(), System.currentTimeMillis());
  }
View Full Code Here

    UserIndexKey key = new UserIndexKey(UserIndexTypes.PHONE_NUMBER,
        phoneNumber);
    UserIndex existingUserIndex = _userService.getOrCreateUserForIndexKey(key,
        "", false);
    User existingUser = existingUserIndex.getUser();

    String id = key.getType() + "|" + key.getValue();
    UserIndexKey studyKey = new UserIndexKey("tccStudyId", id);

    return _userService.addUserIndexToUser(existingUser, studyKey,
View Full Code Here

TOP

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

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.