use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertRecordBean 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";
}
use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertRecordBean in project onebusaway-application-modules by camsys.
the class ServiceAlertsAction method execute.
@SkipValidation
@Override
public String execute() {
_log.info("ServiceAlerts.execute()");
/*
if (submit) {
_log.info("Service Alert submitted");
//doSubmit();
//return "submitResult";
}
if (clear) {
_log.info("Service Alert cleared");
//doClear();
//return "clearResult";
}
*/
// Check that we have permission:
super.execute();
try {
_agencies = _transitDataService.getAgenciesWithCoverage();
_situationsByAgency = new List[_agencies.size()];
// for (AgencyWithCoverageBean agency : _agencies) {
for (int i = 0; i < _agencies.size(); ++i) {
AgencyWithCoverageBean agency = _agencies.get(i);
String agencyId = agency.getAgency().getId();
ListBean<ServiceAlertRecordBean> result = _transitDataService.getAllServiceAlertRecordsForAgencyId(agencyId);
List<ServiceAlertRecordBean> serviceAlerts = result.getList();
_situationsByAgency[i] = serviceAlerts;
}
for (int i = 0; i < _agencies.size(); ++i) {
_log.info("Agency " + _agencies.get(i).getAgency().getId());
List<ServiceAlertRecordBean> serviceAlerts = _situationsByAgency[i];
for (ServiceAlertRecordBean serviceAlert : serviceAlerts) {
_log.info(" Alert: " + serviceAlert.getServiceAlertBean().getSummaries().get(0));
}
}
} 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);
}
return SUCCESS;
}
Aggregations