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