use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class SituationsPresentation method getUnreadCount.
public int getUnreadCount() {
int unreadServiceAlertCount = 0;
Map<String, Long> readServiceAlerts = _user.getReadServiceAlerts();
for (ServiceAlertBean situation : _situations) {
if (isSituationUnread(readServiceAlerts, situation))
unreadServiceAlertCount++;
}
return unreadServiceAlertCount;
}
use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class ServiceAlertAffectsAction method delete.
public String delete() {
if (_id == null || _index == -1) {
return INPUT;
}
ServiceAlertBean alert = null;
try {
alert = _transitDataService.getServiceAlertForId(_id);
} catch (RuntimeException e) {
_log.error("Error retrieving Service Alert", e);
throw e;
}
if (alert == null) {
return INPUT;
}
List<SituationAffectsBean> allAffects = alert.getAllAffects();
if (allAffects == null || _index >= allAffects.size()) {
return INPUT;
}
allAffects.remove(_index);
try {
_transitDataService.updateServiceAlert(alert);
} catch (RuntimeException e) {
_log.error("Error removing Service Alert Affects clause", e);
throw e;
}
return SUCCESS;
}
use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class ServiceAlertEditAction method getModel.
@Override
public ServiceAlertBean getModel() {
if (_model == null) {
_model = new ServiceAlertBean();
_model.setReason("Initial setup of empty ServiceAlert");
}
return _model;
}
use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean 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.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class BeanFactoryV2 method getStopWithArrivalAndDepartures.
public StopWithArrivalsAndDeparturesV2Bean getStopWithArrivalAndDepartures(StopWithArrivalsAndDeparturesBean sad) {
StopWithArrivalsAndDeparturesV2Bean bean = new StopWithArrivalsAndDeparturesV2Bean();
bean.setStopId(sad.getStop().getId());
addToReferences(sad.getStop());
List<ArrivalAndDepartureV2Bean> ads = new ArrayList<ArrivalAndDepartureV2Bean>();
for (ArrivalAndDepartureBean ad : sad.getArrivalsAndDepartures()) ads.add(getArrivalAndDeparture(ad));
bean.setArrivalsAndDepartures(ads);
List<String> nearbyStopIds = new ArrayList<String>();
for (StopBean nearbyStop : sad.getNearbyStops()) {
nearbyStopIds.add(nearbyStop.getId());
addToReferences(nearbyStop);
}
bean.setNearbyStopIds(nearbyStopIds);
List<ServiceAlertBean> situations = sad.getSituations();
if (!CollectionsLibrary.isEmpty(situations)) {
List<String> situationIds = new ArrayList<String>();
for (ServiceAlertBean situation : situations) {
addToReferences(situation);
situationIds.add(situation.getId());
}
bean.setSituationIds(situationIds);
}
return bean;
}
Aggregations