Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- main
- upgrade_netex_2_0
pull_request:
branches:
- main
Expand All @@ -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
Expand Down Expand Up @@ -69,4 +70,13 @@ jobs:
secrets: inherit
with:
push_to_repo: true
snapshot: false
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
24 changes: 17 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>org.entur</groupId>
<artifactId>netex-validator-java</artifactId>
<version>12.0.1-SNAPSHOT</version>
<version>13.0.0-SNAPSHOT</version>

<name>netex-validator-java</name>
<description>Library for validating NeTEx datasets against the Nordic NeTEx Profile.</description>
Expand Down Expand Up @@ -53,10 +53,10 @@
<properties>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jdk.version>17</jdk.version>
<jdk.version>21</jdk.version>

<netex-java-model.version>2.0.16</netex-java-model.version>
<netex-parser-java.version>4.0.0</netex-parser-java.version>
<netex-java-model.version>3.0.0-SNAPSHOT</netex-java-model.version>
<netex-parser-java.version>5.0.0-SNAPSHOT</netex-parser-java.version>
<saxon.version>12.9</saxon.version>
<geotools.version>33.0</geotools.version>
<snakeyaml.version>2.6</snakeyaml.version>
Expand Down Expand Up @@ -97,8 +97,8 @@

<!-- empty argLine property, the value is set up by Jacoco during unit tests execution -->
<argLine/>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>


<!-- GPG configuration for jar signing-->
Expand Down Expand Up @@ -481,6 +481,16 @@
<name>Open Source Geospatial Foundation Repository</name>
<url>https://repo.osgeo.org/repository/release/</url>
</repository>
<repository>
<id>maven-snapshots</id>
<url>https://central.sonatype.com/repository/maven-snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<profiles>
<profile>
Expand Down Expand Up @@ -531,7 +541,7 @@
</activation>

<properties>
<jdk.version>17</jdk.version>
<jdk.version>21</jdk.version>
</properties>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,7 @@ public Collection<ServiceCalendarFrame> serviceCalendarFrames() {
*/
@Nullable
public TransportModeAndSubMode transportModeAndSubMode(ServiceJourney serviceJourney) {
AllVehicleModesOfTransportEnumeration transportMode =
serviceJourney.getTransportMode();
AllPublicTransportModesEnumeration transportMode = serviceJourney.getTransportMode();

TransportSubmodeStructure subModeStructure = serviceJourney.getTransportSubmode();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ private DatedServiceJourneyUtils() {}
public static String originalDatedServiceJourneyRef(
DatedServiceJourney datedServiceJourney
) {
if (datedServiceJourney.getReplacedJourneys() == null) {
return null;
}
return datedServiceJourney
.getReplacedJourneys()
.getDatedVehicleJourneyRefOrNormalDatedVehicleJourneyRef()
Expand Down
Original file line number Diff line number Diff line change
@@ -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<Serializable> 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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
);
}
Expand All @@ -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
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

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;

/**
* A pair of mode and sub-mode.
*/
public record TransportModeAndSubMode(
AllVehicleModesOfTransportEnumeration mode,
AllPublicTransportModesEnumeration mode,
TransportSubMode subMode
) {
public TransportModeAndSubMode {
Expand All @@ -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;
}
Expand All @@ -42,7 +42,7 @@ public static TransportModeAndSubMode of(StopPlace stopPlace) {
*/
@Nullable
public static TransportModeAndSubMode of(
AllVehicleModesOfTransportEnumeration transportMode,
AllPublicTransportModesEnumeration transportMode,
TransportSubmodeStructure submodeStructure
) {
if (transportMode == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -64,7 +64,7 @@ public static Optional<TransportSubMode> of(StopPlace stopPlace) {
}

public static Optional<TransportSubMode> of(
AllVehicleModesOfTransportEnumeration transportMode,
AllPublicTransportModesEnumeration transportMode,
TransportSubmodeStructure subModeStructure
) {
if (transportMode == null || subModeStructure == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
);
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -178,7 +172,7 @@ void transportModeAndSubModeDefinedOnLineFromServiceJourney() {

@Test
void transportModeAndSubModeDefinedOnServiceJourneyFromServiceJourney() {
serviceJourney.withTransportMode(AllVehicleModesOfTransportEnumeration.RAIL);
serviceJourney.withTransportMode(AllPublicTransportModesEnumeration.RAIL);
serviceJourney.withTransportSubmode(
new TransportSubmodeStructure().withRailSubmode(RailSubmodeEnumeration.LOCAL)
);
Expand All @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
);
Expand All @@ -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()
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Loading
Loading