use of org.onebusaway.transit_data.model.schedule.FrequencyBean in project onebusaway-application-modules by camsys.
the class TripStatusBeanServiceImpl method getTripEntryAndBlockLocationAsTripDetails.
private TripDetailsBean getTripEntryAndBlockLocationAsTripDetails(BlockTripInstance blockTripInstance, BlockLocation blockLocation, TripDetailsInclusionBean inclusion, long time) {
TripBean trip = null;
long serviceDate = blockTripInstance.getServiceDate();
FrequencyBean frequency = null;
TripStopTimesBean stopTimes = null;
TripStatusBean status = null;
AgencyAndId vehicleId = null;
boolean missing = false;
FrequencyEntry frequencyLabel = blockTripInstance.getFrequencyLabel();
if (frequencyLabel != null) {
frequency = FrequencyBeanLibrary.getBeanForFrequency(serviceDate, frequencyLabel);
}
BlockTripEntry blockTrip = blockTripInstance.getBlockTrip();
TripEntry tripEntry = blockTrip.getTrip();
if (inclusion.isIncludeTripBean()) {
trip = _tripBeanService.getTripForId(tripEntry.getId());
if (trip == null)
missing = true;
}
if (inclusion.isIncludeTripSchedule()) {
stopTimes = _tripStopTimesBeanService.getStopTimesForBlockTrip(blockTripInstance);
if (stopTimes == null)
missing = true;
}
if (inclusion.isIncludeTripStatus() && blockLocation != null) {
status = getBlockLocationAsStatusBean(blockLocation, time);
if (status == null)
missing = true;
else
vehicleId = AgencyAndIdLibrary.convertFromString(status.getVehicleId());
}
List<ServiceAlertBean> situations = _serviceAlertBeanService.getServiceAlertsForVehicleJourney(time, blockTripInstance, vehicleId);
if (missing)
return null;
String tripId = AgencyAndIdLibrary.convertToString(tripEntry.getId());
TripDetailsBean bean = new TripDetailsBean();
bean.setTripId(tripId);
bean.setServiceDate(serviceDate);
bean.setFrequency(frequency);
bean.setTrip(trip);
bean.setSchedule(stopTimes);
bean.setStatus(status);
bean.setSituations(situations);
return bean;
}
use of org.onebusaway.transit_data.model.schedule.FrequencyBean in project onebusaway-application-modules by camsys.
the class TripStopTimesBeanServiceImpl method getStopTimesForBlockTrip.
@Override
public TripStopTimesBean getStopTimesForBlockTrip(BlockTripInstance blockTripInstance) {
BlockTripEntry blockTrip = blockTripInstance.getBlockTrip();
TripStopTimesBean bean = getStopTimesForTrip(blockTrip.getTrip());
if (blockTrip.getPreviousTrip() != null) {
BlockTripEntry previous = blockTrip.getPreviousTrip();
TripBean previousTrip = _tripBeanService.getTripForId(previous.getTrip().getId());
bean.setPreviousTrip(previousTrip);
}
if (blockTrip.getNextTrip() != null) {
BlockTripEntry next = blockTrip.getNextTrip();
TripBean nextTrip = _tripBeanService.getTripForId(next.getTrip().getId());
bean.setNextTrip(nextTrip);
}
FrequencyEntry frequencyLabel = blockTripInstance.getFrequencyLabel();
if (frequencyLabel != null) {
long serviceDate = blockTripInstance.getServiceDate();
FrequencyBean fb = FrequencyBeanLibrary.getBeanForFrequency(serviceDate, frequencyLabel);
bean.setFrequency(fb);
}
return bean;
}
use of org.onebusaway.transit_data.model.schedule.FrequencyBean in project onebusaway-application-modules by camsys.
the class ArrivalsAndDeparturesBeanServiceImpl method getStopTimeInstanceAsBean.
/**
**
* Private Methods
***
*/
private ArrivalAndDepartureBean getStopTimeInstanceAsBean(long time, ArrivalAndDepartureInstance instance, Map<AgencyAndId, StopBean> stopBeanCache) {
ArrivalAndDepartureBean pab = new ArrivalAndDepartureBean();
pab.setServiceDate(instance.getServiceDate());
BlockStopTimeEntry blockStopTime = instance.getBlockStopTime();
BlockTripEntry blockTrip = blockStopTime.getTrip();
StopTimeEntry stopTime = blockStopTime.getStopTime();
StopEntry stop = stopTime.getStop();
TripEntry trip = stopTime.getTrip();
TripBean tripBean = _tripBeanService.getTripForId(trip.getId());
pab.setTrip(tripBean);
pab.setBlockTripSequence(blockTrip.getSequence());
pab.setArrivalEnabled(stopTime.getSequence() > 0);
pab.setDepartureEnabled(stopTime.getSequence() + 1 < trip.getStopTimes().size());
StopTimeNarrative stopTimeNarrative = _narrativeService.getStopTimeForEntry(stopTime);
pab.setRouteShortName(stopTimeNarrative.getRouteShortName());
pab.setTripHeadsign(stopTimeNarrative.getStopHeadsign());
StopBean stopBean = stopBeanCache.get(stop.getId());
if (stopBean == null) {
stopBean = _stopBeanService.getStopForId(stop.getId());
stopBeanCache.put(stop.getId(), stopBean);
}
pab.setStop(stopBean);
pab.setStopSequence(stopTime.getSequence());
pab.setTotalStopsInTrip(stopTime.getTotalStopsInTrip());
pab.setStatus("default");
pab.setScheduledArrivalTime(instance.getScheduledArrivalTime());
pab.setScheduledDepartureTime(instance.getScheduledDepartureTime());
FrequencyEntry frequency = instance.getFrequencyLabel();
pab.setFrequency(null);
if (frequency != null) {
FrequencyBean fb = FrequencyBeanLibrary.getBeanForFrequency(instance.getServiceDate(), frequency);
pab.setFrequency(fb);
}
return pab;
}
use of org.onebusaway.transit_data.model.schedule.FrequencyBean in project onebusaway-application-modules by camsys.
the class BeanFactoryV2 method getTripStopTimes.
public TripStopTimesV2Bean getTripStopTimes(TripStopTimesBean tripStopTimes) {
TripStopTimesV2Bean bean = new TripStopTimesV2Bean();
bean.setTimeZone(tripStopTimes.getTimeZone());
List<TripStopTimeV2Bean> instances = new ArrayList<TripStopTimeV2Bean>();
for (TripStopTimeBean sti : tripStopTimes.getStopTimes()) {
TripStopTimeV2Bean stiBean = new TripStopTimeV2Bean();
stiBean.setArrivalTime(sti.getArrivalTime());
stiBean.setDepartureTime(sti.getDepartureTime());
stiBean.setStopHeadsign(sti.getStopHeadsign());
stiBean.setDistanceAlongTrip(sti.getDistanceAlongTrip());
stiBean.setStopId(sti.getStop().getId());
addToReferences(sti.getStop());
instances.add(stiBean);
}
bean.setStopTimes(instances);
TripBean nextTrip = tripStopTimes.getNextTrip();
if (nextTrip != null) {
bean.setNextTripId(nextTrip.getId());
addToReferences(nextTrip);
}
TripBean prevTrip = tripStopTimes.getPreviousTrip();
if (prevTrip != null) {
bean.setPreviousTripId(prevTrip.getId());
addToReferences(prevTrip);
}
FrequencyBean freq = tripStopTimes.getFrequency();
if (freq != null)
bean.setFrequency(getFrequency(freq));
return bean;
}
use of org.onebusaway.transit_data.model.schedule.FrequencyBean 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;
}
Aggregations