@Override public void updatePreferences(String userToken, Long itemId, float score) { User user = userDAO.findByToken(userToken); if (user != null) { Preference preference = preferenceDAO.findForUserByItemId(user.getId(), itemId); if (preference != null) { preference.setScore(score); preferenceDAO.store(preference); } } }
@Override public void updateLocation(String userToken, double latitude, double longitude, Date time) { Location location = new Location(latitude, longitude, time); // TODO: side effect, move it to a separate method User user = userDAO.findByToken(userToken); if (user == null) { user = new User(userToken, location); } user.setLocation(location); userDAO.store(user); }
@Override public User findUser(String userToken) { return userDAO.findByToken(userToken); }