Search in sources :

Example 1 with StopSelectionBean

use of org.onebusaway.presentation.model.StopSelectionBean in project onebusaway-application-modules by camsys.

the class StopsForRouteAction method execute.

@Override
public String execute() throws Exception {
    /* Need to check this for testing from  the web */
    Integer navState = (Integer) sessionMap.get("navState");
    if (navState == null) {
        _log.debug("StopsForRouteAction:navState is null");
    } else {
        _log.debug("StopsForRouteAction:navState is NOT null, resetting to DISPLAY_DATA");
        navState = DISPLAY_DATA;
        sessionMap.put("navState", new Integer(navState));
    }
    _log.debug("in StopsForRoute with input: " + getInput() + " route.getId: " + _route.getId());
    clearInput();
    StopsForRouteBean stopsForRoute = _transitDataService.getStopsForRoute(_route.getId());
    List<Integer> selectionIndices = Collections.emptyList();
    StopSelectionBean selection = _stopSelectionService.getSelectedStops(stopsForRoute, selectionIndices);
    List<NameBean> names = new ArrayList<NameBean>(selection.getNames());
    _navigation = new NavigationBean();
    _navigation.setRoute(_route);
    _navigation.setStopsForRoute(stopsForRoute);
    _navigation.setSelectionIndices(selectionIndices);
    _navigation.setCurrentIndex(0);
    _navigation.setSelection(selection);
    _navigation.setNames(names);
    // Set navigation bean in session
    sessionMap.put("navigation", _navigation);
    if (selection.hasStop()) {
        _log.debug("in StopsForRoute with input=" + getInput());
        _stop = selection.getStop();
        return "stopFound";
    }
    return SUCCESS;
}
Also used : StopSelectionBean(org.onebusaway.presentation.model.StopSelectionBean) ArrayList(java.util.ArrayList) StopsForRouteBean(org.onebusaway.transit_data.model.StopsForRouteBean) NameBean(org.onebusaway.transit_data.model.NameBean)

Example 2 with StopSelectionBean

use of org.onebusaway.presentation.model.StopSelectionBean in project onebusaway-application-modules by camsys.

the class StopSelectionServiceImpl method getSelectedStops.

public StopSelectionBean getSelectedStops(StopsForRouteBean stopsForRoute, List<Integer> selectionIndices) throws InvalidSelectionServiceException {
    StopSelectionBean selection = new StopSelectionBean();
    StopSelectionTreeBean tree = getStopsForRouteAsStopSelectionTree(stopsForRoute);
    visitTree(tree, selection, selectionIndices, 0);
    return selection;
}
Also used : StopSelectionTreeBean(org.onebusaway.presentation.model.StopSelectionTreeBean) StopSelectionBean(org.onebusaway.presentation.model.StopSelectionBean)

Example 3 with StopSelectionBean

use of org.onebusaway.presentation.model.StopSelectionBean in project onebusaway-application-modules by camsys.

the class NavigateDownAction method execute.

@Override
public String execute() throws Exception {
    _index = (Integer) sessionMap.get("index");
    _log.debug("in NavigateDownAction with input: " + getInput() + ", index: " + _index);
    Integer navState = (Integer) sessionMap.get("navState");
    _log.debug("NavigateDownAction:navState: " + navState);
    _log.debug("NavigateDownAction:_index: " + _index);
    if (_navigation == null) {
        _log.debug("NavigateDownAction:navigation bean is null");
        _navigation = (NavigationBean) sessionMap.get("navigation");
        if (_navigation == null) {
            _log.debug("NavigateDownAction:navigation bean is still null after sessionMap.get()");
        }
    }
    // _navigation = new NavigationBean(_navigation);
    List<Integer> indices = new ArrayList<Integer>(_navigation.getSelectionIndices());
    indices.add(_index);
    StopSelectionBean selection = _stopSelectionService.getSelectedStops(_navigation.getStopsForRoute(), indices);
    List<NameBean> names = new ArrayList<NameBean>(selection.getNames());
    _navigation.setSelectionIndices(indices);
    _navigation.setCurrentIndex(0);
    _navigation.setSelection(selection);
    _navigation.setNames(names);
    if (selection.hasStop()) {
        _stop = selection.getStop();
        sessionMap.put("navState", new Integer(DISPLAY_DATA));
        return "stopFound";
    }
    // Get input
    sessionMap.put("navState", new Integer(DISPLAY_DATA));
    sessionMap.put("navigation", _navigation);
    return SUCCESS;
}
Also used : ArrayList(java.util.ArrayList) StopSelectionBean(org.onebusaway.presentation.model.StopSelectionBean) NameBean(org.onebusaway.transit_data.model.NameBean)

Example 4 with StopSelectionBean

use of org.onebusaway.presentation.model.StopSelectionBean in project onebusaway-application-modules by camsys.

the class NavigateDownAction method execute.

@Override
public String execute() throws Exception {
    _navigation = new NavigationBean(_navigation);
    List<Integer> indices = new ArrayList<Integer>(_navigation.getSelectionIndices());
    indices.add(_index);
    StopSelectionBean selection = _stopSelectionService.getSelectedStops(_navigation.getStopsForRoute(), indices);
    List<NameBean> names = new ArrayList<NameBean>(selection.getNames());
    _navigation.setSelectionIndices(indices);
    _navigation.setCurrentIndex(0);
    _navigation.setSelection(selection);
    _navigation.setNames(names);
    if (selection.hasStop()) {
        _stop = selection.getStop();
        return "stopFound";
    }
    return SUCCESS;
}
Also used : ArrayList(java.util.ArrayList) StopSelectionBean(org.onebusaway.presentation.model.StopSelectionBean) NameBean(org.onebusaway.transit_data.model.NameBean)

Example 5 with StopSelectionBean

use of org.onebusaway.presentation.model.StopSelectionBean in project onebusaway-application-modules by camsys.

the class StopsForRouteAction method execute.

@Override
public String execute() throws Exception {
    StopsForRouteBean stopsForRoute = _transitDataService.getStopsForRoute(_route.getId());
    List<Integer> selectionIndices = Collections.emptyList();
    StopSelectionBean selection = _stopSelectionService.getSelectedStops(stopsForRoute, selectionIndices);
    List<NameBean> names = new ArrayList<NameBean>(selection.getNames());
    _navigation = new NavigationBean();
    _navigation.setRoute(_route);
    _navigation.setStopsForRoute(stopsForRoute);
    _navigation.setSelectionIndices(selectionIndices);
    _navigation.setCurrentIndex(0);
    _navigation.setSelection(selection);
    _navigation.setNames(names);
    if (selection.hasStop()) {
        _stop = selection.getStop();
        return "stopFound";
    }
    return SUCCESS;
}
Also used : StopSelectionBean(org.onebusaway.presentation.model.StopSelectionBean) ArrayList(java.util.ArrayList) StopsForRouteBean(org.onebusaway.transit_data.model.StopsForRouteBean) NameBean(org.onebusaway.transit_data.model.NameBean)

Aggregations

StopSelectionBean (org.onebusaway.presentation.model.StopSelectionBean)5 ArrayList (java.util.ArrayList)4 NameBean (org.onebusaway.transit_data.model.NameBean)4 StopsForRouteBean (org.onebusaway.transit_data.model.StopsForRouteBean)2 StopSelectionTreeBean (org.onebusaway.presentation.model.StopSelectionTreeBean)1