use of org.onebusaway.users.model.UserPropertiesV1 in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV1Impl method setRememberUserPreferencesEnabled.
@Override
public void setRememberUserPreferencesEnabled(User user, boolean rememberPreferencesEnabled) {
UserPropertiesV1 properties = getProperties(user);
properties.setRememberPreferencesEnabled(rememberPreferencesEnabled);
if (!rememberPreferencesEnabled)
properties.clear();
_userDao.saveOrUpdateUser(user);
}
use of org.onebusaway.users.model.UserPropertiesV1 in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV1Impl method addStopBookmark.
@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;
}
use of org.onebusaway.users.model.UserPropertiesV1 in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV1Impl method setDefaultLocation.
@Override
public void setDefaultLocation(User user, String locationName, double lat, double lon) {
UserPropertiesV1 properties = getProperties(user);
if (!properties.isRememberPreferencesEnabled())
return;
properties.setDefaultLocationName(locationName);
properties.setDefaultLocationLat(lat);
properties.setDefaultLocationLon(lon);
_userDao.saveOrUpdateUser(user);
}
use of org.onebusaway.users.model.UserPropertiesV1 in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV1Impl method getUserAsBean.
@Override
public UserBean getUserAsBean(User user, UserBean bean) {
UserPropertiesV1 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());
if (properties.getLastSelectedStopId() != null)
bean.setLastSelectedStopIds(Arrays.asList(properties.getLastSelectedStopId()));
int bookmarkIndex = 0;
for (String stopId : properties.getBookmarkedStopIds()) {
BookmarkBean bookmark = new BookmarkBean();
bookmark.setId(bookmarkIndex++);
bookmark.setStopIds(Arrays.asList(stopId));
bean.addBookmark(bookmark);
}
return bean;
}
use of org.onebusaway.users.model.UserPropertiesV1 in project onebusaway-application-modules by camsys.
the class UserDaoImplTest method testGetNumberOfUsers.
@Test
public void testGetNumberOfUsers() {
assertEquals(0, _dao.getNumberOfUsers());
User userA = new User();
userA.setCreationTime(new Date());
userA.setProperties(new UserPropertiesV1());
_dao.saveOrUpdateUser(userA);
assertEquals(1, _dao.getNumberOfUsers());
User userB = new User();
userB.setCreationTime(new Date());
userB.setProperties(new UserPropertiesV1());
_dao.saveOrUpdateUser(userB);
assertEquals(2, _dao.getNumberOfUsers());
}
Aggregations