/** Map from GTFS to OTP model, {@code null} safe. */ public static FeedScopedId mapAgencyAndId(org.onebusaway.gtfs.model.AgencyAndId id) { return id == null ? null : new FeedScopedId(id.getAgencyId(), id.getId()); } }
private void registerAgencyId(Class<?> entityType, AgencyAndId id) { Map<String, String> agencyIdsByEntityId = _agencyIdsByEntityClassAndId.get(entityType); if (agencyIdsByEntityId == null) { agencyIdsByEntityId = new HashMap<String, String>(); _agencyIdsByEntityClassAndId.put(entityType, agencyIdsByEntityId); } if (agencyIdsByEntityId.containsKey(id.getId()) && !_overwriteDuplicates) { throw new DuplicateEntityException(entityType, id); } agencyIdsByEntityId.put(id.getId(), id.getAgencyId()); } }
@Override public List<Ridership> getRidershipForTrip(AgencyAndId tripId) { return _ops.findByNamedQueryAndNamedParam("ridershipsForTripId", "tripId", tripId.getId()); }
@Override public void translateFromObjectToCSV(CsvEntityContext context, BeanWrapper object, Map<String, Object> csvValues) { AgencyAndId id = (AgencyAndId) object.getPropertyValue(_objFieldName); csvValues.put(_csvFieldName + "_agencyId", id.getAgencyId()); csvValues.put(_csvFieldName + "_id", id.getId()); }
@Override public void translateFromObjectToCSV(CsvEntityContext context, BeanWrapper object, Map<String, Object> csvValues) { AgencyAndId id = (AgencyAndId) object.getPropertyValue(_objFieldName); csvValues.put(_csvFieldName + "_agencyId", id.getAgencyId()); csvValues.put(_csvFieldName + "_id", id.getId()); }
@Override public void translateFromObjectToCSV(CsvEntityContext context, BeanWrapper object, Map<String, Object> csvValues) { if (isMissingAndOptional(object)) return; AgencyAndId id = (AgencyAndId) object.getPropertyValue(_objFieldName); csvValues.put(_csvFieldName, id.getId()); }
public AgencyAndId getShiftedServiceId() { String shiftedId = originalServiceId.getId() + " " + ((dayOffset < 0) ? "-" : "+") + Math.abs(dayOffset); return new AgencyAndId(originalServiceId.getAgencyId(), shiftedId); }
@Override public List<Trip> getTripsForBlockId(AgencyAndId blockId) { String[] names = {"agencyId", "blockId"}; Object[] values = {blockId.getAgencyId(), blockId.getId()}; return _ops.findByNamedQueryAndNamedParams("tripsByBlockId", names, values); }
@Override public List<StopTime> getStopTimesForBlockId(AgencyAndId blockId) { String[] names = {"agencyId", "blockId"}; Object[] values = {blockId.getAgencyId(), blockId.getId()}; return _ops.findByNamedQueryAndNamedParams("stopTimesByBlockId", names, values); }
@Override public String convertStopId(String stopId) { AgencyAndId id = new AgencyAndId(_agencyId, stopId); AgencyAndId newId = _consolidatedStopsService.getConsolidatedStopIdForHiddenStopId(id); if (newId == null) return stopId; return newId.getId(); } }
@SuppressWarnings("unchecked") public void translateFromObjectToCSV(CsvEntityContext context, BeanWrapper object, Map<String, Object> csvValues) { IdentityBean<AgencyAndId> entity = (IdentityBean<AgencyAndId>) object.getPropertyValue(_objFieldName); if (isOptional() && entity == null) return; AgencyAndId id = entity.getId(); csvValues.put(_csvFieldName, id.getId()); }
@SuppressWarnings("unchecked") public void translateFromObjectToCSV(CsvEntityContext context, BeanWrapper object, Map<String, Object> csvValues) { IdentityBean<AgencyAndId> entity = (IdentityBean<AgencyAndId>) object.getPropertyValue(_objFieldName); if (isOptional() && entity == null) return; AgencyAndId id = entity.getId(); csvValues.put(_csvFieldName, id.getId()); }
private <T extends IdentityBean<AgencyAndId>> void bulkRenameAgencyId( Iterable<T> elements, String oldAgencyId, String newAgencyId) { for (T element : elements) { AgencyAndId id = element.getId(); if (id.getAgencyId().equals(oldAgencyId)) { AgencyAndId newId = new AgencyAndId(newAgencyId, id.getId()); element.setId(newId); } } }
private AgencyAndId getRouteCollectionIdForRoute(Route route) { String id = trim(route.getShortName()); // If no short name is supplied, we go back to using the original route id if (id == null || id.length() == 0) id = route.getId().getId(); id = id.replace('/', '_'); id = id.replace('\\', '_'); return new AgencyAndId(route.getId().getAgencyId(), id); }
private AgencyAndId getRouteCollectionIdForRoute(Route route) { String id = trim(route.getShortName()); // If no short name is supplied, we go back to using the original route id if (id == null || id.length() == 0) id = route.getId().getId(); id = id.replace('/', '_'); id = id.replace('\\', '_'); return new AgencyAndId(route.getId().getAgencyId(), id); }
private void loadStifBlocks(StifTripLoader loader) { Map<Trip, RawRunData> rawData = loader.getRawRunDataByTrip(); for (Map.Entry<Trip, RawRunData> entry : rawData.entrySet()) { Trip trip = entry.getKey(); if (trip.getBlockId() == null || trip.getBlockId().length() == 0) { RawRunData data = entry.getValue(); trip.setBlockId(trip.getServiceId().getId() + "_STIF_" + data.getDepotCode() + "_" + data.getBlock()); _gtfsMutableRelationalDao.updateEntity(trip); } } }
@Override public List<Stop> getStopsForStation(Stop station) { String[] names = { "stationId", "agencyId" }; Object[] values = { station.getId().getId(), station.getId().getAgencyId() }; return _ops.findByNamedQueryAndNamedParams("stopsForStation", names, values); }
@Override public void run() { logger.header("gtfs_trips_with_missing_shape_ids.csv", "agency_id,trip_id"); for (Trip trip : _dao.getAllTrips()) { if (trip.getShapeId() == null) { logger.log("gtfs_trips_with_missing_shape_ids.csv", trip.getId().getAgencyId(), trip.getId().getId()); } } }
private void loadStops(Graph graph) { for (Stop stop : _dao.getAllStops()) { graph.addVertex(new TransitStop(id(stop.getId()), stop.getLon(), stop.getLat(), stop.getName(), stop.getId().getId(), stop)); } } /**
private void fillStopBean(StopEntry stop, StopNarrative narrative, StopBean bean) { bean.setId(ApplicationBeanLibrary.getId(stop.getId())); bean.setLat(stop.getStopLat()); bean.setLon(stop.getStopLon()); bean.setName(narrative.getName()); bean.setCode(StringLibrary.getBestName(narrative.getCode(), stop.getId().getId())); bean.setLocationType(narrative.getLocationType()); bean.setDirection(narrative.getDirection()); bean.setWheelchairBoarding(stop.getWheelchairBoarding()); }