use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class BeanFactoryV2 method getTripDetails.
public TripDetailsV2Bean getTripDetails(TripDetailsBean tripDetails) {
TripDetailsV2Bean bean = new TripDetailsV2Bean();
bean.setTripId(tripDetails.getTripId());
bean.setServiceDate(tripDetails.getServiceDate());
if (tripDetails.getFrequency() != null)
bean.setFrequency(getFrequency(tripDetails.getFrequency()));
TripBean trip = tripDetails.getTrip();
if (trip != null)
addToReferences(trip);
TripStopTimesBean stopTimes = tripDetails.getSchedule();
if (stopTimes != null)
bean.setSchedule(getTripStopTimes(stopTimes));
TripStatusBean status = tripDetails.getStatus();
if (status != null)
bean.setStatus(getTripStatus(status));
List<ServiceAlertBean> situations = tripDetails.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;
}
use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class BeanFactoryV2 method getArrivalAndDeparture.
public ArrivalAndDepartureV2Bean getArrivalAndDeparture(ArrivalAndDepartureBean ad) {
TripBean trip = ad.getTrip();
RouteBean route = trip.getRoute();
StopBean stop = ad.getStop();
ArrivalAndDepartureV2Bean bean = new ArrivalAndDepartureV2Bean();
bean.setTripId(trip.getId());
addToReferences(trip);
bean.setServiceDate(ad.getServiceDate());
bean.setVehicleId(ad.getVehicleId());
bean.setStopId(stop.getId());
addToReferences(stop);
bean.setStopSequence(ad.getStopSequence());
bean.setBlockTripSequence(ad.getBlockTripSequence());
bean.setTotalStopsInTrip(ad.getTotalStopsInTrip());
bean.setRouteId(route.getId());
addToReferences(route);
String routeShortName = ad.getRouteShortName();
if (routeShortName == null || routeShortName.isEmpty())
routeShortName = trip.getRouteShortName();
if (routeShortName == null || routeShortName.isEmpty())
routeShortName = route.getShortName();
bean.setRouteShortName(routeShortName);
bean.setRouteLongName(route.getLongName());
String tripHeadsign = ad.getTripHeadsign();
if (tripHeadsign == null || tripHeadsign.isEmpty())
tripHeadsign = trip.getTripHeadsign();
bean.setTripHeadsign(tripHeadsign);
bean.setArrivalEnabled(ad.isArrivalEnabled());
bean.setDepartureEnabled(ad.isDepartureEnabled());
bean.setScheduledArrivalTime(ad.getScheduledArrivalTime());
bean.setScheduledDepartureTime(ad.getScheduledDepartureTime());
bean.setPredictedArrivalTime(ad.getPredictedArrivalTime());
bean.setPredictedDepartureTime(ad.getPredictedDepartureTime());
bean.setScheduledArrivalInterval(getTimeInterval(ad.getScheduledArrivalInterval()));
bean.setScheduledDepartureInterval(getTimeInterval(ad.getScheduledDepartureInterval()));
bean.setPredictedArrivalInterval(getTimeInterval(ad.getPredictedArrivalInterval()));
bean.setPredictedDepartureInterval(getTimeInterval(ad.getPredictedDepartureInterval()));
if (ad.getFrequency() != null)
bean.setFrequency(getFrequency(ad.getFrequency()));
bean.setStatus(ad.getStatus());
if (ad.isDistanceFromStopSet())
bean.setDistanceFromStop(ad.getDistanceFromStop());
bean.setNumberOfStopsAway(ad.getNumberOfStopsAway());
TripStatusBean tripStatus = ad.getTripStatus();
if (tripStatus != null)
bean.setTripStatus(getTripStatus(tripStatus));
bean.setPredicted(ad.isPredicted());
bean.setLastUpdateTime(ad.getLastUpdateTime());
List<ServiceAlertBean> situations = ad.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 AlertsForAgencyAction method fillFeedMessage.
@Override
protected void fillFeedMessage(FeedMessage.Builder feed, String agencyId, long timestamp) {
ListBean<ServiceAlertBean> alerts = _service.getAllServiceAlertsForAgencyId(agencyId);
for (ServiceAlertBean serviceAlert : alerts.getList()) {
FeedEntity.Builder entity = feed.addEntityBuilder();
entity.setId(Integer.toString(feed.getEntityCount()));
Alert.Builder alert = entity.getAlertBuilder();
fillTranslations(serviceAlert.getSummaries(), alert.getHeaderTextBuilder());
fillTranslations(serviceAlert.getDescriptions(), alert.getDescriptionTextBuilder());
if (serviceAlert.getActiveWindows() != null) {
for (TimeRangeBean range : serviceAlert.getActiveWindows()) {
TimeRange.Builder timeRange = alert.addActivePeriodBuilder();
if (range.getFrom() != 0) {
timeRange.setStart(range.getFrom() / 1000);
}
if (range.getTo() != 0) {
timeRange.setEnd(range.getTo() / 1000);
}
}
}
if (serviceAlert.getAllAffects() != null) {
for (SituationAffectsBean affects : serviceAlert.getAllAffects()) {
EntitySelector.Builder entitySelector = alert.addInformedEntityBuilder();
if (affects.getAgencyId() != null) {
entitySelector.setAgencyId(affects.getAgencyId());
}
if (affects.getRouteId() != null) {
entitySelector.setRouteId(normalizeId(affects.getRouteId()));
}
if (affects.getTripId() != null) {
TripDescriptor.Builder trip = entitySelector.getTripBuilder();
trip.setTripId(normalizeId(affects.getTripId()));
entitySelector.setTrip(trip);
}
if (affects.getStopId() != null) {
AgencyAndId stopId = modifiedStopId(agencyId, affects.getStopId());
if (stopId.getAgencyId().equals(agencyId)) {
entitySelector.setStopId(normalizeId(stopId.toString()));
}
}
}
}
}
}
use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class RealtimeServiceImpl method getServiceAlertsForRouteAndDirection.
@Override
public List<ServiceAlertBean> getServiceAlertsForRouteAndDirection(String routeId, String directionId) {
SituationQueryBean query = new SituationQueryBean();
SituationQueryBean.AffectsBean affects = new SituationQueryBean.AffectsBean();
query.getAffects().add(affects);
affects.setRouteId(routeId);
if (directionId != null) {
affects.setDirectionId(directionId);
} else {
/*
* TODO
* The route index is not currently being populated correctly; query by route and direction,
* and supply both directions if not present
*/
SituationQueryBean.AffectsBean affects1 = new SituationQueryBean.AffectsBean();
query.getAffects().add(affects1);
affects1.setRouteId(routeId);
affects1.setDirectionId("0");
SituationQueryBean.AffectsBean affects2 = new SituationQueryBean.AffectsBean();
query.getAffects().add(affects2);
affects2.setRouteId(routeId);
affects2.setDirectionId("1");
}
ListBean<ServiceAlertBean> serviceAlerts = _transitDataService.getServiceAlerts(query);
return serviceAlerts.getList();
}
use of org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean in project onebusaway-application-modules by camsys.
the class SiriSupport method fillSituations.
private static void fillSituations(MonitoredVehicleJourneyStructure monitoredVehicleJourney, TripStatusBean tripStatus) {
if (tripStatus == null || tripStatus.getSituations() == null || tripStatus.getSituations().isEmpty()) {
return;
}
List<SituationRefStructure> situationRef = monitoredVehicleJourney.getSituationRef();
for (ServiceAlertBean situation : tripStatus.getSituations()) {
SituationRefStructure sitRef = new SituationRefStructure();
SituationSimpleRefStructure sitSimpleRef = new SituationSimpleRefStructure();
sitSimpleRef.setValue(situation.getId());
sitRef.setSituationSimpleRef(sitSimpleRef);
situationRef.add(sitRef);
}
}
Aggregations