diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index d9e8ff2a..54141a5e 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -3,6 +3,7 @@ on: push: branches: - main + - update_netex_1_16_jakarta pull_request: branches: - main @@ -69,4 +70,13 @@ jobs: secrets: inherit with: push_to_repo: true - snapshot: false \ No newline at end of file + snapshot: false + publish-snapshot: + if: github.repository_owner == 'entur' && github.event_name == 'push' && github.ref == 'refs/heads/update_netex_1_16_jakarta' + needs: [maven-package] + name: Publish snapshot to maven central + uses: entur/gha-maven-central/.github/workflows/maven-publish.yml@v1 + secrets: inherit + with: + push_to_repo: true + snapshot: true \ No newline at end of file diff --git a/pom.xml b/pom.xml index f13ce46b..fba9b0f7 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.entur netex-validator-java - 11.0.26-SNAPSHOT + 12.0.0-SNAPSHOT netex-validator-java Library for validating NeTEx datasets against the Nordic NeTEx Profile. @@ -55,8 +55,8 @@ UTF-8 17 - 2.0.15.2 - 3.1.73 + 2.0.16-SNAPSHOT + 4.0.0-SNAPSHOT 12.9 33.0 2.6 @@ -481,6 +481,16 @@ Open Source Geospatial Foundation Repository https://repo.osgeo.org/repository/release/ + + maven-snapshots + https://central.sonatype.com/repository/maven-snapshots + + false + + + true + + diff --git a/src/main/java/org/entur/netex/validation/validator/id/ReferenceToValidEntityTypeValidator.java b/src/main/java/org/entur/netex/validation/validator/id/ReferenceToValidEntityTypeValidator.java index 9a122735..24519e7d 100644 --- a/src/main/java/org/entur/netex/validation/validator/id/ReferenceToValidEntityTypeValidator.java +++ b/src/main/java/org/entur/netex/validation/validator/id/ReferenceToValidEntityTypeValidator.java @@ -139,6 +139,10 @@ private Map> getAllowedSubstitutions() { vehicleScheduleJourneyRefSubstitutions.add("DeadRun"); substitutions.put("VehicleJourneyRef", vehicleScheduleJourneyRefSubstitutions); + Set datedVehicleJourneyRefSubstitutions = new HashSet<>(); + datedVehicleJourneyRefSubstitutions.add("DatedServiceJourney"); + substitutions.put("DatedVehicleJourneyRef", datedVehicleJourneyRefSubstitutions); + Set serviceJourneyPatternRefSubstitutions = new HashSet<>(); serviceJourneyPatternRefSubstitutions.add("ServiceJourneyPattern"); substitutions.put("JourneyPatternRef", serviceJourneyPatternRefSubstitutions); diff --git a/src/main/java/org/entur/netex/validation/validator/jaxb/support/DatedServiceJourneyUtils.java b/src/main/java/org/entur/netex/validation/validator/jaxb/support/DatedServiceJourneyUtils.java index c6b35122..d35a0be9 100644 --- a/src/main/java/org/entur/netex/validation/validator/jaxb/support/DatedServiceJourneyUtils.java +++ b/src/main/java/org/entur/netex/validation/validator/jaxb/support/DatedServiceJourneyUtils.java @@ -3,8 +3,7 @@ import jakarta.xml.bind.JAXBElement; import javax.annotation.Nullable; import org.rutebanken.netex.model.DatedServiceJourney; -import org.rutebanken.netex.model.DatedServiceJourneyRefStructure; -import org.rutebanken.netex.model.VersionOfObjectRefStructure; +import org.rutebanken.netex.model.VehicleJourneyRefStructure; public class DatedServiceJourneyUtils { @@ -18,12 +17,11 @@ public static String originalDatedServiceJourneyRef( DatedServiceJourney datedServiceJourney ) { return datedServiceJourney - .getJourneyRef() + .getReplacedJourneys() + .getDatedVehicleJourneyRefOrNormalDatedVehicleJourneyRef() .stream() .map(JAXBElement::getValue) - .filter(DatedServiceJourneyRefStructure.class::isInstance) - .map(DatedServiceJourneyRefStructure.class::cast) - .map(VersionOfObjectRefStructure::getRef) + .map(VehicleJourneyRefStructure::getRef) .findFirst() .orElse(null); } diff --git a/src/main/java/org/entur/netex/validation/validator/xpath/tree/DefaultTimetableFrameValidationTreeFactory.java b/src/main/java/org/entur/netex/validation/validator/xpath/tree/DefaultTimetableFrameValidationTreeFactory.java index 4c27774f..caf5912a 100644 --- a/src/main/java/org/entur/netex/validation/validator/xpath/tree/DefaultTimetableFrameValidationTreeFactory.java +++ b/src/main/java/org/entur/netex/validation/validator/xpath/tree/DefaultTimetableFrameValidationTreeFactory.java @@ -230,7 +230,7 @@ public ValidationTreeBuilder builder() { ) .withRuleForLineFile( new ValidateNotExist( - "vehicleJourneys/DatedServiceJourney/DatedServiceJourneyRef[@ref = preceding-sibling::DatedServiceJourneyRef/@ref]", + "vehicleJourneys/DatedServiceJourney/replacedJourneys/DatedVehicleJourneyRef[@ref = preceding-sibling::DatedVehicleJourneyRef/@ref]", CODE_DATED_SERVICE_JOURNEY_5, "DatedServiceJourney multiple references to the same DatedServiceJourney", "Multiple references from a DatedServiceJourney to the same DatedServiceJourney", diff --git a/src/main/java/org/entur/netex/validation/xml/NetexSchemaRepository.java b/src/main/java/org/entur/netex/validation/xml/NetexSchemaRepository.java index d2a998c0..4689fbcb 100644 --- a/src/main/java/org/entur/netex/validation/xml/NetexSchemaRepository.java +++ b/src/main/java/org/entur/netex/validation/xml/NetexSchemaRepository.java @@ -82,6 +82,8 @@ public static NeTExValidator.NetexVersion detectNetexSchemaVersion(byte[] conten return NeTExValidator.NetexVersion.v1_14; case "1.15": return NeTExValidator.NetexVersion.v1_15; + case "1.16": + return NeTExValidator.NetexVersion.v1_16; default: } } diff --git a/src/test/java/org/entur/netex/validation/validator/id/ReferenceToValidEntityTypeValidatorTest.java b/src/test/java/org/entur/netex/validation/validator/id/ReferenceToValidEntityTypeValidatorTest.java index ac764e6b..5722197a 100644 --- a/src/test/java/org/entur/netex/validation/validator/id/ReferenceToValidEntityTypeValidatorTest.java +++ b/src/test/java/org/entur/netex/validation/validator/id/ReferenceToValidEntityTypeValidatorTest.java @@ -104,4 +104,31 @@ void testValidReferenceType() { ); Assertions.assertTrue(validationIssues.isEmpty()); } + + @Test + void testDatedVehicleJourneyRefReferencingDatedServiceJourney() { + IdVersion idVersion = new IdVersion( + "XXX:DatedServiceJourney:1", + null, + "DatedVehicleJourneyRef", + null, + null, + 0, + 0 + ); + List localRefs = List.of(idVersion); + XPathValidationContext xPathValidationContext = new XPathValidationContext( + null, + null, + TEST_CODESPACE, + null, + Set.of(), + localRefs, + validationReport.getValidationReportId() + ); + List validationIssues = referenceToValidEntityTypeValidator.validate( + xPathValidationContext + ); + Assertions.assertTrue(validationIssues.isEmpty()); + } } diff --git a/src/test/resources/test-multiple-references-to-same-dsj.zip b/src/test/resources/test-multiple-references-to-same-dsj.zip index 39a14f99..ff7e7789 100644 Binary files a/src/test/resources/test-multiple-references-to-same-dsj.zip and b/src/test/resources/test-multiple-references-to-same-dsj.zip differ