Package org.onebusaway.users.client.model

Examples of org.onebusaway.users.client.model.UserBean


  }

  @Override
  public String execute() throws ServiceException, BookmarkException {

    UserBean currentUser = _currentUserService.getCurrentUser();

    if (_arg != null && _arg.length() > 0) {

      if (_arg.startsWith("add")) {
       
        if( currentUser == null)
          return "noUser";
       
        List<String> lastSelectedStopIds = currentUser.getLastSelectedStopIds();
        if (!lastSelectedStopIds.isEmpty()) {
          String name = _bookmarkPresentationService.getNameForStopIds(lastSelectedStopIds);
          _currentUserService.addStopBookmark(name, lastSelectedStopIds,
              new RouteFilter());
        }
       
        logUserInteraction("bookmark","added","stopIds",lastSelectedStopIds);
       
        return "added";
      }

      if (_arg.startsWith("delete")) {
        int index = _arg.indexOf(' ');
        if (index == -1)
          return INPUT;
        int bookmarkIndex = Integer.parseInt(_arg.substring(index + 1).trim()) - 1;
        _currentUserService.deleteStopBookmarks(bookmarkIndex);
        return "deleted";
      }

      if (_arg.matches("\\d+")) {
        int index = Integer.parseInt(_arg) - 1;

        List<BookmarkBean> bookmarks = currentUser.getBookmarks();
        if (index < 0 || index >= bookmarks.size())
          return INPUT;

        BookmarkBean bookmark = bookmarks.get(index);
        _stopIds = bookmark.getStopIds();
        _routeFilter = bookmark.getRouteFilter().getRouteIds();
       
        logUserInteraction("stopIds",_stopIds,"routeIds",_routeFilter);

        return "arrivals-and-departures";
      }
    }

    _bookmarks = _bookmarkPresentationService.getBookmarksWithStops(currentUser.getBookmarks());
   
    logUserInteraction();

    return SUCCESS;
  }
View Full Code Here


  }

  @Override
  public UserBean getUserAsBean(User user) {

    UserBean bean = new UserBean();
    bean.setUserId(Integer.toString(user.getId()));

    UserRole anonymous = _authoritiesService.getAnonymousRole();
    boolean isAnonymous = user.getRoles().contains(anonymous);
    bean.setAnonymous(isAnonymous);

    UserRole admin = _authoritiesService.getAdministratorRole();
    boolean isAdmin = user.getRoles().contains(admin);
    bean.setAdmin(isAdmin);

    List<UserIndexBean> indices = new ArrayList<UserIndexBean>();
    bean.setIndices(indices);

    for (UserIndex index : user.getUserIndices()) {
      UserIndexKey key = index.getId();

      UserIndexBean indexBean = new UserIndexBean();
View Full Code Here

  }

  @Override
  public UserBean getAnonymousUser() {

    UserBean bean = new UserBean();
    bean.setUserId("-1");

    bean.setAnonymous(true);
    bean.setAdmin(false);

    _userPropertiesService.getAnonymousUserAsBean(bean);

    return bean;
  }
View Full Code Here

    if (userIndex == null) {
      return null;
    }

    User user = userIndex.getUser();
    UserBean bean = getUserAsBean(user);
    return bean.getMinApiRequestInterval();
  }
View Full Code Here

    final Object action = invocation.getAction();

    if (action instanceof CurrentUserAware) {
      CurrentUserAware currentUserAware = (CurrentUserAware) action;
      UserBean currentUser = _currentUserService.getCurrentUser();
      if( currentUser != null)
        currentUserAware.setCurrentUser(currentUser);
    }

    return invocation.invoke();
View Full Code Here

  }

  @Override
  public DefaultSearchLocation getDefaultSearchLocationForCurrentUser() {

    UserBean user = _currentUserService.getCurrentUser();

    if (user != null && user.hasDefaultLocation()) {
      return new DefaultSearchLocation(user.getDefaultLocationName(),
          user.getDefaultLocationLat(), user.getDefaultLocationLon(), false);
    }

    RequestAttributes attributes = RequestContextHolder.currentRequestAttributes();
    DefaultSearchLocation location = (DefaultSearchLocation) attributes.getAttribute(
        KEY_DEFAULT_SEARCH_LOCATION_FOR_SESSSION,
View Full Code Here

  @Override
  public void buildTemplate(ActionContext context) {

    ValueStack stack = context.getValueStack();
    UserBean user = (UserBean) stack.findValue("currentUser");
    if (user.getDefaultLocationName() != null) {
      addMessage(Messages.SETTINGS_YOUR_DEFAULT_SEARCH_LOCATION_IS_CURRENTLY);
      addText(_locationPronunciation.modify(user.getDefaultLocationName()));
    }
    addMessage(Messages.INDEX_ACTION_SET_DEFAULT_SEARCH_LOCATION);
    addAction("1", "/settings/askForDefaultSearchLocation");

    if (user != null) {
      if (user.isRememberPreferencesEnabled())
        addMessage(Messages.PREFERENCES_DO_NOT_REMEMBER);
      else
        addMessage(Messages.PREFERENCES_DO_REMEMBER);
      addAction("2", "/settings/setRememberPreferences", "enabled",
          !user.isRememberPreferencesEnabled());
    }

    addMessage(Messages.HOW_TO_GO_BACK);
    addAction("\\*", "/back");

View Full Code Here

  protected CoordinateBounds getServiceArea() {
    return _serviceAreaService.getServiceArea();
  }

  protected UserBean getCurrentUser() {
    UserBean user = _currentUserService.getCurrentUser();
    if (user == null)
      user = _currentUserService.getAnonymousUser();
    return user;
  }
View Full Code Here

    UserIndexKey key = new UserIndexKey(UserIndexTypes.API_KEY,
        _model.getApiKey());
    UserIndex userIndex = _userService.getUserIndexForId(key);
    if (userIndex == null)
      return INPUT;
    UserBean bean = _userService.getUserAsBean(userIndex.getUser());
    _model.setMinApiRequestInterval(bean.getMinApiRequestInterval());

    _apiKeys = _userService.getUserIndexKeyValuesForKeyType(UserIndexTypes.API_KEY);

    return SUCCESS;
  }
View Full Code Here

   * {@link WebappService} Interface
   **************************************************************************/

  @Override
  public UserBean getCurrentUser() {
    UserBean user = _currentUserService.getCurrentUser();
    if (user == null)
      user = _currentUserService.getAnonymousUser();
    return user;
  }
View Full Code Here

TOP

Related Classes of org.onebusaway.users.client.model.UserBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.