Search in sources :

Example 1 with UserPropertiesV4

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

the class UserPropertiesServiceV4Impl method markServiceAlertAsRead.

@Override
public void markServiceAlertAsRead(User user, String situationId, long time, boolean isRead) {
    UserPropertiesV4 properties = getProperties(user);
    Map<String, Long> readSituationIdsWithReadTime = properties.getReadSituationIdsWithReadTime();
    if (isRead) {
        if (readSituationIdsWithReadTime == null) {
            readSituationIdsWithReadTime = new HashMap<String, Long>();
            properties.setReadSituationIdsWithReadTime(readSituationIdsWithReadTime);
        }
        readSituationIdsWithReadTime.put(situationId, time);
        _userDao.saveOrUpdateUser(user);
    } else {
        if (readSituationIdsWithReadTime == null)
            return;
        if (readSituationIdsWithReadTime.remove(situationId) != null)
            _userDao.saveOrUpdateUser(user);
    }
}
Also used : UserPropertiesV4(org.onebusaway.users.model.properties.UserPropertiesV4)

Example 2 with UserPropertiesV4

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

the class UserPropertiesServiceV4Impl method getProperties.

/**
 **
 * Private Methods
 ***
 */
private UserPropertiesV4 getProperties(User user) {
    UserProperties props = user.getProperties();
    UserPropertiesV4 v4 = _userPropertiesMigration.migrate(props, UserPropertiesV4.class);
    if (props != v4)
        user.setProperties(v4);
    return v4;
}
Also used : UserProperties(org.onebusaway.users.model.UserProperties) UserPropertiesV4(org.onebusaway.users.model.properties.UserPropertiesV4)

Example 3 with UserPropertiesV4

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

the class UserPropertiesServiceV4Impl method setDefaultLocation.

@Override
public void setDefaultLocation(User user, String locationName, double lat, double lon) {
    UserPropertiesV4 properties = getProperties(user);
    if (!properties.isRememberPreferencesEnabled())
        return;
    properties.setDefaultLocationName(locationName);
    properties.setDefaultLocationLat(lat);
    properties.setDefaultLocationLon(lon);
    _userDao.saveOrUpdateUser(user);
}
Also used : UserPropertiesV4(org.onebusaway.users.model.properties.UserPropertiesV4)

Example 4 with UserPropertiesV4

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

the class UserPropertiesServiceVersionedInvocationHandler method getPropertiesVersion.

private int getPropertiesVersion(User user) {
    UserProperties props = user.getProperties();
    if (props instanceof UserPropertiesV1)
        return 1;
    if (props instanceof UserPropertiesV2)
        return 2;
    if (props instanceof UserPropertiesV3)
        return 3;
    if (props instanceof UserPropertiesV4)
        return 4;
    _log.warn("unknown user properties version: " + props.getClass());
    return 0;
}
Also used : UserProperties(org.onebusaway.users.model.UserProperties) UserPropertiesV3(org.onebusaway.users.model.properties.UserPropertiesV3) UserPropertiesV2(org.onebusaway.users.model.properties.UserPropertiesV2) UserPropertiesV1(org.onebusaway.users.model.UserPropertiesV1) UserPropertiesV4(org.onebusaway.users.model.properties.UserPropertiesV4)

Example 5 with UserPropertiesV4

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

the class UserServiceImpl method getOrCreateUserForIndexKey.

@Override
public UserIndex getOrCreateUserForIndexKey(UserIndexKey key, String credentials, boolean isAnonymous) {
    UserIndex userIndex = _userDao.getUserIndexForId(key);
    if (userIndex == null) {
        User user = new User();
        user.setCreationTime(new Date());
        user.setTemporary(true);
        user.setProperties(new UserPropertiesV4());
        Set<UserRole> roles = new HashSet<UserRole>();
        if (isAnonymous)
            roles.add(_authoritiesService.getAnonymousRole());
        else
            roles.add(_authoritiesService.getUserRole());
        user.setRoles(roles);
        userIndex = new UserIndex();
        userIndex.setId(key);
        userIndex.setCredentials(credentials);
        userIndex.setUser(user);
        user.getUserIndices().add(userIndex);
        _userDao.saveOrUpdateUser(user);
    }
    return userIndex;
}
Also used : UserIndex(org.onebusaway.users.model.UserIndex) User(org.onebusaway.users.model.User) UserRole(org.onebusaway.users.model.UserRole) Date(java.util.Date) UserPropertiesV4(org.onebusaway.users.model.properties.UserPropertiesV4) HashSet(java.util.HashSet)

Aggregations

UserPropertiesV4 (org.onebusaway.users.model.properties.UserPropertiesV4)16 Bookmark (org.onebusaway.users.model.properties.Bookmark)4 UserProperties (org.onebusaway.users.model.UserProperties)2 Date (java.util.Date)1 HashSet (java.util.HashSet)1 BookmarkBean (org.onebusaway.users.client.model.BookmarkBean)1 User (org.onebusaway.users.model.User)1 UserIndex (org.onebusaway.users.model.UserIndex)1 UserPropertiesV1 (org.onebusaway.users.model.UserPropertiesV1)1 UserRole (org.onebusaway.users.model.UserRole)1 UserPropertiesV2 (org.onebusaway.users.model.properties.UserPropertiesV2)1 UserPropertiesV3 (org.onebusaway.users.model.properties.UserPropertiesV3)1