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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations