Search in sources :

Example 1 with AffectsBean

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

Aggregations

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 ServiceAlertBean (org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)1 SituationQueryBean (org.onebusaway.transit_data.model.service_alerts.SituationQueryBean)1 AffectsBean (org.onebusaway.transit_data.model.service_alerts.SituationQueryBean.AffectsBean)1