Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #113 - enable implementations of GtfsTransformStrategy to use GTFS extensions #115

Merged
merged 1 commit into from
Jul 14, 2020

Conversation

kurtraschke
Copy link
Contributor

@kurtraschke kurtraschke commented May 6, 2019

Summary:

Fix #113 by adding methods (with empty default implementations) to GtfsTransformStrategy to permit transforms to register extensions (using onebusaway-csv-modules's extensions mechanism) which they will use during reading and/or writing.

Expected behavior:

Implementations of GtfsTransformStrategy can implement one or both of UpdateReadSchema and UpdateWriteSchema to register GTFS extension classes.

Note: There is no deconfliction performed: if multiple transforms are invoked in a single operation, and they register different extensions which use the same column names on the same objects, undefined behavior may result.

Please make sure these boxes are checked before submitting your pull request - thanks!

  • Run the unit tests with mvn test to make sure you didn't break anything
  • Format the title like "Fix #<issue_number> - short description of fix and changes"
  • Linked all relevant issues

…egy to enable transform strategies to add extension classes for reading and/or writing.
@sdjacobs
Copy link
Contributor

Note: There is no deconfliction performed: if multiple transforms are invoked in a single operation, and they register different extensions which use the same column names on the same objects, undefined behavior may result.

I'm noticing that it's also true that if multiple transforms register the same extension, bad behavior results. In particular, the column will be output twice:

stop_id,stop_name,stop_lat,stop_lon,location_type,parent_station,wheelchair_boarding,sample_extension,sample_extension

Personally, I'd prefer to address this issue, rather than leave it to users to decide which transform should declare extensions, if multiple transforms need the same extension. (I'd think this is a common usage pattern: agency X may make use of extension field E, which could be populated in a few different ways by different transforms.)

Something like the following could work in GTFSTransformStrategy:

public List<Pair<Class<? extends HasExtensions>, Class<?>> getDeclaredExtensions();

and then GTFSTransformer could add all extensions to a set before calling DefaultEntitySchemaFactory.addExtension. Thoughts?

@sheldonabrown
Copy link
Member

Thanks @kurtraschke

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

How should GTFS transform strategies interact with extensions?
3 participants