Skip to content
Draft
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
15 changes: 13 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ on:
push:
branches:
- main
- update_netex_1_16_jakarta
- upgrade-netex-java-model-3
pull_request:
branches:
- main
Expand All @@ -27,7 +29,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@v4
with:
java-version: 17
java-version: 21
distribution: liberica
- name: Cache Maven dependencies
uses: actions/cache@v4
Expand Down Expand Up @@ -69,4 +71,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/update_netex_1_16_jakarta' || github.ref == 'refs/heads/upgrade-netex-java-model-3')
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>11.0.26-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.15.2</netex-java-model.version>
<netex-parser-java.version>3.1.73</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 @@ -139,6 +139,10 @@ private Map<String, Set<String>> getAllowedSubstitutions() {
vehicleScheduleJourneyRefSubstitutions.add("DeadRun");
substitutions.put("VehicleJourneyRef", vehicleScheduleJourneyRefSubstitutions);

Set<String> datedVehicleJourneyRefSubstitutions = new HashSet<>();
datedVehicleJourneyRefSubstitutions.add("DatedServiceJourney");
substitutions.put("DatedVehicleJourneyRef", datedVehicleJourneyRefSubstitutions);

Set<String> serviceJourneyPatternRefSubstitutions = new HashSet<>();
serviceJourneyPatternRefSubstitutions.add("ServiceJourneyPattern");
substitutions.put("JourneyPatternRef", serviceJourneyPatternRefSubstitutions);
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 @@ -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 {

Expand All @@ -17,13 +16,15 @@ private DatedServiceJourneyUtils() {}
public static String originalDatedServiceJourneyRef(
DatedServiceJourney datedServiceJourney
) {
if (datedServiceJourney.getReplacedJourneys() == null) {
return null;
}
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);
}
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 @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<IdVersion> localRefs = List.of(idVersion);
XPathValidationContext xPathValidationContext = new XPathValidationContext(
null,
null,
TEST_CODESPACE,
null,
Set.of(),
localRefs,
validationReport.getValidationReportId()
);
List<ValidationIssue> validationIssues = referenceToValidEntityTypeValidator.validate(
xPathValidationContext
);
Assertions.assertTrue(validationIssues.isEmpty());
}
}
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
Loading