@Override protected void replaceDuplicateEntry(GtfsMergeContext context, Route oldRoute, Route newRoute) { GtfsRelationalDao source = context.getSource(); for (Trip trip : source.getTripsForRoute(oldRoute)) { trip.setRoute(newRoute); } MergeSupport.bulkReplaceValueInProperties(source.getAllFareRules(), oldRoute, newRoute, "route"); } }
@Override protected void replaceDuplicateEntry(GtfsMergeContext context, Route oldRoute, Route newRoute) { GtfsRelationalDao source = context.getSource(); for (Trip trip : source.getTripsForRoute(oldRoute)) { trip.setRoute(newRoute); } MergeSupport.bulkReplaceValueInProperties(source.getAllFareRules(), oldRoute, newRoute, "route"); } }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { Map<Route, Route> shuttleRoutes = new HashMap<>(); for (Trip trip : dao.getAllTrips()) { if (trip.getTripHeadsign().endsWith(SHUTTLE_HEADSIGN_SUFFIX)) { Route shuttleRoute = shuttleRoutes.computeIfAbsent(trip.getRoute(), r -> getShuttleRoute(dao, r)); trip.setRoute(shuttleRoute); dao.updateEntity(trip); } } // Shuttle stops share mta_stop_id with non-shuttle version Map<String, String> parentStopByMtaStopId = new HashMap<>(); for (Stop stop : dao.getAllStops()) { if (!stop.getName().endsWith(SHUTTLE_STOP_SUFFIX) && stop.getParentStation() != null) { parentStopByMtaStopId.put(stop.getMtaStopId(), stop.getParentStation()); } } for (Stop stop : dao.getAllStops()) { if (stop.getName().endsWith(SHUTTLE_STOP_SUFFIX)) { String parent = parentStopByMtaStopId.get(stop.getMtaStopId()); if (parent == null) { _log.info("No parent for shuttle stop {}", stop.getId()); } stop.setParentStation(parent); dao.updateEntity(stop); } } }
@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { RemoveEntityLibrary removeEntityLibrary = new RemoveEntityLibrary(); String agency = dao.getAllTrips().iterator().next().getId().getAgencyId(); //Merge route 5X into route 5, then remove route 5X Route routeFive = dao.getRouteForId(new AgencyAndId(agency, "5")); Route routeFiveX = dao.getRouteForId(new AgencyAndId(agency, "5X")); if (routeFive != null && routeFiveX != null) { for (Trip trip : dao.getTripsForRoute(routeFiveX)) { trip.setRoute(routeFive); } dao.removeEntity(routeFiveX); } } }
routesToRemove.add(route); for (Trip trip : dao.getTripsForRoute(route)) { trip.setRoute(dao.getRouteForId(new AgencyAndId(route.getId().getAgencyId(), refRoute.getId().getId()))); routesToRemove.add(route); for (Trip trip : dao.getTripsForRoute(route)) { trip.setRoute(dao.getRouteForId(new AgencyAndId(route.getId().getAgencyId(), "Q6")));
private Trip createTrip(GtfsMutableRelationalDao dao, Trip referenceTrip, Trip atisTrip) { Trip trip = new Trip(); trip.setRoute(atisTrip.getRoute()); trip.setId(referenceTrip.getId()); trip.setTripHeadsign(atisTrip.getTripHeadsign()); trip.setDirectionId(atisTrip.getDirectionId()); trip.setShapeId(atisTrip.getShapeId()); trip.setPeakOffpeak(atisTrip.getPeakOffpeak()); trip.setMtaTripId(referenceTrip.getId().getId()); dao.saveOrUpdateEntity(trip); //_log.info("Created new trip: {}", trip.getId().getId()); return trip; }