use of org.onebusaway.rss.model.ServiceAlertRssBean in project onebusaway-application-modules by camsys.
the class AlertsAction method setServiceAlerts.
private void setServiceAlerts(AgencyWithCoverageBean agency, List<ServiceAlertRssBean> beans, String baseUrl) {
ListBean<ServiceAlertBean> allServiceAlertsForAgencyId = _transitDataService.getAllServiceAlertsForAgencyId(agency.getAgency().getId());
if (allServiceAlertsForAgencyId == null) {
_log.info("no service alerts returned for agency " + agency.getAgency().getId());
return;
}
long time = System.currentTimeMillis();
for (ServiceAlertBean sab : allServiceAlertsForAgencyId.getList()) {
if (!containsActiveAlert(sab, time)) {
continue;
}
ServiceAlertRssBean bean = new ServiceAlertRssBean();
bean.setId(sab.getId());
bean.setReason(sab.getReason());
if (sab.getSeverity() != null) {
bean.setSeverity(sab.getSeverity().getTpegCodes()[0]);
}
bean.setSummary(ServiceAlertRssBean.getLocalString(sab.getSummaries()));
bean.setDescription(ServiceAlertRssBean.getLocalString(sab.getDescriptions()));
bean.setPublicationWindows(toTimeRange(sab.getPublicationWindows()));
bean.setAffectsClauses(toAffectClause(sab.getAllAffects()));
beans.add(bean);
}
}
use of org.onebusaway.rss.model.ServiceAlertRssBean in project onebusaway-application-modules by camsys.
the class AlertsAction method execute.
@Override
public String execute() {
try {
_feed = new SyndFeedImpl();
List<ServiceAlertRssBean> beans = new ArrayList<>();
String baseUrl = createBaseUrl(ServletActionContext.getRequest());
setServiceAlerts(beans, baseUrl);
for (Object objBean : beans) {
ServiceAlertRssBean rssBean = (ServiceAlertRssBean) objBean;
_feed.getModules().add(rssBean);
}
_feed.setTitle("OneBusAway Service Alerts");
_feed.setLink("");
_feed.setDescription("Service Information - Service Alerts");
return SUCCESS;
} catch (Throwable t) {
_log.error("Exception in execute: ", t);
return ERROR;
}
}
Aggregations