use of org.onebusaway.transit_data.model.trips.TripBean in project onebusaway-application-modules by camsys.
the class TripBeanServiceImpl method getTripForId.
@Cacheable
public TripBean getTripForId(AgencyAndId tripId) {
TripEntry tripEntry = _graph.getTripEntryForId(tripId);
if (tripEntry == null)
return null;
AgencyAndId routeId = tripEntry.getRouteCollection().getId();
RouteBean routeBean = _routeBeanService.getRouteForId(routeId);
TripNarrative tripNarrative = _narrativeService.getTripForId(tripId);
TripBean tripBean = new TripBean();
tripBean.setId(ApplicationBeanLibrary.getId(tripId));
tripBean.setTripShortName(tripNarrative.getTripShortName());
tripBean.setTripHeadsign(tripNarrative.getTripHeadsign());
tripBean.setRoute(routeBean);
tripBean.setRouteShortName(tripNarrative.getRouteShortName());
tripBean.setServiceId(ApplicationBeanLibrary.getId(tripEntry.getServiceId().getId()));
AgencyAndId shapeId = tripEntry.getShapeId();
if (shapeId != null && shapeId.hasValues())
tripBean.setShapeId(ApplicationBeanLibrary.getId(shapeId));
tripBean.setDirectionId(tripEntry.getDirectionId());
tripBean.setTotalTripDistance(tripEntry.getTotalTripDistance());
BlockEntry block = tripEntry.getBlock();
tripBean.setBlockId(ApplicationBeanLibrary.getId(block.getId()));
return tripBean;
}
use of org.onebusaway.transit_data.model.trips.TripBean 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.trips.TripBean 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.trips.TripBean in project onebusaway-application-modules by camsys.
the class BlockBeanServiceImpl method getBlockTripAsBean.
@Override
public BlockTripBean getBlockTripAsBean(BlockTripEntry blockTrip) {
TripEntry trip = blockTrip.getTrip();
TripBean tripBean = _tripBeanService.getTripForId(trip.getId());
if (tripBean == null)
throw new IllegalStateException("unknown trip: " + trip.getId());
BlockTripBean bean = new BlockTripBean();
bean.setTrip(tripBean);
bean.setAccumulatedSlackTime(blockTrip.getAccumulatedSlackTime());
bean.setDistanceAlongBlock(blockTrip.getDistanceAlongBlock());
List<BlockStopTimeBean> blockStopTimes = new ArrayList<BlockStopTimeBean>();
for (BlockStopTimeEntry blockStopTime : blockTrip.getStopTimes()) {
BlockStopTimeBean blockStopTimeAsBean = getBlockStopTimeAsBean(blockStopTime);
blockStopTimes.add(blockStopTimeAsBean);
}
bean.setBlockStopTimes(blockStopTimes);
return bean;
}
use of org.onebusaway.transit_data.model.trips.TripBean 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;
}
Aggregations