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);
}
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);
}
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);
}
}
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);
}
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());
}
Aggregations