use of org.onebusaway.transit_data.model.service_alerts.SituationQueryBean in project onebusaway-application-modules by camsys.
the class ArrivalsAndDeparturesAction method getServiceAlertsForStopRoute.
private List<ServiceAlertBean> getServiceAlertsForStopRoute(String stopId, String routeId) {
SituationQueryBean query = new SituationQueryBean();
SituationQueryBean.AffectsBean affects = new SituationQueryBean.AffectsBean();
query.getAffects().add(affects);
affects.setStopId(stopId);
affects.setRouteId(routeId);
ListBean<ServiceAlertBean> alerts = _transitDataService.getServiceAlerts(query);
if (alerts != null) {
return alerts.getList();
}
return Collections.emptyList();
}
use of org.onebusaway.transit_data.model.service_alerts.SituationQueryBean in project onebusaway-application-modules by camsys.
the class ArrivalsAndDeparturesAction method getServiceAlertsForStop.
private List<ServiceAlertBean> getServiceAlertsForStop(String stopId) {
SituationQueryBean query = new SituationQueryBean();
SituationQueryBean.AffectsBean affects = new SituationQueryBean.AffectsBean();
query.getAffects().add(affects);
affects.setStopId(stopId);
ListBean<ServiceAlertBean> alerts = _transitDataService.getServiceAlerts(query);
if (alerts != null) {
return alerts.getList();
}
return Collections.emptyList();
}
use of org.onebusaway.transit_data.model.service_alerts.SituationQueryBean in project onebusaway-application-modules by camsys.
the class RealtimeServiceV2Impl method getServiceAlertsGlobal.
/**
* Returns true if there are vehicles in service for given route+direction
* that will stop at the indicated stop in the future.
*/
/* These methods were used in nyc branch. Not used here so far.
@Override
public boolean getVehiclesInServiceForStopAndRoute(String stopId,
String routeId, long currentTime) {
for (ArrivalAndDepartureBean adBean : getArrivalsAndDeparturesForStop(
stopId, currentTime)) {
TripStatusBean statusBean = adBean.getTripStatus();
if (!_presentationService.include(statusBean)
|| !_presentationService.include(adBean, statusBean))
continue;
// filtered out by user
if (routeId != null
&& !adBean.getTrip().getRoute().getId().equals(routeId))
continue;
return true;
}
return false;
}
*/
/**
* SERVICE ALERTS METHODS
*/
/*
@Override
public List<ServiceAlertBean> getServiceAlertsForRoute(String routeId) {
return getServiceAlertsForRouteAndDirection(routeId, null);
}
@Override
public List<ServiceAlertBean> getServiceAlertsForRouteAndDirection(
String routeId, String directionId) {
SituationQueryBean query = new SituationQueryBean();
SituationQueryBean.AffectsBean affects = new SituationQueryBean.AffectsBean();
query.getAffects().add(affects);
affects.setRouteId(routeId);
if (directionId != null) {
affects.setDirectionId(directionId);
} else {
*/
/*
* TODO The route index is not currently being populated correctly;
* query by route and direction, and supply both directions if not
* present
*/
/*
SituationQueryBean.AffectsBean affects1 = new SituationQueryBean.AffectsBean();
query.getAffects().add(affects1);
affects1.setRouteId(routeId);
affects1.setDirectionId("0");
SituationQueryBean.AffectsBean affects2 = new SituationQueryBean.AffectsBean();
query.getAffects().add(affects2);
affects2.setRouteId(routeId);
affects2.setDirectionId("1");
}
ListBean<ServiceAlertBean> serviceAlerts = _nycTransitDataService
.getServiceAlerts(query);
return serviceAlerts.getList();
}
*/
@Override
public List<ServiceAlertBean> getServiceAlertsGlobal() {
SituationQueryBean query = new SituationQueryBean();
SituationQueryBean.AffectsBean affects = new SituationQueryBean.AffectsBean();
affects.setAgencyId("__ALL_OPERATORS__");
query.getAffects().add(affects);
ListBean<ServiceAlertBean> serviceAlerts = _transitDataService.getServiceAlerts(query);
return serviceAlerts.getList();
}
use of org.onebusaway.transit_data.model.service_alerts.SituationQueryBean in project onebusaway-application-modules by camsys.
the class ServiceAlertsHelperV2 method handleStopGroupBean.
private void handleStopGroupBean(String stopIdString, SituationQueryBean query, RouteBean route, StopGroupBean stopGroup) {
List<StopGroupBean> subGroups = stopGroup.getSubGroups();
if (subGroups != null && !subGroups.isEmpty()) {
for (StopGroupBean stopSubGroup : subGroups) {
handleStopGroupBean(stopIdString, query, route, stopSubGroup);
}
}
String direction = stopGroup.getId();
for (String groupStopId : stopGroup.getStopIds()) {
if (groupStopId.equals(stopIdString)) {
SituationQueryBean.AffectsBean affects = new SituationQueryBean.AffectsBean();
query.getAffects().add(affects);
affects.setRouteId(route.getId());
affects.setDirectionId(direction);
}
}
}
use of org.onebusaway.transit_data.model.service_alerts.SituationQueryBean in project onebusaway-application-modules by camsys.
the class ServiceAlertsHelperV2 method addSituationExchangeToSiriForStops.
public void addSituationExchangeToSiriForStops(ServiceDelivery serviceDelivery, List<MonitoredStopVisitStructure> visits, TransitDataService transitDataService, List<AgencyAndId> stopIds) {
Map<String, PtSituationElementStructure> ptSituationElements = new HashMap<String, PtSituationElementStructure>();
for (MonitoredStopVisitStructure visit : visits) {
if (visit.getMonitoredVehicleJourney() != null)
addSituationElement(transitDataService, ptSituationElements, visit.getMonitoredVehicleJourney().getSituationRef());
}
if (stopIds != null && stopIds.size() > 0) {
for (AgencyAndId stopId : stopIds) {
String stopIdString = stopId.toString();
// First get service alerts for the stop
SituationQueryBean query = new SituationQueryBean();
List<String> stopIdStrings = new ArrayList<String>();
stopIdStrings.add(stopIdString);
SituationQueryBean.AffectsBean affects = new SituationQueryBean.AffectsBean();
query.getAffects().add(affects);
affects.setStopId(stopIdString);
addFromQuery(transitDataService, ptSituationElements, query);
// Now also add service alerts for (route+direction)s of the stop
query = new SituationQueryBean();
StopBean stopBean = transitDataService.getStop(stopIdString);
List<RouteBean> routes = stopBean.getRoutes();
for (RouteBean route : routes) {
StopsForRouteBean stopsForRoute = transitDataService.getStopsForRoute(route.getId());
List<StopGroupingBean> stopGroupings = stopsForRoute.getStopGroupings();
for (StopGroupingBean stopGrouping : stopGroupings) {
if (!stopGrouping.getType().equalsIgnoreCase("direction"))
continue;
for (StopGroupBean stopGroup : stopGrouping.getStopGroups()) {
handleStopGroupBean(stopIdString, query, route, stopGroup);
}
}
}
addFromQuery(transitDataService, ptSituationElements, query);
}
}
addPtSituationElementsToServiceDelivery(serviceDelivery, ptSituationElements);
}
Aggregations