Skip to content

Commit

Permalink
Merge pull request #297 from ibi-group/mtc-config
Browse files Browse the repository at this point in the history
Add call to MTCValidator
  • Loading branch information
landonreed authored Apr 14, 2020
2 parents 12f8dd5 + 0ae68ed commit 62dd007
Show file tree
Hide file tree
Showing 3 changed files with 194 additions and 192 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
<dependency>
<groupId>com.conveyal</groupId>
<artifactId>gtfs-lib</artifactId>
<version>5.1.0</version>
<version>6.0.0</version>
<!-- Exclusions added in order to silence SLF4J warnings about multiple bindings:
http://www.slf4j.org/codes.html#multiple_bindings
-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.conveyal.gtfs.GTFS;
import com.conveyal.gtfs.loader.Feed;
import com.conveyal.gtfs.loader.FeedLoadResult;
import com.conveyal.gtfs.validator.MTCValidator;
import com.conveyal.gtfs.validator.ValidationResult;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
Expand All @@ -32,6 +33,7 @@
import java.util.Set;
import java.util.UUID;

import static com.conveyal.datatools.manager.DataManager.isExtensionEnabled;
import static com.conveyal.datatools.manager.utils.StringUtils.getCleanName;
import static com.mongodb.client.model.Filters.and;
import static com.mongodb.client.model.Filters.eq;
Expand Down Expand Up @@ -226,7 +228,7 @@ public void load(MonitorableJob.Status status, boolean isNewVersion) {
File gtfsFile;
// STEP 1. LOAD GTFS feed into relational database
try {
status.update(false,"Unpacking feed...", 15.0);
status.update("Unpacking feed...", 15.0);
// Get SQL schema namespace for the feed version. This is needed for reconnecting with feeds
// in the database.
gtfsFile = retrieveGtfsFile();
Expand All @@ -241,19 +243,15 @@ public void load(MonitorableJob.Status status, boolean isNewVersion) {
this.namespace = feedLoadResult.uniqueIdentifier;
LOG.info("Loaded GTFS into SQL {}", feedLoadResult.uniqueIdentifier);
} catch (Exception e) {
String errorString = String.format("Error loading GTFS feed for version: %s", this.id);
LOG.warn(errorString, e);
status.update(true, errorString, 0);
status.fail(String.format("Error loading GTFS feed for version: %s", this.id), e);
// FIXME: Delete local copy of feed version after failed load?
return;
}

// FIXME: is this the right approach?
// if load was unsuccessful, update status and return
if(this.feedLoadResult == null) {
String errorString = String.format("Could not load GTFS for FeedVersion %s", id);
LOG.error(errorString);
status.update(true, errorString, 0);
status.fail(String.format("Could not load GTFS for FeedVersion %s", id));
// FIXME: Delete local copy of feed version after failed load?
return;
}
Expand Down Expand Up @@ -310,14 +308,18 @@ public void validate(MonitorableJob.Status status) {
// VALIDATE GTFS feed
try {
LOG.info("Beginning validation...");
// run validation on feed version
// FIXME: pass status to validate? Or somehow listen to events?
status.update("Validating feed...", 33);
validationResult = GTFS.validate(feedLoadResult.uniqueIdentifier, DataManager.GTFS_DATA_SOURCE);

// Validate the feed version.
// Certain extensions, if enabled, have extra validators
if (isExtensionEnabled("mtc")) {
validationResult = GTFS.validate(feedLoadResult.uniqueIdentifier, DataManager.GTFS_DATA_SOURCE, MTCValidator::new);
} else {
validationResult = GTFS.validate(feedLoadResult.uniqueIdentifier, DataManager.GTFS_DATA_SOURCE);
}
} catch (Exception e) {
String message = String.format("Unable to validate feed %s", this.id);
LOG.error(message, e);
status.update(true, message, 100, true);
status.fail(String.format("Unable to validate feed %s", this.id), e);
// FIXME create validation result with new constructor?
validationResult = new ValidationResult();
validationResult.fatalException = "failure!";
Expand Down
Loading

0 comments on commit 62dd007

Please sign in to comment.