Search in sources :

Example 21 with NameBean

use of org.onebusaway.transit_data.model.NameBean 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 22 with NameBean

use of org.onebusaway.transit_data.model.NameBean in project onebusaway-application-modules by camsys.

the class RealtimeServiceV2Impl method getStopRouteDirection.

private StopRouteDirection getStopRouteDirection(StopBean stop, List<StopsForRouteBean> stopsForRouteList, Map<Filters, String> filters) {
    // Filter Values
    String upcomingScheduledServiceFilter = filters.get(Filters.UPCOMING_SCHEDULED_SERVICE);
    String directionIdFilter = filters.get(Filters.DIRECTION_REF);
    StopRouteDirection stopRouteDirection = new StopRouteDirection(stop);
    for (StopsForRouteBean stopsForRoute : stopsForRouteList) // Check to see which stop group the specified stop exists in (usually 2 stop groups)
    for (StopGroupingBean stopGrouping : stopsForRoute.getStopGroupings()) {
        for (StopGroupBean stopGroup : stopGrouping.getStopGroups()) {
            NameBean name = stopGroup.getName();
            String type = name.getType();
            String directionId = stopGroup.getId();
            RouteBean route = stopsForRoute.getRoute();
            // Destination and DirectionId Filter
            if (!type.equals("destination") || !SiriSupportV2.passFilter(directionId, directionIdFilter))
                continue;
            // filter out route directions that don't stop at this stop
            if (!stopGroup.getStopIds().contains(stop.getId()))
                continue;
            // filter hasUpcomingScheduledService
            Boolean hasUpcomingScheduledService = _transitDataService.stopHasUpcomingScheduledService((route.getAgency() != null ? route.getAgency().getId() : null), SystemTime.currentTimeMillis(), stop.getId(), stopsForRoute.getRoute().getId(), directionId);
            String hasUpcomingScheduledServiceVal = String.valueOf(hasUpcomingScheduledService);
            if (!hasUpcomingScheduledServiceVal.trim().equals("false")) {
                hasUpcomingScheduledServiceVal = "true";
            }
            if (!SiriSupportV2.passFilter(hasUpcomingScheduledServiceVal, upcomingScheduledServiceFilter))
                continue;
            stopRouteDirection.addRouteDirection(new RouteForDirection(route.getId(), directionId, hasUpcomingScheduledService));
        }
    }
    return stopRouteDirection;
}
Also used : RouteBean(org.onebusaway.transit_data.model.RouteBean) StopsForRouteBean(org.onebusaway.transit_data.model.StopsForRouteBean) StopRouteDirection(org.onebusaway.api.actions.siri.model.StopRouteDirection) StopGroupingBean(org.onebusaway.transit_data.model.StopGroupingBean) StopGroupBean(org.onebusaway.transit_data.model.StopGroupBean) StopsForRouteBean(org.onebusaway.transit_data.model.StopsForRouteBean) RouteForDirection(org.onebusaway.api.actions.siri.model.RouteForDirection) NameBean(org.onebusaway.transit_data.model.NameBean)

Example 23 with NameBean

use of org.onebusaway.transit_data.model.NameBean 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 24 with NameBean

use of org.onebusaway.transit_data.model.NameBean 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)

Example 25 with NameBean

use of org.onebusaway.transit_data.model.NameBean in project onebusaway-application-modules by camsys.

the class RouteBeanServiceImpl method getStopsForRouteCollectionAndNarrative.

private StopsForRouteBean getStopsForRouteCollectionAndNarrative(RouteCollectionEntry routeCollection, RouteCollectionNarrative narrative) {
    StopsForRouteBean result = new StopsForRouteBean();
    AgencyAndId routeCollectionId = routeCollection.getId();
    result.setRoute(getRouteBeanForRouteCollection(routeCollectionId, narrative));
    result.setStops(getStopBeansForRoute(routeCollectionId));
    result.setPolylines(getEncodedPolylinesForRoute(routeCollection));
    StopGroupingBean directionGrouping = new StopGroupingBean();
    directionGrouping.setType(TransitDataConstants.STOP_GROUPING_TYPE_DIRECTION);
    List<StopGroupBean> directionGroups = new ArrayList<StopGroupBean>();
    directionGrouping.setStopGroups(directionGroups);
    directionGrouping.setOrdered(true);
    result.addGrouping(directionGrouping);
    List<BlockTripIndex> blockIndices = _blockIndexService.getBlockTripIndicesForRouteCollectionId(routeCollectionId);
    List<FrequencyBlockTripIndex> frequencyBlockIndices = _blockIndexService.getFrequencyBlockTripIndicesForRouteCollectionId(routeCollectionId);
    List<BlockTripEntry> blockTrips = new ArrayList<BlockTripEntry>();
    getBlockTripsForIndicesMatchingRouteCollection(blockIndices, routeCollectionId, blockTrips);
    getBlockTripsForIndicesMatchingRouteCollection(frequencyBlockIndices, routeCollectionId, blockTrips);
    List<StopSequence> sequences = _stopSequencesService.getStopSequencesForTrips(blockTrips);
    List<StopSequenceCollection> blocks = _stopSequenceBlocksService.getStopSequencesAsCollections(sequences);
    for (StopSequenceCollection block : blocks) {
        NameBean name = new NameBean(NameBeanTypes.DESTINATION, block.getDescription());
        List<StopEntry> stops = getStopsInOrder(block);
        List<String> groupStopIds = new ArrayList<String>();
        for (StopEntry stop : stops) groupStopIds.add(ApplicationBeanLibrary.getId(stop.getId()));
        Set<AgencyAndId> shapeIds = getShapeIdsForStopSequenceBlock(block);
        List<EncodedPolylineBean> polylines = _shapeBeanService.getMergedPolylinesForShapeIds(shapeIds);
        StopGroupBean group = new StopGroupBean();
        group.setId(block.getPublicId());
        group.setName(name);
        group.setStopIds(groupStopIds);
        group.setPolylines(polylines);
        directionGroups.add(group);
    }
    sortResult(result);
    return result;
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) StopGroupBean(org.onebusaway.transit_data.model.StopGroupBean) ArrayList(java.util.ArrayList) StopsForRouteBean(org.onebusaway.transit_data.model.StopsForRouteBean) StopSequence(org.onebusaway.transit_data_federation.model.StopSequence) FrequencyBlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndex) StopGroupingBean(org.onebusaway.transit_data.model.StopGroupingBean) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) NameBean(org.onebusaway.transit_data.model.NameBean) EncodedPolylineBean(org.onebusaway.geospatial.model.EncodedPolylineBean) BlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.BlockTripIndex) FrequencyBlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.FrequencyBlockTripIndex) AbstractBlockTripIndex(org.onebusaway.transit_data_federation.services.blocks.AbstractBlockTripIndex) StopSequenceCollection(org.onebusaway.transit_data_federation.model.StopSequenceCollection)

Aggregations

NameBean (org.onebusaway.transit_data.model.NameBean)25 ArrayList (java.util.ArrayList)16 StopsForRouteBean (org.onebusaway.transit_data.model.StopsForRouteBean)16 StopGroupBean (org.onebusaway.transit_data.model.StopGroupBean)14 StopGroupingBean (org.onebusaway.transit_data.model.StopGroupingBean)14 StopBean (org.onebusaway.transit_data.model.StopBean)10 RouteBean (org.onebusaway.transit_data.model.RouteBean)7 EncodedPolylineBean (org.onebusaway.geospatial.model.EncodedPolylineBean)6 HashMap (java.util.HashMap)5 HashSet (java.util.HashSet)4 List (java.util.List)3 Matchers.anyString (org.mockito.Matchers.anyString)3 RouteDirection (org.onebusaway.enterprise.webapp.actions.api.model.RouteDirection)3 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)3 StopSelectionBean (org.onebusaway.presentation.model.StopSelectionBean)3 ValueStack (com.opensymphony.xwork2.util.ValueStack)2 IOException (java.io.IOException)2 Before (org.junit.Before)2 StopRouteDirection (org.onebusaway.api.actions.siri.model.StopRouteDirection)2 RouteAtStop (org.onebusaway.enterprise.webapp.actions.api.model.RouteAtStop)2