if (!tripDescriptor.hasTripId()) { LOG.warn("No trip id found for ADDED trip, skipping."); return false;
if (!tripDescriptor.hasTripId()) { LOG.warn("No trip id found for MODIFIED trip, skipping."); return false;
private boolean handleCanceledTrip(final TripUpdate tripUpdate, final String feedId, final ServiceDate serviceDate) { boolean success = false; if (tripUpdate.getTrip().hasTripId()) { // Try to cancel scheduled trip final String tripId = tripUpdate.getTrip().getTripId(); final boolean cancelScheduledSuccess = cancelScheduledTrip(feedId, tripId, serviceDate); // Try to cancel previously added trip final boolean cancelPreviouslyAddedSuccess = cancelPreviouslyAddedTrip(feedId, tripId, serviceDate); if (cancelScheduledSuccess || cancelPreviouslyAddedSuccess) { success = true; } else { LOG.warn("No pattern found for tripId {}, skipping TripUpdate.", tripId); } } else { LOG.warn("No trip id in CANCELED trip update, skipping TripUpdate."); } return success; }
tu.setDelay(entity.getTripUpdate().getDelay()); if (t.hasTripId()) tu.setTripId(t.getTripId()); if (t.hasRouteId()) {
if (!v.hasTrip() || !v.getTrip().hasTripId()) { return;
if (t.hasTripId()) esm.setTripId(t.getTripId()); if (t.hasRouteId()) {
public Builder mergeFrom(com.google.transit.realtime.GtfsRealtime.TripDescriptor other) { if (other == com.google.transit.realtime.GtfsRealtime.TripDescriptor.getDefaultInstance()) return this; if (other.hasTripId()) { bitField0_ |= 0x00000001; tripId_ = other.tripId_;
/** * Checks rule E035 - "GTFS-rt trip.trip_id does not belong to GTFS-rt trip.route_id in GTFS trips.txt", and adds any errors that are found to the provided error list * * @param entity entity which contains the specified trip * @param trip trip to examine to see if the trip_id belongs to the route_id * @param gtfsMetadata information about the GTFS dataset * @param errors list to add any errors for E034 to */ private void checkE035(GtfsRealtime.FeedEntity entity, GtfsRealtime.TripDescriptor trip, GtfsMetadata gtfsMetadata, List<OccurrenceModel> errors) { if (trip.hasTripId() && trip.hasRouteId()) { if (!gtfsMetadata.getRouteIds().contains(trip.getRouteId())) { // route_id isn't in GTFS data (which will be caught by E004) - return; return; } Trip gtfsTrip = gtfsMetadata.getTrips().get(trip.getTripId()); if (gtfsTrip == null) { // trip_id isn't in GTFS data (which will be caught by E003) - return; return; } String gtfsRouteId = gtfsTrip.getRoute().getId().getId(); if (!gtfsRouteId.equals(trip.getRouteId())) { RuleUtils.addOccurrence(E035, "GTFS-rt entity ID " + entity.getId() + " trip_id " + trip.getTripId() + " has route_id " + trip.getRouteId() + " but belongs to GTFS route_id " + gtfsRouteId, errors, _log); } } }
/** * Checks rule E033 - "Alert informed_entity does not have any specifiers" and adds * any errors that are found to the provided errors list * * @param entity feed entity to examine that contains an alert * @param entitySelector EntitySelector to examine for specifiers * @param errors list to add any errors for E033 to */ private void checkE033(GtfsRealtime.FeedEntity entity, GtfsRealtime.EntitySelector entitySelector, List<OccurrenceModel> errors) { GtfsRealtime.TripDescriptor trip = null; if (entitySelector.hasTrip()) { trip = entitySelector.getTrip(); } if (!entitySelector.hasAgencyId() && !entitySelector.hasRouteId() && !entitySelector.hasRouteType() && !entitySelector.hasStopId()) { // informed_entity isn't populated - check TripDescriptor if (trip == null || (!trip.hasTripId() && !trip.hasRouteId())) { RuleUtils.addOccurrence(E033, "alert ID " + entity.getId() + " informed_entity and informed_entity.trip do not not reference any agency, route, trip, or stop", errors, _log); } } }
private Affects.Builder getEntitySelectorAsAffects(EntitySelector selector, Map agencyIdMap) { Affects.Builder affects = Affects.newBuilder(); if (selector.hasAgencyId()) { String agencyId = selector.getAgencyId(); if (agencyIdMap != null && agencyIdMap.get(agencyId) != null) { agencyId = (String) agencyIdMap.get(agencyId); } affects.setAgencyId(agencyId); } if (selector.hasRouteId()) { Id routeId = _entitySource.getRouteId(selector.getRouteId()); affects.setRouteId(routeId); } if (selector.hasStopId()) { Id stopId = _entitySource.getStopId(selector.getStopId()); affects.setStopId(stopId); } if (selector.hasTrip()) { TripDescriptor trip = selector.getTrip(); if (trip.hasTripId()) affects.setTripId(_entitySource.getTripId(trip.getTripId())); else if (trip.hasRouteId()) affects.setRouteId(_entitySource.getRouteId(trip.getRouteId())); } return affects; }
/** * Checks rule E030 - "GTFS-rt alert trip_id does not belong to GTFS-rt alert route_id in GTFS trips.txt" and adds * any errors that are found to the provided errors list * * @param entity feed entity to examine that contains an alert * @param entitySelector EntitySelector that has both a routeId and a tripDescriptor * @param gtfsMetadata metadata for the static GTFS data * @param errors list to add any errors for E030 to */ private void checkE030(GtfsRealtime.FeedEntity entity, GtfsRealtime.EntitySelector entitySelector, GtfsMetadata gtfsMetadata, List<OccurrenceModel> errors) { String routeId = entitySelector.getRouteId(); GtfsRealtime.TripDescriptor tripDescriptor = entitySelector.getTrip(); if (tripDescriptor.hasTripId()) { Trip gtfsTrip = gtfsMetadata.getTrips().get(tripDescriptor.getTripId()); if (gtfsTrip != null && !routeId.equals(gtfsTrip.getRoute().getId().getId())) { String prefix = "alert ID " + entity.getId() + " informed_entity.trip.trip_id " + tripDescriptor.getTripId() + " does not belong to informed_entity.route_id " + routeId + " (GTFS says it belongs to route_id " + gtfsTrip.getRoute().getId().getId() + ")"; RuleUtils.addOccurrence(E030, prefix, errors, _log); } } }
/** * Checks rule W006 - "trip missing trip_id", and adds any warnings that are found to the provided warning list * * @param entity entity which contains the specified trip * @param tripDescriptor trip to examine to see if it has trip_id * @param warnings list to add any warnings for W009 to */ private void checkW006(GtfsRealtime.FeedEntity entity, GtfsRealtime.TripDescriptor tripDescriptor, List<OccurrenceModel> warnings) { if (tripDescriptor != null && !tripDescriptor.hasTripId()) { RuleUtils.addOccurrence(W006, "entity ID " + entity.getId(), warnings, _log); } }
/** * Returns the trip_id for the given TripDescriptor if one exists, if not the entity ID is returned in the format * "trip_id 1234" or "entity ID 4321". * * @param entity the entity that the TripUpdate belongs to * @param tripDescriptor the tripDescriptor to get the ID for * @return the trip_id for the given TripUpdate if one exists, if not the entity ID is returned in the format "trip_id 1234" or "entity ID 4321". */ public static String getTripId(GtfsRealtime.FeedEntity entity, GtfsRealtime.TripDescriptor tripDescriptor) { return tripDescriptor.hasTripId() ? "trip_id " + tripDescriptor.getTripId() : "entity ID " + entity.getId(); }
/** * Returns true if this tripUpdate has a trip_id, false if it does not * * @param tripUpdate to examine * @return true if this tripUpdate has a trip_id, false if it does not */ private boolean hasTripId(GtfsRealtime.TripUpdate tripUpdate) { return tripUpdate.hasTrip() && tripUpdate.getTrip().hasTripId(); }
if (!tripDescriptor.hasTripId()) { LOG.error("TripDescriptor object has no TripId field"); return null;
if (informed.hasTrip() && informed.getTrip().hasTripId()) { tripId = informed.getTrip().getTripId();
public TripDescriptor match(String feedId, TripDescriptor trip) { if (trip.hasTripId()) {
public Builder mergeFrom(com.google.transit.realtime.GtfsRealtime.TripDescriptor other) { if (other == com.google.transit.realtime.GtfsRealtime.TripDescriptor.getDefaultInstance()) return this; if (other.hasTripId()) { bitField0_ |= 0x00000001; tripId_ = other.tripId_;
private String createId(String id, EntitySelector informed) { return id + " " + (informed.hasAgencyId () ? informed.getAgencyId () : " null ") + " " + (informed.hasRouteId () ? informed.getRouteId () : " null ") + " " + (informed.hasTrip() && informed.getTrip().hasDirectionId() ? informed.getTrip().hasDirectionId() : " null ") + " " + (informed.hasRouteType () ? informed.getRouteType () : " null ") + " " + (informed.hasStopId () ? informed.getStopId () : " null ") + " " + (informed.hasTrip() && informed.getTrip().hasTripId() ? informed.getTrip().getTripId() : " null "); }