├── .dockerignore ├── .github ├── ISSUE_TEMPLATE.md ├── PULL_REQUEST_TEMPLATE.md ├── semantic.yml └── workflows │ ├── docker.yml │ └── test_package.yml ├── .gitignore ├── .mvn ├── custom-settings.xml └── maven.config ├── ADDING_NEW_RULES.md ├── CONFIG.md ├── Dockerfile ├── LICENSE ├── README.md ├── RULES.md ├── TROUBLESHOOTING.md ├── gtfs-realtime-validator-lib ├── .gitignore ├── .mvn │ └── jvm.config ├── LICENSE ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── edu │ │ │ └── usf │ │ │ └── cutr │ │ │ └── gtfsrtvalidator │ │ │ └── lib │ │ │ ├── Main.java │ │ │ ├── batch │ │ │ └── BatchProcessor.java │ │ │ ├── model │ │ │ ├── ErrorMessageModel.java │ │ │ ├── GtfsFeedIterationModel.java │ │ │ ├── GtfsFeedModel.java │ │ │ ├── GtfsRtFeedIterationModel.java │ │ │ ├── GtfsRtFeedIterationString.java │ │ │ ├── GtfsRtFeedModel.java │ │ │ ├── MessageLogModel.java │ │ │ ├── OccurrenceModel.java │ │ │ ├── SessionModel.java │ │ │ ├── ValidationRule.java │ │ │ ├── ViewErrorLogModel.java │ │ │ ├── ViewErrorSummaryModel.java │ │ │ ├── ViewFeedIterationsCount.java │ │ │ ├── ViewFeedMessageModel.java │ │ │ ├── ViewFeedUniqueResponseCount.java │ │ │ ├── ViewGtfsErrorCountModel.java │ │ │ ├── ViewGtfsRtFeedErrorCountModel.java │ │ │ ├── ViewIterationErrorsModel.java │ │ │ ├── ViewMessageDetailsModel.java │ │ │ ├── combined │ │ │ │ ├── CombinedIterationMessageModel.java │ │ │ │ └── CombinedMessageOccurrenceModel.java │ │ │ └── helper │ │ │ │ ├── ErrorListHelperModel.java │ │ │ │ ├── IterationErrorListHelperModel.java │ │ │ │ └── MergeMonitorData.java │ │ │ ├── util │ │ │ ├── GtfsUtils.java │ │ │ ├── RuleUtils.java │ │ │ ├── SortUtils.java │ │ │ └── TimestampUtils.java │ │ │ └── validation │ │ │ ├── GtfsMetadata.java │ │ │ ├── IterationStatistics.java │ │ │ ├── RuleStatistics.java │ │ │ ├── ValidationRules.java │ │ │ ├── gtfs │ │ │ └── StopLocationTypeValidator.java │ │ │ ├── interfaces │ │ │ ├── FeedEntityValidator.java │ │ │ └── GtfsFeedValidator.java │ │ │ └── rules │ │ │ ├── CrossFeedDescriptorValidator.java │ │ │ ├── FrequencyTypeOneValidator.java │ │ │ ├── FrequencyTypeZeroValidator.java │ │ │ ├── HeaderValidator.java │ │ │ ├── StopTimeUpdateValidator.java │ │ │ ├── StopValidator.java │ │ │ ├── TimestampValidator.java │ │ │ ├── TripDescriptorValidator.java │ │ │ └── VehicleValidator.java │ └── resources │ │ └── simplelogger.properties │ └── test │ ├── java │ └── edu │ │ └── usf │ │ └── cutr │ │ └── gtfsrtvalidator │ │ └── lib │ │ └── test │ │ ├── BatchTest.java │ │ ├── FeedMessageTest.java │ │ ├── UtilTest.java │ │ ├── rules │ │ ├── CrossFeedDescriptorValidatorTest.java │ │ ├── FrequencyTypeOneValidatorTest.java │ │ ├── FrequencyTypeZeroValidatorTest.java │ │ ├── HeaderValidatorTest.java │ │ ├── StopLocationTypeValidatorTest.java │ │ ├── StopTimeUpdateValidatorTest.java │ │ ├── StopValidatorTest.java │ │ ├── TimestampValidatorTest.java │ │ ├── TripDescriptorValidatorTest.java │ │ └── VehicleValidatorTest.java │ │ └── util │ │ └── TestUtils.java │ └── resources │ ├── .gitignore │ ├── TripUpdates-2017-02-18T20-00-08Z.txt │ ├── TripUpdates-2017-02-18T20-00-23Z.txt │ ├── TripUpdates-2017-02-18T20-01-08Z.txt │ ├── VehiclePositions-2017-02-18T20-01-08Z.txt │ ├── badgtfs.zip │ ├── bullrunner-gtfs-no-shapes.zip │ ├── bullrunner-gtfs-timepoints-only-legacy-exact-times-1.zip │ ├── bullrunner-gtfs.zip │ ├── bullrunner-vehicle-positions │ ├── testSQLScript.sql │ ├── testagency.zip │ └── testagency2.zip ├── gtfs-realtime-validator-webapp ├── .gitignore ├── .mvn │ └── jvm.config ├── LICENSE ├── README.md ├── pom.xml └── src │ ├── main │ ├── java │ │ └── edu │ │ │ └── usf │ │ │ └── cutr │ │ │ └── gtfsrtvalidator │ │ │ ├── Main.java │ │ │ ├── api │ │ │ └── resource │ │ │ │ ├── GtfsFeed.java │ │ │ │ └── GtfsRtFeed.java │ │ │ ├── background │ │ │ └── BackgroundTask.java │ │ │ ├── db │ │ │ └── GTFSDB.java │ │ │ ├── helper │ │ │ ├── DBHelper.java │ │ │ ├── HttpMessageHelper.java │ │ │ ├── QueryHelper.java │ │ │ └── ServiceScheduler.java │ │ │ ├── hibernate │ │ │ └── HibernateUtil.java │ │ │ ├── servlets │ │ │ └── GetFeedJSON.java │ │ │ └── util │ │ │ ├── FileUtil.java │ │ │ └── ProtoBufUtils.java │ └── resources │ │ ├── hibernate.cfg.xml │ │ ├── simplelogger.properties │ │ └── webroot │ │ ├── css │ │ ├── bootstrap-table.css │ │ ├── bootstrap-theme.css │ │ ├── bootstrap-theme.css.map │ │ ├── bootstrap-theme.min.css │ │ ├── bootstrap-toggle.min.css │ │ ├── bootstrap.css │ │ ├── bootstrap.css.map │ │ ├── bootstrap.min.css │ │ ├── jquery.bs_pagination.min.css │ │ └── style.css │ │ ├── custom-js │ │ ├── error.js │ │ ├── index.js │ │ ├── iteration.js │ │ ├── loading.js │ │ ├── monitoring.js │ │ └── session-monitor.js │ │ ├── detailed.html │ │ ├── error.html │ │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.svg │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ │ ├── index.html │ │ ├── iteration.html │ │ ├── js │ │ ├── bootstrap-table.js │ │ ├── bootstrap-toggle.min.js │ │ ├── bootstrap.min.js │ │ ├── clipboard.min.js │ │ ├── detail_table.js │ │ ├── detail_table_sample_data.js │ │ ├── en.min.js │ │ ├── filesaver.min.js │ │ ├── handlebars.js │ │ ├── jquery-2.1.4.min.js │ │ ├── jquery-highlight1.js │ │ ├── jquery.bs_pagination.min.js │ │ ├── jquery.flot.js │ │ ├── jquery.highlight.js │ │ ├── jsonpath-0.8.0.js │ │ └── tableexport.js │ │ ├── loading.html │ │ ├── monitoring.html │ │ ├── session-monitor.html │ │ └── swagger.yaml │ └── test │ ├── java │ └── edu │ │ └── usf │ │ └── cutr │ │ └── gtfsrtvalidator │ │ ├── api │ │ └── resource │ │ │ └── GtfsFeedTest.java │ │ └── test │ │ └── queries │ │ └── QueryTest.java │ └── resources │ ├── TripUpdates-2017-02-18T20-00-08Z.txt │ ├── TripUpdates-2017-02-18T20-00-23Z.txt │ ├── TripUpdates-2017-02-18T20-01-08Z.txt │ ├── VehiclePositions-2017-02-18T20-01-08Z.txt │ ├── badgtfs.zip │ ├── bullrunner-gtfs-no-shapes.zip │ ├── bullrunner-gtfs-timepoints-only-legacy-exact-times-1.zip │ ├── bullrunner-gtfs.zip │ ├── bullrunner-vehicle-positions │ ├── testSQLScript.sql │ ├── testagency.zip │ └── testagency2.zip └── pom.xml /.dockerignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .idea/ 3 | 4 | target/ 5 | **/target/ 6 | pom.xml.tag 7 | pom.xml.releaseBackup 8 | pom.xml.versionsBackup 9 | pom.xml.next 10 | release.properties 11 | dependency-reduced-pom.xml 12 | buildNumber.properties 13 | .mvn/timing.properties 14 | *.swp 15 | *.log 16 | *~ 17 | 18 | *.db 19 | .travis.yml 20 | .github/ -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **Summary:** 2 | 3 | Summarize your issue in one sentence (what goes wrong, what did you expect to happen) 4 | 5 | **Steps to reproduce:** 6 | 7 | How can we reproduce the issue? 8 | 9 | **Expected behavior:** 10 | 11 | What did you expect the application to do? 12 | 13 | **Observed behavior:** 14 | 15 | What happened instead? Describe your issue in detail here. 16 | 17 | **Platform:** 18 | 19 | What is the operating system and Java version of your machine? What browser (Chrome, Internet Explorer, Firefox)did you use? 20 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | **Summary:** 2 | 3 | Summarize the changes in the pull request including how it relates to any issues (include the #number, or link them). 4 | 5 | **Expected behavior:** 6 | 7 | Explain and/or show screenshots for how you expect the pull request to work in your testing (in case other devices exhibit different behavior). 8 | 9 | 10 | Please make sure these boxes are checked before submitting your pull request - thanks! 11 | 12 | - [ ] Run the unit tests with `mvn test` to make sure you didn't break anything 13 | - [ ] Format the title like "feat: {new feature short description}" or "fix: {describe what was fixed}". Title must follow the Conventional Commit Specification (https://www.conventionalcommits.org/en/v1.0.0/). 14 | - [ ] Linked all relevant issues 15 | - [ ] Include screenshot(s) showing how this pull request works and fixes the issue(s) 16 | -------------------------------------------------------------------------------- /.github/semantic.yml: -------------------------------------------------------------------------------- 1 | #============================================================================================================ 2 | # This file contains configuration for https://github.com/zeke/semantic-pull-requests 3 | #============================================================================================================ 4 | 5 | # Always validate the PR title, and ignore the commits 6 | titleOnly: true 7 | -------------------------------------------------------------------------------- /.github/workflows/docker.yml: -------------------------------------------------------------------------------- 1 | name: Docker image 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | release: 7 | types: [ prereleased, released ] 8 | 9 | jobs: 10 | test: 11 | runs-on: ubuntu-latest 12 | steps: 13 | - uses: actions/checkout@v2 14 | - name: Set up JDK 11 15 | uses: actions/setup-java@v2 16 | with: 17 | java-version: '11' 18 | distribution: 'temurin' 19 | cache: maven 20 | - name: Run Java tests 21 | run: mvn test 22 | - name: Persist Java tests reports 23 | if: always() 24 | uses: actions/upload-artifact@v4 25 | with: 26 | name: Test reports 27 | path: | 28 | gtfs-realtime-validator-lib/target/surefire-reports 29 | gtfs-realtime-validator-webapp/target/surefire-reports 30 | build_push: 31 | needs: test 32 | name: Build and push Docker image 33 | runs-on: ubuntu-latest 34 | steps: 35 | - uses: actions/checkout@v2 36 | - name: Prepare 37 | id: prep 38 | run: | 39 | DOCKER_IMAGE=ghcr.io/mobilitydata/gtfs-realtime-validator 40 | VERSION=edge 41 | if [[ $GITHUB_REF == refs/tags/* ]]; then 42 | VERSION=${GITHUB_REF#refs/tags/} 43 | elif [[ $GITHUB_REF == refs/heads/* ]]; then 44 | VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') 45 | elif [[ $GITHUB_REF == refs/pull/* ]]; then 46 | VERSION=pr-${{ github.event.number }} 47 | fi 48 | TAGS="${DOCKER_IMAGE}:${VERSION}" 49 | if [ "${{ github.event_name }}" = "push" ]; then 50 | TAGS="${DOCKER_IMAGE}:latest" 51 | fi 52 | echo "version=${VERSION}" >> $GITHUB_OUTPUT 53 | echo "tags=${TAGS}" >> $GITHUB_OUTPUT 54 | echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_OUTPUT 55 | - name: Set up JDK 11 56 | uses: actions/setup-java@v2 57 | with: 58 | java-version: '11' 59 | distribution: 'temurin' 60 | cache: maven 61 | - name: Package lib and webapp JARs with Maven 62 | run: mvn package 63 | - name: Set up Docker Buildx 64 | uses: docker/setup-buildx-action@v1 65 | - name: Login to GitHub Container Registry 66 | uses: docker/login-action@v1 67 | with: 68 | registry: ghcr.io 69 | username: ${{ github.repository_owner }} 70 | password: ${{ secrets.GITHUB_TOKEN }} 71 | - name: Build and push 72 | uses: docker/build-push-action@v2 73 | with: 74 | context: . 75 | file: ./Dockerfile 76 | push: true 77 | tags: ${{ steps.prep.outputs.tags }} 78 | labels: | 79 | org.opencontainers.image.source=https://github.com/mobilitydata/gtfs-realtime-validator.git 80 | org.opencontainers.image.created=${{ steps.prep.outputs.created }} 81 | org.opencontainers.image.revision=${{ github.sha }} 82 | # should be org.opencontainers.image.source=${{ github.event.repository.clone_url }} but caps in MobilityData seem to break something 83 | -------------------------------------------------------------------------------- /.github/workflows/test_package.yml: -------------------------------------------------------------------------------- 1 | # This workflow will test and build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven 3 | 4 | name: Test and Package 5 | 6 | on: 7 | push: 8 | branches: [ master ] 9 | paths-ignore: 10 | - '**.md' 11 | pull_request: 12 | branches: [ master ] 13 | paths-ignore: 14 | - '**.md' 15 | release: 16 | types: [ prereleased, released ] 17 | 18 | jobs: 19 | test: 20 | runs-on: ubuntu-latest 21 | steps: 22 | - uses: actions/checkout@v2 23 | - name: Set up JDK 11 24 | uses: actions/setup-java@v2 25 | with: 26 | java-version: '11' 27 | distribution: 'temurin' 28 | cache: maven 29 | - name: Run Java tests 30 | run: mvn --batch-mode --update-snapshots test 31 | - name: Persist Java tests reports 32 | if: always() 33 | uses: actions/upload-artifact@v4 34 | with: 35 | name: Test reports 36 | path: | 37 | gtfs-realtime-validator-lib/target/surefire-reports 38 | gtfs-realtime-validator-webapp/target/surefire-reports 39 | package: 40 | needs: [test] 41 | runs-on: ubuntu-latest 42 | steps: 43 | - uses: actions/checkout@v2 44 | - name: Set up JDK 11 45 | uses: actions/setup-java@v2 46 | with: 47 | java-version: '11' 48 | distribution: 'temurin' 49 | cache: maven 50 | - name: Deploy to Github Package Registry 51 | if: github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.os == 'ubuntu-latest' 52 | env: 53 | GITHUB_ACTOR: ${{ github.actor }} 54 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 55 | run: mvn --batch-mode --update-snapshots deploy -DskipTests -DGITHUB_REPOSITORY=$GITHUB_REPOSITORY 56 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .idea/ 3 | 4 | target/ 5 | **/target/ 6 | pom.xml.tag 7 | pom.xml.releaseBackup 8 | pom.xml.versionsBackup 9 | pom.xml.next 10 | release.properties 11 | dependency-reduced-pom.xml 12 | buildNumber.properties 13 | .mvn/timing.properties 14 | *.swp 15 | *.log 16 | *~ 17 | 18 | *.db -------------------------------------------------------------------------------- /.mvn/custom-settings.xml: -------------------------------------------------------------------------------- 1 | 4 | 5 | 6 | 7 | conveyal-snapshots-mvn-repo-mirror 8 | conveyal-snapshots-mvn-repo 9 | Snapshots build.staging.obanyc.com 10 | http://build.staging.obanyc.com/archiva/repository/snapshots/ 11 | false 12 | 13 | 14 | conveyal-releases-mvn-repo-mirror 15 | conveyal-releases-mvn-repo 16 | Releases build.staging.obanyc.com 17 | http://build.staging.obanyc.com/archiva/repository/releases/ 18 | false 19 | 20 | 21 | 22 | 23 | github 24 | ${env.GITHUB_ACTOR} 25 | ${env.GITHUB_TOKEN} 26 | 27 | 28 | -------------------------------------------------------------------------------- /.mvn/maven.config: -------------------------------------------------------------------------------- 1 | --settings ./.mvn/custom-settings.xml -------------------------------------------------------------------------------- /CONFIG.md: -------------------------------------------------------------------------------- 1 | ## Configuration options 2 | 3 | #### Port number 4 | 5 | In server mode, port `8080` is used by default. If you'd like to change the port number (e.g., port `80`), you can use the command line parameter `-port 80`: 6 | 7 | `java -jar target/gtfs-realtime-validator-webapp-1.0.0-SNAPSHOT.jar -port 80` 8 | 9 | #### Database 10 | 11 | We use [Hibernate](http://hibernate.org/) to manage data persistence to a database. To allow you to get the tool up and running quickly, we use the embedded [HSQLDB](http://hsqldb.org/) by default. This is not recommended for a production deployment. 12 | 13 | Hibernate configuration can be changed in [`src/main/resources/hibernate.cfg.xml`](https://github.com/CUTR-at-USF/gtfs-realtime-validator/blob/master/src/main/resources/hibernate.cfg.xml) to store data in any relational database. You might want to check out the following resources for getting started: 14 | 15 | * [MySQL](https://docs.jboss.org/hibernate/orm/3.3/reference/en-US/html/session-configuration.html#configuration-xmlconfig) 16 | * [PostgreSQL](http://stackoverflow.com/a/16572156/937715) 17 | * [Microsoft SQL Server](http://stackoverflow.com/a/3588652/937715) 18 | * [Oracle](https://docs.oracle.com/cd/E11035_01/workshop102/ormworkbench/hibernate-tutorial/tutHibernate9.html) 19 | 20 | A list of all the dialect properties for specific database versions is shown [here](http://www.tutorialspoint.com/hibernate/hibernate_configuration.htm). 21 | 22 | #### Logging 23 | 24 | If you'd like to change the logging level, for example to see all debug statements, in `src/main/resources/simplelogger.properties` change the following line to say `DEBUG`: 25 | 26 | ~~~ 27 | org.slf4j.simpleLogger.defaultLogLevel=DEBUG 28 | ~~~ 29 | 30 | `DEBUG` level will show the output for all rule validation in the log. 31 | 32 | `WARN` will show a smaller number of informational messages. 33 | 34 | #### Batch processing 35 | 36 | We support a command-line batch processing mode for archived GTFS Realtime files. See the [**gtfs-realtime-validator-lib** README](gtfs-realtime-validator-lib/README.md) page for details, including command-line configuration options for the batch processing mode. -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM maven:3.8.5-jdk-11-slim AS build 2 | 3 | WORKDIR /build 4 | COPY ./ . 5 | RUN mvn package 6 | 7 | FROM openjdk:11 AS final 8 | EXPOSE 8080 9 | ENTRYPOINT ["java", "-Djsee.enableSNIExtension=false", "-jar", "gtfs-realtime-validator-webapp-1.0.0-SNAPSHOT.jar"] 10 | CMD [] 11 | WORKDIR /app 12 | COPY --from=build /build/gtfs-realtime-validator-webapp/target/ . 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2015-2019 Nipuna Gunathilake, University of South Florida 2 | All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | -------------------------------------------------------------------------------- /TROUBLESHOOTING.md: -------------------------------------------------------------------------------- 1 | # Troubleshooting 2 | 3 | Things not going well? See if your problem is one that we've encountered before. 4 | 5 | ### Java 9 compatibility - `NoClassDefFoundError: javax/xml/bind/JAXBException` when running project 6 | 7 | *Symptom* - I try to run the application using Java 9, but I get an error message (e.g., `NoClassDefFoundError`) about missing modules 8 | 9 | *Solution* - Java 9 changes to a modular architecture, which means that you need to tell Java to load certain modules required by the project. 10 | 11 | Try including the `java.xml.bind` module with the `--add-modules` parameter: 12 | 13 | `java -Djsee.enableSNIExtension=false --add-modules java.xml.bind -jar gtfs-realtime-validator-webapp/target/gtfs-realtime-validator-webapp-1.0.0-SNAPSHOT.jar` 14 | 15 | ### SSL handshake still fails after following [prerequisites](https://github.com/CUTR-at-USF/gtfs-realtime-validator#prerequisites-1) 16 | 17 | *Symptom* - I use `java -Djsee.enableSNIExtension=false ...` as instructed to run the app when retrieving GTFS or GTFS Realtime feeds from HTTPS URLs over SSL, but it fails with an error like `javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: No subject alternative DNS name matching www.donneesquebec.ca found.` 18 | 19 | *Solution* - The underlying problem is probably with the server certificate configuration where the GTFS or GTFS Realtime data is hosted. You can try to change the parameter to `-Djsse.enableSNIExtension=true` instead, which has helped [in the past](https://github.com/CUTR-at-USF/gtfs-realtime-validator/pull/310) for Linux deployments. 20 | 21 | ### `java.lang.OutOfMemoryError: Java heap space` when running project 22 | 23 | *Symptom* - I try to run the application on a dataset and I get an error that looks like: 24 | 25 | ``` 26 | [main] INFO edu.usf.cutr.gtfsrtvalidator.lib.batch.BatchProcessor - Starting batch processor... 27 | [main] INFO edu.usf.cutr.gtfsrtvalidator.lib.batch.BatchProcessor - Reading GTFS data from /tmp/validation_165096_gtfs_rt/file.zip... 28 | [main] INFO edu.usf.cutr.gtfsrtvalidator.lib.batch.BatchProcessor - file.zip read in 16.145 seconds 29 | [main] INFO edu.usf.cutr.gtfsrtvalidator.lib.validation.GtfsMetadata - Building GtfsMetadata for /tmp/validation_165096_gtfs_rt/file.zip... 30 | [main] INFO edu.usf.cutr.gtfsrtvalidator.lib.validation.GtfsMetadata - Processing trips and building trip shapes for /tmp/validation_165096_gtfs_rt/file.zip... 31 | Exception in thread \"main\" java.lang.OutOfMemoryError: Java heap space 32 | at org.locationtech.spatial4j.shape.jts.JtsShapeFactory$CoordinatesAccumulator.pointXYZ(JtsShapeFactory.java:316) 33 | at org.locationtech.spatial4j.shape.jts.JtsShapeFactory$CoordinatesAccumulator.pointXY(JtsShapeFactory.java:310) 34 | at org.locationtech.spatial4j.shape.jts.JtsShapeFactory$JtsLineStringBuilder.pointXY(JtsShapeFactory.java:228) 35 | at edu.usf.cutr.gtfsrtvalidator.lib.validation.GtfsMetadata.(GtfsMetadata.java:184) 36 | at edu.usf.cutr.gtfsrtvalidator.lib.batch.BatchProcessor.processFeeds(BatchProcessor.java:145) 37 | at edu.usf.cutr.gtfsrtvalidator.lib.Main.main(Main.java:62)" 38 | ``` 39 | 40 | *Solution* - Typically you can fix a `java.lang.OutOfMemoryError: Java heap space` by increasing the heap size using the following command-line parameters when running the batch validator: 41 | 42 | ``` 43 | java ... -Xmx512m -XX:MaxMetaspaceSize=512m 44 | ``` 45 | 46 | See [this StackOverflow post](https://stackoverflow.com/a/38336005/937715) for more details. 47 | 48 | If you can't allocate more memory to the batch validator, note that you can typically avoid OOM errors on larger feeds by ignoring the rules that process shapes.txt file by adding the command line parameter: 49 | 50 | `-ignoreShapes yes` 51 | 52 | Note that setting this to true will prevent the validator from checking rules like E029 that require spatial data. 53 | 54 | See the [batch processor command-line parameters](https://github.com/MobilityData/gtfs-realtime-validator/blob/master/gtfs-realtime-validator-lib/README.md#command-line-config-parameters) for details. 55 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .idea/ 3 | 4 | target/ 5 | **/target/ 6 | pom.xml.tag 7 | pom.xml.releaseBackup 8 | pom.xml.versionsBackup 9 | pom.xml.next 10 | release.properties 11 | dependency-reduced-pom.xml 12 | buildNumber.properties 13 | .mvn/timing.properties 14 | *.swp 15 | *.log 16 | *~ 17 | 18 | *.db -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -Xmx4G -Xms1G -Djava.awt.headless=true 2 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2015-2017 Nipuna Gunathilake, University of South Florida 2 | All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/ErrorMessageModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model; 19 | 20 | import javax.xml.bind.annotation.XmlRootElement; 21 | 22 | @XmlRootElement 23 | public class ErrorMessageModel { 24 | private String title; 25 | private String message; 26 | 27 | public ErrorMessageModel(){} 28 | 29 | public ErrorMessageModel(String errorMessage) { 30 | setMessage(errorMessage); 31 | } 32 | 33 | public ErrorMessageModel(String title, String message) { 34 | this.title = title; 35 | this.message = message; 36 | } 37 | 38 | public String getMessage() { 39 | return message; 40 | } 41 | 42 | public void setMessage(String message) { 43 | this.message = message; 44 | } 45 | 46 | public String getTitle() { 47 | return title; 48 | } 49 | 50 | public void setTitle(String title) { 51 | this.title = title; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/GtfsFeedIterationModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model; 19 | 20 | import javax.persistence.*; 21 | import javax.xml.bind.annotation.XmlRootElement; 22 | import java.io.Serializable; 23 | 24 | @XmlRootElement 25 | @Entity 26 | @Table(name="GtfsFeedIteration") 27 | public class GtfsFeedIterationModel implements Serializable { 28 | 29 | public GtfsFeedIterationModel() {} 30 | 31 | @Id 32 | @Column(name="IterationID") 33 | @GeneratedValue(strategy=GenerationType.IDENTITY) 34 | private int IterationId; 35 | @Column(name="IterationTimestamp") 36 | private long timeStamp; 37 | @ManyToOne 38 | @JoinColumn(name = "feedID") 39 | private GtfsFeedModel gtfsFeedModel; 40 | 41 | public GtfsFeedModel getGtfsFeedModel() { 42 | return gtfsFeedModel; 43 | } 44 | 45 | public void setGtfsFeedModel(GtfsFeedModel gtfsFeedModel) { 46 | this.gtfsFeedModel = gtfsFeedModel; 47 | } 48 | 49 | public int getIterationId() { 50 | return IterationId; 51 | } 52 | 53 | public void setIterationId(int iterationId) { 54 | IterationId = iterationId; 55 | } 56 | 57 | public long getTimeStamp() { 58 | return timeStamp; 59 | } 60 | 61 | public void setTimeStamp(long timeStamp) { 62 | this.timeStamp = timeStamp; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/GtfsFeedModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model; 19 | 20 | import javax.persistence.*; 21 | import javax.xml.bind.annotation.XmlRootElement; 22 | import java.io.Serializable; 23 | 24 | @XmlRootElement 25 | @Entity 26 | @Table(name = "GtfsFeed") 27 | public class GtfsFeedModel implements Serializable { 28 | 29 | @Column(name="feedUrl") 30 | private String gtfsUrl; 31 | @Id 32 | @GeneratedValue(strategy=GenerationType.IDENTITY) 33 | @Column(name="feedID") 34 | private int feedId; 35 | @Column(name="downloadTimestamp") 36 | private long startTime; 37 | @Column(name="fileLocation") 38 | private String feedLocation; 39 | @Column(name = "agency") 40 | private String agency; 41 | @Column(name="fileChecksum") 42 | @Lob 43 | private byte[] checksum; 44 | @Column(name = "errorCount") 45 | private int errorCount; 46 | 47 | public GtfsFeedModel(){} 48 | 49 | public String getGtfsUrl() { 50 | return gtfsUrl; 51 | } 52 | 53 | public void setGtfsUrl(String gtfsUrl) { 54 | this.gtfsUrl = gtfsUrl; 55 | } 56 | 57 | public int getFeedId() { 58 | return feedId; 59 | } 60 | 61 | public void setFeedId(int feedId) { 62 | this.feedId = feedId; 63 | } 64 | 65 | public long getStartTime() { 66 | return startTime; 67 | } 68 | 69 | public byte[] getChecksum() { 70 | return checksum; 71 | } 72 | 73 | public void setStartTime(long startTime) { 74 | this.startTime = startTime; 75 | } 76 | 77 | public String getFeedLocation() { 78 | return feedLocation; 79 | } 80 | 81 | public void setFeedLocation(String feedLocation) { 82 | this.feedLocation = feedLocation; 83 | } 84 | 85 | public String getAgency() { 86 | return agency; 87 | } 88 | 89 | public void setAgency(String agency) { 90 | this.agency = agency; 91 | } 92 | 93 | public void setChecksum(byte[] checksum) { 94 | this.checksum = checksum; 95 | } 96 | 97 | public int getErrorCount() { 98 | return errorCount; 99 | } 100 | 101 | public void setErrorCount(int errorCount) { 102 | this.errorCount = errorCount; 103 | } 104 | 105 | @Override 106 | public String toString() { 107 | return "GtfsFeedModel{" + 108 | "gtfsUrl='" + gtfsUrl + '\'' + 109 | ", feedId=" + feedId + 110 | ", startTime=" + startTime + 111 | ", feedLocation='" + feedLocation + '\'' + 112 | ", checkSum=" + checksum + 113 | ", errorCount=" + errorCount + 114 | '}'; 115 | } 116 | } 117 | 118 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/GtfsRtFeedIterationModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model; 19 | 20 | import javax.persistence.*; 21 | import javax.xml.bind.annotation.XmlRootElement; 22 | import java.io.Serializable; 23 | 24 | @XmlRootElement 25 | @Entity 26 | @Table(name = "GtfsRtFeedIteration") 27 | public class GtfsRtFeedIterationModel implements Serializable { 28 | 29 | public GtfsRtFeedIterationModel() {} 30 | 31 | public GtfsRtFeedIterationModel(long timeStamp, long feedTimestamp, byte[] feedprotobuf, GtfsRtFeedModel gtfsRtFeedModel, byte[] feedHash) { 32 | this.timeStamp = timeStamp; 33 | this.feedTimestamp = feedTimestamp; 34 | this.feedprotobuf = feedprotobuf; 35 | this.gtfsRtFeedModel = gtfsRtFeedModel; 36 | this.feedHash = feedHash; 37 | } 38 | 39 | @Id 40 | @Column(name="IterationID") 41 | @GeneratedValue(strategy=GenerationType.IDENTITY) 42 | private int IterationId; 43 | @Column(name="IterationTimestamp") 44 | private long timeStamp; 45 | @Column(name = "feedTimestamp") 46 | private long feedTimestamp; 47 | @Column(name="feedProtobuf") 48 | @Lob 49 | private byte[] feedprotobuf; 50 | @ManyToOne 51 | @JoinColumn(name = "rtFeedID") 52 | private GtfsRtFeedModel gtfsRtFeedModel; 53 | @Column(name = "feedHash") 54 | private byte[] feedHash; 55 | 56 | /* 57 | * '@Transient' does not persist 'dateFormat' to the database i.e., 'dateFormat' is not added as a column in this table. 58 | * If 'dateFormat' is set, it contains the date format representation of 'feedTimestamp'. 59 | */ 60 | @Transient 61 | private String dateFormat; 62 | 63 | public GtfsRtFeedModel getGtfsRtFeedModel() { 64 | return gtfsRtFeedModel; 65 | } 66 | 67 | public void setGtfsRtFeedModel(GtfsRtFeedModel gtfsRtFeedModel) { 68 | this.gtfsRtFeedModel = gtfsRtFeedModel; 69 | } 70 | 71 | public int getIterationId() { 72 | return IterationId; 73 | } 74 | 75 | public void setIterationId(int iterationId) { 76 | IterationId = iterationId; 77 | } 78 | 79 | public long getTimeStamp() { 80 | return timeStamp; 81 | } 82 | 83 | public void setTimeStamp(long timeStamp) { 84 | this.timeStamp = timeStamp; 85 | } 86 | 87 | public long getFeedTimestamp() { 88 | return feedTimestamp; 89 | } 90 | 91 | public void setFeedTimestamp(long feedTimestamp) { 92 | this.feedTimestamp = feedTimestamp; 93 | } 94 | 95 | public byte[] getFeedprotobuf() { 96 | return feedprotobuf; 97 | } 98 | 99 | public void setFeedprotobuf(byte[] feedprotobuf) { 100 | this.feedprotobuf = feedprotobuf; 101 | } 102 | 103 | public byte[] getFeedHash() { 104 | return feedHash; 105 | } 106 | 107 | public void setFeedHash(byte[] feedHash) { 108 | this.feedHash = feedHash; 109 | } 110 | 111 | public String getDateFormat() { 112 | return dateFormat; 113 | } 114 | 115 | public void setDateFormat(String dateFormat) { 116 | this.dateFormat = dateFormat; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/GtfsRtFeedIterationString.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model; 19 | 20 | import com.google.protobuf.InvalidProtocolBufferException; 21 | import com.google.transit.realtime.GtfsRealtime; 22 | import com.googlecode.protobuf.format.JsonFormat; 23 | 24 | import javax.xml.bind.annotation.XmlElement; 25 | import javax.xml.bind.annotation.XmlRootElement; 26 | 27 | @XmlRootElement 28 | public class GtfsRtFeedIterationString { 29 | 30 | public GtfsRtFeedIterationString(GtfsRtFeedIterationModel iterationModel) { 31 | setFeedprotobuf(iterationModel.getFeedprotobuf()); 32 | setTimeStamp(iterationModel.getTimeStamp()); 33 | setIterationId(iterationModel.getIterationId()); 34 | setRtFeedId(iterationModel.getGtfsRtFeedModel().getGtfsRtId()); 35 | } 36 | 37 | private int IterationId; 38 | private long timeStamp; 39 | private String feedprotobuf; 40 | private int rtFeedId; 41 | 42 | @XmlElement 43 | public int getRtFeedId() { 44 | return rtFeedId; 45 | } 46 | 47 | public void setRtFeedId(int rtFeedId) { 48 | this.rtFeedId = rtFeedId; 49 | } 50 | 51 | @XmlElement 52 | public int getIterationId() { 53 | return IterationId; 54 | } 55 | 56 | public void setIterationId(int iterationId) { 57 | IterationId = iterationId; 58 | } 59 | 60 | @XmlElement 61 | public long getTimeStamp() { 62 | return timeStamp; 63 | } 64 | 65 | public void setTimeStamp(long timeStamp) { 66 | this.timeStamp = timeStamp; 67 | } 68 | 69 | @XmlElement 70 | public String getFeedprotobuf() { 71 | return feedprotobuf; 72 | } 73 | 74 | public void setFeedprotobuf(byte[] feedprotobuf) { 75 | String s = ""; 76 | 77 | if (feedprotobuf == null) { 78 | return; 79 | } 80 | 81 | try { 82 | GtfsRealtime.FeedMessage feedMessage = GtfsRealtime.FeedMessage.parseFrom(feedprotobuf); 83 | s = JsonFormat.printToString(feedMessage); 84 | s.replace('\\', ' '); 85 | } catch (InvalidProtocolBufferException e) { 86 | e.printStackTrace(); 87 | } 88 | 89 | this.feedprotobuf = s; 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/GtfsRtFeedModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model; 19 | 20 | import javax.persistence.*; 21 | import javax.xml.bind.annotation.XmlRootElement; 22 | import java.io.Serializable; 23 | 24 | @XmlRootElement 25 | @Entity 26 | @Table(name = "GtfsRtFeed") 27 | public class GtfsRtFeedModel implements Serializable { 28 | 29 | @Column(name="feedURL") 30 | private String gtfsRtUrl; 31 | @ManyToOne 32 | @JoinColumn(name = "gtfsFeedID") 33 | private GtfsFeedModel gtfsFeedModel; 34 | @Id 35 | @GeneratedValue(strategy=GenerationType.IDENTITY) 36 | @Column(name="rtFeedID") 37 | private int gtfsRtId; 38 | @Transient 39 | private boolean enableShapes; 40 | 41 | public GtfsRtFeedModel(){} 42 | 43 | public String getGtfsRtUrl () { 44 | return gtfsRtUrl; 45 | } 46 | 47 | public void setGtfsRtUrl (String gtfsRtUrl) { 48 | this.gtfsRtUrl = gtfsRtUrl; 49 | } 50 | 51 | public GtfsFeedModel getGtfsFeedModel() { 52 | return gtfsFeedModel; 53 | } 54 | 55 | public void setGtfsFeedModel(GtfsFeedModel gtfsFeedModel) { 56 | this.gtfsFeedModel = gtfsFeedModel; 57 | } 58 | 59 | public int getGtfsRtId() { 60 | return gtfsRtId; 61 | } 62 | 63 | public void setGtfsRtId(int gtfsRtId) { 64 | this.gtfsRtId = gtfsRtId; 65 | } 66 | 67 | public boolean getEnableShapes() { 68 | return enableShapes; 69 | } 70 | 71 | public void setEnableShapes (boolean enableShapes) { 72 | this.enableShapes = enableShapes; 73 | } 74 | 75 | @Override 76 | public String toString() { 77 | return "GtfsRtFeedModel{" + 78 | "gtfsRtUrl='" + gtfsRtUrl + '\'' + 79 | ", gtfsId=" + gtfsFeedModel.getFeedId() + 80 | ", gtfsRtId=" + gtfsRtId + 81 | ", enableShapes=" + enableShapes + 82 | '}'; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/MessageLogModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model; 19 | 20 | import javax.persistence.*; 21 | import javax.xml.bind.annotation.XmlRootElement; 22 | import java.io.Serializable; 23 | 24 | @XmlRootElement 25 | @Entity 26 | @Table(name="MessageLog") 27 | public class MessageLogModel implements Serializable { 28 | 29 | public MessageLogModel(){}; 30 | 31 | public MessageLogModel(ValidationRule validationRule) { 32 | this.setValidationRule(validationRule); 33 | } 34 | 35 | @Id 36 | @Column(name="messageID") 37 | @GeneratedValue(strategy=GenerationType.IDENTITY) 38 | private int messageId; 39 | @ManyToOne 40 | @JoinColumn(name = "iterationID") 41 | private GtfsRtFeedIterationModel gtfsRtFeedIterationModel; 42 | @ManyToOne 43 | @JoinColumn(name = "errorID") 44 | private ValidationRule validationRule; 45 | @Column(name = "errorDetails") 46 | private String errorDetails; 47 | 48 | public int getMessageId() { 49 | return messageId; 50 | } 51 | 52 | public void setMessageId(int messageId) { 53 | this.messageId = messageId; 54 | } 55 | 56 | public GtfsRtFeedIterationModel getGtfsRtFeedIterationModel() { 57 | return gtfsRtFeedIterationModel; 58 | } 59 | 60 | public void setGtfsRtFeedIterationModel(GtfsRtFeedIterationModel gtfsRtFeedIterationModel) { 61 | this.gtfsRtFeedIterationModel = gtfsRtFeedIterationModel; 62 | } 63 | 64 | public ValidationRule getValidationRule() { 65 | return validationRule; 66 | } 67 | 68 | public void setValidationRule(ValidationRule validationRule) { 69 | this.validationRule = validationRule; 70 | } 71 | 72 | public String getErrorDetails() { 73 | return errorDetails; 74 | } 75 | 76 | public void setErrorDetails(String errorDetails) { 77 | this.errorDetails = errorDetails; 78 | } 79 | } -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/OccurrenceModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model; 19 | 20 | import javax.persistence.*; 21 | import javax.xml.bind.annotation.XmlRootElement; 22 | import java.io.Serializable; 23 | 24 | @XmlRootElement 25 | @Entity 26 | @Table(name="Occurrence") 27 | public class OccurrenceModel implements Serializable { 28 | 29 | public OccurrenceModel(String prefix) { 30 | this.prefix = prefix; 31 | } 32 | 33 | public OccurrenceModel() { 34 | } 35 | 36 | @Id 37 | @Column(name="occurrenceID") 38 | @GeneratedValue(strategy=GenerationType.IDENTITY) 39 | private int occurrenceId; 40 | 41 | @ManyToOne 42 | @JoinColumn(name = "messageID") 43 | private MessageLogModel messageLogModel; 44 | 45 | /** 46 | * This is used along with ValidationRule.occurrenceSuffix to create a description of this occurrence of an error/warning. 47 | *

48 | * For example, for E004 "GTFS-rt trip_ids must appear in GTFS data", the error message we want to show the user could be 49 | * "trip_id 6234 doesn't appear in the GTFS data" 50 | *

51 | * For this message, the prefix would be: 52 | * "trip_id 6234" 53 | *

54 | * And the second part of the text (stored in ValidationRule.occurrenceSuffix) would be: 55 | * "doesn't appear in the GTFS data" 56 | * 57 | * @see ValidationRule 58 | */ 59 | @Column(name = "prefix", length = 1000) 60 | private String prefix; 61 | 62 | public int getOccurrenceId() { 63 | return occurrenceId; 64 | } 65 | 66 | public void setOccurrenceId(int occurrenceId) { 67 | this.occurrenceId = occurrenceId; 68 | } 69 | 70 | public MessageLogModel getMessageLogModel() { 71 | return messageLogModel; 72 | } 73 | 74 | public void setMessageLogModel(MessageLogModel messageLogModel) { 75 | this.messageLogModel = messageLogModel; 76 | } 77 | 78 | public String getPrefix() { 79 | return prefix; 80 | } 81 | 82 | public void setPrefix(String prefix) { 83 | this.prefix = prefix; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/SessionModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 University of South Florida. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model; 19 | 20 | import javax.persistence.*; 21 | import javax.xml.bind.annotation.XmlRootElement; 22 | import java.io.Serializable; 23 | 24 | @XmlRootElement 25 | @Entity 26 | @Table(name = "Session") 27 | public class SessionModel implements Serializable { 28 | 29 | @Id 30 | @GeneratedValue(strategy=GenerationType.IDENTITY) 31 | @Column(name = "sessionId") 32 | private int sessionId; 33 | 34 | @ManyToOne 35 | @JoinColumn(name = "rtFeedId") 36 | private GtfsRtFeedModel gtfsRtFeedModel; 37 | 38 | @Column(name = "startTime") 39 | private long sessionStartTime; 40 | 41 | @Column(name = "endTime") 42 | private long sessionEndTime; 43 | 44 | @Column(name = "clientId") 45 | private String clientId; 46 | 47 | @Column(name = "errorCount") 48 | private int errorCount = 0; 49 | 50 | @Column(name = "warningCount") 51 | private int warningCount = 0; 52 | 53 | // To retrieve records sequentially starting from 1 54 | @Transient 55 | private int rowId; 56 | 57 | // Holds the required date format of 'sessionStartTime' 58 | @Transient 59 | private String startTimeFormat; 60 | 61 | // Holds the required date format of 'sessionEndTime' 62 | @Transient 63 | private String endTimeFormat; 64 | 65 | // Holds the elapsed time(in Xh Xm Xs format) from start of a session to end of a session 66 | @Transient 67 | private String totalTime; 68 | 69 | public int getSessionId() { 70 | return sessionId; 71 | } 72 | 73 | public void setSessionId(int sessionId) { 74 | this.sessionId = sessionId; 75 | } 76 | 77 | public GtfsRtFeedModel getGtfsRtFeedModel() { 78 | return gtfsRtFeedModel; 79 | } 80 | 81 | public void setGtfsRtFeedModel(GtfsRtFeedModel gtfsRtFeedModel) { 82 | this.gtfsRtFeedModel = gtfsRtFeedModel; 83 | } 84 | 85 | public long getSessionStartTime() { 86 | return sessionStartTime; 87 | } 88 | 89 | public void setSessionStartTime(long sessionStartTime) { 90 | this.sessionStartTime = sessionStartTime; 91 | } 92 | 93 | public long getSessionEndTime() { 94 | return sessionEndTime; 95 | } 96 | 97 | public void setSessionEndTime(long sessionEndTime) { 98 | this.sessionEndTime = sessionEndTime; 99 | } 100 | 101 | public String getClientId() { 102 | return clientId; 103 | } 104 | 105 | public void setClientId(String clientId) { 106 | this.clientId = clientId; 107 | } 108 | 109 | public String getStartTimeFormat() { 110 | return startTimeFormat; 111 | } 112 | 113 | public void setStartTimeFormat(String startTimeFormat) { 114 | this.startTimeFormat = startTimeFormat; 115 | } 116 | 117 | public String getEndTimeFormat() { 118 | return endTimeFormat; 119 | } 120 | 121 | public void setEndTimeFormat(String endTimeFormat) { 122 | this.endTimeFormat = endTimeFormat; 123 | } 124 | 125 | public String getTotalTime() { 126 | return totalTime; 127 | } 128 | 129 | public void setTotalTime(String totalTime) { 130 | this.totalTime = totalTime; 131 | } 132 | 133 | public int getErrorCount() { 134 | return errorCount; 135 | } 136 | 137 | public void setErrorCount(int errorCount) { 138 | this.errorCount = errorCount; 139 | } 140 | 141 | public int getWarningCount() { 142 | return warningCount; 143 | } 144 | 145 | public void setWarningCount(int warningCount) { 146 | this.warningCount = warningCount; 147 | } 148 | 149 | public int getRowId() { 150 | return rowId; 151 | } 152 | 153 | public void setRowId(int rowId) { 154 | this.rowId = rowId; 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/ValidationRule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model; 19 | 20 | import org.hibernate.annotations.Type; 21 | 22 | import javax.persistence.Column; 23 | import javax.persistence.Entity; 24 | import javax.persistence.Id; 25 | import javax.persistence.Table; 26 | import javax.xml.bind.annotation.XmlRootElement; 27 | import java.io.Serializable; 28 | 29 | @XmlRootElement 30 | @Entity 31 | @Table(name = "Error") 32 | public class ValidationRule implements Serializable { 33 | 34 | @Id 35 | @Column(name="errorID") 36 | private String errorId; 37 | 38 | @Column(name = "severity") 39 | private String severity; 40 | 41 | @Column(name = "title") 42 | @Type(type = "text") 43 | private String title; 44 | 45 | @Column(name="errorDescription") 46 | @Type(type = "text") 47 | private String errorDescription; 48 | 49 | /** 50 | * Text used to help describe an occurrence of this warning/error following the specific elements that it relates to. 51 | *

52 | * For example, for E004 "GTFS-rt trip_ids must appear in GTFS data", the error message we want to show the user could be 53 | * * "trip_id 6234 doesn't appear in the GTFS data" 54 | *

55 | * For this message, the occurenceSuffix would be: 56 | * * "doesn't appear in the GTFS data" 57 | *

58 | * And the first part of the text (stored in OccurrenceModel.prefix) would be: 59 | * * "trip_id 6234" 60 | * 61 | * @see OccurrenceModel 62 | */ 63 | @Column(name = "occurrenceSuffix") 64 | @Type(type = "text") 65 | private String occurrenceSuffix; 66 | 67 | public ValidationRule() { 68 | } 69 | 70 | public ValidationRule(String errorId, String severity, String title, String errorDescription, String occurrenceSuffix) { 71 | this.setErrorId(errorId); 72 | this.setSeverity(severity); 73 | this.setTitle(title); 74 | this.setErrorDescription(errorDescription); 75 | this.setOccurrenceSuffix(occurrenceSuffix); 76 | } 77 | 78 | public String getErrorDescription() { 79 | return errorDescription; 80 | } 81 | 82 | public void setErrorDescription(String errorDescription) { 83 | this.errorDescription = errorDescription; 84 | } 85 | 86 | public String getErrorId() { 87 | return errorId; 88 | } 89 | 90 | public void setErrorId(String errorId) { 91 | this.errorId = errorId; 92 | } 93 | 94 | public String getSeverity() { 95 | return severity; 96 | } 97 | 98 | public void setSeverity(String errorType) { 99 | this.severity = errorType; 100 | } 101 | 102 | public String getTitle() { 103 | return title; 104 | } 105 | 106 | public void setTitle(String title) { 107 | this.title = title; 108 | } 109 | 110 | public String getOccurrenceSuffix() { 111 | return occurrenceSuffix; 112 | } 113 | 114 | public void setOccurrenceSuffix(String occurenceSuffix) { 115 | this.occurrenceSuffix = occurenceSuffix; 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/ViewFeedIterationsCount.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 University of South Florida. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model; 19 | 20 | import javax.persistence.Column; 21 | import javax.persistence.Entity; 22 | import javax.persistence.Id; 23 | import javax.persistence.NamedNativeQuery; 24 | import javax.xml.bind.annotation.XmlRootElement; 25 | 26 | @XmlRootElement 27 | @Entity 28 | @NamedNativeQuery(name = "feedIterationsCount", 29 | query = "SELECT count(IterationID) AS iterationCount " + 30 | "FROM GtfsRtFeedIteration " + 31 | "WHERE rtFeedID = :gtfsRtId " + 32 | "AND IterationTimestamp >= :sessionStartTime AND IterationTimestamp <= :sessionEndTime ", 33 | resultClass = ViewFeedIterationsCount.class) 34 | public class ViewFeedIterationsCount { 35 | 36 | @Id 37 | @Column(name = "iterationCount") 38 | private int iterationCount; 39 | 40 | public int getIterationCount() { 41 | return iterationCount; 42 | } 43 | 44 | public void setIterationCount(int iterationCount) { 45 | this.iterationCount = iterationCount; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/ViewFeedMessageModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 University of South Florida. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package edu.usf.cutr.gtfsrtvalidator.lib.model; 18 | 19 | import com.google.transit.realtime.GtfsRealtime; 20 | import com.googlecode.protobuf.format.JsonFormat; 21 | 22 | import javax.persistence.*; 23 | import javax.xml.bind.annotation.XmlRootElement; 24 | import java.io.ByteArrayInputStream; 25 | import java.io.IOException; 26 | import java.io.InputStream; 27 | 28 | @XmlRootElement 29 | @Entity 30 | @NamedNativeQueries ({ 31 | @NamedNativeQuery (name = "feedMessageByIterationId", 32 | query = "SELECT feedProtobuf AS feedMessage " + 33 | "FROM GtfsRtFeedIteration " + 34 | "WHERE IterationID = :iterationId ", 35 | resultClass = ViewFeedMessageModel.class), 36 | @NamedNativeQuery (name = "feedMessageByGtfsRtId", 37 | query = "SELECT feedProtobuf AS feedMessage " + 38 | "FROM GtfsRtFeedIteration " + 39 | "WHERE rtFeedId = :gtfsRtId ORDER BY IterationTimestamp DESC", 40 | resultClass = ViewFeedMessageModel.class) 41 | }) 42 | public class ViewFeedMessageModel { 43 | 44 | @Id 45 | @Column(name = "feedMessage") 46 | private byte[] byteFeedMessage; 47 | 48 | @Transient 49 | String jsonFeedMessage; 50 | 51 | public byte[] getByteFeedMessage() { 52 | return byteFeedMessage; 53 | } 54 | 55 | public void setByteFeedMessage(byte[] byteFeedMessage) { 56 | this.byteFeedMessage = byteFeedMessage; 57 | } 58 | 59 | public String getJsonFeedMessage() { 60 | return jsonFeedMessage; 61 | } 62 | 63 | public void setJsonFeedMessage(byte[] byteFeedMessage) { 64 | InputStream is = new ByteArrayInputStream(byteFeedMessage); 65 | GtfsRealtime.FeedMessage feedMessage = null; 66 | try { 67 | feedMessage = GtfsRealtime.FeedMessage.parseFrom(is); 68 | } catch (IOException e) { 69 | e.printStackTrace(); 70 | } 71 | this.jsonFeedMessage = JsonFormat.printToString(feedMessage); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/ViewFeedUniqueResponseCount.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 University of South Florida. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model; 19 | 20 | import javax.persistence.Column; 21 | import javax.persistence.Entity; 22 | import javax.persistence.Id; 23 | import javax.persistence.NamedNativeQuery; 24 | import javax.xml.bind.annotation.XmlRootElement; 25 | 26 | @XmlRootElement 27 | @Entity 28 | @NamedNativeQuery(name = "feedUniqueResponseCount", 29 | query = "SELECT count(*) AS uniqueFeedCount " + 30 | "FROM GtfsRtFeedIteration " + 31 | "WHERE (rtFeedID = :gtfsRtId " + 32 | "AND IterationTimestamp >= :sessionStartTime AND IterationTimestamp <= :sessionEndTime " + 33 | "AND feedProtobuf IS NOT NULL) ", 34 | resultClass = ViewFeedUniqueResponseCount.class) 35 | public class ViewFeedUniqueResponseCount { 36 | 37 | @Id 38 | @Column(name = "uniqueFeedCount") 39 | private int uniqueFeedCount; 40 | 41 | public int getUniqueFeedCount() { 42 | return uniqueFeedCount; 43 | } 44 | 45 | public void setUniqueFeedCount(int uniqueFeedCount) { 46 | this.uniqueFeedCount = uniqueFeedCount; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/ViewGtfsErrorCountModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model; 19 | 20 | import javax.annotation.concurrent.Immutable; 21 | import javax.persistence.Column; 22 | import javax.persistence.Entity; 23 | import javax.persistence.Id; 24 | import javax.persistence.NamedNativeQuery; 25 | import javax.xml.bind.annotation.XmlRootElement; 26 | import java.io.Serializable; 27 | 28 | @XmlRootElement 29 | @Entity 30 | @Immutable 31 | @NamedNativeQuery(name = "GtfsErrorCountByID", 32 | query="SELECT * FROM (GtfsMessageLog JOIN GtfsOccurrence ON GtfsMessageLog.messageID = GtfsOccurrence.messageID JOIN Error ON Error.errorID = GtfsMessageLog.errorID)", 33 | resultClass = ViewGtfsErrorCountModel.class) 34 | public class ViewGtfsErrorCountModel implements Serializable { 35 | public static final Integer MESSAGE_ID = 0; 36 | public static final Integer ITERATION_ID = 0; 37 | public static final String ERROR_ID = "errorID"; 38 | public static final String ERROR_DESC = "errorDescription"; 39 | public static final String FEED_URL = "feedUrl"; 40 | public static final String FILE_LOCATION = "fileLocation"; 41 | public static final String DOWNLOAD_TIME = "downloadTimestamp"; 42 | public static final String ERROR_COUNT = "errorCount"; 43 | 44 | @Column(name="messageID") 45 | private int messageId; 46 | @Id 47 | @Column(name="iterationID") 48 | private int iterationId; 49 | @Column(name="errorID") 50 | private String errorId; 51 | @Column(name="errorDescription") 52 | private String errorDesc; 53 | @Column(name="feedURL") 54 | private String feedUrl; 55 | @Column(name="fileLocation") 56 | private String fileLocation; 57 | @Column(name="downloadTimestamp") 58 | private long downloadTime; 59 | @Column(name="errorCount") 60 | private int errorCount; 61 | 62 | public int getMessageId() { 63 | return messageId; 64 | } 65 | 66 | public void setMessageId(int messageId) { 67 | this.messageId = messageId; 68 | } 69 | 70 | public int getIterationId() { 71 | return iterationId; 72 | } 73 | 74 | public void setIterationId(int iterationId) { 75 | this.iterationId = iterationId; 76 | } 77 | 78 | public String getErrorId() { 79 | return errorId; 80 | } 81 | 82 | public void setErrorId(String errorId) { 83 | this.errorId = errorId; 84 | } 85 | 86 | public String getErrorDesc() { 87 | return errorDesc; 88 | } 89 | 90 | public void setErrorDesc(String errorDesc) { 91 | this.errorDesc = errorDesc; 92 | } 93 | 94 | public String getFeedUrl() { 95 | return feedUrl; 96 | } 97 | 98 | public void setFeedUrl(String feedUrl) { 99 | this.feedUrl = feedUrl; 100 | } 101 | 102 | public String getFileLocation() { 103 | return fileLocation; 104 | } 105 | 106 | public void setFileLocation(String fileLocation) { 107 | this.fileLocation = fileLocation; 108 | } 109 | 110 | public long getDownloadTime() { 111 | return downloadTime; 112 | } 113 | 114 | public void setDownloadTime(long downloadTime) { 115 | this.downloadTime = downloadTime; 116 | } 117 | 118 | public int getErrorCount() { 119 | return errorCount; 120 | } 121 | 122 | public void setErrorCount(int errorCount) { 123 | this.errorCount = errorCount; 124 | } 125 | 126 | @Override 127 | public String toString() { 128 | return "ViewGtfsErrorCountModel{" + 129 | "messageId=" + messageId + 130 | ", iterationId=" + iterationId + 131 | ", errorId='" + errorId + '\'' + 132 | ", errorDesc='" + errorDesc + '\'' + 133 | ", feedUrl='" + feedUrl + '\'' + 134 | ", fileLocation='" + fileLocation + '\'' + 135 | ", downloadTime=" + downloadTime + 136 | ", errorCount=" + errorCount + 137 | '}'; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/ViewGtfsRtFeedErrorCountModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 University of South Florida. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model; 19 | 20 | import javax.persistence.Column; 21 | import javax.persistence.Entity; 22 | import javax.persistence.Id; 23 | import javax.persistence.NamedNativeQuery; 24 | import javax.xml.bind.annotation.XmlRootElement; 25 | 26 | @XmlRootElement 27 | @Entity 28 | @NamedNativeQuery(name = "feedErrorCount", 29 | query = "SELECT Error.errorID AS id, errorCount.totalCount " + 30 | "FROM Error " + 31 | "INNER JOIN " + 32 | "(SELECT errorID, count(*) AS totalCount, " + 33 | "MAX(IterationTimestamp) AS IterationTimestamp, " + 34 | "MAX(IterationID) AS lastIterationId " + 35 | "FROM MessageLog " + 36 | "INNER JOIN " + 37 | "(SELECT IterationID, IterationTimestamp " + 38 | "FROM GtfsRtFeedIteration " + 39 | "WHERE rtFeedID = :gtfsRtId) GtfsRtFeedIDIteration " + 40 | "ON MessageLog.iterationID = GtfsRtFeedIDIteration.IterationID " + 41 | "AND IterationTimestamp >= :sessionStartTime AND IterationTimestamp <= :sessionEndTime " + 42 | "GROUP BY errorID) errorCount " + 43 | "ON Error.errorID = errorCount.errorID ", 44 | resultClass = ViewGtfsRtFeedErrorCountModel.class) 45 | public class ViewGtfsRtFeedErrorCountModel { 46 | 47 | @Id 48 | @Column(name = "id") 49 | private String id; 50 | @Column(name = "totalCount") 51 | private int count; 52 | 53 | public String getId() { 54 | return id; 55 | } 56 | 57 | public void setId(String id) { 58 | this.id = id; 59 | } 60 | 61 | public int getCount() { 62 | return count; 63 | } 64 | 65 | public void setCount(int count) { 66 | this.count = count; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/ViewIterationErrorsModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 University of South Florida. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package edu.usf.cutr.gtfsrtvalidator.lib.model; 18 | 19 | import javax.persistence.Column; 20 | import javax.persistence.Entity; 21 | import javax.persistence.Id; 22 | import javax.persistence.NamedNativeQuery; 23 | import javax.xml.bind.annotation.XmlRootElement; 24 | 25 | @XmlRootElement 26 | @Entity 27 | @NamedNativeQuery(name = "IterationIdErrors", 28 | query = "SELECT ROWNUM() AS rowId, occurrenceId, " + 29 | "errorId, title, occurrencePrefix, occurrenceSuffix " + 30 | "FROM Error " + 31 | "INNER JOIN " + 32 | "(SELECT messageId, errorId, prefix AS occurrencePrefix, occurrenceId " + 33 | "FROM " + 34 | "Occurrence " + 35 | "INNER JOIN " + 36 | "(SELECT messageId, errorId " + 37 | "FROM MessageLog " + 38 | "WHERE iterationId = :iterationId) MessageLogIteration " + 39 | "ON Occurrence.messageId = MessageLogIteration.messageId " + 40 | "WHERE messageId = :messageId ) OccurrenceList " + 41 | "ON Error.errorId = OccurrenceList.errorId " + 42 | "ORDER BY occurrenceId ", 43 | resultClass = ViewIterationErrorsModel.class) 44 | public class ViewIterationErrorsModel { 45 | 46 | @Id 47 | @Column(name = "rowId") 48 | private int rowId; 49 | 50 | @Column(name = "occurrenceId") 51 | private int occurrenceId; 52 | 53 | @Column(name = "errorId") 54 | private String errorId; 55 | 56 | // Title of issue/warning from Error table matching errorId 57 | @Column(name = "title") 58 | private String title; 59 | 60 | // prefix of issue/warning from Occurrence table 61 | @Column(name = "occurrencePrefix") 62 | private String occurrencePrefix; 63 | 64 | @Column(name = "occurrenceSuffix") 65 | private String occurrenceSuffix; 66 | 67 | public int getRowId() { 68 | return rowId; 69 | } 70 | 71 | public void setRowId(int rowId) { 72 | this.rowId = rowId; 73 | } 74 | 75 | public int getOccurrenceId() { 76 | return occurrenceId; 77 | } 78 | 79 | public void setOccurrenceId(int occurrenceId) { 80 | this.occurrenceId = occurrenceId; 81 | } 82 | 83 | public String getErrorId() { 84 | return errorId; 85 | } 86 | 87 | public void setErrorId(String errorId) { 88 | this.errorId = errorId; 89 | } 90 | 91 | public String getTitle() { 92 | return title; 93 | } 94 | 95 | public void setTitle(String title) { 96 | this.title = title; 97 | } 98 | 99 | public String getOccurrencePrefix() { 100 | return occurrencePrefix; 101 | } 102 | 103 | public void setOccurrencePrefix(String occurrencePrefix) { 104 | this.occurrencePrefix = occurrencePrefix; 105 | } 106 | 107 | public String getOccurrenceSuffix() { 108 | return occurrenceSuffix; 109 | } 110 | 111 | public void setOccurrenceSuffix(String occurrenceSuffix) { 112 | this.occurrenceSuffix = occurrenceSuffix; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/ViewMessageDetailsModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model; 19 | 20 | import javax.annotation.concurrent.Immutable; 21 | import javax.persistence.Column; 22 | import javax.persistence.Entity; 23 | import javax.persistence.Id; 24 | import javax.xml.bind.annotation.XmlRootElement; 25 | import java.io.Serializable; 26 | import java.util.Arrays; 27 | 28 | @XmlRootElement 29 | @Entity 30 | @Immutable 31 | public class ViewMessageDetailsModel implements Serializable { 32 | public static final String FEED_PROTOCOL_BUFFER = "feedProtobuf"; 33 | public static final String MESSAGE_ID = "messageId"; 34 | public static final String ITERATION_ID = "iterationId"; 35 | public static final String ERROR_ID = "errorId"; 36 | public static final String ERROR_DESC = "errorDescription"; 37 | public static final String OCCURRENCE_ID = "occurrenceId"; 38 | public static final String ELEMENT_PATH = "elementPath"; 39 | public static final String ELEMENT_VALUE = "elementValue"; 40 | 41 | @Column(name="feedProtobuf") 42 | private byte[] feedProtobuf; 43 | @Column(name="messageID") 44 | private int messageId; 45 | @Id 46 | @Column(name="IterationID") 47 | private int iterationId; 48 | @Column(name="errorID") 49 | private String errorId; 50 | @Column(name="errorDescription") 51 | private String errorDescription; 52 | @Column(name="occurrenceID") 53 | private int occurrenceId; 54 | @Column(name="elementPath") 55 | private String elementPath; 56 | @Column(name="elementValue") 57 | private String elementValue; 58 | 59 | public int getMessageId() { 60 | return messageId; 61 | } 62 | 63 | public void setMessageId(int messageId) { 64 | this.messageId = messageId; 65 | } 66 | 67 | public int getIterationId() { 68 | return iterationId; 69 | } 70 | 71 | public void setIterationId(int iterationId) { 72 | this.iterationId = iterationId; 73 | } 74 | 75 | public String getErrorId() { 76 | return errorId; 77 | } 78 | 79 | public void setErrorId(String errorId) { 80 | this.errorId = errorId; 81 | } 82 | 83 | public String getErrorDescription() { 84 | return errorDescription; 85 | } 86 | 87 | public void setErrorDescription(String errorDescription) { 88 | this.errorDescription = errorDescription; 89 | } 90 | 91 | public int getOccurrenceId() { 92 | return occurrenceId; 93 | } 94 | 95 | public void setOccurrenceId(int occurrenceId) { 96 | this.occurrenceId = occurrenceId; 97 | } 98 | 99 | public String getElementPath() { 100 | return elementPath; 101 | } 102 | 103 | public void setElementPath(String elementPath) { 104 | this.elementPath = elementPath; 105 | } 106 | 107 | public String getElementValue() { 108 | return elementValue; 109 | } 110 | 111 | public void setElementValue(String elementValue) { 112 | this.elementValue = elementValue; 113 | } 114 | 115 | public byte[] getFeedProtobuf() { 116 | return feedProtobuf; 117 | } 118 | 119 | public void setFeedProtobuf(byte[] feedProtobuf) { 120 | this.feedProtobuf = feedProtobuf; 121 | } 122 | 123 | @Override 124 | public String toString() { 125 | return "MessageDetailsModel{" + 126 | "feedProtobuf=" + Arrays.toString(feedProtobuf) + 127 | ", messageId=" + messageId + 128 | ", iterationId=" + iterationId + 129 | ", errorId='" + errorId + '\'' + 130 | ", errorDescription='" + errorDescription + '\'' + 131 | ", occurrenceId=" + occurrenceId + 132 | ", elementPath='" + elementPath + '\'' + 133 | ", elementValue='" + elementValue + '\'' + 134 | '}'; 135 | } 136 | } 137 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/combined/CombinedIterationMessageModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model.combined; 19 | 20 | import edu.usf.cutr.gtfsrtvalidator.lib.model.GtfsRtFeedIterationString; 21 | 22 | import javax.xml.bind.annotation.XmlRootElement; 23 | import java.util.List; 24 | 25 | @XmlRootElement 26 | public class CombinedIterationMessageModel { 27 | 28 | public CombinedIterationMessageModel() {} 29 | 30 | private GtfsRtFeedIterationString gtfsFeedIterationModel; 31 | private List messageOccurrenceList; 32 | 33 | public GtfsRtFeedIterationString getGtfsFeedIterationModel() { 34 | return gtfsFeedIterationModel; 35 | } 36 | 37 | public void setGtfsFeedIterationModel(GtfsRtFeedIterationString gtfsFeedIterationModel) { 38 | this.gtfsFeedIterationModel = gtfsFeedIterationModel; 39 | } 40 | 41 | public List getMessageOccurrenceList() { 42 | return messageOccurrenceList; 43 | } 44 | 45 | public void setMessageOccurrenceList(List messageOccurrenceList) { 46 | this.messageOccurrenceList = messageOccurrenceList; 47 | } 48 | 49 | @Override 50 | public String toString() { 51 | return "IterationMessageModel{" + 52 | "gtfsFeedIterationModel=" + gtfsFeedIterationModel + 53 | ", messageOccurrenceList=" + messageOccurrenceList + 54 | '}'; 55 | } 56 | } 57 | 58 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/combined/CombinedMessageOccurrenceModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model.combined; 19 | 20 | import edu.usf.cutr.gtfsrtvalidator.lib.model.MessageLogModel; 21 | import edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel; 22 | 23 | import javax.xml.bind.annotation.XmlRootElement; 24 | import java.util.ArrayList; 25 | import java.util.List; 26 | 27 | @XmlRootElement 28 | public class CombinedMessageOccurrenceModel { 29 | MessageLogModel messageLogModel = new MessageLogModel(); 30 | List occurrenceModels = new ArrayList<>(); 31 | 32 | public MessageLogModel getMessageLogModel() { 33 | return messageLogModel; 34 | } 35 | 36 | public void setMessageLogModel(MessageLogModel messageLogModel) { 37 | this.messageLogModel = messageLogModel; 38 | } 39 | 40 | public List getOccurrenceModels() { 41 | return occurrenceModels; 42 | } 43 | 44 | public void setOccurrenceModels(List occurrenceModels) { 45 | this.occurrenceModels = occurrenceModels; 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return "MessageOccurenceModel{" + 51 | "messageLogModel=" + messageLogModel + 52 | ", occurrenceModels=" + occurrenceModels + 53 | '}'; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/helper/ErrorListHelperModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.model.helper; 19 | 20 | import edu.usf.cutr.gtfsrtvalidator.lib.model.MessageLogModel; 21 | import edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel; 22 | 23 | import java.util.List; 24 | 25 | public class ErrorListHelperModel { 26 | private MessageLogModel errorMessage; 27 | private List occurrenceList; 28 | 29 | public ErrorListHelperModel(){} 30 | 31 | public ErrorListHelperModel(MessageLogModel errorMessage, List occurrenceList) { 32 | this.errorMessage = errorMessage; 33 | this.occurrenceList = occurrenceList; 34 | } 35 | 36 | public MessageLogModel getErrorMessage() { 37 | return errorMessage; 38 | } 39 | 40 | public void setErrorMessage(MessageLogModel errorMessage) { 41 | this.errorMessage = errorMessage; 42 | } 43 | 44 | public List getOccurrenceList() { 45 | return occurrenceList; 46 | } 47 | 48 | public void setOccurrenceList(List occurrenceList) { 49 | this.occurrenceList = occurrenceList; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/helper/IterationErrorListHelperModel.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 University of South Florida. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package edu.usf.cutr.gtfsrtvalidator.lib.model.helper; 18 | 19 | import edu.usf.cutr.gtfsrtvalidator.lib.model.ViewIterationErrorsModel; 20 | 21 | import java.util.ArrayList; 22 | import java.util.List; 23 | 24 | public class IterationErrorListHelperModel { 25 | 26 | private List viewIterationErrorsModelList; 27 | private String errorId; 28 | private String title; 29 | private int errorOccurrences; 30 | 31 | public IterationErrorListHelperModel() { 32 | this.viewIterationErrorsModelList = new ArrayList<>(); 33 | } 34 | 35 | public List getViewIterationErrorsModelList() { 36 | return viewIterationErrorsModelList; 37 | } 38 | 39 | public void setViewIterationErrorsModelList(List viewIterationErrorsModelList) { 40 | this.viewIterationErrorsModelList = viewIterationErrorsModelList; 41 | } 42 | 43 | public String getErrorId() { 44 | return errorId; 45 | } 46 | 47 | public void setErrorId(String errorId) { 48 | this.errorId = errorId; 49 | } 50 | 51 | public String getTitle() { 52 | return title; 53 | } 54 | 55 | public void setTitle(String title) { 56 | this.title = title; 57 | } 58 | 59 | public int getErrorOccurrences() { 60 | return errorOccurrences; 61 | } 62 | 63 | public void setErrorOccurrences(int errorOccurrences) { 64 | this.errorOccurrences = errorOccurrences; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/model/helper/MergeMonitorData.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 University of South Florida. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package edu.usf.cutr.gtfsrtvalidator.lib.model.helper; 18 | 19 | import edu.usf.cutr.gtfsrtvalidator.lib.model.ViewErrorLogModel; 20 | import edu.usf.cutr.gtfsrtvalidator.lib.model.ViewErrorSummaryModel; 21 | import edu.usf.cutr.gtfsrtvalidator.lib.model.ViewGtfsRtFeedErrorCountModel; 22 | 23 | import java.util.ArrayList; 24 | import java.util.List; 25 | 26 | public class MergeMonitorData { 27 | 28 | private int iterationCount; 29 | private int uniqueFeedCount; 30 | private List viewGtfsRtFeedErrorCountModelList; 31 | private List viewErrorSummaryModelList; 32 | private List viewErrorLogModelList; 33 | 34 | public MergeMonitorData() { 35 | 36 | viewGtfsRtFeedErrorCountModelList = new ArrayList<>(); 37 | viewErrorSummaryModelList = new ArrayList<>(); 38 | viewErrorLogModelList = new ArrayList<>(); 39 | } 40 | 41 | public int getIterationCount() { 42 | return iterationCount; 43 | } 44 | 45 | public void setIterationCount(int iterationCount) { 46 | this.iterationCount = iterationCount; 47 | } 48 | 49 | public int getUniqueFeedCount() { 50 | return uniqueFeedCount; 51 | } 52 | 53 | public void setUniqueFeedCount(int uniqueFeedCount) { 54 | this.uniqueFeedCount = uniqueFeedCount; 55 | } 56 | 57 | public List getViewGtfsRtFeedErrorCountModelList() { 58 | return viewGtfsRtFeedErrorCountModelList; 59 | } 60 | 61 | public void setViewGtfsRtFeedErrorCountModelList(List viewGtfsRtFeedErrorCountModelList) { 62 | this.viewGtfsRtFeedErrorCountModelList = viewGtfsRtFeedErrorCountModelList; 63 | } 64 | 65 | public List getViewErrorSummaryModelList() { 66 | return viewErrorSummaryModelList; 67 | } 68 | 69 | public void setViewErrorSummaryModelList(List viewErrorSummaryModelList) { 70 | this.viewErrorSummaryModelList = viewErrorSummaryModelList; 71 | } 72 | 73 | public List getViewErrorLogModelList() { 74 | return viewErrorLogModelList; 75 | } 76 | 77 | public void setViewErrorLogModelList(List viewErrorLogModelList) { 78 | this.viewErrorLogModelList = viewErrorLogModelList; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/util/RuleUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 University of South Florida. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package edu.usf.cutr.gtfsrtvalidator.lib.util; 18 | 19 | import edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel; 20 | import edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule; 21 | 22 | import java.util.List; 23 | 24 | /** 25 | * Utilities related to rules 26 | */ 27 | public class RuleUtils { 28 | 29 | /** 30 | * Adds occurrence for rule 31 | * 32 | * @param rule rule to add occurrence for 33 | * @param occurrencePrefix prefix to use for the OccurrenceModel constructor 34 | * @param list list to add occurrence for the rule to 35 | * @param log logger to use to output occurrence info 36 | */ 37 | public static void addOccurrence(ValidationRule rule, String occurrencePrefix, List list, org.slf4j.Logger log) { 38 | OccurrenceModel om = new OccurrenceModel(occurrencePrefix); 39 | list.add(om); 40 | log.debug(om.getPrefix() + " " + rule.getOccurrenceSuffix()); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/util/SortUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 University of South Florida 3 | * 4 | * All rights reserved. 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | package edu.usf.cutr.gtfsrtvalidator.lib.util; 19 | 20 | import java.io.File; 21 | import java.io.IOException; 22 | import java.nio.file.Files; 23 | import java.nio.file.Path; 24 | import java.util.Arrays; 25 | import java.util.Comparator; 26 | 27 | /** 28 | * Utility methods to sort things 29 | */ 30 | public class SortUtils { 31 | 32 | /** 33 | * Sorts the provided list of files by date modified (ascending) 34 | * 35 | * @param files the list of files to sort by date modified (ascending) 36 | * @return the provided list of files sorted by date modified (ascending) 37 | */ 38 | public static File[] sortByDateModified(File[] files) { 39 | Arrays.sort(files, Comparator.comparingLong(File::lastModified)); 40 | return files; 41 | } 42 | 43 | /** 44 | * Compares the value of two Path objects for order by date modified 45 | * 46 | * @param o1 first path to compare 47 | * @param o2 second path to compare 48 | * @return 0 if o1 date modified is equal to o2, a value less than 0 if o1 has a date 49 | * modified that is before o2, and a value greater than 0 if o1 50 | * represents a date modified that is after o2 51 | */ 52 | public static int compareByDateModified(Path o1, Path o2) throws IOException { 53 | return Long.compare(Files.getLastModifiedTime(o1).toMillis(), Files.getLastModifiedTime(o2).toMillis()); 54 | } 55 | 56 | /** 57 | * Sorts the provided list of files by name (ascending) 58 | * 59 | * @param files the list of files to sort by name (ascending) 60 | * @return the provided list of files sorted by name (ascending) 61 | */ 62 | public static File[] sortByName(File[] files) { 63 | Arrays.sort(files, Comparator.comparing(File::getName)); 64 | return files; 65 | } 66 | 67 | /** 68 | * Compares the value of two Path objects for order by file name 69 | * 70 | * @param o1 first path to compare 71 | * @param o2 second path to compare 72 | * @return 0 if o1 name is equal to o2 name, a value less than 0 if o1 has a name that 73 | * comes before the name of o2, and a value greater than 0 if o1 74 | * has a name that is after o2 75 | */ 76 | public static int compareByFileName(Path o1, Path o2) { 77 | return o1.getFileName().toString().compareTo(o2.getFileName().toString()); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/validation/RuleStatistics.java: -------------------------------------------------------------------------------- 1 | package edu.usf.cutr.gtfsrtvalidator.lib.validation; 2 | 3 | public class RuleStatistics { 4 | 5 | private double ruleExecutionTime; 6 | private String ruleId; 7 | 8 | public RuleStatistics() { 9 | } 10 | 11 | /** 12 | * Returns the amount of time it took to execute the rule specified by the getRuleId() method on this object, in seconds as a decimal (0.22) 13 | * 14 | * @return the amount of time it took to execute the rule specified by the getRuleId() method on this object, in seconds as a decimal (0.22) 15 | */ 16 | public double getRuleExecutionTime() { 17 | return ruleExecutionTime; 18 | } 19 | 20 | /** 21 | * Sets the amount of time it took to execute the rule specified by the getRuleId() method on this object, in seconds as a decimal (0.22) 22 | * 23 | * @param ruleExecutionTime the amount of time it took to execute the rule specified by the getRuleId() method on this object, in seconds as a decimal (0.22) 24 | */ 25 | public void setRuleExecutionTime(double ruleExecutionTime) { 26 | this.ruleExecutionTime = ruleExecutionTime; 27 | } 28 | 29 | /** 30 | * Returns the validator class name for which this ruleExecutionTime was recorded 31 | * 32 | * @return the validator class name for which this ruleExecutionTime was recorded 33 | */ 34 | public String getValidator() { 35 | return ruleId; 36 | } 37 | 38 | /** 39 | * Sets the validator class name for which this ruleExecutionTime was recorded 40 | * 41 | * @param ruleId the validator class name for which this ruleExecutionTime was recorded 42 | */ 43 | public void setValidator(String ruleId) { 44 | this.ruleId = ruleId; 45 | } 46 | 47 | @Override 48 | public String toString() { 49 | return "RuleStatistics{" + 50 | "ruleExecutionTime=" + ruleExecutionTime + 51 | ", ruleId='" + ruleId + '\'' + 52 | '}'; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/validation/gtfs/StopLocationTypeValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.validation.gtfs; 19 | 20 | import edu.usf.cutr.gtfsrtvalidator.lib.model.MessageLogModel; 21 | import edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel; 22 | import edu.usf.cutr.gtfsrtvalidator.lib.model.helper.ErrorListHelperModel; 23 | import edu.usf.cutr.gtfsrtvalidator.lib.util.RuleUtils; 24 | import edu.usf.cutr.gtfsrtvalidator.lib.validation.interfaces.GtfsFeedValidator; 25 | import org.onebusaway.gtfs.impl.GtfsDaoImpl; 26 | import org.onebusaway.gtfs.model.Stop; 27 | import org.onebusaway.gtfs.model.StopTime; 28 | import org.slf4j.LoggerFactory; 29 | 30 | import java.util.*; 31 | 32 | import static edu.usf.cutr.gtfsrtvalidator.lib.validation.ValidationRules.E010; 33 | 34 | /** 35 | * E010 - If location_type is used in stops.txt, all stops referenced in stop_times.txt must have location_type of 0 36 | */ 37 | public class StopLocationTypeValidator implements GtfsFeedValidator { 38 | 39 | private static final org.slf4j.Logger _log = LoggerFactory.getLogger(StopLocationTypeValidator.class); 40 | 41 | @Override 42 | public List validate(GtfsDaoImpl gtfsData) { 43 | List e010List = new ArrayList<>(); 44 | 45 | Collection stopTimes = gtfsData.getAllStopTimes(); 46 | Set checkedStops = new HashSet<>(); 47 | 48 | for (StopTime stopTime : stopTimes) { 49 | if (!checkedStops.contains(stopTime.getStop())) { 50 | checkedStops.add(stopTime.getStop()); 51 | 52 | if (stopTime.getStop().getLocationType() != 0) { 53 | RuleUtils.addOccurrence(E010, "stop_id " + stopTime.getStop().getId(), e010List, _log); 54 | } 55 | } 56 | } 57 | 58 | List errors = new ArrayList<>(); 59 | if (!e010List.isEmpty()) { 60 | errors.add(new ErrorListHelperModel(new MessageLogModel(E010), e010List)); 61 | } 62 | return errors; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/validation/interfaces/FeedEntityValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.validation.interfaces; 19 | 20 | import com.google.transit.realtime.GtfsRealtime; 21 | import edu.usf.cutr.gtfsrtvalidator.lib.model.helper.ErrorListHelperModel; 22 | import edu.usf.cutr.gtfsrtvalidator.lib.validation.GtfsMetadata; 23 | import org.onebusaway.gtfs.services.GtfsMutableDao; 24 | 25 | import java.util.List; 26 | 27 | /** 28 | * Interface used for all rules that produce error or warning messages 29 | */ 30 | public interface FeedEntityValidator { 31 | /** 32 | * Validates a particular rule implemented by this interface 33 | * 34 | * @param currentTimeMillis the current system time, in milliseconds 35 | * @param gtfsData GTFS schedule data 36 | * @param gtfsMetadata Data structures that contain processed information about the GTFS data 37 | * @param feedMessage Current GTFS-rt data that was most recently captured (should NOT be equal to previousFeedMessage) 38 | * @param previousFeedMessage Previous GTFS-rt data from the previous iteration of the feed (should NOT be the same as feedMessage) 39 | * @param combinedFeedMessage A GTFS-rt message that includes entities from all GTFS-rt feeds being monitored simultaneously for the same GTFS dataset. If only one GTFS-rt feed is being monitored for the GTFS dataset, then this is null. 40 | * @return a list of errors and warnings that was generated by the implementing rule 41 | */ 42 | List validate(long currentTimeMillis, GtfsMutableDao gtfsData, GtfsMetadata gtfsMetadata, GtfsRealtime.FeedMessage feedMessage, GtfsRealtime.FeedMessage previousFeedMessage, GtfsRealtime.FeedMessage combinedFeedMessage); 43 | } 44 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/validation/interfaces/GtfsFeedValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.lib.validation.interfaces; 19 | 20 | import edu.usf.cutr.gtfsrtvalidator.lib.model.helper.ErrorListHelperModel; 21 | import org.onebusaway.gtfs.impl.GtfsDaoImpl; 22 | 23 | import java.util.List; 24 | 25 | public interface GtfsFeedValidator { 26 | List validate(GtfsDaoImpl gtfsData); 27 | } 28 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/java/edu/usf/cutr/gtfsrtvalidator/lib/validation/rules/HeaderValidator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 University of South Florida. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package edu.usf.cutr.gtfsrtvalidator.lib.validation.rules; 18 | 19 | import com.google.transit.realtime.GtfsRealtime; 20 | import edu.usf.cutr.gtfsrtvalidator.lib.model.MessageLogModel; 21 | import edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel; 22 | import edu.usf.cutr.gtfsrtvalidator.lib.model.helper.ErrorListHelperModel; 23 | import edu.usf.cutr.gtfsrtvalidator.lib.util.GtfsUtils; 24 | import edu.usf.cutr.gtfsrtvalidator.lib.util.RuleUtils; 25 | import edu.usf.cutr.gtfsrtvalidator.lib.validation.GtfsMetadata; 26 | import edu.usf.cutr.gtfsrtvalidator.lib.validation.interfaces.FeedEntityValidator; 27 | import org.onebusaway.gtfs.services.GtfsMutableDao; 28 | import org.slf4j.LoggerFactory; 29 | 30 | import java.util.ArrayList; 31 | import java.util.List; 32 | 33 | import static edu.usf.cutr.gtfsrtvalidator.lib.validation.ValidationRules.*; 34 | 35 | /** 36 | * E038 - Invalid header.gtfs_realtime_version 37 | * E039 - FULL_DATASET feeds should not include entity.is_deleted 38 | * E049 - header incrementality not populated 39 | */ 40 | public class HeaderValidator implements FeedEntityValidator { 41 | 42 | private static final org.slf4j.Logger _log = LoggerFactory.getLogger(HeaderValidator.class); 43 | 44 | @Override 45 | public List validate(long currentTimeMillis, GtfsMutableDao gtfsData, GtfsMetadata gtfsMetadata, GtfsRealtime.FeedMessage feedMessage, GtfsRealtime.FeedMessage previousFeedMessage, GtfsRealtime.FeedMessage combinedFeedMessage) { 46 | List errorListE038 = new ArrayList<>(); 47 | List errorListE039 = new ArrayList<>(); 48 | List errorListE049 = new ArrayList<>(); 49 | 50 | if (!GtfsUtils.isValidVersion(feedMessage.getHeader())) { 51 | // E038 - Invalid header.gtfs_realtime_version 52 | RuleUtils.addOccurrence(E038, "header.gtfs_realtime_version of " + feedMessage.getHeader().getGtfsRealtimeVersion(), errorListE038, _log); 53 | } 54 | 55 | try { 56 | if (GtfsUtils.isV2orHigher(feedMessage.getHeader()) && !feedMessage.getHeader().hasIncrementality()) { 57 | // E049 - header incrementality not populated 58 | RuleUtils.addOccurrence(E049, "", errorListE049, _log); 59 | } 60 | } catch (Exception e) { 61 | _log.error("Error checking header version for E049: " + e); 62 | } 63 | 64 | if (feedMessage.getHeader().getIncrementality().equals(GtfsRealtime.FeedHeader.Incrementality.FULL_DATASET)) { 65 | for (GtfsRealtime.FeedEntity entity : feedMessage.getEntityList()) { 66 | if (entity.hasIsDeleted()) { 67 | // E039 - FULL_DATASET feeds should not include entity.is_deleted 68 | RuleUtils.addOccurrence(E039, "entity ID " + entity.getId() + " has is_deleted=" + entity.getIsDeleted(), errorListE039, _log); 69 | } 70 | } 71 | } 72 | 73 | List errors = new ArrayList<>(); 74 | if (!errorListE038.isEmpty()) { 75 | errors.add(new ErrorListHelperModel(new MessageLogModel(E038), errorListE038)); 76 | } 77 | if (!errorListE039.isEmpty()) { 78 | errors.add(new ErrorListHelperModel(new MessageLogModel(E039), errorListE039)); 79 | } 80 | if (!errorListE049.isEmpty()) { 81 | errors.add(new ErrorListHelperModel(new MessageLogModel(E049), errorListE049)); 82 | } 83 | return errors; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/main/resources/simplelogger.properties: -------------------------------------------------------------------------------- 1 | handlers = org.eclipse.jetty.demo.SystemOutHandler 2 | .level = INFO 3 | 4 | # To include log levels, add "org.slf4j.simpleLogger.log.[to be applied API] = REQUIRED_LEVEL" 5 | org.slf4j.simpleLogger.log.org.eclipse.jetty = WARN 6 | org.slf4j.simpleLogger.log.org.hibernate = WARN 7 | org.slf4j.simpleLogger.log.org.onebusaway = WARN 8 | org.slf4j.simpleLogger.defaultLogLevel=INFO 9 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/test/java/edu/usf/cutr/gtfsrtvalidator/lib/test/BatchTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 University of South Florida. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package edu.usf.cutr.gtfsrtvalidator.lib.test; 18 | 19 | import com.fasterxml.jackson.databind.ObjectMapper; 20 | import edu.usf.cutr.gtfsrtvalidator.lib.batch.BatchProcessor; 21 | import edu.usf.cutr.gtfsrtvalidator.lib.model.helper.ErrorListHelperModel; 22 | import org.junit.Test; 23 | 24 | import java.io.File; 25 | import java.io.IOException; 26 | import java.security.NoSuchAlgorithmException; 27 | 28 | import static org.junit.Assert.assertEquals; 29 | import static org.junit.Assert.assertTrue; 30 | 31 | /** 32 | * Tests for the batch processing validation mode 33 | */ 34 | public class BatchTest { 35 | 36 | @Test 37 | public void testBatchProcessing() throws IOException, NoSuchAlgorithmException { 38 | // Run batch validation on the bundled USF Bull Runner GTFS and GTFS-realtime data 39 | BatchProcessor.Builder builder = new BatchProcessor.Builder("src/test/resources/bullrunner-gtfs.zip", "src/test/resources/"); 40 | BatchProcessor processor = builder.build(); 41 | processor.processFeeds(); 42 | 43 | // Read in validation results for GTFS-realtime bullrunner-vehicle-positions file 44 | ObjectMapper mapper = new ObjectMapper(); 45 | ErrorListHelperModel[] allErrorLists = mapper.readValue(new File("src/test/resources/bullrunner-vehicle-positions" + BatchProcessor.RESULTS_FILE_EXTENSION), ErrorListHelperModel[].class); 46 | 47 | // We should have 3 warnings - W001, W006, and W009, with 10 occurrences each. 48 | // If running on Travis we may have another warning, W008, due to timestamp being older than 65 seconds 49 | assertTrue(allErrorLists.length == 3 || allErrorLists.length == 4); 50 | for (ErrorListHelperModel model : allErrorLists) { 51 | switch (model.getErrorMessage().getValidationRule().getErrorId()) { 52 | case "W001": 53 | assertEquals(10, model.getOccurrenceList().size()); 54 | break; 55 | case "W006": 56 | assertEquals(10, model.getOccurrenceList().size()); 57 | break; 58 | case "W008": 59 | assertEquals(1, model.getOccurrenceList().size()); 60 | break; 61 | case "W009": 62 | assertEquals(10, model.getOccurrenceList().size()); 63 | break; 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/test/java/edu/usf/cutr/gtfsrtvalidator/lib/test/rules/FrequencyTypeOneValidatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 University of South Florida 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package edu.usf.cutr.gtfsrtvalidator.lib.test.rules; 18 | 19 | import com.google.transit.realtime.GtfsRealtime; 20 | import edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule; 21 | import edu.usf.cutr.gtfsrtvalidator.lib.test.FeedMessageTest; 22 | import edu.usf.cutr.gtfsrtvalidator.lib.test.util.TestUtils; 23 | import edu.usf.cutr.gtfsrtvalidator.lib.validation.rules.FrequencyTypeOneValidator; 24 | import org.junit.Test; 25 | 26 | import java.io.IOException; 27 | import java.util.HashMap; 28 | import java.util.Map; 29 | 30 | import static edu.usf.cutr.gtfsrtvalidator.lib.util.TimestampUtils.MIN_POSIX_TIME; 31 | import static edu.usf.cutr.gtfsrtvalidator.lib.validation.ValidationRules.E019; 32 | 33 | /** 34 | * Tests to evaluate rules for Frequency-based exact_times=1 trips 35 | *

36 | * Tests: 37 | *

38 | * E019 - GTFS-rt frequency type 1 trip start_time must be a multiple of GTFS data start_time 39 | */ 40 | public class FrequencyTypeOneValidatorTest extends FeedMessageTest { 41 | 42 | 43 | public FrequencyTypeOneValidatorTest() throws IOException { 44 | } 45 | 46 | /** 47 | * E019 - GTFS-rt trip start_date and start_time must match GTFS data 48 | *

49 | * testagency.zip (gtfsData) has exact_times = 1 trips for 15.1 with a 1 hr (3600 sec) headway 50 | */ 51 | @Test 52 | public void testE019() { 53 | Map expected = new HashMap<>(); 54 | 55 | /** 56 | * Set start_time to match GTFS start_time exactly - 6am - no errors 57 | */ 58 | FrequencyTypeOneValidator frequencyTypeOneValidator = new FrequencyTypeOneValidator(); 59 | GtfsRealtime.TripDescriptor.Builder tripDescriptorBuilder = GtfsRealtime.TripDescriptor.newBuilder(); 60 | tripDescriptorBuilder.setTripId("15.1"); 61 | tripDescriptorBuilder.setStartTime("06:00:00"); 62 | 63 | feedHeaderBuilder.setTimestamp(MIN_POSIX_TIME); 64 | feedMessageBuilder.setHeader(feedHeaderBuilder.build()); 65 | 66 | tripUpdateBuilder.setTimestamp(MIN_POSIX_TIME); 67 | tripUpdateBuilder.setTrip(tripDescriptorBuilder.build()); 68 | feedEntityBuilder.setTripUpdate(tripUpdateBuilder); 69 | 70 | vehiclePositionBuilder.setTimestamp(MIN_POSIX_TIME); 71 | vehiclePositionBuilder.setTrip(tripDescriptorBuilder.build()); 72 | feedEntityBuilder.setVehicle(vehiclePositionBuilder.build()); 73 | 74 | feedMessageBuilder.setEntity(0, feedEntityBuilder.build()); 75 | 76 | results = frequencyTypeOneValidator.validate(MIN_POSIX_TIME, gtfsData, gtfsDataMetadata, feedMessageBuilder.build(), null, null); 77 | expected.clear(); 78 | TestUtils.assertResults(expected, results); 79 | 80 | /** 81 | * Set start_time to be a multiple of headway_secs - 1 hr later at 7:00am - 0 errors 82 | */ 83 | 84 | tripDescriptorBuilder.setTripId("15.1"); 85 | tripDescriptorBuilder.setStartTime("07:00:00"); 86 | 87 | feedHeaderBuilder.setTimestamp(MIN_POSIX_TIME); 88 | feedMessageBuilder.setHeader(feedHeaderBuilder.build()); 89 | 90 | tripUpdateBuilder.setTimestamp(MIN_POSIX_TIME); 91 | tripUpdateBuilder.setTrip(tripDescriptorBuilder.build()); 92 | feedEntityBuilder.setTripUpdate(tripUpdateBuilder); 93 | 94 | vehiclePositionBuilder.setTimestamp(MIN_POSIX_TIME); 95 | vehiclePositionBuilder.setTrip(tripDescriptorBuilder.build()); 96 | feedEntityBuilder.setVehicle(vehiclePositionBuilder.build()); 97 | 98 | feedMessageBuilder.setEntity(0, feedEntityBuilder.build()); 99 | 100 | results = frequencyTypeOneValidator.validate(MIN_POSIX_TIME, gtfsData, gtfsDataMetadata, feedMessageBuilder.build(), null, null); 101 | expected.clear(); 102 | TestUtils.assertResults(expected, results); 103 | 104 | /** 105 | * Set start_time to NOT be a multiple of headway_secs - 2.5 hr later at 7:30am - 2 errors 106 | */ 107 | 108 | tripDescriptorBuilder.setTripId("15.1"); 109 | tripDescriptorBuilder.setStartTime("07:30:00"); 110 | 111 | feedHeaderBuilder.setTimestamp(MIN_POSIX_TIME); 112 | feedMessageBuilder.setHeader(feedHeaderBuilder.build()); 113 | 114 | tripUpdateBuilder.setTimestamp(MIN_POSIX_TIME); 115 | tripUpdateBuilder.setTrip(tripDescriptorBuilder.build()); 116 | feedEntityBuilder.setTripUpdate(tripUpdateBuilder); 117 | 118 | vehiclePositionBuilder.setTimestamp(MIN_POSIX_TIME); 119 | vehiclePositionBuilder.setTrip(tripDescriptorBuilder.build()); 120 | feedEntityBuilder.setVehicle(vehiclePositionBuilder.build()); 121 | 122 | feedMessageBuilder.setEntity(0, feedEntityBuilder.build()); 123 | 124 | results = frequencyTypeOneValidator.validate(MIN_POSIX_TIME, gtfsData, gtfsDataMetadata, feedMessageBuilder.build(), null, null); 125 | expected.put(E019, 2); 126 | TestUtils.assertResults(expected, results); 127 | 128 | clearAndInitRequiredFeedFields(); 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/test/java/edu/usf/cutr/gtfsrtvalidator/lib/test/rules/StopLocationTypeValidatorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 University of South Florida 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package edu.usf.cutr.gtfsrtvalidator.lib.test.rules; 18 | 19 | import edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule; 20 | import edu.usf.cutr.gtfsrtvalidator.lib.model.helper.ErrorListHelperModel; 21 | import edu.usf.cutr.gtfsrtvalidator.lib.test.FeedMessageTest; 22 | import edu.usf.cutr.gtfsrtvalidator.lib.test.util.TestUtils; 23 | import edu.usf.cutr.gtfsrtvalidator.lib.validation.gtfs.StopLocationTypeValidator; 24 | import org.junit.Test; 25 | 26 | import java.io.IOException; 27 | import java.util.HashMap; 28 | import java.util.Map; 29 | 30 | import static edu.usf.cutr.gtfsrtvalidator.lib.validation.ValidationRules.E010; 31 | import static org.junit.Assert.assertEquals; 32 | 33 | /** 34 | * Tests for rules implemented in StopLocationTypeValidator 35 | */ 36 | public class StopLocationTypeValidatorTest extends FeedMessageTest { 37 | 38 | public StopLocationTypeValidatorTest() throws IOException { 39 | } 40 | 41 | /** 42 | * E010 - If location_type is used in stops.txt, all stops referenced in stop_times.txt must have location_type of 0 43 | */ 44 | @Test 45 | public void testE010() { 46 | StopLocationTypeValidator stopLocationValidator = new StopLocationTypeValidator(); 47 | Map expected = new HashMap<>(); 48 | 49 | // gtfsData does not contain location_type = 1 for stop_id. Therefore returns 0 results 50 | results = stopLocationValidator.validate(gtfsData); 51 | for (ErrorListHelperModel error : results) { 52 | assertEquals(0, error.getOccurrenceList().size()); 53 | } 54 | 55 | // gtfsData2 contains location_type = 1 for stop_ids. Therefore returns errorcount = (number of location_type = 1 for stop_ids) 56 | results = stopLocationValidator.validate(gtfsData2); 57 | expected.put(E010, 1); 58 | TestUtils.assertResults(expected, results); 59 | 60 | clearAndInitRequiredFeedFields(); 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/test/java/edu/usf/cutr/gtfsrtvalidator/lib/test/util/TestUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 University of South Florida. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package edu.usf.cutr.gtfsrtvalidator.lib.test.util; 18 | 19 | import edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule; 20 | import edu.usf.cutr.gtfsrtvalidator.lib.model.helper.ErrorListHelperModel; 21 | 22 | import javax.validation.constraints.NotNull; 23 | import java.util.HashMap; 24 | import java.util.List; 25 | import java.util.Map; 26 | 27 | import static org.junit.Assert.assertEquals; 28 | import static org.junit.Assert.fail; 29 | 30 | /** 31 | * Utilities to help with test execution and assertions 32 | */ 33 | public class TestUtils { 34 | 35 | /** 36 | * Asserts that for a given map of rules to expected number of warnings/errors (expected) and 37 | * error/warning results (results), there should be a certain number of errors warnings for each rule. There should 38 | * be 0 errors/warnings for all other rules not included in the map. In expected, the key is the 39 | * ValidationRule, and the value is the number of expected warnings/errors for that rule. 40 | * 41 | * @param expected A map of the ValidationRules to the number of expected warnings/errors for each rule. If a ValidationRule isn't included in this map, it is expected that there are 0 errors/warnings for that rule. 42 | * @param results list of errors or warnings output from validation 43 | */ 44 | public static void assertResults(@NotNull Map expected, @NotNull List results) { 45 | if (expected == null) { 46 | throw new IllegalArgumentException("expected cannot be null - it must be a list of expected errors or warnings"); 47 | } 48 | if (results == null) { 49 | throw new IllegalArgumentException("results cannot be null - it must be a list of actual errors or warnings"); 50 | } 51 | 52 | // We need to create a map of actual results to actual count, so we can loop through 53 | Map actual = new HashMap<>(); 54 | 55 | /** 56 | * First, confirm that all actual count for all rules in results match the expected count 57 | */ 58 | for (ErrorListHelperModel error : results) { 59 | // Save the actual count to a map for quick access in the next FOR loop 60 | ValidationRule rule = error.getErrorMessage().getValidationRule(); 61 | Integer actualCount = error.getOccurrenceList().size(); 62 | actual.put(rule, actualCount); 63 | 64 | // Get the expected count for this rule 65 | Integer expectedCount = expected.get(rule); 66 | if (expectedCount != null) { 67 | // Make sure we have expected number of errors/warnings 68 | assertEquals(expectedCount, actualCount); 69 | } else { 70 | // Make sure there aren't any errors/warnings for this rule, as it wasn't in the expected HashMap 71 | assertEquals(0, actualCount.intValue()); 72 | } 73 | } 74 | 75 | /** 76 | * Second, make sure that all expected counts for all rules in expected match the actual count. We need this loop 77 | * to make sure that there isn't an expected rule in expected that's not included in results. 78 | */ 79 | for (Map.Entry entry : expected.entrySet()) { 80 | ValidationRule rule = entry.getKey(); 81 | Integer expectedCount = entry.getValue(); 82 | 83 | // Get the actual count for this rule 84 | Integer actualCount = actual.get(rule); 85 | if (actualCount != null) { 86 | // Make sure we have expected number of errors/warnings for this rule 87 | assertEquals(actualCount, expectedCount); 88 | } else { 89 | // We're expecting errors/warnings for a rule that wasn't included in the actual results 90 | fail("Expected " + expectedCount + " occurrences for " + rule.getErrorId() + " but found 0 occurrences in actual results"); 91 | } 92 | } 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/test/resources/.gitignore: -------------------------------------------------------------------------------- 1 | bullrunner-vehicle-positions.results.json -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/test/resources/TripUpdates-2017-02-18T20-00-08Z.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MobilityData/gtfs-realtime-validator/57146b4eb7a55e68f4655b8c3f3ffb5ed9cebff1/gtfs-realtime-validator-lib/src/test/resources/TripUpdates-2017-02-18T20-00-08Z.txt -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/test/resources/TripUpdates-2017-02-18T20-00-23Z.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MobilityData/gtfs-realtime-validator/57146b4eb7a55e68f4655b8c3f3ffb5ed9cebff1/gtfs-realtime-validator-lib/src/test/resources/TripUpdates-2017-02-18T20-00-23Z.txt -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/test/resources/TripUpdates-2017-02-18T20-01-08Z.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MobilityData/gtfs-realtime-validator/57146b4eb7a55e68f4655b8c3f3ffb5ed9cebff1/gtfs-realtime-validator-lib/src/test/resources/TripUpdates-2017-02-18T20-01-08Z.txt -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/test/resources/VehiclePositions-2017-02-18T20-01-08Z.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MobilityData/gtfs-realtime-validator/57146b4eb7a55e68f4655b8c3f3ffb5ed9cebff1/gtfs-realtime-validator-lib/src/test/resources/VehiclePositions-2017-02-18T20-01-08Z.txt -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/test/resources/badgtfs.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MobilityData/gtfs-realtime-validator/57146b4eb7a55e68f4655b8c3f3ffb5ed9cebff1/gtfs-realtime-validator-lib/src/test/resources/badgtfs.zip -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/test/resources/bullrunner-gtfs-no-shapes.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MobilityData/gtfs-realtime-validator/57146b4eb7a55e68f4655b8c3f3ffb5ed9cebff1/gtfs-realtime-validator-lib/src/test/resources/bullrunner-gtfs-no-shapes.zip -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/test/resources/bullrunner-gtfs-timepoints-only-legacy-exact-times-1.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MobilityData/gtfs-realtime-validator/57146b4eb7a55e68f4655b8c3f3ffb5ed9cebff1/gtfs-realtime-validator-lib/src/test/resources/bullrunner-gtfs-timepoints-only-legacy-exact-times-1.zip -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/test/resources/bullrunner-gtfs.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MobilityData/gtfs-realtime-validator/57146b4eb7a55e68f4655b8c3f3ffb5ed9cebff1/gtfs-realtime-validator-lib/src/test/resources/bullrunner-gtfs.zip -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/test/resources/bullrunner-vehicle-positions: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MobilityData/gtfs-realtime-validator/57146b4eb7a55e68f4655b8c3f3ffb5ed9cebff1/gtfs-realtime-validator-lib/src/test/resources/bullrunner-vehicle-positions -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/test/resources/testSQLScript.sql: -------------------------------------------------------------------------------- 1 | 2 | -- Insert records into GtfsFeed table 3 | INSERT INTO GtfsFeed -- Columns (feedId, agency, fileCheckSum, errorCount, fileLocation, feedUrl, downloadTimestamp) 4 | -- We ensures that record is not inserted if already exists, to avoid primary key constraint violation 5 | SELECT * FROM (VALUES(-1, 'America/New_York', NULL, 0, 'dummy', 'dummy', 1)) 6 | WHERE NOT EXISTS (SELECT * FROM GtfsFeed WHERE feedId = -1); 7 | 8 | -- Insert records into GtfsRtFeed table 9 | INSERT INTO GtfsRtFeed -- Columns (rtFeedId, rtFeedUrl, gtfsFeedId) 10 | -- We ensures that record is not inserted if already exists, to avoid primary key constraint violation 11 | SELECT * FROM (VALUES( -1, 'dummy', -1)) 12 | WHERE NOT EXISTS (SELECT * FROM GtfsRtFeed WHERE rtFeedId = -1); 13 | 14 | -- Insert records into GtfsRtFeedIteration 15 | INSERT INTO GtfsRtFeedIteration -- Columns (iterationId, feedHash, feedTimestamp, feedProtoBuf, iterationTimestamp, rtFeedId) 16 | -- We ensures that record is not inserted if already exists, to avoid primary key constraint violation 17 | SELECT * FROM (VALUES( -2, NULL, 1, NULL, 1, -1)) 18 | WHERE NOT EXISTS (SELECT * FROM GtfsRtFeedIteration WHERE IterationId = -2); 19 | 20 | INSERT INTO GtfsRtFeedIteration 21 | SELECT * FROM (VALUES( -1, NULL, 2, NULL, 2, -1)) 22 | WHERE NOT EXISTS (SELECT * FROM GtfsRtFeedIteration WHERE IterationId = -1); 23 | 24 | -- Insert records into MessageLog table 25 | INSERT INTO MessageLog -- Columns (messageId, errorDetails, iterationId, errorId) 26 | -- We ensures that record is not inserted if already exists, to avoid primary key constraint violation 27 | SELECT * FROM (VALUES( -6, NULL, -2, 'W002')) 28 | WHERE NOT EXISTS (SELECT * FROM MessageLog WHERE messageId = -6); 29 | 30 | INSERT INTO MessageLog 31 | SELECT * FROM (VALUES( -5, NULL, -2, 'W001')) 32 | WHERE NOT EXISTS (SELECT * FROM MessageLog WHERE messageId = -5); 33 | 34 | INSERT INTO MessageLog 35 | SELECT * FROM (VALUES( -4, NULL, -2, 'E002')) 36 | WHERE NOT EXISTS (SELECT * FROM MessageLog WHERE messageId = -4); 37 | 38 | INSERT INTO MessageLog 39 | SELECT * FROM (VALUES( -3, NULL, -1, 'W002')) 40 | WHERE NOT EXISTS (SELECT * FROM MessageLog WHERE messageId = -3); 41 | 42 | INSERT INTO MessageLog 43 | SELECT * FROM (VALUES( -2, NULL, -1, 'W001')) 44 | WHERE NOT EXISTS (SELECT * FROM MessageLog WHERE messageId = -2); 45 | 46 | INSERT INTO MessageLog 47 | SELECT * FROM (VALUES( -1, NULL, -1, 'E002')) 48 | WHERE NOT EXISTS (SELECT * FROM MessageLog WHERE messageId = -1); -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/test/resources/testagency.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MobilityData/gtfs-realtime-validator/57146b4eb7a55e68f4655b8c3f3ffb5ed9cebff1/gtfs-realtime-validator-lib/src/test/resources/testagency.zip -------------------------------------------------------------------------------- /gtfs-realtime-validator-lib/src/test/resources/testagency2.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MobilityData/gtfs-realtime-validator/57146b4eb7a55e68f4655b8c3f3ffb5ed9cebff1/gtfs-realtime-validator-lib/src/test/resources/testagency2.zip -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .idea/ 3 | 4 | target/ 5 | **/target/ 6 | pom.xml.tag 7 | pom.xml.releaseBackup 8 | pom.xml.versionsBackup 9 | pom.xml.next 10 | release.properties 11 | dependency-reduced-pom.xml 12 | buildNumber.properties 13 | .mvn/timing.properties 14 | *.swp 15 | *.log 16 | *~ 17 | 18 | *.db -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/.mvn/jvm.config: -------------------------------------------------------------------------------- 1 | -Xmx4G -Xms1G -Djava.awt.headless=true 2 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2015-2017 Nipuna Gunathilake, University of South Florida 2 | All rights reserved. 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | 16 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/README.md: -------------------------------------------------------------------------------- 1 | # gtfs-realtime-validator-webapp 2 | 3 | A server and website that allows multiple users to validate GTFS Realtime feeds by simply entering URLs into the website. 4 | 5 | Uses the [**gtfs-realtime-validator-lib**](https://github.com/MobilityData/gtfs-realtime-validator/tree/master/gtfs-realtime-validator-lib) submodule in this repository, which implements the [validation rules](../RULES.md). 6 | 7 | See the main project [README](../README.md) for more details. 8 | 9 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/java/edu/usf/cutr/gtfsrtvalidator/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2017 Nipuna Gunathilake, University of South Florida 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator; 19 | 20 | import edu.usf.cutr.gtfsrtvalidator.db.GTFSDB; 21 | import edu.usf.cutr.gtfsrtvalidator.hibernate.HibernateUtil; 22 | import edu.usf.cutr.gtfsrtvalidator.servlets.GetFeedJSON; 23 | import edu.usf.cutr.gtfsrtvalidator.util.FileUtil; 24 | import org.apache.commons.cli.*; 25 | import org.eclipse.jetty.server.Server; 26 | import org.eclipse.jetty.servlet.DefaultServlet; 27 | import org.eclipse.jetty.servlet.ServletContextHandler; 28 | import org.eclipse.jetty.servlet.ServletHolder; 29 | import org.eclipse.jetty.util.resource.ResourceCollection; 30 | import org.glassfish.jersey.servlet.ServletContainer; 31 | import org.slf4j.LoggerFactory; 32 | 33 | import java.io.File; 34 | 35 | import static edu.usf.cutr.gtfsrtvalidator.util.FileUtil.GTFS_VALIDATOR_OUTPUT_FILE_PATH; 36 | 37 | public class Main { 38 | private static final org.slf4j.Logger _log = LoggerFactory.getLogger(Main.class); 39 | 40 | static String BASE_RESOURCE = Main.class.getResource("/webroot").toExternalForm(); 41 | 42 | private final static String PORT_NUMBER_OPTION = "port"; 43 | 44 | public static void main(String[] args) throws InterruptedException, ParseException { 45 | // Parse command line parameters 46 | Options options = setupCommandLineOptions(); 47 | 48 | // Start validator in normal server mode 49 | int port = getPortFromArgs(options, args); 50 | HibernateUtil.configureSessionFactory(); 51 | GTFSDB.initializeDB(); 52 | 53 | Server server = new Server(port); 54 | ServletContextHandler context = new ServletContextHandler(); 55 | context.setContextPath("/"); 56 | 57 | /* 58 | * Create '/classes/webroot' directory if not exists in the same directory where jar is located. 59 | * '/jar-location-directory/classes/webroot' is where we store static GTFS feed validation json output. 60 | * 'classes/webroot' is created so that it will be in sync with or without build directories. 61 | */ 62 | String gtfsValidationOutputDir = FileUtil.getJarLocation(server).getParentFile() + File.separator + GTFS_VALIDATOR_OUTPUT_FILE_PATH; 63 | File gtfsValidationOutputFile = new File(gtfsValidationOutputDir); 64 | gtfsValidationOutputFile.mkdirs(); 65 | 66 | /* 67 | * As we cannot directly add static GTFS feed json output file to jar, we add an other web resource directory 'GTFS_VALIDATOR_OUTPUT_FILE_PATH' 68 | * such that json output file can also be accessed from server. 69 | * Now there are two paths for web resources; 'BASE_RESOURCE' and 'GTFS_VALIDATOR_OUTPUT_FILE_PATH'. 70 | * 'GTFS_VALIDATOR_OUTPUT_FILE_PATH' as web resource directory is needed when we don't have any build folders. For example, see issue #181 71 | * where we only have Travis generated jar file without any build directories. 72 | */ 73 | ResourceCollection resources = new ResourceCollection(new String[] { 74 | BASE_RESOURCE, 75 | gtfsValidationOutputDir, 76 | }); 77 | context.setBaseResource(resources); 78 | 79 | server.setHandler(context); 80 | 81 | context.addServlet(GetFeedJSON.class, "/getFeed"); 82 | context.addServlet(DefaultServlet.class, "/"); 83 | 84 | ServletHolder jerseyServlet = context.addServlet(ServletContainer.class, "/api/*"); 85 | jerseyServlet.setInitOrder(1); 86 | jerseyServlet.setInitParameter("jersey.config.server.provider.classnames", "org.glassfish.jersey.moxy.json.MoxyJsonFeature"); 87 | jerseyServlet.setInitParameter("jersey.config.server.provider.packages", "edu.usf.cutr.gtfsrtvalidator.api.resource"); 88 | 89 | try { 90 | server.start(); 91 | _log.info("Go to http://localhost:" + port + " in your browser"); 92 | server.join(); 93 | } catch (Exception e) { 94 | e.printStackTrace(); 95 | } 96 | } 97 | 98 | /** 99 | * Sets up the command-line options that this application supports 100 | */ 101 | private static Options setupCommandLineOptions() { 102 | Options options = new Options(); 103 | Option portOption = Option.builder(PORT_NUMBER_OPTION) 104 | .hasArg() 105 | .desc("Port number the server should run on") 106 | .build(); 107 | options.addOption(portOption); 108 | return options; 109 | } 110 | 111 | /** 112 | * Returns the port to use from command line arguments, or 8080 if no args are provided 113 | * 114 | * @param options command line options that this application supports 115 | * @param args 116 | * @return the port to use from command line arguments, or 8080 if no args are provided 117 | */ 118 | private static int getPortFromArgs(Options options, String[] args) throws ParseException { 119 | int port = 8080; 120 | CommandLineParser parser = new DefaultParser(); 121 | CommandLine cmd = parser.parse(options, args); 122 | if (cmd.hasOption(PORT_NUMBER_OPTION)) { 123 | port = Integer.valueOf(cmd.getOptionValue(PORT_NUMBER_OPTION)); 124 | } 125 | return port; 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/java/edu/usf/cutr/gtfsrtvalidator/db/GTFSDB.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.db; 19 | 20 | import edu.usf.cutr.gtfsrtvalidator.hibernate.HibernateUtil; 21 | import edu.usf.cutr.gtfsrtvalidator.lib.model.ValidationRule; 22 | import edu.usf.cutr.gtfsrtvalidator.lib.validation.ValidationRules; 23 | import org.hibernate.Session; 24 | import org.hibernate.Transaction; 25 | import org.slf4j.Logger; 26 | import org.slf4j.LoggerFactory; 27 | 28 | import java.util.List; 29 | 30 | public class GTFSDB { 31 | 32 | private static final Logger _log = LoggerFactory.getLogger(GTFSDB.class); 33 | 34 | public static void initializeDB() { 35 | Session session = initSessionBeginTrans(); 36 | List rules = ValidationRules.getRules(); 37 | try { 38 | for (ValidationRule rule : rules) { 39 | session.saveOrUpdate(rule); 40 | } 41 | commitAndCloseSession(session); 42 | } catch (Exception ex) { 43 | ex.printStackTrace(); 44 | return; 45 | } 46 | _log.info("Table initialized successfully"); 47 | } 48 | 49 | public static Session initSessionBeginTrans() { 50 | Session session = null; 51 | Transaction tx = null; 52 | try{ 53 | session = HibernateUtil.getSessionFactory().openSession(); 54 | tx = session.beginTransaction(); 55 | }catch (Exception ex) { 56 | ex.printStackTrace(); 57 | } 58 | return session; 59 | } 60 | 61 | /** 62 | * Closes a session opened for an UPDATE operation or single READ-ONLY operation 63 | * @param session session to be committed and closed 64 | */ 65 | public static void commitAndCloseSession(Session session) { 66 | Transaction tx = null; 67 | try{ 68 | session.flush(); 69 | tx = session.getTransaction(); 70 | tx.commit(); 71 | } catch(Exception ex) { 72 | ex.printStackTrace(); 73 | if(tx != null) tx.rollback(); 74 | } finally { 75 | if(session != null) 76 | session.close(); 77 | } 78 | } 79 | 80 | /** 81 | * Closes a session used for multiple READ-ONLY operations - 82 | * see https://github.com/CUTR-at-USF/gtfs-realtime-validator/pull/135#discussion_r113005572. 83 | * 84 | * @param session session to be closed 85 | */ 86 | public static void closeSession(Session session) { 87 | if(session != null) { 88 | session.close(); 89 | } 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/java/edu/usf/cutr/gtfsrtvalidator/helper/DBHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.helper; 19 | 20 | import edu.usf.cutr.gtfsrtvalidator.db.GTFSDB; 21 | import edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel; 22 | import edu.usf.cutr.gtfsrtvalidator.lib.model.helper.ErrorListHelperModel; 23 | import org.hibernate.Session; 24 | 25 | public class DBHelper { 26 | public static void saveError(ErrorListHelperModel errorListHelperModel) { 27 | Session session = GTFSDB.initSessionBeginTrans(); 28 | session.save(errorListHelperModel.getErrorMessage()); 29 | GTFSDB.commitAndCloseSession(session); 30 | 31 | session = GTFSDB.initSessionBeginTrans(); 32 | for (OccurrenceModel occurrence : errorListHelperModel.getOccurrenceList()) { 33 | occurrence.setMessageLogModel(errorListHelperModel.getErrorMessage()); 34 | session.save(occurrence); 35 | } 36 | GTFSDB.commitAndCloseSession(session); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/java/edu/usf/cutr/gtfsrtvalidator/helper/HttpMessageHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.helper; 19 | 20 | import edu.usf.cutr.gtfsrtvalidator.lib.model.ErrorMessageModel; 21 | 22 | import javax.ws.rs.core.Response; 23 | 24 | public class HttpMessageHelper { 25 | /** 26 | * Method for generating error response given a message title, description and the error status code 27 | * @param title Title of the error 28 | * @param message Detailed description of the error 29 | * @param errorStatus Status code of the error 30 | * @return Returns a Response generated with the provided details 31 | */ 32 | public static Response generateError(String title, String message, Response.Status errorStatus) { 33 | ErrorMessageModel errorMessageModel = new ErrorMessageModel(title, message); 34 | return Response.status(errorStatus).entity(errorMessageModel).build(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/java/edu/usf/cutr/gtfsrtvalidator/helper/QueryHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 University of South Florida. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.helper; 19 | 20 | /** 21 | * QueryHelper contains queries that are used for database retrievals without any need to persist in database. 22 | */ 23 | public class QueryHelper { 24 | 25 | // Queries all the errors and warnings occurred in a session for a particular 'gtfsRtId' 26 | public static final String sessionErrorsAndWarnings = 27 | " SELECT DISTINCT(validationRule.errorId) " + 28 | " FROM MessageLogModel " + 29 | " WHERE gtfsRtFeedIterationModel.IterationId IN " + 30 | " (SELECT IterationId " + 31 | " FROM GtfsRtFeedIterationModel " + 32 | " WHERE gtfsRtFeedModel.gtfsRtId = :gtfsRtId AND timeStamp >= :startTime AND timeStamp <= :endTime) "; 33 | } 34 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/java/edu/usf/cutr/gtfsrtvalidator/helper/ServiceScheduler.java: -------------------------------------------------------------------------------- 1 | package edu.usf.cutr.gtfsrtvalidator.helper; 2 | 3 | import java.util.concurrent.ScheduledExecutorService; 4 | 5 | public class ServiceScheduler { 6 | ScheduledExecutorService scheduler; 7 | Integer updateInterval; 8 | Integer parallelClientCount; 9 | 10 | public Integer getUpdateInterval() { 11 | return updateInterval; 12 | } 13 | 14 | public void setUpdateInterval(Integer updateInterval) { 15 | this.updateInterval = updateInterval; 16 | } 17 | 18 | public Integer getParallelClientCount() { 19 | return parallelClientCount; 20 | } 21 | 22 | public void setParallelClientCount(Integer parallelClientCount) { 23 | this.parallelClientCount = parallelClientCount; 24 | } 25 | 26 | public ScheduledExecutorService getScheduler() { 27 | return scheduler; 28 | } 29 | 30 | public void setScheduler(ScheduledExecutorService scheduler) { 31 | this.scheduler = scheduler; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/java/edu/usf/cutr/gtfsrtvalidator/hibernate/HibernateUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * To change this license header, choose License Headers in Project Properties. 3 | * To change this template file, choose Tools | Templates 4 | * and open the template in the editor. 5 | */ 6 | package edu.usf.cutr.gtfsrtvalidator.hibernate; 7 | 8 | import org.hibernate.HibernateException; 9 | import org.hibernate.SessionFactory; 10 | import org.hibernate.cfg.Configuration; 11 | 12 | public class HibernateUtil { 13 | private static SessionFactory sessionFactory = null; 14 | 15 | public static void configureSessionFactory() throws HibernateException { 16 | // Set jboss logging provider to use slf4j configuration provided in 'simplelogger.properties' file 17 | System.setProperty("org.jboss.logging.provider", "slf4j"); 18 | 19 | sessionFactory = new Configuration().configure().buildSessionFactory(); 20 | } 21 | 22 | public static SessionFactory getSessionFactory() { 23 | return sessionFactory; 24 | } 25 | 26 | public static void shutdown() { 27 | // Close caches and connection pools 28 | getSessionFactory().close(); 29 | } 30 | } -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/java/edu/usf/cutr/gtfsrtvalidator/servlets/GetFeedJSON.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.servlets; 19 | 20 | import edu.usf.cutr.gtfsrtvalidator.util.ProtoBufUtils; 21 | 22 | import javax.servlet.http.HttpServlet; 23 | import javax.servlet.http.HttpServletRequest; 24 | import javax.servlet.http.HttpServletResponse; 25 | import java.io.IOException; 26 | 27 | public class GetFeedJSON extends HttpServlet { 28 | 29 | @Override 30 | protected void doGet(HttpServletRequest request, HttpServletResponse response){ 31 | String value = request.getParameter("path"); 32 | String jsonString = ProtoBufUtils.protoToJSON(value); 33 | 34 | response.setContentType("application/json"); 35 | response.setStatus(HttpServletResponse.SC_OK); 36 | 37 | //Creates simple json object giving the feed type 38 | //Should be changed to a java object if more complexities occur. 39 | try { 40 | response.getWriter().println(jsonString); 41 | } catch (IOException e) { 42 | e.printStackTrace(); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/java/edu/usf/cutr/gtfsrtvalidator/util/FileUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011-2018 Nipuna Gunathilake, University of South Florida (sjbarbeau@gmail.com) 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package edu.usf.cutr.gtfsrtvalidator.util; 18 | 19 | import java.io.File; 20 | import java.io.UnsupportedEncodingException; 21 | import java.net.URISyntaxException; 22 | import java.net.URL; 23 | import java.net.URLEncoder; 24 | 25 | /** 26 | * Utility class to get the file location for the GTFS (schedule data) validation output. 27 | */ 28 | public class FileUtil { 29 | 30 | public static final String GTFS_VALIDATOR_OUTPUT_FILE_PATH = "classes" + File.separator + "webroot"; 31 | 32 | /** 33 | * Returns the JAR location on disk 34 | * @param o any instantiated class 35 | * @return the JAR location on disk 36 | */ 37 | public static File getJarLocation(Object o) { 38 | URL jarLocation = o.getClass().getProtectionDomain().getCodeSource().getLocation(); 39 | File f = null; 40 | try { 41 | f = new File(jarLocation.toURI()); 42 | } catch (URISyntaxException e) { 43 | e.printStackTrace(); 44 | } 45 | return f; 46 | } 47 | 48 | /** 49 | * Returns the file name for a provided GTFS data URL, or null if one couldn't be created 50 | * @param url URL of the GTFS zip file 51 | * @return the file name for a provided GTFS data URL, or null if one couldn't be created 52 | */ 53 | public static String getGtfsFileName(String url) { 54 | String fileName = null; 55 | try { 56 | fileName = URLEncoder.encode(url, "UTF-8"); 57 | } catch (UnsupportedEncodingException e) { 58 | e.printStackTrace(); 59 | } 60 | return fileName; 61 | } 62 | 63 | /** 64 | * Returns a reference to the file for the GTFS schedule validation output 65 | * @param o any instantiated class, used to get the JAR file location 66 | * @param gtfsFileName the file name for a GTFS zip file (can be derived from URL using getGtfsFileName()) 67 | * @return a reference to the file for the GTFS schedule validation output 68 | */ 69 | public static File getGtfsValidationOutputFile(Object o, String gtfsFileName) { 70 | String saveDir = FileUtil.getJarLocation(o).getParentFile().getAbsolutePath(); 71 | String validationFileName = saveDir + File.separator + GTFS_VALIDATOR_OUTPUT_FILE_PATH + File.separator + gtfsFileName + "_out.json"; 72 | return new File(validationFileName); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/java/edu/usf/cutr/gtfsrtvalidator/util/ProtoBufUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package edu.usf.cutr.gtfsrtvalidator.util; 19 | 20 | import com.google.transit.realtime.GtfsRealtime; 21 | import com.googlecode.protobuf.format.JsonFormat; 22 | 23 | import java.io.FileInputStream; 24 | import java.io.IOException; 25 | 26 | public class ProtoBufUtils { 27 | 28 | // Convert profbuf to JSON 29 | public static String protoToJSON(String path) { 30 | 31 | String workingDir = System.getProperty("user.dir"); 32 | String tripUpdatePath = workingDir + "/target/classes/tripupdate"; 33 | String json = ""; 34 | 35 | try { 36 | FileInputStream fis = new FileInputStream(tripUpdatePath); 37 | GtfsRealtime.FeedMessage message = GtfsRealtime.FeedMessage.parseFrom(fis); 38 | 39 | json = JsonFormat.printToString(message); 40 | } catch (IOException e) { 41 | e.printStackTrace(); 42 | } 43 | return json; 44 | } 45 | } -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/resources/hibernate.cfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | org.hibernate.dialect.HSQLDialect 6 | org.hsqldb.jdbcDriver 7 | jdbc:hsqldb:file:gtfsrthsql;hsqldb.log_data=false 8 | 1 9 | 1 10 | 1800 11 | 50 12 | sa 13 | 14 | update 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/resources/simplelogger.properties: -------------------------------------------------------------------------------- 1 | handlers = org.eclipse.jetty.demo.SystemOutHandler 2 | .level = INFO 3 | 4 | # To include log levels, add "org.slf4j.simpleLogger.log.[to be applied API] = REQUIRED_LEVEL" 5 | org.slf4j.simpleLogger.log.org.eclipse.jetty = WARN 6 | org.slf4j.simpleLogger.log.org.hibernate = WARN 7 | org.slf4j.simpleLogger.log.org.onebusaway = WARN 8 | org.slf4j.simpleLogger.defaultLogLevel=INFO 9 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/resources/webroot/css/bootstrap-toggle.min.css: -------------------------------------------------------------------------------- 1 | /*! ======================================================================== 2 | * Bootstrap Toggle: bootstrap-toggle.css v2.2.0 3 | * http://www.bootstraptoggle.com 4 | * ======================================================================== 5 | * Copyright 2014 Min Hur, The New York Times Company 6 | * Licensed under MIT 7 | * ======================================================================== */ 8 | .checkbox label .toggle,.checkbox-inline .toggle{margin-left:-20px;margin-right:5px} 9 | .toggle{position:relative;overflow:hidden} 10 | .toggle input[type=checkbox]{display:none} 11 | .toggle-group{position:absolute;width:200%;top:0;bottom:0;left:0;transition:left .35s;-webkit-transition:left .35s;-moz-user-select:none;-webkit-user-select:none} 12 | .toggle.off .toggle-group{left:-100%} 13 | .toggle-on{position:absolute;top:0;bottom:0;left:0;right:50%;margin:0;border:0;border-radius:0} 14 | .toggle-off{position:absolute;top:0;bottom:0;left:50%;right:0;margin:0;border:0;border-radius:0} 15 | .toggle-handle{position:relative;margin:0 auto;padding-top:0;padding-bottom:0;height:100%;width:0;border-width:0 1px} 16 | .toggle.btn{min-width:59px;min-height:34px} 17 | .toggle-on.btn{padding-right:24px} 18 | .toggle-off.btn{padding-left:24px} 19 | .toggle.btn-lg{min-width:79px;min-height:45px} 20 | .toggle-on.btn-lg{padding-right:31px} 21 | .toggle-off.btn-lg{padding-left:31px} 22 | .toggle-handle.btn-lg{width:40px} 23 | .toggle.btn-sm{min-width:50px;min-height:30px} 24 | .toggle-on.btn-sm{padding-right:20px} 25 | .toggle-off.btn-sm{padding-left:20px} 26 | .toggle.btn-xs{min-width:35px;min-height:22px} 27 | .toggle-on.btn-xs{padding-right:12px} 28 | .toggle-off.btn-xs{padding-left:12px} -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/resources/webroot/css/jquery.bs_pagination.min.css: -------------------------------------------------------------------------------- 1 | .row-space{margin-top:15px !important}.pagination_custom{margin:0}.small-input{width:50px !important}@media(min-width:768px){.row-space{margin-top:15px !important}}@media(min-width:992px){.row-space{margin-top:0 !important}}@media(min-width:1200px){.row-space{margin-top:0 !important}} -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/resources/webroot/css/style.css: -------------------------------------------------------------------------------- 1 | .main-container { 2 | background-color: #ffffff; 3 | } 4 | 5 | .navbar-fixed-top { 6 | min-height: 70px; 7 | } 8 | 9 | .content-well { 10 | padding-top: 0; 11 | } 12 | 13 | .content-well hr { 14 | margin: 0 0 10px 0; 15 | } 16 | 17 | .progress { 18 | height: 15px; 19 | } 20 | 21 | .badge { 22 | background: red; 23 | } 24 | 25 | .info-text { 26 | color: darkred; 27 | font-size: large; 28 | } 29 | 30 | /*bootstrap-checkbox BEGIN*/ 31 | .bootstrap-checkbox { 32 | display:inline-block; 33 | position:relative; 34 | width:13px; 35 | height:13px; 36 | border:1px solid #000; 37 | -webkit-user-select: none; 38 | -moz-user-select: none; 39 | -ms-user-select: none; 40 | user-select: none; 41 | } 42 | 43 | .bootstrap-checkbox i{ 44 | position:absolute; 45 | left : -1px; 46 | top : -2px; 47 | } 48 | 49 | 50 | /*bootstrap-checkbox END*/ 51 | .panel-heading a:hover{ 52 | text-decoration: none !important; 53 | } 54 | .panel-heading a:after { 55 | font-family: 'Glyphicons Halflings', sans-serif; 56 | content:"\e114"; 57 | float: right; 58 | color: grey; 59 | } 60 | .panel-heading a.collapsed:after { 61 | content:"\e080"; 62 | } 63 | 64 | .highlight { 65 | background-color: #FFFF88; 66 | } 67 | 68 | #feed-display { 69 | position: relative; 70 | height: 105vh; 71 | overflow: auto; 72 | outline: 2px solid rgb(229, 229, 229); 73 | } 74 | 75 | #feedMessage{ 76 | border-radius: 0px; 77 | } 78 | 79 | .feed-padding { 80 | padding-top: 80px; 81 | } 82 | 83 | #copy-clipboard { 84 | cursor: pointer; 85 | position: absolute; 86 | font-size: 3em; 87 | /* right and bottom are relative to the parent element #feed-display*/ 88 | right: 7vh; 89 | bottom: 3vh; 90 | } 91 | 92 | .iteration-issues { 93 | position: relative; 94 | padding-top: 20px; 95 | height: 100vh; 96 | overflow: auto; 97 | } 98 | 99 | .modal-title { 100 | text-align: center; 101 | } 102 | 103 | .feed-padding .content-well { 104 | margin: 0; 105 | padding-top: 10px; 106 | } 107 | 108 | .each-card { 109 | background-color: #ffffff; 110 | } 111 | 112 | .iterations-thead { 113 | background-color: rgba(85, 85, 85, 0.62); 114 | } 115 | 116 | .iterations-td { 117 | background-color: rgba(85, 85, 85, 0.11); 118 | } 119 | 120 | .feed-page-loader, .issues-page-loader { 121 | background-color: #fffff; 122 | position: absolute; 123 | top: 50%; 124 | left: 50%; 125 | } 126 | 127 | .download-button { 128 | cursor: pointer; 129 | font-size: 1.2em; 130 | } 131 | 132 | .download-button:hover { 133 | color: #0027ff; 134 | } 135 | 136 | ::-ms-clear { 137 | display: none; 138 | } 139 | 140 | .form-control-clear { 141 | z-index: 10; 142 | pointer-events: auto; 143 | cursor: pointer; 144 | } -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/resources/webroot/custom-js/error.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2011 Nipuna Gunathilake. 3 | * All rights reserved. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | /** 19 | * Created by nipuna on 8/21/15. 20 | */ 21 | 22 | $.get(window.location.protocol + "//" + window.location.host + "/getFeed") 23 | .done(function (data) { 24 | 25 | var res1 = jsonPath(data, "$.entity.*"); 26 | var res2 = jsonPath(data, "$.entity.*", {resultType: "PATH"}); 27 | 28 | var text = ""; 29 | 30 | for (var errorItem in res1) { 31 | var jsonItem = JSON.stringify(res1[errorItem], null, 2); 32 | $("#error-list").append("

" + jsonItem + "
"); 33 | } 34 | 35 | for (var item in res2) { 36 | var subitemArray = res2[item].split(";"); 37 | 38 | subitemArray.shift(); 39 | for (var subItem in subitemArray) { 40 | 41 | if (!isNaN(text)) { 42 | text += "." + subitemArray[subItem]; 43 | } else { 44 | text += "[" + subitemArray[subItem] + "]"; 45 | } 46 | } 47 | var parsedPath = "data" + text; 48 | 49 | var jsonObject = eval(parsedPath); 50 | 51 | 52 | eval(parsedPath + "['color'] = '#e4e4e4'"); 53 | eval(parsedPath + "['error'] = 'Timestamp error occurred'"); 54 | text = ""; 55 | } 56 | 57 | Handlebars.registerPartial("marked", $("#marked-partial").html()); 58 | 59 | var feedTemplateScript = $("#gtfsrt-feed-template").html(); 60 | var feedTemplate = Handlebars.compile(feedTemplateScript); 61 | var compiledHtml = feedTemplate(data); 62 | //$('#googleFeed').html(compiledHtml); 63 | 64 | 65 | var jsonPrint = JSON.stringify(data, null, 2); 66 | $("#error-json").html(jsonPrint); 67 | 68 | var lines = jsonPrint.split('\n'); 69 | 70 | $(".errorItem").hover(function () { 71 | var selectedText = $(this).text(); 72 | console.log(selectedText); 73 | $("body").highlight(selectedText, true); 74 | }, function () { 75 | $("body").removeHighlight(); 76 | }); 77 | 78 | }); -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/resources/webroot/detailed.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | GTFS-RT Validator 7 | 8 | 9 | 10 | 11 | 14 | 15 | 16 | 36 | 37 |
38 | 39 |
40 |
41 |

Detailed Log: 123456

42 |
43 |
44 | 45 |
46 |
47 | 48 |
49 | 50 | 51 |
52 |
53 |

54 | 55 | Filters 56 | 57 |

58 |
59 |
60 |
61 |
62 |
63 |

Error Type

64 |
65 | 69 |
70 | 71 |
72 | 76 |
77 |
78 | 79 |
80 |

Stream

81 |
82 | 86 |
87 | 88 |
89 | 93 |
94 | 95 |
96 | 100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 | 108 | 109 | 110 |
111 |
112 |

Error Details

113 |
114 | 115 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 |
#Err#Error TypeDescriptionFeedOccurrences
136 |
137 |
138 |
139 |
140 |
141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/resources/webroot/error.html: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | GTFS-RT Validator 25 | 26 | 27 | 28 | 31 | 32 | 33 | 34 | 54 | 55 |
56 | 57 |
58 |
59 |

JSON Errors

60 |
61 |
62 | 63 |
64 |
65 |

Original Feed

66 | 67 |

 68 |             
69 |
70 |
71 |

Error segments

72 |
73 |
74 |
75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 86 | 87 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/resources/webroot/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MobilityData/gtfs-realtime-validator/57146b4eb7a55e68f4655b8c3f3ffb5ed9cebff1/gtfs-realtime-validator-webapp/src/main/resources/webroot/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/resources/webroot/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MobilityData/gtfs-realtime-validator/57146b4eb7a55e68f4655b8c3f3ffb5ed9cebff1/gtfs-realtime-validator-webapp/src/main/resources/webroot/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/resources/webroot/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MobilityData/gtfs-realtime-validator/57146b4eb7a55e68f4655b8c3f3ffb5ed9cebff1/gtfs-realtime-validator-webapp/src/main/resources/webroot/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/resources/webroot/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/MobilityData/gtfs-realtime-validator/57146b4eb7a55e68f4655b8c3f3ffb5ed9cebff1/gtfs-realtime-validator-webapp/src/main/resources/webroot/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/resources/webroot/iteration.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Iteration details 6 | 7 | 8 | 9 | 10 | 11 | 19 | 20 |
21 |
22 |
23 |
24 |

 25 |                     
26 | 27 |
28 |
29 | 30 | 31 |
32 |
33 |
34 | 35 | 36 |
37 |
38 |
39 |
40 |
41 | 0 42 |  error(s), 43 | 0 44 |  warning(s) 45 |
46 |
47 | Download all  48 | 49 |
50 |
51 |
52 |
53 | 54 |
55 |
56 | 57 |
58 |
59 |
60 |
61 |
62 |
63 | 64 |
65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 113 | 114 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /gtfs-realtime-validator-webapp/src/main/resources/webroot/js/bootstrap-toggle.min.js: -------------------------------------------------------------------------------- 1 | /*! ======================================================================== 2 | * Bootstrap Toggle: bootstrap-toggle.js v2.2.0 3 | * http://www.bootstraptoggle.com 4 | * ======================================================================== 5 | * Copyright 2014 Min Hur, The New York Times Company 6 | * Licensed under MIT 7 | * ======================================================================== */ 8 | +function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.toggle"),f="object"==typeof b&&b;e||d.data("bs.toggle",e=new c(this,f)),"string"==typeof b&&e[b]&&e[b]()})}var c=function(b,c){this.$element=a(b),this.options=a.extend({},this.defaults(),c),this.render()};c.VERSION="2.2.0",c.DEFAULTS={on:"On",off:"Off",onstyle:"primary",offstyle:"default",size:"normal",style:"",width:null,height:null},c.prototype.defaults=function(){return{on:this.$element.attr("data-on")||c.DEFAULTS.on,off:this.$element.attr("data-off")||c.DEFAULTS.off,onstyle:this.$element.attr("data-onstyle")||c.DEFAULTS.onstyle,offstyle:this.$element.attr("data-offstyle")||c.DEFAULTS.offstyle,size:this.$element.attr("data-size")||c.DEFAULTS.size,style:this.$element.attr("data-style")||c.DEFAULTS.style,width:this.$element.attr("data-width")||c.DEFAULTS.width,height:this.$element.attr("data-height")||c.DEFAULTS.height}},c.prototype.render=function(){this._onstyle="btn-"+this.options.onstyle,this._offstyle="btn-"+this.options.offstyle;var b="large"===this.options.size?"btn-lg":"small"===this.options.size?"btn-sm":"mini"===this.options.size?"btn-xs":"",c=a('