diff --git a/src/main/java/org/opentripplanner/netex/validation/InterchangeServiceJourneyNotFound.java b/src/main/java/org/opentripplanner/netex/validation/InterchangeServiceJourneyNotFound.java deleted file mode 100644 index 390371e31ba..00000000000 --- a/src/main/java/org/opentripplanner/netex/validation/InterchangeServiceJourneyNotFound.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.opentripplanner.netex.validation; - -import org.opentripplanner.graph_builder.issue.api.DataImportIssue; -import org.opentripplanner.netex.issues.ObjectNotFound; -import org.rutebanken.netex.model.ServiceJourney; -import org.rutebanken.netex.model.ServiceJourneyInterchange; - -class InterchangeServiceJourneyNotFound - extends AbstractHMapValidationRule { - - private String missingFromServiceJourneyId; - private String missingToServiceJourneyId; - - @Override - public Status validate(ServiceJourneyInterchange interchange) { - String serviceJourneyFromRef = interchange.getFromJourneyRef().getRef(); - String serviceJourneyToRef = interchange.getToJourneyRef().getRef(); - ServiceJourney fromServiceJourney = index.getServiceJourneyById().lookup(serviceJourneyFromRef); - ServiceJourney toServiceJourney = index.getServiceJourneyById().lookup(serviceJourneyToRef); - if (fromServiceJourney == null) { - missingFromServiceJourneyId = serviceJourneyFromRef; - return Status.DISCARD; - } else if (toServiceJourney == null) { - missingToServiceJourneyId = serviceJourneyToRef; - return Status.DISCARD; - } - return Status.OK; - } - - @Override - public DataImportIssue logMessage(String dsjId, ServiceJourneyInterchange interchange) { - String targetFieldName = missingFromServiceJourneyId != null - ? "FromJourneyRef" - : "ToJourneyRef"; - String missingServiceJourneyId = missingFromServiceJourneyId != null - ? missingFromServiceJourneyId - : missingToServiceJourneyId; - return new ObjectNotFound( - "ServiceJourneyInterchange", - interchange.getId(), - targetFieldName, - missingServiceJourneyId - ); - } -} diff --git a/src/main/java/org/opentripplanner/netex/validation/ServiceJourneyNonIncreasingPassingTime.java b/src/main/java/org/opentripplanner/netex/validation/ServiceJourneyNonIncreasingPassingTime.java index 3eff1c77a0d..f7326128fe9 100644 --- a/src/main/java/org/opentripplanner/netex/validation/ServiceJourneyNonIncreasingPassingTime.java +++ b/src/main/java/org/opentripplanner/netex/validation/ServiceJourneyNonIncreasingPassingTime.java @@ -21,13 +21,13 @@ /** * Ensure that passing times are increasing along the service journey. * The validator checks first that individual TimetabledPassingTimes are valid, i.e: - * - a fixed stop has either arrivalTime or departureTime specified, and arrivalTime < departureTime - * - a flex stop has both earliestDepartureTime and latestArrivalTime specified, and earliestDepartureTime < latestArrivalTime + * - a regular stop has either arrivalTime or departureTime specified, and arrivalTime < departureTime + * - an area stop has both earliestDepartureTime and latestArrivalTime specified, and earliestDepartureTime < latestArrivalTime * The validator then checks that successive stops have increasing times, taking into account 4 different cases: - * - a fixed stop followed by a fixed stop - * - a flex stop followed by a flex stop - * - a fixed stop followed by a flex stop - * - a flex stop followed by a fixed stop + * - a regular stop followed by a regular stop + * - an area stop followed by an area stop + * - a regular stop followed by an area stop + * - an area stop followed by a regular stop */ class ServiceJourneyNonIncreasingPassingTime extends AbstractHMapValidationRule { @@ -54,10 +54,10 @@ public Status validate(ServiceJourney sj) { } if ( - serviceJourneyInfo.hasFixedStop(previousTimetabledPassingTime) && - serviceJourneyInfo.hasFixedStop(currentTimetabledPassingTime) && + serviceJourneyInfo.hasRegularStop(previousTimetabledPassingTime) && + serviceJourneyInfo.hasRegularStop(currentTimetabledPassingTime) && ( - !isValidFixedStopFollowedByFixedStop( + !isValidRegularStopFollowedByRegularStop( previousTimetabledPassingTime, currentTimetabledPassingTime ) @@ -66,10 +66,10 @@ public Status validate(ServiceJourney sj) { return Status.DISCARD; } if ( - serviceJourneyInfo.hasFlexStop(previousTimetabledPassingTime) && - serviceJourneyInfo.hasFlexStop(currentTimetabledPassingTime) && + serviceJourneyInfo.hasAreaStop(previousTimetabledPassingTime) && + serviceJourneyInfo.hasAreaStop(currentTimetabledPassingTime) && ( - !isValidFlexStopFollowedByFlexStop( + !isValidAreaStopFollowedByAreaStop( previousTimetabledPassingTime, currentTimetabledPassingTime ) @@ -79,10 +79,10 @@ public Status validate(ServiceJourney sj) { } if ( - serviceJourneyInfo.hasFixedStop(previousTimetabledPassingTime) && - serviceJourneyInfo.hasFlexStop(currentTimetabledPassingTime) && + serviceJourneyInfo.hasRegularStop(previousTimetabledPassingTime) && + serviceJourneyInfo.hasAreaStop(currentTimetabledPassingTime) && ( - !isValidFixedStopFollowedByFlexStop( + !isValidRegularStopFollowedByAreaStop( previousTimetabledPassingTime, currentTimetabledPassingTime ) @@ -92,10 +92,10 @@ public Status validate(ServiceJourney sj) { } if ( - serviceJourneyInfo.hasFlexStop(previousTimetabledPassingTime) && - serviceJourneyInfo.hasFixedStop(currentTimetabledPassingTime) && + serviceJourneyInfo.hasAreaStop(previousTimetabledPassingTime) && + serviceJourneyInfo.hasRegularStop(currentTimetabledPassingTime) && ( - !isValidFlexStopFollowedByFixedStop( + !isValidAreaStopFollowedByRegularStop( previousTimetabledPassingTime, currentTimetabledPassingTime ) @@ -130,15 +130,15 @@ private boolean isValidTimetabledPassingTime( } /** - * A passing time on a fixed stop is complete if either arrival or departure time is present. - * A passing time on a flex stop is complete if both earliest departure time and latest arrival time are present. + * A passing time on a regular stop is complete if either arrival or departure time is present. + * A passing time on a area stop is complete if both earliest departure time and latest arrival time are present. * */ private boolean hasCompletePassingTime( TimetabledPassingTime timetabledPassingTime, ServiceJourneyInfo serviceJourneyInfo ) { - if (serviceJourneyInfo.hasFixedStop(timetabledPassingTime)) { + if (serviceJourneyInfo.hasRegularStop(timetabledPassingTime)) { return ( timetabledPassingTime.getArrivalTime() != null || timetabledPassingTime.getDepartureTime() != null @@ -151,8 +151,8 @@ private boolean hasCompletePassingTime( } /** - * A passing time on a fixed stop is consistent if departure time is after arrival time. - * A passing time on a flex stop is consistent if latest arrival time is after earliest departure time. + * A passing time on a regular stop is consistent if departure time is after arrival time. + * A passing time on a area stop is consistent if latest arrival time is after earliest departure time. * */ private boolean hasConsistentPassingTime( @@ -160,7 +160,7 @@ private boolean hasConsistentPassingTime( ServiceJourneyInfo serviceJourneyInfo ) { if ( - serviceJourneyInfo.hasFixedStop(timetabledPassingTime) && + serviceJourneyInfo.hasRegularStop(timetabledPassingTime) && ( timetabledPassingTime.getArrivalTime() == null || timetabledPassingTime.getDepartureTime() == null @@ -169,7 +169,7 @@ private boolean hasConsistentPassingTime( return true; } if ( - serviceJourneyInfo.hasFixedStop(timetabledPassingTime) && + serviceJourneyInfo.hasRegularStop(timetabledPassingTime) && timetabledPassingTime.getArrivalTime() != null && timetabledPassingTime.getDepartureTime() != null ) { @@ -186,9 +186,9 @@ private boolean hasConsistentPassingTime( } /** - * Fixed stop followed by a fixed stop: check that arrivalTime(n+1) > departureTime(n) + * regular stop followed by a regular stop: check that arrivalTime(n+1) > departureTime(n) */ - private boolean isValidFixedStopFollowedByFixedStop( + private boolean isValidRegularStopFollowedByRegularStop( TimetabledPassingTime previousTimetabledPassingTime, TimetabledPassingTime currentTimetabledPassingTime ) { @@ -200,17 +200,17 @@ private boolean isValidFixedStopFollowedByFixedStop( ); if (currentArrivalOrDepartureTime < previousDepartureOrArrivalTime) { invalidTimetabledPassingTime = currentTimetabledPassingTime; - errorMessage = "non-increasing time between fixed stops"; + errorMessage = "non-increasing time between regular stops"; return false; } return true; } /** - * Flex stop followed by a flex stop: check that earliestDepartureTime(n+1) > earliestDepartureTime(n) + * area stop followed by a area stop: check that earliestDepartureTime(n+1) > earliestDepartureTime(n) * and latestArrivalTime(n+1) > latestArrivalTime(n) */ - private boolean isValidFlexStopFollowedByFlexStop( + private boolean isValidAreaStopFollowedByAreaStop( TimetabledPassingTime previousTimetabledPassingTime, TimetabledPassingTime currentTimetabledPassingTime ) { @@ -228,16 +228,16 @@ private boolean isValidFlexStopFollowedByFlexStop( currentLatestArrivalTime < previousLatestArrivalTime ) { invalidTimetabledPassingTime = currentTimetabledPassingTime; - errorMessage = "non-increasing time between flex stops"; + errorMessage = "non-increasing time between area stops"; return false; } return true; } /** - * Fixed stop followed by a flex stop: check that earliestDepartureTime(n+1) > departureTime(n) + * regular stop followed by a area stop: check that earliestDepartureTime(n+1) > departureTime(n) */ - private boolean isValidFixedStopFollowedByFlexStop( + private boolean isValidRegularStopFollowedByAreaStop( TimetabledPassingTime previousTimetabledPassingTime, TimetabledPassingTime currentTimetabledPassingTime ) { @@ -251,16 +251,16 @@ private boolean isValidFixedStopFollowedByFlexStop( if (currentEarliestDepartureTime < previousDepartureOrArrivalTime) { invalidTimetabledPassingTime = currentTimetabledPassingTime; - errorMessage = "non-increasing time between fixed stop and flex stop"; + errorMessage = "non-increasing time between regular stop and area stop"; return false; } return true; } /** - * Flex stop followed by a fixed stop: check that arrivalTime(n+1) > latestArrivalTime(n) + * area stop followed by a regular stop: check that arrivalTime(n+1) > latestArrivalTime(n) */ - private boolean isValidFlexStopFollowedByFixedStop( + private boolean isValidAreaStopFollowedByRegularStop( TimetabledPassingTime previousTimetabledPassingTime, TimetabledPassingTime currentTimetabledPassingTime ) { @@ -271,7 +271,7 @@ private boolean isValidFlexStopFollowedByFixedStop( if (currentArrivalOrDepartureTime < previousLatestArrivalTime) { invalidTimetabledPassingTime = currentTimetabledPassingTime; - errorMessage = "non-increasing time between flex stop and fixed stop"; + errorMessage = "non-increasing time between area stop and regular stop"; return false; } return true; @@ -318,7 +318,7 @@ private class ServiceJourneyInfo { private final List orderedTimetabledPassingTimes; /** - * Map a timetabledPassingTime to true if its stop is flexible, false otherwise. + * Map a timetabledPassingTime to true if its stop is a stop area, false otherwise. */ private final Map stopFlexibility; @@ -354,12 +354,12 @@ public List getOrderedTimetabledPassingTimes() { return orderedTimetabledPassingTimes; } - public boolean hasFlexStop(TimetabledPassingTime timetabledPassingTime) { + public boolean hasAreaStop(TimetabledPassingTime timetabledPassingTime) { return stopFlexibility.get(timetabledPassingTime); } - public boolean hasFixedStop(TimetabledPassingTime timetabledPassingTime) { - return !hasFlexStop(timetabledPassingTime); + public boolean hasRegularStop(TimetabledPassingTime timetabledPassingTime) { + return !hasAreaStop(timetabledPassingTime); } } } diff --git a/src/main/java/org/opentripplanner/netex/validation/Validator.java b/src/main/java/org/opentripplanner/netex/validation/Validator.java index 7622eaf3aab..2b80a9c4fa5 100644 --- a/src/main/java/org/opentripplanner/netex/validation/Validator.java +++ b/src/main/java/org/opentripplanner/netex/validation/Validator.java @@ -36,7 +36,6 @@ private void run() { validate(index.serviceJourneyById, ServiceJourneyNonIncreasingPassingTime::new); validate(index.datedServiceJourneys, new DSJOperatingDayNotFound()); validate(index.datedServiceJourneys, new DSJServiceJourneyNotFound()); - validate(index.serviceJourneyInterchangeById, InterchangeServiceJourneyNotFound::new); } /** diff --git a/src/test/java/org/opentripplanner/netex/validation/ServiceJourneyNonIncreasingPassingTimeTest.java b/src/test/java/org/opentripplanner/netex/validation/ServiceJourneyNonIncreasingPassingTimeTest.java index 65263859236..d64f2e69ec3 100644 --- a/src/test/java/org/opentripplanner/netex/validation/ServiceJourneyNonIncreasingPassingTimeTest.java +++ b/src/test/java/org/opentripplanner/netex/validation/ServiceJourneyNonIncreasingPassingTimeTest.java @@ -17,7 +17,7 @@ class ServiceJourneyNonIncreasingPassingTimeTest { @Test - void testValidateServiceJourneyWithFixedStop() { + void testValidateServiceJourneyWithRegularStop() { NetexTestDataSample sample = new NetexTestDataSample(); ServiceJourney serviceJourney = getServiceJourney(sample); JourneyPattern journeyPattern = sample.getJourneyPattern(); @@ -36,7 +36,7 @@ void testValidateServiceJourneyWithFixedStop() { } @Test - void testValidateServiceJourneyWithFixedStopMissingTime() { + void testValidateServiceJourneyWithRegularStopMissingTime() { NetexTestDataSample sample = new NetexTestDataSample(); ServiceJourney serviceJourney = getServiceJourney(sample); JourneyPattern journeyPattern = sample.getJourneyPattern(); @@ -59,7 +59,7 @@ void testValidateServiceJourneyWithFixedStopMissingTime() { } @Test - void testValidateServiceJourneyWithFixedStopInconsistentTime() { + void testValidateServiceJourneyWithRegularStopInconsistentTime() { NetexTestDataSample sample = new NetexTestDataSample(); ServiceJourney serviceJourney = getServiceJourney(sample); JourneyPattern journeyPattern = sample.getJourneyPattern(); @@ -81,7 +81,7 @@ void testValidateServiceJourneyWithFixedStopInconsistentTime() { } @Test - void testValidateServiceJourneyWithFlexibleStop() { + void testValidateServiceJourneyWithAreaStop() { NetexTestDataSample sample = new NetexTestDataSample(); ServiceJourney serviceJourney = getServiceJourney(sample); JourneyPattern journeyPattern = sample.getJourneyPattern(); @@ -113,7 +113,7 @@ void testValidateServiceJourneyWithFlexibleStop() { } @Test - void testValidateServiceJourneyWithFlexibleStopMissingTimeWindow() { + void testValidateServiceJourneyWithAreaStopMissingTimeWindow() { NetexTestDataSample sample = new NetexTestDataSample(); ServiceJourney serviceJourney = getServiceJourney(sample); JourneyPattern journeyPattern = sample.getJourneyPattern(); @@ -145,7 +145,7 @@ void testValidateServiceJourneyWithFlexibleStopMissingTimeWindow() { } @Test - void testValidateServiceJourneyWithFlexibleStopInconsistentTimeWindow() { + void testValidateServiceJourneyWithAreaStopInconsistentTimeWindow() { NetexTestDataSample sample = new NetexTestDataSample(); ServiceJourney serviceJourney = getServiceJourney(sample); JourneyPattern journeyPattern = sample.getJourneyPattern(); @@ -184,7 +184,7 @@ void testValidateServiceJourneyWithFlexibleStopInconsistentTimeWindow() { } @Test - void testValidateServiceJourneyWithFixedStopFollowedByFixedStopNonIncreasingTime() { + void testValidateServiceJourneyWithRegularStopFollowedByRegularStopNonIncreasingTime() { NetexTestDataSample sample = new NetexTestDataSample(); ServiceJourney serviceJourney = getServiceJourney(sample); JourneyPattern journeyPattern = sample.getJourneyPattern(); @@ -207,7 +207,7 @@ void testValidateServiceJourneyWithFixedStopFollowedByFixedStopNonIncreasingTime } @Test - void testValidateServiceJourneyWithFixedStopFollowedByFlexStop() { + void testValidateServiceJourneyWithRegularStopFollowedByStopArea() { NetexTestDataSample sample = new NetexTestDataSample(); ServiceJourney serviceJourney = getServiceJourney(sample); JourneyPattern journeyPattern = sample.getJourneyPattern(); @@ -238,7 +238,7 @@ void testValidateServiceJourneyWithFixedStopFollowedByFlexStop() { } @Test - void testValidateServiceJourneyWithFixedStopFollowedByFlexStopNonIncreasingTime() { + void testValidateServiceJourneyWithRegularStopFollowedByStopAreaNonIncreasingTime() { NetexTestDataSample sample = new NetexTestDataSample(); ServiceJourney serviceJourney = getServiceJourney(sample); JourneyPattern journeyPattern = sample.getJourneyPattern(); @@ -269,7 +269,7 @@ void testValidateServiceJourneyWithFixedStopFollowedByFlexStopNonIncreasingTime( } @Test - void testValidateServiceJourneyWithFlexStopFollowedByFixedStop() { + void testValidateServiceJourneyWithStopAreaFollowedByRegularStop() { NetexTestDataSample sample = new NetexTestDataSample(); ServiceJourney serviceJourney = getServiceJourney(sample); JourneyPattern journeyPattern = sample.getJourneyPattern(); @@ -300,7 +300,7 @@ void testValidateServiceJourneyWithFlexStopFollowedByFixedStop() { } @Test - void testValidateServiceJourneyWithFlexStopFollowedByFlexStop() { + void testValidateServiceJourneyWithStopAreaFollowedByStopArea() { NetexTestDataSample sample = new NetexTestDataSample(); ServiceJourney serviceJourney = getServiceJourney(sample); JourneyPattern journeyPattern = sample.getJourneyPattern(); @@ -341,7 +341,7 @@ void testValidateServiceJourneyWithFlexStopFollowedByFlexStop() { } @Test - void testValidateServiceJourneyWithFlexStopFollowedByFlexStopNonIncreasingTime() { + void testValidateServiceJourneyWithStopAreaFollowedByStopAreaNonIncreasingTime() { NetexTestDataSample sample = new NetexTestDataSample(); ServiceJourney serviceJourney = getServiceJourney(sample); JourneyPattern journeyPattern = sample.getJourneyPattern(); @@ -383,7 +383,7 @@ void testValidateServiceJourneyWithFlexStopFollowedByFlexStopNonIncreasingTime() } @Test - void testValidateServiceJourneyWithFlexStopFollowedByFixedStopNonIncreasingTime() { + void testValidateServiceJourneyWithStopAreaFollowedByRegularStopNonIncreasingTime() { NetexTestDataSample sample = new NetexTestDataSample(); ServiceJourney serviceJourney = getServiceJourney(sample); JourneyPattern journeyPattern = sample.getJourneyPattern();