3636 * This transformation removes non revenue trips from a feed. Establishing trips where _all_ related stop times have
3737 * "no pickup available" or "no continuous stopping pickup". Then remove these stop times and related trips from the
3838 * feed. "Non revenue" stops are kept because the transit ops systems use these in the published feed for all trips.
39+ *
40+ * If the transformation fails for any reason e.g. because of missing fields, the transformation is skipped instead of
41+ * being failed. This allows subsequent transformations to take place and for the import to still succeed.
3942 */
4043public class RemoveNonRevenueTripsTransformation extends ZipTransformation {
4144 private static final Logger LOG = LoggerFactory .getLogger (RemoveNonRevenueTripsTransformation .class );
@@ -60,8 +63,7 @@ public void transform(FeedTransformZipTarget zipTarget, MonitorableJob.Status st
6063 Field [] fieldsFoundInStopTimes = gtfsTable .getFieldsFromFieldHeaders (headersForStopTime , null );
6164 Map <String , Integer > fieldIndexes = getFieldIndexes (fieldsFoundInStopTimes );
6265 if (!hasRequiredFields (fieldIndexes )) {
63- status .error = true ;
64- status .fail ("Unable to remove non revenue trips because the stop times file does not contain all required fields." );
66+ LOG .warn ("Unable to remove non revenue trips because the stop times file does not contain all required fields." );
6567 return ;
6668 }
6769
@@ -76,8 +78,7 @@ public void transform(FeedTransformZipTarget zipTarget, MonitorableJob.Status st
7678 Field [] fieldsFoundInStopTrips = gtfsTable .getFieldsFromFieldHeaders (headersForTrips , null );
7779 int tripIdFieldIndex = getFieldIndex (fieldsFoundInStopTrips , TRIP_ID_FIELD_NAME );
7880 if (tripIdFieldIndex == -1 ) {
79- status .error = true ;
80- status .fail ("Unable to remove non revenue trips because the trips file does not contain the required trip id field." );
81+ LOG .warn ("Unable to remove non revenue trips because the trips file does not contain the required trip id field." );
8182 return ;
8283 }
8384 RevenueData revenueTrips = getAllRevenueTrips (csvReaderForTrips , revenueStopTimes .getStopTimeRows ().keySet (), tripIdFieldIndex );
@@ -101,7 +102,7 @@ public void transform(FeedTransformZipTarget zipTarget, MonitorableJob.Status st
101102 revenueTrips .getDeletedRowCount ()
102103 );
103104 } catch (Exception e ) {
104- status . fail ("Unknown error encountered while attempting to remove non revenue trip from zip file." , e );
105+ LOG . error ("Unknown error encountered while attempting to remove non revenue trip from zip file." , e );
105106 }
106107 }
107108
0 commit comments