use of edu.usf.cutr.gtfsrtvalidator.lib.model.OccurrenceModel in project gtfs-realtime-validator by CUTR-at-USF.
the class HeaderValidator method validate.
@Override
public List<ErrorListHelperModel> validate(long currentTimeMillis, GtfsDaoImpl gtfsData, GtfsMetadata gtfsMetadata, GtfsRealtime.FeedMessage feedMessage, GtfsRealtime.FeedMessage previousFeedMessage, GtfsRealtime.FeedMessage combinedFeedMessage) {
List<OccurrenceModel> errorListE038 = new ArrayList<>();
List<OccurrenceModel> errorListE039 = new ArrayList<>();
List<OccurrenceModel> errorListE049 = new ArrayList<>();
if (!GtfsUtils.isValidVersion(feedMessage.getHeader())) {
// E038 - Invalid header.gtfs_realtime_version
RuleUtils.addOccurrence(E038, "header.gtfs_realtime_version of " + feedMessage.getHeader().getGtfsRealtimeVersion(), errorListE038, _log);
}
try {
if (GtfsUtils.isV2orHigher(feedMessage.getHeader()) && !feedMessage.getHeader().hasIncrementality()) {
// E049 - header incrementality not populated
RuleUtils.addOccurrence(E049, "", errorListE049, _log);
}
} catch (Exception e) {
_log.error("Error checking header version for E049: " + e);
}
if (feedMessage.getHeader().getIncrementality().equals(GtfsRealtime.FeedHeader.Incrementality.FULL_DATASET)) {
for (GtfsRealtime.FeedEntity entity : feedMessage.getEntityList()) {
if (entity.hasIsDeleted()) {
// E039 - FULL_DATASET feeds should not include entity.is_deleted
RuleUtils.addOccurrence(E039, "entity ID " + entity.getId() + " has is_deleted=" + entity.getIsDeleted(), errorListE039, _log);
}
}
}
List<ErrorListHelperModel> errors = new ArrayList<>();
if (!errorListE038.isEmpty()) {
errors.add(new ErrorListHelperModel(new MessageLogModel(E038), errorListE038));
}
if (!errorListE039.isEmpty()) {
errors.add(new ErrorListHelperModel(new MessageLogModel(E039), errorListE039));
}
if (!errorListE049.isEmpty()) {
errors.add(new ErrorListHelperModel(new MessageLogModel(E049), errorListE049));
}
return errors;
}
Aggregations