Search in sources :

Example 1 with TripStopTimesBean

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;
}
Also used : AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) TripBean(org.onebusaway.transit_data.model.trips.TripBean) FrequencyEntry(org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry) TripEntry(org.onebusaway.transit_data_federation.services.transit_graph.TripEntry) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) TripStopTimesBean(org.onebusaway.transit_data.model.TripStopTimesBean) FrequencyBean(org.onebusaway.transit_data.model.schedule.FrequencyBean) TripStatusBean(org.onebusaway.transit_data.model.trips.TripStatusBean) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean) TripDetailsBean(org.onebusaway.transit_data.model.trips.TripDetailsBean)

Example 2 with TripStopTimesBean

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;
}
Also used : FrequencyBean(org.onebusaway.transit_data.model.schedule.FrequencyBean) BlockTripEntry(org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry) TripBean(org.onebusaway.transit_data.model.trips.TripBean) FrequencyEntry(org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry) TripStopTimesBean(org.onebusaway.transit_data.model.TripStopTimesBean)

Example 3 with TripStopTimesBean

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;
}
Also used : TimeZone(java.util.TimeZone) AgencyAndId(org.onebusaway.gtfs.model.AgencyAndId) StopTimeEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry) TripStopTimeBean(org.onebusaway.transit_data.model.TripStopTimeBean) StopEntry(org.onebusaway.transit_data_federation.services.transit_graph.StopEntry) StopBean(org.onebusaway.transit_data.model.StopBean) TripStopTimesBean(org.onebusaway.transit_data.model.TripStopTimesBean)

Example 4 with TripStopTimesBean

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;
}
Also used : TripDetailsQueryBean(org.onebusaway.transit_data.model.trips.TripDetailsQueryBean) NoSuchTripServiceException(org.onebusaway.exceptions.NoSuchTripServiceException) TripStopTimesBean(org.onebusaway.transit_data.model.TripStopTimesBean) Date(java.util.Date) Actions(org.apache.struts2.convention.annotation.Actions)

Example 5 with TripStopTimesBean

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;
}
Also used : ArrayList(java.util.ArrayList) BlockTripBean(org.onebusaway.transit_data.model.blocks.BlockTripBean) TripBean(org.onebusaway.transit_data.model.trips.TripBean) TripStatusBean(org.onebusaway.transit_data.model.trips.TripStatusBean) ServiceAlertBean(org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean) TripStopTimesBean(org.onebusaway.transit_data.model.TripStopTimesBean)

Aggregations

TripStopTimesBean (org.onebusaway.transit_data.model.TripStopTimesBean)5 TripBean (org.onebusaway.transit_data.model.trips.TripBean)3 AgencyAndId (org.onebusaway.gtfs.model.AgencyAndId)2 FrequencyBean (org.onebusaway.transit_data.model.schedule.FrequencyBean)2 ServiceAlertBean (org.onebusaway.transit_data.model.service_alerts.ServiceAlertBean)2 TripStatusBean (org.onebusaway.transit_data.model.trips.TripStatusBean)2 BlockTripEntry (org.onebusaway.transit_data_federation.services.transit_graph.BlockTripEntry)2 FrequencyEntry (org.onebusaway.transit_data_federation.services.transit_graph.FrequencyEntry)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 TimeZone (java.util.TimeZone)1 Actions (org.apache.struts2.convention.annotation.Actions)1 NoSuchTripServiceException (org.onebusaway.exceptions.NoSuchTripServiceException)1 StopBean (org.onebusaway.transit_data.model.StopBean)1 TripStopTimeBean (org.onebusaway.transit_data.model.TripStopTimeBean)1 BlockTripBean (org.onebusaway.transit_data.model.blocks.BlockTripBean)1 TripDetailsBean (org.onebusaway.transit_data.model.trips.TripDetailsBean)1 TripDetailsQueryBean (org.onebusaway.transit_data.model.trips.TripDetailsQueryBean)1 StopEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopEntry)1 StopTimeEntry (org.onebusaway.transit_data_federation.services.transit_graph.StopTimeEntry)1