use of org.onebusaway.transit_data.model.TripStopTimesBean 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.TripStopTimesBean 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.TripStopTimesBean in project onebusaway-application-modules by camsys.
the class TripStopTimesBeanServiceImpl method getStopTimesForTrip.
/**
**
* Private Methods
***
*/
private TripStopTimesBean getStopTimesForTrip(TripEntry trip) {
AgencyAndId tripId = trip.getId();
TripStopTimesBean bean = new TripStopTimesBean();
TimeZone tz = _agencyService.getTimeZoneForAgencyId(tripId.getAgencyId());
bean.setTimeZone(tz.getID());
for (StopTimeEntry stopTime : trip.getStopTimes()) {
TripStopTimeBean stBean = new TripStopTimeBean();
stBean.setArrivalTime(stopTime.getArrivalTime());
stBean.setDepartureTime(stopTime.getDepartureTime());
StopEntry stopEntry = stopTime.getStop();
StopBean stopBean = _stopBeanService.getStopForId(stopEntry.getId());
stBean.setStop(stopBean);
stBean.setDistanceAlongTrip(stopTime.getShapeDistTraveled());
bean.addStopTime(stBean);
}
return bean;
}
use of org.onebusaway.transit_data.model.TripStopTimesBean in project onebusaway-application-modules by camsys.
the class TripAction method execute.
@Override
@Actions({ @Action(value = "/where/trip"), @Action(value = "/where/iphone/trip") })
public String execute() throws ServiceException {
if (_id == null)
return INPUT;
if (_time == null)
_time = new Date();
TripDetailsQueryBean query = new TripDetailsQueryBean();
query.setTripId(_id);
if (_serviceDate != null)
query.setServiceDate(_serviceDate.getTime());
query.setVehicleId(_vehicleId);
query.setTime(_time.getTime());
_tripDetails = _service.getSingleTripDetails(query);
if (_tripDetails == null)
throw new NoSuchTripServiceException(_id);
TripStopTimesBean stopTimes = _tripDetails.getSchedule();
_timeZone = TimeZone.getTimeZone(stopTimes.getTimeZone());
_actualServiceDate = getActualServiceDate();
return SUCCESS;
}
use of org.onebusaway.transit_data.model.TripStopTimesBean 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;
}
Aggregations