Search in sources :

Example 11 with SituationQueryBean

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();
}
Also used : SituationQueryBean(org.onebusaway.transit_data.model.service_alerts.SituationQueryBean) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 12 with SituationQueryBean

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();
}
Also used : SituationQueryBean(org.onebusaway.transit_data.model.service_alerts.SituationQueryBean) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 13 with SituationQueryBean

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();
}
Also used : SituationQueryBean(org.onebusaway.transit_data.model.service_alerts.SituationQueryBean) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 14 with SituationQueryBean

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);
        }
    }
}
Also used : SituationAffectsBean(org.onebusaway.transit_data.model.service_alerts.SituationAffectsBean) SituationQueryBean(org.onebusaway.transit_data.model.service_alerts.SituationQueryBean) StopGroupBean(org.onebusaway.transit_data.model.StopGroupBean)

Example 15 with SituationQueryBean

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);
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) HashMap(java.util.HashMap) StopGroupBean(org.onebusaway.transit_data.model.StopGroupBean) ArrayList(java.util.ArrayList) PtSituationElementStructure(uk.org.siri.siri_2.PtSituationElementStructure) StopsForRouteBean(org.onebusaway.transit_data.model.StopsForRouteBean) MonitoredStopVisitStructure(uk.org.siri.siri_2.MonitoredStopVisitStructure) SituationAffectsBean(org.onebusaway.transit_data.model.service_alerts.SituationAffectsBean) RouteBean(org.onebusaway.transit_data.model.RouteBean) StopsForRouteBean(org.onebusaway.transit_data.model.StopsForRouteBean) StopGroupingBean(org.onebusaway.transit_data.model.StopGroupingBean) SituationQueryBean(org.onebusaway.transit_data.model.service_alerts.SituationQueryBean) StopBean(org.onebusaway.transit_data.model.StopBean)

Aggregations

SituationQueryBean (org.onebusaway.transit_data.model.service_alerts.SituationQueryBean)16 ServiceAlertBean (org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)10 SituationAffectsBean (org.onebusaway.transit_data.model.service_alerts.SituationAffectsBean)6 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)5 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 StopGroupBean (org.onebusaway.transit_data.model.StopGroupBean)4 RouteBean (org.onebusaway.transit_data.model.RouteBean)2 StopBean (org.onebusaway.transit_data.model.StopBean)2 StopGroupingBean (org.onebusaway.transit_data.model.StopGroupingBean)2 StopsForRouteBean (org.onebusaway.transit_data.model.StopsForRouteBean)2 PtSituationElementStructure (uk.org.siri.siri.PtSituationElementStructure)2 PtSituationElementStructure (uk.org.siri.siri_2.PtSituationElementStructure)2 StatusGroup (org.onebusaway.enterprise.webapp.actions.status.model.StatusGroup)1 StatusItem (org.onebusaway.enterprise.webapp.actions.status.model.StatusItem)1 AgencyWithCoverageBean (org.onebusaway.transit_data.model.AgencyWithCoverageBean)1 AffectsBean (org.onebusaway.transit_data.model.service_alerts.SituationQueryBean.AffectsBean)1 MonitoredStopVisitStructure (uk.org.siri.siri.MonitoredStopVisitStructure)1 VehicleActivityStructure (uk.org.siri.siri.VehicleActivityStructure)1 MonitoredStopVisitStructure (uk.org.siri.siri_2.MonitoredStopVisitStructure)1