Skip to content

Commit

Permalink
fix(shared stops): temp revert to avoid bug
Browse files Browse the repository at this point in the history
  • Loading branch information
philip-cline committed Sep 28, 2023
1 parent 7461805 commit 20940aa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.conveyal.datatools.manager.jobs.validation;

import com.conveyal.datatools.common.utils.aws.S3Utils;
import com.conveyal.datatools.manager.models.Project;
import com.conveyal.gtfs.error.NewGTFSError;
import com.conveyal.gtfs.error.NewGTFSErrorType;
Expand All @@ -23,30 +24,24 @@ public class SharedStopsValidator extends FeedValidator {
private static final Logger LOG = LoggerFactory.getLogger(SharedStopsValidator.class);

Feed feed;
String feedId;
Project project;

public SharedStopsValidator(Project project, String feedId) {
public SharedStopsValidator(Project project) {
super(null, null);
this.project = project;
this.feedId = feedId;
}

// This method can only be run on a SharedStopsValidator that has been set up with a project only
public SharedStopsValidator buildSharedStopsValidator(Feed feed, SQLErrorStorage errorStorage) {
if (this.project == null) {
throw new RuntimeException("Shared stops validator can not be called because no project has been set!");
}
if (this.feedId == null) {
throw new RuntimeException("Shared stops validator can not be called because no feed ID has been set!");
}
return new SharedStopsValidator(feed, errorStorage, this.project, this.feedId);
return new SharedStopsValidator(feed, errorStorage, this.project);
}
public SharedStopsValidator(Feed feed, SQLErrorStorage errorStorage, Project project, String feedId) {
public SharedStopsValidator(Feed feed, SQLErrorStorage errorStorage, Project project) {
super(feed, errorStorage);
this.feed = feed;
this.project = project;
this.feedId = feedId;
}

@Override
Expand All @@ -58,11 +53,9 @@ public void validate() {

CsvReader configReader = CsvReader.parse(config);

// TODO: pull indicies from the CSV header
final int STOP_GROUP_ID_INDEX = 0;
final int STOP_ID_INDEX = 2;
final int IS_PRIMARY_INDEX = 3;
final int FEED_ID_INDEX = 1;

// Build list of stop Ids.
List<String> stopIds = new ArrayList<>();
Expand All @@ -81,7 +74,6 @@ public void validate() {
while (configReader.readRecord()) {
String stopGroupId = configReader.get(STOP_GROUP_ID_INDEX);
String stopId = configReader.get(STOP_ID_INDEX);
String sharedStopFeedId = configReader.get(FEED_ID_INDEX);

if (stopId.equals("stop_id")) {
// Swallow header row
Expand Down Expand Up @@ -111,8 +103,8 @@ public void validate() {
}

// Check for SS_03 (stop_id referenced doesn't exist)
// Make sure this error is only returned if we are inside the feed that is being checked
if (feedId.equals(sharedStopFeedId) && !stopIds.contains(stopId)) {
// TODO: CHECK FEED ID (adjust the pre-build constructor to include feed_id)
if (!stopIds.contains(stopId)) {
registerError(NewGTFSError.forFeed(NewGTFSErrorType.SHARED_STOP_GROUP_ENTITY_DOES_NOT_EXIST, stopId));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.conveyal.gtfs.BaseGTFSCache;
import com.conveyal.gtfs.GTFS;
import com.conveyal.gtfs.error.NewGTFSErrorType;
import com.conveyal.gtfs.graphql.fetchers.JDBCFetcher;
import com.conveyal.gtfs.loader.Feed;
import com.conveyal.gtfs.loader.FeedLoadResult;
import com.conveyal.gtfs.validator.MTCValidator;
Expand Down Expand Up @@ -373,22 +372,7 @@ public void validate(MonitorableJob.Status status) {
);
} else {
FeedSource fs = Persistence.feedSources.getById(this.feedSourceId);

/*
Get feed_id from feed version
This could potentially happen inside gtfs-lib, however
because this functionality is specific to datatools and the
shared stops feature, it lives only here instead. Changes to
gtfs-lib have been avoided, so that gtfs-lib isn't being modified
to support proprietary features.
*/
JDBCFetcher feedFetcher = new JDBCFetcher("feed_info");
Object gtfsFeedId = feedFetcher.getResults(this.namespace, null, null).get(0).get("feed_id");


String feedId = gtfsFeedId == null ? "" : gtfsFeedId.toString();
SharedStopsValidator ssv = new SharedStopsValidator(fs.retrieveProject(), feedId);
SharedStopsValidator ssv = new SharedStopsValidator(fs.retrieveProject());

validationResult = GTFS.validate(
feedLoadResult.uniqueIdentifier,
Expand Down

0 comments on commit 20940aa

Please sign in to comment.