Search in sources :

Example 21 with User

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

the class CurrentUserServiceImpl method handleRegistration.

@Override
public IndexedUserDetails handleRegistration(String type, String id, String credentials, boolean isAnonymous) {
    UserIndexKey key = new UserIndexKey(type, id);
    UserIndex index = _userService.getOrCreateUserForIndexKey(key, credentials, isAnonymous);
    User oldUser = _currentUserStrategy.getCurrentUser(false);
    if (oldUser != null && _userService.isAnonymous(oldUser))
        _userService.mergeUsers(oldUser, index.getUser());
    return new IndexedUserDetailsImpl(_authoritiesService, index);
}
Also used : UserIndex(org.onebusaway.users.model.UserIndex) UserIndexKey(org.onebusaway.users.model.UserIndexKey) User(org.onebusaway.users.model.User)

Example 22 with User

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

the class CurrentUserServiceImpl method deleteStopBookmarks.

@Override
public void deleteStopBookmarks(int index) {
    User user = _currentUserStrategy.getCurrentUser(false);
    if (user == null)
        return;
    _userPropertiesService.deleteStopBookmarks(user, index);
}
Also used : User(org.onebusaway.users.model.User)

Example 23 with User

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

the class UserLastAccessTimeServiceImpl method handleAccessForUser.

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);
    }
}
Also used : User(org.onebusaway.users.model.User) Element(net.sf.ehcache.Element) Date(java.util.Date)

Example 24 with User

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

the class UserDaoImplTest method testGetAllUserIds.

@Test
public void testGetAllUserIds() {
    Set<Integer> ids = new HashSet<Integer>();
    for (int i = 0; i < 100; i++) {
        User userA = new User();
        userA.setCreationTime(new Date());
        userA.setProperties(new UserPropertiesV1());
        _dao.saveOrUpdateUser(userA);
        ids.add(userA.getId());
    }
    int n = _dao.getNumberOfUsers();
    assertEquals(100, n);
    Set<Integer> retreivedIds = new HashSet<Integer>();
    final int limit = 20;
    for (int i = 0; i < n; i += limit) {
        List<Integer> pageOfIds = _dao.getAllUserIdsInRange(i, limit);
        assertTrue(pageOfIds.size() <= limit);
        retreivedIds.addAll(pageOfIds);
    }
    assertEquals(ids, retreivedIds);
}
Also used : User(org.onebusaway.users.model.User) UserPropertiesV1(org.onebusaway.users.model.UserPropertiesV1) Date(java.util.Date) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 25 with User

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

the class UserDaoImplTest method testTransitionUserIndex.

@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());
    index.setUser(userB);
    userA.getUserIndices().remove(index);
    userB.getUserIndices().add(index);
    _dao.saveOrUpdateUsers(userA, userB);
    assertEquals(0, _dao.getUserForId(userA.getId()).getUserIndices().size());
    assertEquals(1, _dao.getUserForId(userB.getId()).getUserIndices().size());
}
Also used : UserIndex(org.onebusaway.users.model.UserIndex) UserIndexKey(org.onebusaway.users.model.UserIndexKey) User(org.onebusaway.users.model.User) UserPropertiesV2(org.onebusaway.users.model.properties.UserPropertiesV2) Date(java.util.Date) Test(org.junit.Test)

Aggregations

User (org.onebusaway.users.model.User)56 UserIndex (org.onebusaway.users.model.UserIndex)23 UserIndexKey (org.onebusaway.users.model.UserIndexKey)16 Test (org.junit.Test)13 Date (java.util.Date)9 UserBean (org.onebusaway.users.client.model.UserBean)8 UserPropertiesV1 (org.onebusaway.users.model.UserPropertiesV1)7 ArrayList (java.util.ArrayList)5 IOException (java.io.IOException)4 SQLException (java.sql.SQLException)4 List (java.util.List)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 JsonGenerationException (org.codehaus.jackson.JsonGenerationException)4 JsonMappingException (org.codehaus.jackson.map.JsonMappingException)4 Criteria (org.hibernate.Criteria)4 HibernateException (org.hibernate.HibernateException)4 Session (org.hibernate.Session)4 UserDetail (org.onebusaway.admin.model.ui.UserDetail)4 RouteFilter (org.onebusaway.users.model.properties.RouteFilter)4 UserRole (org.onebusaway.users.model.UserRole)3