use of org.onebusaway.transit_data.model.AgencyWithCoverageBean in project onebusaway-application-modules by camsys.
the class AgencyListAction method getModel.
@Override
public Body<Agency> getModel() {
Body<Agency> body = new Body<Agency>();
try {
List<AgencyWithCoverageBean> agencies = _service.getAgenciesWithCoverage();
for (AgencyWithCoverageBean agencyBean : agencies) {
Agency agency = new Agency();
agency.setTag(agencyBean.getAgency().getId());
agency.setTitle(agencyBean.getAgency().getName());
agency.setRegionTitle(agencyBean.getAgency().getName());
body.getResponse().add(agency);
}
} catch (ServiceException e) {
body.getErrors().add(new BodyError(ErrorMsg.SERVICE_ERROR.getDescription()));
}
return body;
}
use of org.onebusaway.transit_data.model.AgencyWithCoverageBean in project onebusaway-application-modules by camsys.
the class AlertsAction method setServiceAlerts.
private void setServiceAlerts(List<ServiceAlertRssBean> beans, String baseUrl) {
List<AgencyWithCoverageBean> agencies = _transitDataService.getAgenciesWithCoverage();
for (AgencyWithCoverageBean agency : agencies) {
String agencyId = agency.getAgency().getId();
String agencyName = agency.getAgency().getName();
if (StringUtils.isNotBlank(_agencyId)) {
// we have a filter, only return service alerts for that agency
if (_agencyId.equals(agencyId)) {
setServiceAlerts(agency, beans, baseUrl);
} else {
// here we reject the agency and its alerts
}
} else {
// we don't have a filter, render all agencies
setServiceAlerts(agency, beans, baseUrl);
}
}
}
use of org.onebusaway.transit_data.model.AgencyWithCoverageBean 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;
}
use of org.onebusaway.transit_data.model.AgencyWithCoverageBean in project onebusaway-application-modules by camsys.
the class RouteListServiceImpl method getRoutes.
@Override
public List<RouteBean> getRoutes() {
List<RouteBean> allRoutes = new ArrayList<RouteBean>();
List<AgencyWithCoverageBean> agencies = _transitDataService.getAgenciesWithCoverage();
for (AgencyWithCoverageBean agency : agencies) {
allRoutes.addAll(_transitDataService.getRoutesForAgencyId(agency.getAgency().getId()).getList());
}
Collections.sort(allRoutes, (getShowAgencyNames() ? new AgencyAndRouteComparator() : new RouteComparator()));
return allRoutes;
}
use of org.onebusaway.transit_data.model.AgencyWithCoverageBean in project onebusaway-application-modules by camsys.
the class ServiceAlertEditAction method execute.
@Override
public String execute() {
try {
if (_alertId != null && !_alertId.trim().isEmpty()) {
_model = _transitDataService.getServiceAlertForId(_alertId);
if (_agencyId == null) {
_agencyId = ServiceAlertsUtil.getAgencyFromAlertId(_alertId);
}
}
} catch (RuntimeException e) {
_log.error("Unable to retrieve Service Alert", e);
throw e;
}
try {
_agencies = _transitDataService.getAgenciesWithCoverage();
_situationTemplatesByAgency = new ArrayList<ServiceAlertBean>();
for (int i = 0; i < _agencies.size(); ++i) {
AgencyWithCoverageBean agency = _agencies.get(i);
String agencyId = agency.getAgency().getId();
ListBean<ServiceAlertRecordBean> result = _transitDataService.getAllServiceAlertRecordsForAgencyId(agencyId);
for (ServiceAlertRecordBean serviceAlertRecord : result.getList()) {
if (Boolean.TRUE.equals(serviceAlertRecord.isCopy())) {
_situationTemplatesByAgency.add(serviceAlertRecord.getServiceAlertBean());
}
}
}
} catch (Throwable t) {
_log.error("unable to retrieve agencies with coverage", t);
_log.error("issue connecting to TDS -- check your configuration in data-sources.xml");
throw new RuntimeException("Check your onebusaway-nyc-transit-data-federation-webapp configuration", t);
}
if (isFromFavorite()) {
setStartDate(null);
setEndDate(null);
}
return "SUCCESS";
}
Aggregations