-
Notifications
You must be signed in to change notification settings - Fork 113
feat: added support + automated documentation extraction for summary metadata #1974
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
Changes from all commits
fdf2916
ca142aa
1e2e7d7
8c7d6ff
7ade131
1cf3c07
e3cdcf5
3d3da0a
40e9a98
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package org.mobilitydata.gtfsvalidator.reportsummary; | ||
|
|
||
| public class JsonReportAgencyMetadata { | ||
| /** `agency_name` from `agency.txt`. Full name of the transit agency. */ | ||
| private final String name; | ||
|
|
||
| /** `agency_url` from `agency.txt`. URL of the transit agency. */ | ||
| private final String url; | ||
|
|
||
| /** `agency_phone` from `agency.txt`. A voice telephone number for the transit agency. */ | ||
| private final String phone; | ||
|
|
||
| /** | ||
| * `agency_email` from `agency.txt`. Email address actively monitored by the agency’s customer | ||
| * service department. | ||
| */ | ||
| private final String email; | ||
|
|
||
| /** `agency_timezone` from `agency.txt`. Timezone where the transit agency is located. */ | ||
| private final String timezone; | ||
|
|
||
| public JsonReportAgencyMetadata(AgencyMetadata agencyMetadata) { | ||
| name = agencyMetadata.name; | ||
| url = agencyMetadata.url; | ||
| phone = agencyMetadata.phone; | ||
| email = agencyMetadata.email; | ||
| timezone = agencyMetadata.timezone; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| package org.mobilitydata.gtfsvalidator.reportsummary; | ||
|
|
||
| import com.google.gson.annotations.SerializedName; | ||
| import java.util.Map; | ||
|
|
||
| public class JsonReportCounts { | ||
|
|
||
| /* | ||
| * Use these strings as keys in the counts map. Also used to specify the info that will appear in | ||
| * the json report. Adding elements to feedInfo will not automatically be included in the json | ||
| * report and should be explicitly handled in the json report code. | ||
| */ | ||
| public static final String COUNTS_SHAPES = "Shapes"; | ||
| public static final String COUNTS_STOPS = "Stops"; | ||
| public static final String COUNTS_ROUTES = "Routes"; | ||
| public static final String COUNTS_TRIPS = "Trips"; | ||
| public static final String COUNTS_AGENCIES = "Agencies"; | ||
| public static final String COUNTS_BLOCKS = "Blocks"; | ||
|
|
||
| public JsonReportCounts(Map<String, Integer> counts) { | ||
| shapes = counts.get(COUNTS_SHAPES); | ||
| stops = counts.get(COUNTS_STOPS); | ||
| routes = counts.get(COUNTS_ROUTES); | ||
| trips = counts.get(COUNTS_TRIPS); | ||
| agencies = counts.get(COUNTS_AGENCIES); | ||
| blocks = counts.get(COUNTS_BLOCKS); | ||
| } | ||
|
|
||
| /** Number of shapes in `shapes.txt`. */ | ||
| @SerializedName("Shapes") | ||
| Integer shapes; | ||
|
|
||
| /** Number of stops in `stops.txt`. */ | ||
| @SerializedName("Stops") | ||
| Integer stops; | ||
|
|
||
| /** Number of routes in `routes.txt`. */ | ||
| @SerializedName("Routes") | ||
| Integer routes; | ||
|
|
||
| /** Number of trips in `trips.txt`. */ | ||
| @SerializedName("Trips") | ||
| Integer trips; | ||
|
|
||
| /** Number of agencies in `agency.txt`. */ | ||
| @SerializedName("Agencies") | ||
| Integer agencies; | ||
|
|
||
| /** Number of blocks in `blocks.txt`. */ | ||
| @SerializedName("Blocks") | ||
| Integer blocks; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| package org.mobilitydata.gtfsvalidator.reportsummary; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * This class is used as a container of data to be converted to json using the builtin object | ||
| * serialization of GSON. We use this class instead of the Map in FeedMetadata directly because the | ||
| * schema of the resulting json file has to be stable and controlled as it becomes part of the | ||
| * exported API. | ||
| */ | ||
| public class JsonReportFeedInfo { | ||
| /* | ||
| * Use these strings as keys in the FeedInfo map. Also used to specify the info that will appear | ||
| * in the json report. Adding elements to feedInfo will not automatically be included in the json | ||
| * report and should be explicitly handled in the json report code. | ||
| */ | ||
| public static final String FEED_INFO_PUBLISHER_NAME = "Publisher Name"; | ||
| public static final String FEED_INFO_PUBLISHER_URL = "Publisher URL"; | ||
| public static final String FEED_INFO_FEED_CONTACT_EMAIL = "Feed Email"; | ||
| public static final String FEED_INFO_FEED_LANGUAGE = "Feed Language"; | ||
| public static final String FEED_INFO_FEED_START_DATE = "Feed Start Date"; | ||
| public static final String FEED_INFO_FEED_END_DATE = "Feed End Date"; | ||
| public static final String FEED_INFO_SERVICE_WINDOW = "Service Window"; | ||
| public static final String FEED_INFO_SERVICE_WINDOW_START = "Service Window Start"; | ||
| public static final String FEED_INFO_SERVICE_WINDOW_END = "Service Window End"; | ||
|
|
||
| public JsonReportFeedInfo(Map<String, String> feedInfo) { | ||
| publisherName = feedInfo.get(FEED_INFO_PUBLISHER_NAME); | ||
| publisherUrl = feedInfo.get(FEED_INFO_PUBLISHER_URL); | ||
| feedEmail = feedInfo.get(FEED_INFO_FEED_CONTACT_EMAIL); | ||
| feedLanguage = feedInfo.get(FEED_INFO_FEED_LANGUAGE); | ||
| feedStartDate = feedInfo.get(FEED_INFO_FEED_START_DATE); | ||
| feedEndDate = feedInfo.get(FEED_INFO_FEED_END_DATE); | ||
| feedServiceWindowStart = feedInfo.get(FEED_INFO_SERVICE_WINDOW_START); | ||
| feedServiceWindowEnd = feedInfo.get(FEED_INFO_SERVICE_WINDOW_END); | ||
| } | ||
|
|
||
| /** | ||
| * `feed_publisher_name` from `feed_info.txt. Full name of the organization that publishes the | ||
| * dataset. | ||
| */ | ||
| String publisherName; | ||
|
|
||
| /** | ||
| * `feed_publisher_url` from `feed_info.txt`. URL of the dataset publishing organization's | ||
| * website. | ||
| */ | ||
| String publisherUrl; | ||
|
|
||
| /** `feed_lang` from `feed_info.txt`. Default language used for the text in this dataset. */ | ||
| String feedLanguage; | ||
|
|
||
| /** | ||
| * `feed_start_date` from `feed_info.txt`. The dataset provides complete and reliable schedule | ||
| * information for service in the period from the beginning of the `feed_start_date` day to the | ||
| * end of the `feed_end_date` day. | ||
| */ | ||
| String feedStartDate; | ||
|
|
||
| /** `feed_end_date` from `feed_info.txt`. See above. */ | ||
| String feedEndDate; | ||
|
|
||
| /** | ||
| * `feed_contact_email` from `feed_info.txt`. Email address for communication regarding the GTFS | ||
| * dataset and data publishing practices. | ||
| */ | ||
| String feedEmail; | ||
|
|
||
| /** | ||
| * The start date of the service, based on the earliest date referenced in `calendar.txt` or | ||
| * `calendar_dates.txt` that is used by a `trip_id` in `trips.txt`. | ||
| */ | ||
| String feedServiceWindowStart; | ||
|
|
||
| /** | ||
| * The end date of the service, based on the latest date referenced in `calendar.txt` or | ||
| * `calendar_dates.txt` that is used by a `trip_id` in `trips.txt`. | ||
| */ | ||
| String feedServiceWindowEnd; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| package org.mobilitydata.gtfsvalidator.reportsummary; | ||
|
|
||
| import com.google.gson.annotations.SerializedName; | ||
| import java.util.List; | ||
| import java.util.Set; | ||
| import org.mobilitydata.gtfsvalidator.annotation.GtfsReportSummary; | ||
| import org.mobilitydata.gtfsvalidator.performance.MemoryUsage; | ||
|
|
||
| /** | ||
| * Summary of the validation report. Each field in this class needs to be documented with Javadoc. | ||
| */ | ||
| @GtfsReportSummary | ||
| public class JsonReportSummary { | ||
| /** | ||
| * The version of the validator used to produce the report, e.g <a | ||
| * href="https://github.com/MobilityData/gtfs-validator/releases/tag/v6.0.0">6.0</a>. | ||
| */ | ||
| public final String validatorVersion; | ||
|
|
||
| /** Datetime of the validation. */ | ||
| public final String validatedAt; | ||
|
|
||
| /** File or URL used for the validation. */ | ||
| public final String gtfsInput; | ||
|
|
||
| /** Number of threads used for the validation. */ | ||
| public final int threads; | ||
|
|
||
| /** Output directory used to save the validation report. */ | ||
| public final String outputDirectory; | ||
|
|
||
| /** Filename of the report containing system errors generated during validation. */ | ||
| public final String systemErrorsReportName; | ||
|
|
||
| /** Filename of the JSON validation report. */ | ||
| public final String validationReportName; | ||
|
|
||
| /** Filename of the HTML validation report */ | ||
| public final String htmlReportName; | ||
|
|
||
| /** | ||
| * The <a href="https://www.iso.org/iso-3166-country-codes.html">ISO 3166-1 Alpha 2</a> country | ||
| * code for the region input by a validator user before the report is generated. Specifying the | ||
| * region is optional and used to check the `invalid_phone_number` rule. | ||
| */ | ||
| public final String countryCode; | ||
|
|
||
| /** Date of the validation. */ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is the date used for compiling notices related to dates. It can be different from the date the validation was run.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @emmambd for the description. What should it be changed to?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @jcpitre I'm confused how notice compiling time and validation time differ - can you share an example of what this would look like in the CLI?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Merging this PR for now to be able to complete #1964. We can always open a new issue to change the description of this field if necessary 🙂 |
||
| public final String dateForValidation; | ||
|
|
||
| /** Information about the dataset. */ | ||
| public final JsonReportFeedInfo feedInfo; | ||
|
|
||
| /** List of agencies in the feed based on `agency.txt`. */ | ||
| public final List<JsonReportAgencyMetadata> agencies; | ||
|
|
||
| /** List of GTFS files in the feed. */ | ||
| public final Set<String> files; | ||
|
|
||
| /** | ||
| * The time it took to run the validation in seconds. This value is used internally for | ||
| * performance metrics, and it can change in future versions. <a | ||
| * href="https://github.com/MobilityData/gtfs-validator/pull/1963#issuecomment-2635037575" | ||
| * target="_blank">Example of internal use</a>. | ||
| */ | ||
| public final Double validationTimeSeconds; | ||
|
|
||
| /** | ||
| * List of details for the memory usage of the validation. These values are used internally for | ||
| * performance metrics, and it can change in future versions. <a | ||
| * href="https://github.com/MobilityData/gtfs-validator/pull/1963#issuecomment-2635037575" | ||
| * target="_blank">Example of internal use</a>. | ||
| */ | ||
| public final List<MemoryUsage> memoryUsageRecords; | ||
|
|
||
| /** Number of entities in the feed. */ | ||
| @SerializedName("counts") | ||
| public final JsonReportCounts jsonReportCounts; | ||
|
|
||
| /** | ||
| * List of features in the dataset based on https://gtfs.org/getting-started/features/overview/. | ||
| * You can review how the validator detects features <a | ||
| * href="https://github.com/MobilityData/gtfs-validator/blob/577c2ceba1defea965620dc34af4fc9b26a32450/docs/FEATURES.md">here</a>. | ||
| */ | ||
| public final List<String> gtfsFeatures; | ||
|
|
||
| public JsonReportSummary( | ||
| String validatorVersion, | ||
| String validatedAt, | ||
| String gtfsInput, | ||
| int threads, | ||
| String outputDirectory, | ||
| String systemErrorsReportName, | ||
| String validationReportName, | ||
| String htmlReportName, | ||
| String countryCode, | ||
| String dateForValidation, | ||
| JsonReportFeedInfo feedInfo, | ||
| List<JsonReportAgencyMetadata> agencies, | ||
| Set<String> files, | ||
| Double validationTimeSeconds, | ||
| List<MemoryUsage> memoryUsageRecords, | ||
| JsonReportCounts jsonReportCounts, | ||
| List<String> gtfsFeatures) { | ||
| this.validatorVersion = validatorVersion; | ||
| this.validatedAt = validatedAt; | ||
| this.gtfsInput = gtfsInput; | ||
| this.threads = threads; | ||
| this.outputDirectory = outputDirectory; | ||
| this.systemErrorsReportName = systemErrorsReportName; | ||
| this.validationReportName = validationReportName; | ||
| this.htmlReportName = htmlReportName; | ||
| this.countryCode = countryCode; | ||
| this.dateForValidation = dateForValidation; | ||
| this.feedInfo = feedInfo; | ||
| this.agencies = agencies; | ||
| this.files = files; | ||
| this.validationTimeSeconds = validationTimeSeconds; | ||
| this.memoryUsageRecords = memoryUsageRecords; | ||
| this.jsonReportCounts = jsonReportCounts; | ||
| this.gtfsFeatures = gtfsFeatures; | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.