Search in sources :

Example 36 with User

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

the class CurrentUserServiceImpl method setLastSelectedStopIds.

@Override
public void setLastSelectedStopIds(List<String> stopIds) {
    User user = _currentUserStrategy.getCurrentUser(true);
    if (user == null)
        return;
    _userPropertiesService.setLastSelectedStopIds(user, stopIds);
}
Also used : User(org.onebusaway.users.model.User)

Example 37 with User

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

the class CurrentUserServiceImpl method setDefaultLocation.

@Override
public void setDefaultLocation(String locationName, double lat, double lon) {
    User user = _currentUserStrategy.getCurrentUser(true);
    if (user == null)
        return;
    _userPropertiesService.setDefaultLocation(user, locationName, lat, lon);
}
Also used : User(org.onebusaway.users.model.User)

Example 38 with User

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

the class CurrentUserServiceImpl method markServiceAlertAsRead.

@Override
public void markServiceAlertAsRead(String situationId, long time, boolean isRead) {
    User user = _currentUserStrategy.getCurrentUser(true);
    if (user == null)
        return;
    _userPropertiesService.markServiceAlertAsRead(user, situationId, time, isRead);
}
Also used : User(org.onebusaway.users.model.User)

Example 39 with User

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

the class CurrentUserServiceImpl method deleteCurrentUser.

@Override
public void deleteCurrentUser() {
    User user = _currentUserStrategy.getCurrentUser(false);
    if (user == null)
        return;
    _userService.deleteUser(user);
    _currentUserStrategy.clearCurrentUser();
}
Also used : User(org.onebusaway.users.model.User)

Example 40 with User

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

the class UserServiceImpl method completePhoneNumberRegistration.

@Override
public UserIndex completePhoneNumberRegistration(UserIndex userIndex, String registrationCode) {
    UserRegistration registration = _userIndexRegistrationService.getRegistrationForUserIndexKey(userIndex.getId());
    if (registration == null)
        return null;
    String expectedCode = registration.getRegistrationCode();
    if (!expectedCode.equals(registrationCode))
        return null;
    /**
     * 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());
}
Also used : User(org.onebusaway.users.model.User) UserRegistration(org.onebusaway.users.services.internal.UserRegistration)

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