Search in sources :

Example 11 with UserPropertiesV1

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);
}
Also used : UserPropertiesV1(org.onebusaway.users.model.UserPropertiesV1)

Example 12 with UserPropertiesV1

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;
}
Also used : UserPropertiesV1(org.onebusaway.users.model.UserPropertiesV1)

Example 13 with UserPropertiesV1

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);
}
Also used : UserPropertiesV1(org.onebusaway.users.model.UserPropertiesV1)

Example 14 with UserPropertiesV1

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;
}
Also used : BookmarkBean(org.onebusaway.users.client.model.BookmarkBean) UserPropertiesV1(org.onebusaway.users.model.UserPropertiesV1)

Example 15 with UserPropertiesV1

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());
}
Also used : User(org.onebusaway.users.model.User) UserPropertiesV1(org.onebusaway.users.model.UserPropertiesV1) Date(java.util.Date) Test(org.junit.Test)

Aggregations

UserPropertiesV1 (org.onebusaway.users.model.UserPropertiesV1)20 Test (org.junit.Test)9 User (org.onebusaway.users.model.User)7 RouteFilter (org.onebusaway.users.model.properties.RouteFilter)4 UserPropertiesV2 (org.onebusaway.users.model.properties.UserPropertiesV2)4 Date (java.util.Date)3 Bookmark (org.onebusaway.users.model.properties.Bookmark)3 HashSet (java.util.HashSet)1 BookmarkBean (org.onebusaway.users.client.model.BookmarkBean)1 UserProperties (org.onebusaway.users.model.UserProperties)1 UserRole (org.onebusaway.users.model.UserRole)1 UserPropertiesV3 (org.onebusaway.users.model.properties.UserPropertiesV3)1 UserPropertiesV4 (org.onebusaway.users.model.properties.UserPropertiesV4)1