use of org.onebusaway.users.model.properties.UserPropertiesV4 in project onebusaway-application-modules by camsys.
the class UserPropertiesMigrationImpl method getV4Properties.
/**
**
*
* param UserPropertiesVersion
* return
*/
private UserPropertiesV4 getV4Properties(UserPropertiesV3 v3) {
UserPropertiesV4 v4 = new UserPropertiesV4();
v4.setRememberPreferencesEnabled(v3.isRememberPreferencesEnabled());
v4.setDefaultLocationLat(v3.getDefaultLocationLat());
v4.setDefaultLocationLon(v3.getDefaultLocationLon());
v4.setDefaultLocationName(v3.getDefaultLocationName());
v4.setBookmarks(v3.getBookmarks());
v4.setMinApiRequestInterval(v3.getMinApiRequestInterval());
v4.setReadSituationIdsWithReadTime(v3.getReadSituationIdsWithReadTime());
v4.setContactCompany(v3.getContactCompany());
v4.setContactDetails(v3.getContactDetails());
v4.setContactName(v3.getContactName());
v4.setContactEmail(v3.getContactEmail());
return v4;
}
use of org.onebusaway.users.model.properties.UserPropertiesV4 in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV4Impl method deleteStopBookmarks.
@Override
public void deleteStopBookmarks(User user, int id) {
UserPropertiesV4 properties = getProperties(user);
if (!properties.isRememberPreferencesEnabled())
_log.warn("Attempt to delete bookmark for stateless user. They shouldn't have bookmarks in the first place. User=" + user.getId());
boolean modified = false;
for (Iterator<Bookmark> it = properties.getBookmarks().iterator(); it.hasNext(); ) {
Bookmark bookmark = it.next();
if (bookmark.getId() == id) {
it.remove();
modified = true;
}
}
if (modified)
_userDao.saveOrUpdateUser(user);
}
use of org.onebusaway.users.model.properties.UserPropertiesV4 in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV4Impl method addStopBookmark.
@Override
public int addStopBookmark(User user, String name, List<String> stopIds, RouteFilter filter) {
UserPropertiesV4 properties = getProperties(user);
if (!properties.isRememberPreferencesEnabled())
return -1;
int maxId = 0;
for (Bookmark bookmark : properties.getBookmarks()) maxId = Math.max(maxId, bookmark.getId() + 1);
Bookmark bookmark = new Bookmark(maxId, name, stopIds, filter);
properties.getBookmarks().add(bookmark);
_userDao.saveOrUpdateUser(user);
return bookmark.getId();
}
use of org.onebusaway.users.model.properties.UserPropertiesV4 in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV4Impl method setRememberUserPreferencesEnabled.
@Override
public void setRememberUserPreferencesEnabled(User user, boolean rememberPreferencesEnabled) {
UserPropertiesV4 properties = getProperties(user);
properties.setRememberPreferencesEnabled(rememberPreferencesEnabled);
if (!rememberPreferencesEnabled)
properties.clear();
_userDao.saveOrUpdateUser(user);
}
use of org.onebusaway.users.model.properties.UserPropertiesV4 in project onebusaway-application-modules by camsys.
the class UserPropertiesServiceV4Impl method updateStopBookmark.
@Override
public void updateStopBookmark(User user, int id, String name, List<String> stopIds, RouteFilter routeFilter) {
UserPropertiesV4 properties = getProperties(user);
if (!properties.isRememberPreferencesEnabled())
return;
List<Bookmark> bookmarks = properties.getBookmarks();
for (int index = 0; index < bookmarks.size(); index++) {
Bookmark bookmark = bookmarks.get(index);
if (bookmark.getId() == id) {
bookmark = new Bookmark(id, name, stopIds, routeFilter);
bookmarks.set(index, bookmark);
_userDao.saveOrUpdateUser(user);
return;
}
}
}
Aggregations