Skip to content
This repository has been archived by the owner on May 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #341 from minhhpham/v26-schedule_relationship-SKIPPED
Browse files Browse the repository at this point in the history
Add Rule W101 to count the frequency of issue #26
  • Loading branch information
minhhpham authored Oct 17, 2018
2 parents 2f77595 + 1199a83 commit adbacc1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions RULES.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Rules are declared in the [`ValidationRules` class](https://github.com/CUTR-at-U
| [W007](#W007) | Refresh interval is more than 35 seconds
| [W008](#W008) | Header `timestamp` is older than 65 seconds
| [W009](#W009) | `schedule_relationship` not populated
| [W101](#W101) | `StopTimeUpdate.schedule_relationship: SKIPPED`

# Errors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public class ValidationRules {
public static final ValidationRule W009 = new ValidationRule("W009", "WARNING", "schedule_relationship not populated",
"trip.schedule_relationship and stop_time_update.schedule_relationship should be populated",
"does not have a schedule_relationship");
public static final ValidationRule W101 = new ValidationRule("W101", "WARNING", "StopTimeUpdate.schedule_relationship: SKIPPED",
"StopTimeUpdate.schedule_relationship: SKIPPED",
"StopTimeUpdate.schedule_relationship: SKIPPED");

/**
* Errors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
* E045 - GTFS-rt stop_time_update stop_sequence and stop_id do not match GTFS
* E046 - GTFS-rt stop_time_update without time doesn't have arrival/departure_time in GTFS
* E051 - GTFS-rt stop_sequence not found in GTFS data
* w101 - StopTimeUpdate.schedule_relationship: SKIPPED
*/
public class StopTimeUpdateValidator implements FeedEntityValidator {

Expand All @@ -72,6 +73,7 @@ public List<ErrorListHelperModel> validate(long currentTimeMillis, GtfsMutableDa
List<OccurrenceModel> e045List = new ArrayList<>();
List<OccurrenceModel> e046List = new ArrayList<>();
List<OccurrenceModel> e051List = new ArrayList<>();
List<OccurrenceModel> W101List = new ArrayList<>();

for (GtfsRealtime.FeedEntity entity : entityList) {
if (entity.hasTripUpdate()) {
Expand Down Expand Up @@ -169,6 +171,7 @@ public List<ErrorListHelperModel> validate(long currentTimeMillis, GtfsMutableDa
checkE042(entity, tripUpdate, stopTimeUpdate, e042List);
checkE043(entity, tripUpdate, stopTimeUpdate, e043List);
checkE044(entity, tripUpdate, stopTimeUpdate, e044List);
checkW101(entity, stopTimeUpdate, W101List);

if (unknownRtStopSequence) {
// E051 - GTFS-rt stop_sequence not found in GTFS data
Expand Down Expand Up @@ -236,6 +239,9 @@ public List<ErrorListHelperModel> validate(long currentTimeMillis, GtfsMutableDa
if (!e051List.isEmpty()) {
errors.add(new ErrorListHelperModel(new MessageLogModel(ValidationRules.E051), e051List));
}
if (!W101List.isEmpty()) {
errors.add(new ErrorListHelperModel(new MessageLogModel(ValidationRules.W101), W101List));
}
return errors;
}

Expand Down Expand Up @@ -438,4 +444,14 @@ private void checkE046(GtfsRealtime.FeedEntity entity, GtfsRealtime.TripUpdate t
}
}
}

private void checkW101(GtfsRealtime.FeedEntity entity, GtfsRealtime.TripUpdate.StopTimeUpdate stopTimeUpdate, List<OccurrenceModel> errors) {
if (stopTimeUpdate.hasScheduleRelationship()) {
GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship schedule_relationship = stopTimeUpdate.getScheduleRelationship();
if (schedule_relationship.equals(GtfsRealtime.TripUpdate.StopTimeUpdate.ScheduleRelationship.SKIPPED)) {
String id = GtfsUtils.getTripId(entity, entity.getTripUpdate());
RuleUtils.addOccurrence(ValidationRules.W101, id + " has schedule_relationship: SKIPPED " , errors, _log);
}
}
}
}

0 comments on commit adbacc1

Please sign in to comment.