Search in sources :

Example 1 with BookmarkBean

use of org.onebusaway.users.client.model.BookmarkBean in project onebusaway-application-modules by camsys.

the class UserPropertiesServiceV2Impl method getUserAsBean.

@Override
public UserBean getUserAsBean(User user, UserBean bean) {
    UserPropertiesV2 properties = getProperties(user);
    bean.setRememberPreferencesEnabled(properties.isRememberPreferencesEnabled());
    bean.setHasDefaultLocation(properties.hasDefaultLocationLat() && properties.hasDefaultLocationLon());
    bean.setDefaultLocationName(properties.getDefaultLocationName());
    bean.setDefaultLocationLat(properties.getDefaultLocationLat());
    bean.setDefaultLocationLon(properties.getDefaultLocationLon());
    List<String> stopIds = _lastSelectedStopService.getLastSelectedStopsForUser(user.getId());
    bean.setLastSelectedStopIds(stopIds);
    for (Bookmark bookmark : properties.getBookmarks()) {
        BookmarkBean bookmarkBean = new BookmarkBean();
        bookmarkBean.setId(bookmark.getId());
        bookmarkBean.setName(bookmark.getName());
        bookmarkBean.setStopIds(bookmark.getStopIds());
        bookmarkBean.setRouteFilter(getRouteFilterAsBean(bookmark.getRouteFilter()));
        bean.addBookmark(bookmarkBean);
    }
    bean.setMinApiRequestInterval(properties.getMinApiRequestInterval());
    Map<String, Long> readServiceAlerts = properties.getReadSituationIdsWithReadTime();
    if (readServiceAlerts == null)
        readServiceAlerts = Collections.emptyMap();
    bean.setReadServiceAlerts(readServiceAlerts);
    return bean;
}
Also used : Bookmark(org.onebusaway.users.model.properties.Bookmark) BookmarkBean(org.onebusaway.users.client.model.BookmarkBean) UserPropertiesV2(org.onebusaway.users.model.properties.UserPropertiesV2)

Example 2 with BookmarkBean

use of org.onebusaway.users.client.model.BookmarkBean in project onebusaway-application-modules by camsys.

the class UserPropertiesServiceV3Impl method getUserAsBean.

@Override
public UserBean getUserAsBean(User user, UserBean bean) {
    UserPropertiesV3 properties = getProperties(user);
    bean.setRememberPreferencesEnabled(properties.isRememberPreferencesEnabled());
    bean.setHasDefaultLocation(properties.hasDefaultLocationLat() && properties.hasDefaultLocationLon());
    bean.setDefaultLocationName(properties.getDefaultLocationName());
    bean.setDefaultLocationLat(properties.getDefaultLocationLat());
    bean.setDefaultLocationLon(properties.getDefaultLocationLon());
    bean.setContactName(properties.getContactName());
    bean.setContactCompany(properties.getContactCompany());
    bean.setContactEmail(properties.getContactEmail());
    bean.setContactDetails(properties.getContactDetails());
    List<String> stopIds = _lastSelectedStopService.getLastSelectedStopsForUser(user.getId());
    bean.setLastSelectedStopIds(stopIds);
    for (Bookmark bookmark : properties.getBookmarks()) {
        BookmarkBean bookmarkBean = new BookmarkBean();
        bookmarkBean.setId(bookmark.getId());
        bookmarkBean.setName(bookmark.getName());
        bookmarkBean.setStopIds(bookmark.getStopIds());
        bookmarkBean.setRouteFilter(getRouteFilterAsBean(bookmark.getRouteFilter()));
        bean.addBookmark(bookmarkBean);
    }
    bean.setMinApiRequestInterval(properties.getMinApiRequestInterval());
    Map<String, Long> readServiceAlerts = properties.getReadSituationIdsWithReadTime();
    if (readServiceAlerts == null)
        readServiceAlerts = Collections.emptyMap();
    bean.setReadServiceAlerts(readServiceAlerts);
    return bean;
}
Also used : Bookmark(org.onebusaway.users.model.properties.Bookmark) BookmarkBean(org.onebusaway.users.client.model.BookmarkBean) UserPropertiesV3(org.onebusaway.users.model.properties.UserPropertiesV3)

Example 3 with BookmarkBean

use of org.onebusaway.users.client.model.BookmarkBean in project onebusaway-application-modules by camsys.

the class BookmarkPresentationServiceImpl method getBookmarksWithStops.

@Override
public List<BookmarkWithStopsBean> getBookmarksWithStops(List<BookmarkBean> bookmarks) {
    List<BookmarkWithStopsBean> beans = new ArrayList<BookmarkWithStopsBean>(bookmarks.size());
    for (BookmarkBean bookmark : bookmarks) {
        BookmarkWithStopsBean bean = new BookmarkWithStopsBean();
        bean.setId(bookmark.getId());
        bean.setName(bookmark.getName());
        bean.setStops(getStopsForStopIds(bookmark.getStopIds()));
        bean.setRoutes(getRoutesForRouteFilter(bookmark.getRouteFilter()));
        beans.add(bean);
    }
    return beans;
}
Also used : BookmarkWithStopsBean(org.onebusaway.presentation.model.BookmarkWithStopsBean) BookmarkBean(org.onebusaway.users.client.model.BookmarkBean) ArrayList(java.util.ArrayList)

Example 4 with BookmarkBean

use of org.onebusaway.users.client.model.BookmarkBean in project onebusaway-application-modules by camsys.

the class CommandBookmarksAction method execute.

@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());
            }
            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();
            return "arrivals-and-departures";
        }
    }
    _bookmarks = _bookmarkPresentationService.getBookmarksWithStops(currentUser.getBookmarks());
    return SUCCESS;
}
Also used : UserBean(org.onebusaway.users.client.model.UserBean) BookmarkBean(org.onebusaway.users.client.model.BookmarkBean) RouteFilter(org.onebusaway.users.model.properties.RouteFilter)

Example 5 with BookmarkBean

use of org.onebusaway.users.client.model.BookmarkBean in project onebusaway-application-modules by camsys.

the class UserPropertiesServiceV1Impl method getUserAsBean.

@Override
public UserBean getUserAsBean(User user, UserBean bean) {
    UserPropertiesV1 properties = getProperties(user);
    bean.setRememberPreferencesEnabled(properties.isRememberPreferencesEnabled());
    bean.setHasDefaultLocation(properties.hasDefaultLocationLat() && properties.hasDefaultLocationLon());
    bean.setDefaultLocationName(properties.getDefaultLocationName());
    bean.setDefaultLocationLat(properties.getDefaultLocationLat());
    bean.setDefaultLocationLon(properties.getDefaultLocationLon());
    if (properties.getLastSelectedStopId() != null)
        bean.setLastSelectedStopIds(Arrays.asList(properties.getLastSelectedStopId()));
    int bookmarkIndex = 0;
    for (String stopId : properties.getBookmarkedStopIds()) {
        BookmarkBean bookmark = new BookmarkBean();
        bookmark.setId(bookmarkIndex++);
        bookmark.setStopIds(Arrays.asList(stopId));
        bean.addBookmark(bookmark);
    }
    return bean;
}
Also used : BookmarkBean(org.onebusaway.users.client.model.BookmarkBean) UserPropertiesV1(org.onebusaway.users.model.UserPropertiesV1)

Aggregations

BookmarkBean (org.onebusaway.users.client.model.BookmarkBean)6 Bookmark (org.onebusaway.users.model.properties.Bookmark)3 ArrayList (java.util.ArrayList)1 BookmarkWithStopsBean (org.onebusaway.presentation.model.BookmarkWithStopsBean)1 UserBean (org.onebusaway.users.client.model.UserBean)1 UserPropertiesV1 (org.onebusaway.users.model.UserPropertiesV1)1 RouteFilter (org.onebusaway.users.model.properties.RouteFilter)1 UserPropertiesV2 (org.onebusaway.users.model.properties.UserPropertiesV2)1 UserPropertiesV3 (org.onebusaway.users.model.properties.UserPropertiesV3)1 UserPropertiesV4 (org.onebusaway.users.model.properties.UserPropertiesV4)1