Search in sources :

Example 1 with SituationQueryBean

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

the class MessagesAction method getAllSituations.

private ListBean<ServiceAlertBean> getAllSituations(String agencyId, String routeId) {
    SituationQueryBean query = new SituationQueryBean();
    SituationQueryBean.AffectsBean affects = new SituationQueryBean.AffectsBean();
    query.getAffects().add(affects);
    affects.setRouteId(routeId);
    return _transitDataService.getServiceAlerts(query);
}
Also used : SituationQueryBean(org.onebusaway.transit_data.model.service_alerts.SituationQueryBean)

Example 2 with SituationQueryBean

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

the class ServiceAlertsHelperV2 method addSituationExchangeToServiceDelivery.

/*
  public void addSituationExchangeToServiceDelivery(ServiceDelivery serviceDelivery,
      List<VehicleActivityStructure> activities,
      TransitDataService transitDataService) {
    
    addSituationExchangeToServiceDelivery(serviceDelivery, activities, transitDataService, null);
  }
  */
public void addSituationExchangeToServiceDelivery(ServiceDelivery serviceDelivery, List<VehicleActivityStructure> activities, TransitDataService transitDataService, List<AgencyAndId> routeIds) {
    if (activities == null)
        return;
    Map<String, PtSituationElementStructure> ptSituationElements = new HashMap<String, PtSituationElementStructure>();
    for (VehicleActivityStructure activity : activities) {
        if (activity.getMonitoredVehicleJourney() != null) {
            addSituationElement(transitDataService, ptSituationElements, activity.getMonitoredVehicleJourney().getSituationRef());
        }
    }
    addPtSituationElementsToServiceDelivery(serviceDelivery, ptSituationElements);
    if (routeIds == null)
        return;
    List<ServiceAlertBean> serviceAlerts = new ArrayList<ServiceAlertBean>();
    for (AgencyAndId routeId : routeIds) {
        SituationQueryBean query = new SituationQueryBean();
        SituationQueryBean.AffectsBean affects = new SituationQueryBean.AffectsBean();
        query.getAffects().add(affects);
        affects.setRouteId(routeId.toString());
        ListBean<ServiceAlertBean> serviceAlertsForRoute = transitDataService.getServiceAlerts(query);
        if (serviceAlertsForRoute != null) {
            serviceAlerts.addAll(serviceAlertsForRoute.getList());
        }
    }
    if (serviceAlerts.size() == 0)
        return;
    addSituationExchangeToServiceDelivery(serviceDelivery, serviceAlerts);
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PtSituationElementStructure(uk.org.siri.siri_2.PtSituationElementStructure) SituationAffectsBean(org.onebusaway.transit_data.model.service_alerts.SituationAffectsBean) SituationQueryBean(org.onebusaway.transit_data.model.service_alerts.SituationQueryBean) VehicleActivityStructure(uk.org.siri.siri_2.VehicleActivityStructure) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 3 with SituationQueryBean

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

the class ArrivalsAndDeparturesAction method getServiceAlertsForRoute.

private List<ServiceAlertBean> getServiceAlertsForRoute(String routeId) {
    SituationQueryBean query = new SituationQueryBean();
    SituationQueryBean.AffectsBean affects = new SituationQueryBean.AffectsBean();
    query.getAffects().add(affects);
    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 4 with SituationQueryBean

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

the class StatusProviderImpl method getAgencyServiceAlertStatus.

@Override
public StatusGroup getAgencyServiceAlertStatus() {
    StatusGroup group = new StatusGroup();
    group.setTitle("Agency Advisories");
    group.setScope("Schedule and real-time availability at the agency level");
    group.setSource("Sound Transit administrators -- manual entry");
    List<AgencyWithCoverageBean> agencies = _transitDataService.getAgenciesWithCoverage();
    for (AgencyWithCoverageBean agency : agencies) {
        String agencyId = agency.getAgency().getId();
        String agencyName = agency.getAgency().getName();
        // Use query to limit to agency and no other parameters
        SituationQueryBean query = new SituationQueryBean();
        AffectsBean ab = new AffectsBean();
        ab.setAgencyId(agencyId);
        query.setAffects(Collections.singletonList(ab));
        ListBean<ServiceAlertBean> alerts = _transitDataService.getServiceAlerts(query);
        List<ServiceAlertBean> beans = filterByTime(alerts.getList(), System.currentTimeMillis());
        for (ServiceAlertBean bean : beans) {
            StatusItem item = new StatusItem();
            item.setDescription(bean.getDescriptions().get(0).getValue());
            item.setTitle(agencyName + ": " + bean.getSummaries().get(0).getValue());
            item.setStatus(StatusItem.Status.ALERT);
            group.addItem(item);
        }
    }
    return group;
}
Also used : AffectsBean(org.onebusaway.transit_data.model.service_alerts.SituationQueryBean.AffectsBean) StatusItem(org.onebusaway.enterprise.webapp.actions.status.model.StatusItem) StatusGroup(org.onebusaway.enterprise.webapp.actions.status.model.StatusGroup) SituationQueryBean(org.onebusaway.transit_data.model.service_alerts.SituationQueryBean) AgencyWithCoverageBean(org.onebusaway.transit_data.model.AgencyWithCoverageBean) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

Example 5 with SituationQueryBean

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

the class ServiceAlertsHelper method addSituationExchangeToServiceDelivery.

public void addSituationExchangeToServiceDelivery(ServiceDelivery serviceDelivery, List<VehicleActivityStructure> activities, TransitDataService transitDataService, List<AgencyAndId> routeIds) {
    if (activities == null)
        return;
    Map<String, PtSituationElementStructure> ptSituationElements = new HashMap<String, PtSituationElementStructure>();
    for (VehicleActivityStructure activity : activities) {
        if (activity.getMonitoredVehicleJourney() != null) {
            addSituationElement(transitDataService, ptSituationElements, activity.getMonitoredVehicleJourney().getSituationRef());
        }
    }
    addPtSituationElementsToServiceDelivery(serviceDelivery, ptSituationElements);
    if (routeIds == null)
        return;
    List<ServiceAlertBean> serviceAlerts = new ArrayList<ServiceAlertBean>();
    for (AgencyAndId routeId : routeIds) {
        SituationQueryBean query = new SituationQueryBean();
        SituationQueryBean.AffectsBean affects = new SituationQueryBean.AffectsBean();
        query.getAffects().add(affects);
        affects.setRouteId(routeId.toString());
        ListBean<ServiceAlertBean> serviceAlertsForRoute = transitDataService.getServiceAlerts(query);
        if (serviceAlertsForRoute != null) {
            serviceAlerts.addAll(serviceAlertsForRoute.getList());
        }
    }
    if (serviceAlerts.size() == 0)
        return;
    addSituationExchangeToServiceDelivery(serviceDelivery, serviceAlerts);
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) PtSituationElementStructure(uk.org.siri.siri.PtSituationElementStructure) SituationAffectsBean(org.onebusaway.transit_data.model.service_alerts.SituationAffectsBean) SituationQueryBean(org.onebusaway.transit_data.model.service_alerts.SituationQueryBean) VehicleActivityStructure(uk.org.siri.siri.VehicleActivityStructure) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)

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