Skip to content

Commit

Permalink
Remove calendar dates (not only calendars)
Browse files Browse the repository at this point in the history
  • Loading branch information
enrikomic committed Dec 6, 2024
1 parent c148b56 commit 3e2ee06
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import org.onebusaway.csv_entities.schema.annotations.CsvField;
import org.onebusaway.gtfs.model.ServiceCalendar;
import org.onebusaway.gtfs.model.ServiceCalendarDate;
import org.onebusaway.gtfs.services.GtfsMutableRelationalDao;
import org.onebusaway.gtfs_transformer.services.GtfsTransformStrategy;
import org.onebusaway.gtfs_transformer.services.TransformContext;
Expand Down Expand Up @@ -64,5 +65,16 @@ public void run(TransformContext transformContext, GtfsMutableRelationalDao gtfs
for (ServiceCalendar serviceCalendar : serviceCalendarsToRemove) {
removeEntityLibrary.removeCalendar(gtfsMutableRelationalDao, serviceCalendar.getServiceId());
}

Set<ServiceCalendarDate> serviceCalendarDatesToRemove = new HashSet<ServiceCalendarDate>();
for (ServiceCalendarDate calendarDate : gtfsMutableRelationalDao.getAllCalendarDates()) {
if (calendarDate.getDate().getAsDate().before(today)) {
serviceCalendarDatesToRemove.add(calendarDate);
}
}
for (ServiceCalendarDate serviceCalendarDate : serviceCalendarDatesToRemove) {
// here we can't delete the trips as the serviceid may be active elsewhere
removeEntityLibrary.removeServiceCalendarDate(gtfsMutableRelationalDao, serviceCalendarDate);
}
}
}

0 comments on commit 3e2ee06

Please sign in to comment.