From 4b5972d2e6e32d787c5a18ef9788ed90e7312663 Mon Sep 17 00:00:00 2001 From: Vincent Paturet Date: Fri, 6 Mar 2026 13:10:01 +0100 Subject: [PATCH] Upgrade to netex-java-model 3.0.0-SNAPSHOT and netex-parser-java 5.0.0-SNAPSHOT --- .github/workflows/push.yml | 14 ++++++-- pom.xml | 24 +++++++++---- .../validator/jaxb/JAXBValidationContext.java | 3 +- .../jaxb/SiteFrameStopPlaceRepository.java | 9 +++-- .../support/DatedServiceJourneyUtils.java | 3 ++ .../model/MultilingualStringValue.java | 35 +++++++++++++++++++ .../validator/model/SimpleLine.java | 5 ++- .../model/TransportModeAndSubMode.java | 8 ++--- .../validator/model/TransportSubMode.java | 4 +-- .../jaxb/JAXBValidationContextTest.java | 21 ++++------- .../SiteFrameStopPlaceRepositoryTest.java | 8 ++--- .../model/TransportModeAndSubModeTest.java | 15 ++++---- .../validator/model/TransportSubModeTest.java | 12 +++---- 13 files changed, 102 insertions(+), 59 deletions(-) create mode 100644 src/main/java/org/entur/netex/validation/validator/model/MultilingualStringValue.java diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index c7a2f61a..0a6f9429 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -3,6 +3,7 @@ on: push: branches: - main + - upgrade_netex_2_0 pull_request: branches: - main @@ -27,7 +28,7 @@ jobs: wget https://raw.githubusercontent.com/entur/ror-maven-settings/master/.m2/settings_release_maven_central.xml -O .github/workflows/settings.xml - uses: actions/setup-java@v5 with: - java-version: 17 + java-version: 21 distribution: liberica - name: Cache Maven dependencies uses: actions/cache@v5 @@ -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/upgrade_netex_2_0' + 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 886ecbfc..91b6bd80 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.entur netex-validator-java - 12.0.1-SNAPSHOT + 13.0.0-SNAPSHOT netex-validator-java Library for validating NeTEx datasets against the Nordic NeTEx Profile. @@ -53,10 +53,10 @@ UTF-8 - 17 + 21 - 2.0.16 - 4.0.0 + 3.0.0-SNAPSHOT + 5.0.0-SNAPSHOT 12.9 33.0 2.6 @@ -97,8 +97,8 @@ - 17 - 17 + 21 + 21 @@ -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 + + @@ -531,7 +541,7 @@ - 17 + 21 diff --git a/src/main/java/org/entur/netex/validation/validator/jaxb/JAXBValidationContext.java b/src/main/java/org/entur/netex/validation/validator/jaxb/JAXBValidationContext.java index 345d2cf4..5947faf1 100644 --- a/src/main/java/org/entur/netex/validation/validator/jaxb/JAXBValidationContext.java +++ b/src/main/java/org/entur/netex/validation/validator/jaxb/JAXBValidationContext.java @@ -332,8 +332,7 @@ public Collection serviceCalendarFrames() { */ @Nullable public TransportModeAndSubMode transportModeAndSubMode(ServiceJourney serviceJourney) { - AllVehicleModesOfTransportEnumeration transportMode = - serviceJourney.getTransportMode(); + AllPublicTransportModesEnumeration transportMode = serviceJourney.getTransportMode(); TransportSubmodeStructure subModeStructure = serviceJourney.getTransportSubmode(); diff --git a/src/main/java/org/entur/netex/validation/validator/jaxb/SiteFrameStopPlaceRepository.java b/src/main/java/org/entur/netex/validation/validator/jaxb/SiteFrameStopPlaceRepository.java index 12111efa..d64e0ee0 100644 --- a/src/main/java/org/entur/netex/validation/validator/jaxb/SiteFrameStopPlaceRepository.java +++ b/src/main/java/org/entur/netex/validation/validator/jaxb/SiteFrameStopPlaceRepository.java @@ -2,6 +2,7 @@ import javax.annotation.Nullable; import org.entur.netex.index.api.NetexEntitiesIndex; +import org.entur.netex.validation.validator.model.MultilingualStringValue; import org.entur.netex.validation.validator.model.QuayCoordinates; import org.entur.netex.validation.validator.model.QuayId; import org.entur.netex.validation.validator.model.StopPlaceId; @@ -69,10 +70,8 @@ public String getStopPlaceNameForQuayId(QuayId quayId) { if (stopPlaceId == null) { return null; } - return netexEntitiesIndex - .getStopPlaceIndex() - .getLatestVersion(stopPlaceId) - .getName() - .getValue(); + return MultilingualStringValue.of( + netexEntitiesIndex.getStopPlaceIndex().getLatestVersion(stopPlaceId).getName() + ); } } 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 d35a0be9..fcd96d74 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 @@ -16,6 +16,9 @@ private DatedServiceJourneyUtils() {} public static String originalDatedServiceJourneyRef( DatedServiceJourney datedServiceJourney ) { + if (datedServiceJourney.getReplacedJourneys() == null) { + return null; + } return datedServiceJourney .getReplacedJourneys() .getDatedVehicleJourneyRefOrNormalDatedVehicleJourneyRef() diff --git a/src/main/java/org/entur/netex/validation/validator/model/MultilingualStringValue.java b/src/main/java/org/entur/netex/validation/validator/model/MultilingualStringValue.java new file mode 100644 index 00000000..8446f954 --- /dev/null +++ b/src/main/java/org/entur/netex/validation/validator/model/MultilingualStringValue.java @@ -0,0 +1,35 @@ +package org.entur.netex.validation.validator.model; + +import java.io.Serializable; +import java.util.List; +import javax.annotation.Nullable; +import org.rutebanken.netex.model.MultilingualString; + +/** + * Helper for extracting string values from NeTEx MultilingualString. + * In NeTEx 2.0 (netex-java-model 3.x), MultilingualString uses a mixed content model + * where text is stored in getContent() as a List of Serializable objects, + * replacing the previous getValue() method. + */ +public final class MultilingualStringValue { + + private MultilingualStringValue() {} + + @Nullable + public static String of(@Nullable MultilingualString multilingualString) { + if (multilingualString == null) { + return null; + } + List content = multilingualString.getContent(); + if (content == null || content.isEmpty()) { + return null; + } + StringBuilder sb = new StringBuilder(); + for (Serializable item : content) { + if (item instanceof String s) { + sb.append(s); + } + } + return sb.isEmpty() ? null : sb.toString(); + } +} diff --git a/src/main/java/org/entur/netex/validation/validator/model/SimpleLine.java b/src/main/java/org/entur/netex/validation/validator/model/SimpleLine.java index b538640e..9e3f4b2b 100644 --- a/src/main/java/org/entur/netex/validation/validator/model/SimpleLine.java +++ b/src/main/java/org/entur/netex/validation/validator/model/SimpleLine.java @@ -5,7 +5,6 @@ import org.entur.netex.validation.exception.NetexValidationException; import org.rutebanken.netex.model.FlexibleLine; import org.rutebanken.netex.model.Line; -import org.rutebanken.netex.model.MultilingualString; /** * Light-way representation of a NeTEx Line. @@ -21,7 +20,7 @@ public record SimpleLine(String lineId, String lineName, String fileName) { public static SimpleLine of(Line line, String fileName) { return new SimpleLine( line.getId(), - Optional.ofNullable(line.getName()).map(MultilingualString::getValue).orElse(null), + Optional.ofNullable(line.getName()).map(MultilingualStringValue::of).orElse(null), fileName ); } @@ -31,7 +30,7 @@ public static SimpleLine of(FlexibleLine flexibleLine, String fileName) { flexibleLine.getId(), Optional .ofNullable(flexibleLine.getName()) - .map(MultilingualString::getValue) + .map(MultilingualStringValue::of) .orElse(null), fileName ); diff --git a/src/main/java/org/entur/netex/validation/validator/model/TransportModeAndSubMode.java b/src/main/java/org/entur/netex/validation/validator/model/TransportModeAndSubMode.java index e510e5c8..b5233a0f 100644 --- a/src/main/java/org/entur/netex/validation/validator/model/TransportModeAndSubMode.java +++ b/src/main/java/org/entur/netex/validation/validator/model/TransportModeAndSubMode.java @@ -2,7 +2,7 @@ import java.util.Objects; import javax.annotation.Nullable; -import org.rutebanken.netex.model.AllVehicleModesOfTransportEnumeration; +import org.rutebanken.netex.model.AllPublicTransportModesEnumeration; import org.rutebanken.netex.model.StopPlace; import org.rutebanken.netex.model.TransportSubmodeStructure; @@ -10,7 +10,7 @@ * A pair of mode and sub-mode. */ public record TransportModeAndSubMode( - AllVehicleModesOfTransportEnumeration mode, + AllPublicTransportModesEnumeration mode, TransportSubMode subMode ) { public TransportModeAndSubMode { @@ -25,7 +25,7 @@ public record TransportModeAndSubMode( */ @Nullable public static TransportModeAndSubMode of(StopPlace stopPlace) { - AllVehicleModesOfTransportEnumeration transportMode = stopPlace.getTransportMode(); + AllPublicTransportModesEnumeration transportMode = stopPlace.getTransportMode(); if (transportMode == null) { return null; } @@ -42,7 +42,7 @@ public static TransportModeAndSubMode of(StopPlace stopPlace) { */ @Nullable public static TransportModeAndSubMode of( - AllVehicleModesOfTransportEnumeration transportMode, + AllPublicTransportModesEnumeration transportMode, TransportSubmodeStructure submodeStructure ) { if (transportMode == null) { diff --git a/src/main/java/org/entur/netex/validation/validator/model/TransportSubMode.java b/src/main/java/org/entur/netex/validation/validator/model/TransportSubMode.java index a72af12a..a1d11c95 100644 --- a/src/main/java/org/entur/netex/validation/validator/model/TransportSubMode.java +++ b/src/main/java/org/entur/netex/validation/validator/model/TransportSubMode.java @@ -3,7 +3,7 @@ import java.util.Objects; import java.util.Optional; import org.entur.netex.validation.exception.NetexValidationException; -import org.rutebanken.netex.model.AllVehicleModesOfTransportEnumeration; +import org.rutebanken.netex.model.AllPublicTransportModesEnumeration; import org.rutebanken.netex.model.StopPlace; import org.rutebanken.netex.model.TransportSubmodeStructure; @@ -64,7 +64,7 @@ public static Optional of(StopPlace stopPlace) { } public static Optional of( - AllVehicleModesOfTransportEnumeration transportMode, + AllPublicTransportModesEnumeration transportMode, TransportSubmodeStructure subModeStructure ) { if (transportMode == null || subModeStructure == null) { diff --git a/src/test/java/org/entur/netex/validation/validator/jaxb/JAXBValidationContextTest.java b/src/test/java/org/entur/netex/validation/validator/jaxb/JAXBValidationContextTest.java index 28379da9..274f6e5b 100644 --- a/src/test/java/org/entur/netex/validation/validator/jaxb/JAXBValidationContextTest.java +++ b/src/test/java/org/entur/netex/validation/validator/jaxb/JAXBValidationContextTest.java @@ -16,7 +16,7 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import org.rutebanken.netex.model.AllVehicleModesOfTransportEnumeration; +import org.rutebanken.netex.model.AllPublicTransportModesEnumeration; import org.rutebanken.netex.model.BusSubmodeEnumeration; import org.rutebanken.netex.model.JourneyPattern; import org.rutebanken.netex.model.JourneyPatternRefStructure; @@ -42,7 +42,7 @@ class JAXBValidationContextTest { void setUp() { Line line = new Line() .withId("TST:Line:1") - .withTransportMode(AllVehicleModesOfTransportEnumeration.BUS) + .withTransportMode(AllPublicTransportModesEnumeration.BUS) .withTransportSubmode( new TransportSubmodeStructure().withBusSubmode(BusSubmodeEnumeration.LOCAL_BUS) ); @@ -140,10 +140,7 @@ void transportModeAndSubModeDefinedOnLineFromJourneyPattern() { journeyPattern ); assertNotNull(transportModeAndSubMode); - assertEquals( - AllVehicleModesOfTransportEnumeration.BUS, - transportModeAndSubMode.mode() - ); + assertEquals(AllPublicTransportModesEnumeration.BUS, transportModeAndSubMode.mode()); assertEquals( new TransportSubMode(BusSubmodeEnumeration.LOCAL_BUS.value()), transportModeAndSubMode.subMode() @@ -166,10 +163,7 @@ void transportModeAndSubModeDefinedOnLineFromServiceJourney() { serviceJourney ); assertNotNull(transportModeAndSubMode); - assertEquals( - AllVehicleModesOfTransportEnumeration.BUS, - transportModeAndSubMode.mode() - ); + assertEquals(AllPublicTransportModesEnumeration.BUS, transportModeAndSubMode.mode()); assertEquals( new TransportSubMode(BusSubmodeEnumeration.LOCAL_BUS.value()), transportModeAndSubMode.subMode() @@ -178,7 +172,7 @@ void transportModeAndSubModeDefinedOnLineFromServiceJourney() { @Test void transportModeAndSubModeDefinedOnServiceJourneyFromServiceJourney() { - serviceJourney.withTransportMode(AllVehicleModesOfTransportEnumeration.RAIL); + serviceJourney.withTransportMode(AllPublicTransportModesEnumeration.RAIL); serviceJourney.withTransportSubmode( new TransportSubmodeStructure().withRailSubmode(RailSubmodeEnumeration.LOCAL) ); @@ -197,10 +191,7 @@ void transportModeAndSubModeDefinedOnServiceJourneyFromServiceJourney() { serviceJourney ); assertNotNull(transportModeAndSubMode); - assertEquals( - AllVehicleModesOfTransportEnumeration.RAIL, - transportModeAndSubMode.mode() - ); + assertEquals(AllPublicTransportModesEnumeration.RAIL, transportModeAndSubMode.mode()); assertEquals( new TransportSubMode(RailSubmodeEnumeration.LOCAL.value()), transportModeAndSubMode.subMode() diff --git a/src/test/java/org/entur/netex/validation/validator/jaxb/SiteFrameStopPlaceRepositoryTest.java b/src/test/java/org/entur/netex/validation/validator/jaxb/SiteFrameStopPlaceRepositoryTest.java index d5c3c9b7..0768950c 100644 --- a/src/test/java/org/entur/netex/validation/validator/jaxb/SiteFrameStopPlaceRepositoryTest.java +++ b/src/test/java/org/entur/netex/validation/validator/jaxb/SiteFrameStopPlaceRepositoryTest.java @@ -13,7 +13,7 @@ import org.entur.netex.validation.validator.model.TransportModeAndSubMode; import org.entur.netex.validation.validator.model.TransportSubMode; import org.junit.jupiter.api.Test; -import org.rutebanken.netex.model.AllVehicleModesOfTransportEnumeration; +import org.rutebanken.netex.model.AllPublicTransportModesEnumeration; import org.rutebanken.netex.model.BusSubmodeEnumeration; import org.rutebanken.netex.model.LocationStructure; import org.rutebanken.netex.model.MultilingualString; @@ -28,8 +28,8 @@ class SiteFrameStopPlaceRepositoryTest { private static final int QUAY_LATITUDE = 1; private static final int QUAY_LONGITUDE = 2; private static final String STOP_PLACE_NAME = "STOP_PLACE_NAME"; - private static final AllVehicleModesOfTransportEnumeration STOP_PLACE_TRANSPORT_MODE = - AllVehicleModesOfTransportEnumeration.BUS; + private static final AllPublicTransportModesEnumeration STOP_PLACE_TRANSPORT_MODE = + AllPublicTransportModesEnumeration.BUS; private static final BusSubmodeEnumeration STOP_PLACE_TRANSPORT_SUBMODE = BusSubmodeEnumeration.LOCAL_BUS; @@ -121,7 +121,7 @@ void testGetCoordinatesForNonExistingQuayId() { void testGetStopPlaceNameForQuayId() { NetexEntitiesIndex netexEntitiesIndex = new NetexEntitiesIndexImpl(); StopPlace stopPlace = new StopPlace(); - stopPlace.setName(new MultilingualString().withValue(STOP_PLACE_NAME)); + stopPlace.setName(new MultilingualString().withContent(STOP_PLACE_NAME)); netexEntitiesIndex.getStopPlaceIndex().put(STOP_PLACE_ID, List.of(stopPlace)); Quay quay = new Quay(); netexEntitiesIndex.getQuayIndex().put(QUAY_ID, List.of(quay)); diff --git a/src/test/java/org/entur/netex/validation/validator/model/TransportModeAndSubModeTest.java b/src/test/java/org/entur/netex/validation/validator/model/TransportModeAndSubModeTest.java index 8eb6de6c..2fdf244e 100644 --- a/src/test/java/org/entur/netex/validation/validator/model/TransportModeAndSubModeTest.java +++ b/src/test/java/org/entur/netex/validation/validator/model/TransportModeAndSubModeTest.java @@ -3,7 +3,7 @@ import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; -import org.rutebanken.netex.model.AllVehicleModesOfTransportEnumeration; +import org.rutebanken.netex.model.AllPublicTransportModesEnumeration; import org.rutebanken.netex.model.BusSubmodeEnumeration; import org.rutebanken.netex.model.RailSubmodeEnumeration; import org.rutebanken.netex.model.StopPlace; @@ -23,7 +23,7 @@ void testMissingTransportModeAndSubModeFromStopPlace() { @Test void testMissingTransportSubModeFromStopPlace() { StopPlace stopPlace = new StopPlace(); - stopPlace.withTransportMode(AllVehicleModesOfTransportEnumeration.RAIL); + stopPlace.withTransportMode(AllPublicTransportModesEnumeration.RAIL); TransportModeAndSubMode transportModeAndSubMode = TransportModeAndSubMode.of( stopPlace ); @@ -35,16 +35,13 @@ void testMissingTransportSubModeFromStopPlace() { void testCreateTransportModeAndSubModeFromStopPlace() { StopPlace stopPlace = new StopPlace(); stopPlace - .withTransportMode(AllVehicleModesOfTransportEnumeration.RAIL) + .withTransportMode(AllPublicTransportModesEnumeration.RAIL) .withRailSubmode(RailSubmodeEnumeration.LOCAL); TransportModeAndSubMode transportModeAndSubMode = TransportModeAndSubMode.of( stopPlace ); assertNotNull(transportModeAndSubMode); - assertEquals( - AllVehicleModesOfTransportEnumeration.RAIL, - transportModeAndSubMode.mode() - ); + assertEquals(AllPublicTransportModesEnumeration.RAIL, transportModeAndSubMode.mode()); assertEquals( new TransportSubMode(RailSubmodeEnumeration.LOCAL.value()), transportModeAndSubMode.subMode() @@ -56,7 +53,7 @@ void testCreateTransportModeAndSubModeFromStructure() { TransportSubmodeStructure submode = new TransportSubmodeStructure() .withBusSubmode(BusSubmodeEnumeration.LOCAL_BUS); TransportModeAndSubMode transportModeAndSubMode = TransportModeAndSubMode.of( - AllVehicleModesOfTransportEnumeration.BUS, + AllPublicTransportModesEnumeration.BUS, submode ); assertNotNull(transportModeAndSubMode); @@ -74,7 +71,7 @@ void testUnknownTransportSubModeForMode() { TransportSubmodeStructure submode = new TransportSubmodeStructure() .withBusSubmode(BusSubmodeEnumeration.LOCAL_BUS); TransportModeAndSubMode transportModeAndSubMode = TransportModeAndSubMode.of( - AllVehicleModesOfTransportEnumeration.RAIL, + AllPublicTransportModesEnumeration.RAIL, submode ); assertNotNull(transportModeAndSubMode); diff --git a/src/test/java/org/entur/netex/validation/validator/model/TransportSubModeTest.java b/src/test/java/org/entur/netex/validation/validator/model/TransportSubModeTest.java index c7c0e35a..7a66b3bf 100644 --- a/src/test/java/org/entur/netex/validation/validator/model/TransportSubModeTest.java +++ b/src/test/java/org/entur/netex/validation/validator/model/TransportSubModeTest.java @@ -4,7 +4,7 @@ import java.util.Optional; import org.junit.jupiter.api.Test; -import org.rutebanken.netex.model.AllVehicleModesOfTransportEnumeration; +import org.rutebanken.netex.model.AllPublicTransportModesEnumeration; import org.rutebanken.netex.model.RailSubmodeEnumeration; import org.rutebanken.netex.model.SelfDriveSubmodeEnumeration; import org.rutebanken.netex.model.StopPlace; @@ -28,7 +28,7 @@ void testMissingTransportModeAndSubModeOnStopPlace() { @Test void testMissingTransportSubModeOnStopPlace() { StopPlace stopPlace = new StopPlace(); - stopPlace.withTransportMode(AllVehicleModesOfTransportEnumeration.RAIL); + stopPlace.withTransportMode(AllPublicTransportModesEnumeration.RAIL); Optional transportSubMode = TransportSubMode.of(stopPlace); assertFalse(transportSubMode.isPresent()); } @@ -37,7 +37,7 @@ void testMissingTransportSubModeOnStopPlace() { void testTransportModeAndSubModeOnStopPlace() { StopPlace stopPlace = new StopPlace(); stopPlace - .withTransportMode(AllVehicleModesOfTransportEnumeration.RAIL) + .withTransportMode(AllPublicTransportModesEnumeration.RAIL) .withRailSubmode(RailSubmodeEnumeration.LOCAL); Optional transportSubMode = TransportSubMode.of(stopPlace); assertTrue(transportSubMode.isPresent()); @@ -53,7 +53,7 @@ void testMissingTransportModeAndSubModeFromStructure() { @Test void testMissingTransportSubModeFromStructure() { Optional transportSubMode = TransportSubMode.of( - AllVehicleModesOfTransportEnumeration.RAIL, + AllPublicTransportModesEnumeration.RAIL, null ); assertFalse(transportSubMode.isPresent()); @@ -62,7 +62,7 @@ void testMissingTransportSubModeFromStructure() { @Test void testUnknownTransportSubMode() { Optional transportSubMode = TransportSubMode.of( - AllVehicleModesOfTransportEnumeration.RAIL, + AllPublicTransportModesEnumeration.RAIL, new TransportSubmodeStructure() .withSelfDriveSubmode(SelfDriveSubmodeEnumeration.ALL_VEHICLES) ); @@ -72,7 +72,7 @@ void testUnknownTransportSubMode() { @Test void testTransportModeAndSubModeFromStructure() { Optional transportSubMode = TransportSubMode.of( - AllVehicleModesOfTransportEnumeration.RAIL, + AllPublicTransportModesEnumeration.RAIL, new TransportSubmodeStructure().withRailSubmode(RailSubmodeEnumeration.LOCAL) ); assertTrue(transportSubMode.isPresent());