@Override public void run(TransformContext context, GtfsMutableRelationalDao dao) { GtfsMutableRelationalDao reference = (GtfsMutableRelationalDao) context.getReferenceReader().getEntityStore(); RemoveEntityLibrary removeEntityLibrary = new RemoveEntityLibrary(); //trips updated, array of mta_ids that we've updated HashMap<String, Trip> tripsUpdated = new HashMap<>(); //trips to remove, list of trips that have duplicate mta_ids ArrayList<Trip> tripsToRemove = new ArrayList<>(); _log.info("Total dao {}", dao.getAllTrips().size()); _log.info("Stop times: {}" , dao.getAllStopTimes().size()); for (Trip trip : dao.getAllTrips()) { if (trip.getMtaTripId() != null) { if (tripsUpdated.containsKey(trip.getMtaTripId())) { tripsToRemove.add(trip); for (StopTime stopTime : dao.getStopTimesForTrip(trip)){ stopTime.setTrip(tripsUpdated.get(trip.getMtaTripId())); } } else { tripsUpdated.put(trip.getMtaTripId(), trip); trip.setId(new AgencyAndId(trip.getId().getAgencyId(), trip.getMtaTripId())); } } } for (Trip tripToRemove : tripsToRemove) { //removeEntityLibrary.removeTrip(dao, tripToRemove); dao.removeEntity(tripToRemove); } _log.info("Total dao {}", dao.getAllTrips().size()); _log.info("Stop times: {}" , dao.getAllStopTimes().size()); }
mergeToolIdMapping, tripsForKey); if (updatedTripId != null) { tripToKeep.setId(updatedTripId);
newTrip.setId(new AgencyAndId(trip.getId().getAgencyId(), id));
newTrip.setId(new AgencyAndId("1", id)); tripsToAdd.add(newTrip);
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; }