Skip to content

Commit

Permalink
Merge pull request #726 from conveyal/restore-priority-field
Browse files Browse the repository at this point in the history
Restore priority field
  • Loading branch information
abyrd authored May 16, 2021
2 parents d0388e1 + f6d2001 commit 302224c
Show file tree
Hide file tree
Showing 25 changed files with 34 additions and 118 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/conveyal/analysis/models/Bundle.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public static class GtfsErrorTypeSummary {
public Priority priority;
public GtfsErrorTypeSummary () { /* For deserialization. */ }
public GtfsErrorTypeSummary (GTFSError error) {
this.priority = error.getPriority();
this.priority = error.priority;
this.type = error.errorType;
}
}
Expand Down
6 changes: 1 addition & 5 deletions src/main/java/com/conveyal/gtfs/error/DateParseError.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ public class DateParseError extends GTFSError implements Serializable {
public static final long serialVersionUID = 1L;

public DateParseError(String file, long line, String field) {
super(file, line, field);
super(file, line, field, Priority.MEDIUM);
}

@Override public String getMessage() {
return "Could not parse date (format should be YYYYMMDD).";
}

@Override public Priority getPriority() {
return Priority.MEDIUM;
}
}
6 changes: 1 addition & 5 deletions src/main/java/com/conveyal/gtfs/error/DuplicateKeyError.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,10 @@ public class DuplicateKeyError extends GTFSError implements Serializable {
public static final long serialVersionUID = 1L;

public DuplicateKeyError(String file, long line, String field) {
super(file, line, field);
super(file, line, field, Priority.MEDIUM);
}

@Override public String getMessage() {
return "Duplicate primary key.";
}

@Override public Priority getPriority() {
return Priority.MEDIUM;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@ public class DuplicateStopError extends GTFSError implements Serializable {
public final DuplicateStops duplicateStop;

public DuplicateStopError(DuplicateStops duplicateStop) {
super("stop", duplicateStop.getDuplicatedStop().sourceFileLine, "stop_lat,stop_lon", duplicateStop.getDuplicatedStop().stop_id);
super("stop", duplicateStop.getDuplicatedStop().sourceFileLine, "stop_lat,stop_lon", Priority.MEDIUM, duplicateStop.getDuplicatedStop().stop_id);
this.message = duplicateStop.toString();
this.duplicateStop = duplicateStop;
}

@Override public String getMessage() {
return message;
}

@Override public Priority getPriority() {
return Priority.MEDIUM;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class DuplicateTripError extends GTFSError implements Serializable {
String lastArrival;

public DuplicateTripError(Trip trip, long line, String duplicateTripId, String patternName, String firstDeparture, String lastArrival) {
super("trips", line, "trip_id", trip.trip_id);
super("trips", line, "trip_id", Priority.MEDIUM, trip.trip_id);
this.duplicateTripId = duplicateTripId;
this.patternName = patternName;
this.routeId = trip.route_id;
Expand All @@ -33,8 +33,4 @@ public DuplicateTripError(Trip trip, long line, String duplicateTripId, String p
@Override public String getMessage() {
return String.format("Trip Ids %s & %s (route %s) are duplicates (pattern: %s, calendar: %s, from %s to %s)", duplicateTripId, affectedEntityId, routeId, patternName, serviceId, firstDeparture, lastArrival);
}

@Override public Priority getPriority() {
return Priority.MEDIUM;
}
}
5 changes: 1 addition & 4 deletions src/main/java/com/conveyal/gtfs/error/EmptyFieldError.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ public class EmptyFieldError extends GTFSError implements Serializable {
public static final long serialVersionUID = 1L;

public EmptyFieldError(String file, long line, String field) {
super(file, line, field);
super(file, line, field, Priority.MEDIUM);
}

@Override public String getMessage() {
return String.format("No value supplied for a required column.");
}

@Override public Priority getPriority() {
return Priority.MEDIUM;
}
}
6 changes: 1 addition & 5 deletions src/main/java/com/conveyal/gtfs/error/EmptyTableError.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,10 @@ public class EmptyTableError extends GTFSError implements Serializable {
public static final long serialVersionUID = 1L;

public EmptyTableError(String file) {
super(file, 0, null);
super(file, 0, null, Priority.MEDIUM);
}

@Override public String getMessage() {
return String.format("Table is present in zip file, but it has no entries.");
}

@Override public Priority getPriority() {
return Priority.MEDIUM;
}
}
18 changes: 8 additions & 10 deletions src/main/java/com/conveyal/gtfs/error/GTFSError.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,21 @@ public abstract class GTFSError implements Comparable<GTFSError>, Serializable {
public final String field;
public final String affectedEntityId;
public final String errorType;
// NOTE: Do not remove this field. Though this field is somewhat redundant (since every instance of each class has
// the same priority) we have old MapDB files around that contain serialized errors. They would all break.
public final Priority priority;

public GTFSError(String file, long line, String field) {
this(file, line, field, null);
public GTFSError(String file, long line, String field, Priority priority) {
this(file, line, field, priority, null);
}

public GTFSError(String file, long line, String field, String affectedEntityId) {
public GTFSError(String file, long line, String field, Priority priority, String affectedEntityId) {
this.file = file;
this.line = line;
this.field = field;
this.affectedEntityId = affectedEntityId;
this.errorType = this.getClass().getSimpleName();
this.priority = priority;
}

/**
Expand All @@ -40,6 +44,7 @@ public GTFSError (String entityId) {
this.field = null;
this.errorType = null;
this.affectedEntityId = entityId;
this.priority = Priority.UNKNOWN;
}

/**
Expand All @@ -50,13 +55,6 @@ public final String getErrorCode () {
return this.getClass().getSimpleName();
}

/**
* @return The Error priority level associated with this class.
*/
public Priority getPriority() {
return Priority.UNKNOWN;
}

/**
* @return a Class object for the class of GTFS entity in which the error was found,
* which also implies a table in the GTFS feed.
Expand Down
5 changes: 1 addition & 4 deletions src/main/java/com/conveyal/gtfs/error/GeneralError.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,12 @@ public class GeneralError extends GTFSError implements Serializable {
private String message;

public GeneralError(String file, long line, String field, String message) {
super(file, line, field);
super(file, line, field, Priority.UNKNOWN);
this.message = message;
}

@Override public String getMessage() {
return message;
}

@Override public Priority getPriority() {
return Priority.UNKNOWN;
}
}
8 changes: 3 additions & 5 deletions src/main/java/com/conveyal/gtfs/error/MisplacedStopError.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,16 @@
public class MisplacedStopError extends GTFSError implements Serializable {
public static final long serialVersionUID = 1L;

public final Priority priority;
public final Stop stop;

public MisplacedStopError(String affectedEntityId, long line, Stop stop) {
super("stops", line, "stop_id", affectedEntityId);
super("stops", line, "stop_id", Priority.MEDIUM, affectedEntityId);
this.priority = Priority.HIGH;
this.stop = stop;
}

@Override public String getMessage() {
return String.format("Stop Id %s is misplaced.", affectedEntityId);
}

@Override public Priority getPriority() {
return Priority.MEDIUM;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ public class MissingColumnError extends GTFSError implements Serializable {
public static final long serialVersionUID = 1L;

public MissingColumnError(String file, String field) {
super(file, 1, field);
super(file, 1, field, Priority.MEDIUM);
}

@Override public String getMessage() {
return String.format("Missing required column.");
}

@Override public Priority getPriority() {
return Priority.MEDIUM;
}
}
6 changes: 1 addition & 5 deletions src/main/java/com/conveyal/gtfs/error/MissingShapeError.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,10 @@ public class MissingShapeError extends GTFSError implements Serializable {
public static final long serialVersionUID = 1L;

public MissingShapeError(Trip trip) {
super("trips", trip.sourceFileLine, "shape_id", trip.trip_id);
super("trips", trip.sourceFileLine, "shape_id", Priority.LOW, trip.trip_id);
}

@Override public String getMessage() {
return "Trip " + affectedEntityId + " is missing a shape";
}

@Override public Priority getPriority() {
return Priority.LOW;
}
}
5 changes: 1 addition & 4 deletions src/main/java/com/conveyal/gtfs/error/MissingTableError.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ public class MissingTableError extends GTFSError implements Serializable {
public static final long serialVersionUID = 1L;

public MissingTableError(String file) {
super(file, 0, null);
super(file, 0, null, Priority.MEDIUM);
}

@Override public String getMessage() {
return String.format("This table is required by the GTFS specification but is missing.");
}

@Override public Priority getPriority() {
return Priority.MEDIUM;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@
*/
public class NoAgencyInFeedError extends GTFSError {
public NoAgencyInFeedError() {
super("agency", 0, "agency_id");
super("agency", 0, "agency_id", Priority.HIGH);
}

@Override public String getMessage() {
return String.format("No agency listed in feed (must have at least one).");
}

@Override public Priority getPriority() {
return Priority.HIGH;
}
}
5 changes: 1 addition & 4 deletions src/main/java/com/conveyal/gtfs/error/NumberParseError.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ public class NumberParseError extends GTFSError implements Serializable {
public static final long serialVersionUID = 1L;

public NumberParseError(String file, long line, String field) {
super(file, line, field);
super(file, line, field, Priority.HIGH);
}

@Override public String getMessage() {
return String.format("Error parsing a number from a string.");
}

@Override public Priority getPriority() {
return Priority.HIGH;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,12 @@ public class OverlappingTripsInBlockError extends GTFSError implements Serializa
public final String routeId;

public OverlappingTripsInBlockError(long line, String field, String affectedEntityId, String routeId, String[] tripIds) {
super("trips", line, field, affectedEntityId);
super("trips", line, field, Priority.MEDIUM, affectedEntityId);
this.tripIds = tripIds;
this.routeId = routeId;
}

@Override public String getMessage() {
return String.format("Trip Ids %s overlap (route: %s) and share block ID %s", String.join(" & ", tripIds), routeId, affectedEntityId);
}

@Override public Priority getPriority() {
return Priority.MEDIUM;
}
}
5 changes: 1 addition & 4 deletions src/main/java/com/conveyal/gtfs/error/RangeError.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class RangeError extends GTFSError implements Serializable {
final double min, max, actual;

public RangeError(String file, long line, String field, double min, double max, double actual) {
super(file, line, field);
super(file, line, field, Priority.LOW);
this.min = min;
this.max = max;
this.actual = actual;
Expand All @@ -21,7 +21,4 @@ public RangeError(String file, long line, String field, double min, double max,
return String.format("Number %s outside of acceptable range [%s,%s].", actual, min, max);
}

@Override public Priority getPriority() {
return Priority.LOW;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class ReferentialIntegrityError extends GTFSError implements Serializable
public final String badReference;

public ReferentialIntegrityError(String tableName, long row, String field, String badReference) {
super(tableName, row, field);
super(tableName, row, field, Priority.HIGH);
this.badReference = badReference;
}

Expand All @@ -27,8 +27,4 @@ public int compareTo (GTFSError o) {
@Override public String getMessage() {
return String.format(badReference);
}

@Override public Priority getPriority() {
return Priority.HIGH;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@ public class ReversedTripShapeError extends GTFSError implements Serializable {
public final String shapeId;

public ReversedTripShapeError(Trip trip) {
super("trips", trip.sourceFileLine, "shape_id", trip.trip_id);
super("trips", trip.sourceFileLine, "shape_id", Priority.HIGH, trip.trip_id);
this.shapeId = trip.shape_id;
}

@Override public String getMessage() {
return "Trip " + affectedEntityId + " references reversed shape " + shapeId;
}

@Override public Priority getPriority() {
return Priority.HIGH;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,11 @@ public class ShapeMissingCoordinatesError extends GTFSError implements Serializa
public final String[] tripIds;

public ShapeMissingCoordinatesError(ShapePoint shapePoint, String[] tripIds) {
super("shapes", shapePoint.sourceFileLine, "shape_id", shapePoint.shape_id);
super("shapes", shapePoint.sourceFileLine, "shape_id", Priority.MEDIUM, shapePoint.shape_id);
this.tripIds = tripIds;
}

@Override public String getMessage() {
return "Shape " + affectedEntityId + " is missing coordinates (affects " + tripIds.length + " trips)";
}

@Override public Priority getPriority() {
return Priority.MEDIUM;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,11 @@ public class TableInSubdirectoryError extends GTFSError implements Serializable
public final String directory;

public TableInSubdirectoryError(String file, String directory) {
super(file, 0, null);
super(file, 0, null, Priority.HIGH);
this.directory = directory;
}

@Override public String getMessage() {
return String.format("All GTFS files (including %s.txt) should be at root of zipfile, not nested in subdirectory (%s)", file, directory);
}

@Override public Priority getPriority() {
return Priority.HIGH;
}
}
5 changes: 1 addition & 4 deletions src/main/java/com/conveyal/gtfs/error/TimeParseError.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,11 @@ public class TimeParseError extends GTFSError implements Serializable {
public static final long serialVersionUID = 1L;

public TimeParseError(String file, long line, String field) {
super(file, line, field);
super(file, line, field, Priority.MEDIUM);
}

@Override public String getMessage() {
return "Could not parse time (format should be HH:MM:SS).";
}

@Override public Priority getPriority() {
return Priority.MEDIUM;
}
}
Loading

0 comments on commit 302224c

Please sign in to comment.