use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class BeanFactoryV2 method getTripStatus.
public TripStatusV2Bean getTripStatus(TripStatusBean tripStatus) {
TripStatusV2Bean bean = new TripStatusV2Bean();
TripBean activeTrip = tripStatus.getActiveTrip();
if (activeTrip != null) {
bean.setActiveTripId(activeTrip.getId());
bean.setBlockTripSequence(tripStatus.getBlockTripSequence());
addToReferences(activeTrip);
}
bean.setServiceDate(tripStatus.getServiceDate());
FrequencyBean frequency = tripStatus.getFrequency();
if (frequency != null)
bean.setFrequency(getFrequency(frequency));
bean.setScheduledDistanceAlongTrip(tripStatus.getScheduledDistanceAlongTrip());
bean.setTotalDistanceAlongTrip(tripStatus.getTotalDistanceAlongTrip());
bean.setPosition(tripStatus.getLocation());
if (tripStatus.isOrientationSet())
bean.setOrientation(tripStatus.getOrientation());
StopBean closestStop = tripStatus.getClosestStop();
if (closestStop != null) {
bean.setClosestStop(closestStop.getId());
addToReferences(closestStop);
bean.setClosestStopTimeOffset(tripStatus.getClosestStopTimeOffset());
}
StopBean nextStop = tripStatus.getNextStop();
if (nextStop != null) {
bean.setNextStop(nextStop.getId());
addToReferences(nextStop);
bean.setNextStopTimeOffset(tripStatus.getNextStopTimeOffset());
}
bean.setPhase(tripStatus.getPhase());
bean.setStatus(tripStatus.getStatus());
bean.setPredicted(tripStatus.isPredicted());
if (tripStatus.getLastUpdateTime() > 0)
bean.setLastUpdateTime(tripStatus.getLastUpdateTime());
if (tripStatus.getLastLocationUpdateTime() > 0)
bean.setLastLocationUpdateTime(tripStatus.getLastLocationUpdateTime());
if (tripStatus.isLastKnownDistanceAlongTripSet())
bean.setLastKnownDistanceAlongTrip(tripStatus.getLastKnownDistanceAlongTrip());
bean.setLastKnownLocation(tripStatus.getLastKnownLocation());
if (tripStatus.isLastKnownOrientationSet())
bean.setLastKnownOrientation(tripStatus.getLastKnownOrientation());
if (tripStatus.isScheduleDeviationSet())
bean.setScheduleDeviation((int) tripStatus.getScheduleDeviation());
if (tripStatus.isDistanceAlongTripSet())
bean.setDistanceAlongTrip(tripStatus.getDistanceAlongTrip());
bean.setVehicleId(tripStatus.getVehicleId());
List<ServiceAlertBean> situations = tripStatus.getSituations();
if (situations != null && !situations.isEmpty()) {
List<String> situationIds = new ArrayList<String>();
for (ServiceAlertBean situation : situations) {
situationIds.add(situation.getId());
addToReferences(situation);
}
bean.setSituationIds(situationIds);
}
return bean;
}
use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class SearchResultFactoryImplTest method createServiceAlerts.
private List<ServiceAlertBean> createServiceAlerts(String[] descriptions, String[] summaries) {
List<ServiceAlertBean> serviceAlerts = new ArrayList<ServiceAlertBean>();
ServiceAlertBean saBean = new ServiceAlertBean();
serviceAlerts.add(saBean);
if (descriptions.length > 0)
saBean.setDescriptions(createTextList(descriptions));
if (summaries.length > 0)
saBean.setSummaries(createTextList(summaries));
return serviceAlerts;
}
use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class ArrivalsAndDeparturesAction method getServiceAlertsForStop.
private List<ServiceAlertBean> getServiceAlertsForStop(String stopId) {
SituationQueryBean query = new SituationQueryBean();
SituationQueryBean.AffectsBean affects = new SituationQueryBean.AffectsBean();
query.getAffects().add(affects);
affects.setStopId(stopId);
ListBean<ServiceAlertBean> alerts = _transitDataService.getServiceAlerts(query);
if (alerts != null) {
return alerts.getList();
}
return Collections.emptyList();
}
use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class ServiceAlertAction method prepare.
@Override
public void prepare() throws Exception {
try {
if (_alertId != null && !_alertId.trim().isEmpty()) {
_model = _transitDataService.getServiceAlertForId(_alertId);
_model.setAllAffects(null);
} else {
_model = new ServiceAlertBean();
}
} catch (RuntimeException e) {
_log.error("Unable to retrieve Service Alerts for agency Id", e);
throw e;
}
}
use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class ServiceAlertAffectsAction method update.
public String update() throws IOException, JSONException {
if (_id == null || _index == -1) {
return INPUT;
}
ServiceAlertBean alert = null;
try {
alert = _transitDataService.getServiceAlertForId(_id);
} catch (RuntimeException e) {
_log.error("Error retrieving Service Alerts", e);
throw e;
}
if (alert == null) {
return INPUT;
}
List<SituationAffectsBean> allAffects = alert.getAllAffects();
if (allAffects == null || _index >= allAffects.size()) {
return INPUT;
}
_model.setAgencyId(string(_model.getAgencyId()));
_model.setRouteId(string(_model.getRouteId()));
_model.setDirectionId(string(_model.getDirectionId()));
_model.setTripId(string(_model.getTripId()));
_model.setStopId(string(_model.getStopId()));
allAffects.set(_index, _model);
try {
_transitDataService.updateServiceAlert(alert);
} catch (RuntimeException e) {
_log.error("Error updating Service Alert Affects clause", e);
throw e;
}
return SUCCESS;
}
Aggregations