Skip to content

Commit

Permalink
Clean, comment and format
Browse files Browse the repository at this point in the history
  • Loading branch information
enrikomic committed May 3, 2024
1 parent 8d31324 commit 6be06b3
Showing 1 changed file with 11 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,22 @@
*/
package org.onebusaway.gtfs_transformer.impl;

import java.util.HashSet;
import java.util.Set;

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;
import org.onebusaway.gtfs_transformer.util.CalendarFunctions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashSet;
import java.util.Set;

/**
* Remove calendar dates that are past.
*
* remove_today: delete today's calendar dates if true. Default value is true
*/
public class RemoveOldCalendarStatements implements GtfsTransformStrategy {

private final Logger _log = LoggerFactory.getLogger(RemoveOldCalendarStatements.class);

@CsvField(optional = true)
private boolean removeToday = true;

Expand All @@ -53,12 +52,12 @@ public void run(TransformContext transformContext, GtfsMutableRelationalDao gtfs
Set<ServiceCalendar> serviceCalendarsToRemove = new HashSet<ServiceCalendar>();
java.util.Date today = new java.util.Date();

if(!removeToday) {
if (!removeToday) {
today = helper.removeTime(today);
}

for (ServiceCalendar calendar: gtfsMutableRelationalDao.getAllCalendars()) {
if (calendar.getEndDate().getAsDate().before(today)){
for (ServiceCalendar calendar : gtfsMutableRelationalDao.getAllCalendars()) {
if (calendar.getEndDate().getAsDate().before(today)) {
serviceCalendarsToRemove.add(calendar);
}
}
Expand Down

0 comments on commit 6be06b3

Please sign in to comment.