Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/hotfix-finish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ jobs:

- **Hotfix Version:** $VERSION
- **Git Tag:** \`v${VERSION}\`
- **Maven Central (netex-java-model):** https://central.sonatype.com/artifact/org.entur/netex-java-model/${VERSION}
- **Maven Central (netex2-java-model):** https://central.sonatype.com/artifact/org.entur/netex2-java-model/${VERSION}
- **Hotfix Branch:** Deleted
- **Merged to master:** ${{ inputs.merge_to_master }}

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-finish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ jobs:

- **Released Version:** $VERSION
- **Git Tag:** \`v${VERSION}\`
- **Maven Central (netex-java-model):** https://central.sonatype.com/artifact/org.entur/netex-java-model/${VERSION}
- **Maven Central (netex2-java-model):** https://central.sonatype.com/artifact/org.entur/netex2-java-model/${VERSION}
- **Next Development Version ($BASE_BRANCH):** ${{ steps.next_version.outputs.next_version }}
- **Release Branch:** Merged to $BASE_BRANCH and deleted

Expand Down
10 changes: 5 additions & 5 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
- **Organization**: Entur AS (Norwegian public transport data provider)
- **License**: EUPL-1.2
- **Java Version**: 11+ (builds on 17 in CI)
- **Package**: `org.rutebanken.netex.model` (generated), `org.rutebanken.netex` and `org.rutebanken.netex.util` (source)
- **Package**: `org.entur.netex2.model` (generated), `org.entur.netex2` and `org.entur.netex2.util` (source)

## Build Commands

Expand Down Expand Up @@ -38,8 +38,8 @@ mvn validate
│ └── version_updater.sh # Updates version references
├── bindings.xjb # JAXB customization bindings
├── src/main/java/
│ ├── module-info.java # JPMS module descriptor (org.entur.netex.java.model)
│ └── org/rutebanken/netex/ # Utilities (validation, client, toString style)
│ ├── module-info.java # JPMS module descriptor (org.entur.netex2)
│ └── org/entur/netex2/ # Utilities (validation, client, toString style)
│ └── util/ # XML adapters for Java 8 time types
├── src/main/resources/xsd/ # NeTEx XSD files (downloaded at build time)
├── src/test/ # JUnit 5 tests for marshalling/unmarshalling
Expand All @@ -49,9 +49,9 @@ mvn validate
## Key Technical Details

- **JAXB Bindings**: The `bindings.xjb` file customizes code generation, including:
- Java 8 time type adapters (`LocalDateTime`, `LocalTime`, `Duration`)
- Java 8 time type adapters (`LocalDateTime`, `LocalDate`, `LocalTime`, `Duration`)
- Property name conflict resolution
- Package naming (`org.rutebanken.netex.model`)
- Package naming (`org.entur.netex2.model`)

- **Generated Code**: Model classes are generated in `target/generated-sources/` during build. Do not manually edit generated code.

Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# netex-java-model

[![Build and push](https://github.com/entur/netex-java-model/actions/workflows/deploy.yml/badge.svg)](https://github.com/entur/netex-java-model/actions/workflows/deploy.yml)
[![Maven Central](https://img.shields.io/maven-central/v/org.entur/netex-java-model.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/org.entur/netex-java-model)
[![Maven Snapshots](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fcentral.sonatype.com%2Frepository%2Fmaven-snapshots%2Forg%2Fentur%2Fnetex-java-model%2Fmaven-metadata.xml&label=Snapshot)](https://central.sonatype.com/repository/maven-snapshots)
[![Maven Central](https://img.shields.io/maven-central/v/org.entur/netex2-java-model.svg?label=Maven%20Central)](https://central.sonatype.com/artifact/org.entur/netex2-java-model)
[![Maven Snapshots](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fcentral.sonatype.com%2Frepository%2Fmaven-snapshots%2Forg%2Fentur%2Fnetex2-java-model%2Fmaven-metadata.xml&label=Snapshot)](https://central.sonatype.com/repository/maven-snapshots)
[![License: EUPL-1.2](https://img.shields.io/badge/License-EUPL--1.2-blue.svg)](https://joinup.ec.europa.eu/software/page/eupl)
[![Java 21+](https://img.shields.io/badge/Java-21%2B-orange)](https://adoptium.net/)

Expand All @@ -14,7 +14,7 @@ This library downloads the NeTEx XSD files from the [NeTEx repository](https://g

- **NeTEx version**: 2.0 (model generation), with legacy validation support back to 1.07
- **JAXB**: Jakarta XML Bind 4.x (Jakarta EE 9+)
- **Generated package**: `org.rutebanken.netex.model`
- **Generated package**: `org.entur.netex2.model`
- **GML types package**: `net.opengis.gml._3`

## Usage
Expand All @@ -24,12 +24,12 @@ This library downloads the NeTEx XSD files from the [NeTEx repository](https://g
```xml
<dependency>
<groupId>org.entur</groupId>
<artifactId>netex-java-model</artifactId>
<artifactId>netex2-java-model</artifactId>
<version>LATEST</version>
</dependency>
```

See [Maven Central](https://central.sonatype.com/artifact/org.entur/netex-java-model) for the latest released version.
See [Maven Central](https://central.sonatype.com/artifact/org.entur/netex2-java-model) for the latest released version.

### Snapshot

Expand All @@ -52,7 +52,7 @@ Then add the dependency with the snapshot version:
```xml
<dependency>
<groupId>org.entur</groupId>
<artifactId>netex-java-model</artifactId>
<artifactId>netex2-java-model</artifactId>
<version>LATEST-SNAPSHOT</version>
</dependency>
```
Expand Down Expand Up @@ -88,20 +88,20 @@ The XSD files are downloaded from GitHub during the `generate-sources` phase and
│ ├── annotation-replacer.sh # Post-processes generated Java files
│ └── version_updater.sh # Updates version references in bindings
├── bindings.xjb # JAXB customization bindings
├── src/main/java/org/rutebanken/
│ ├── netex/ # NeTEx utilities (validation, toString style)
│ └── util/ # XML adapters for Java time types
├── src/main/java/org/entur/
│ └── netex2/ # NeTEx utilities (validation, client, toString style)
│ └── util/ # XML adapters for Java time types
├── src/main/resources/xsd/ # Downloaded NeTEx XSD files (build artifact)
└── src/test/ # JUnit 5 marshalling/unmarshalling tests
```

## Key Technical Details

**JAXB customizations** (`bindings.xjb`):
- Java 8 time type adapters (`LocalDateTime`, `LocalTime`, `Duration`) via `threeten-jaxb-core`
- Java 8 time type adapters (`LocalDateTime`, `LocalDate`, `LocalTime`, `Duration`) via `threeten-jaxb-core`
- Fluent builder API (`withX()` methods) via `jaxb-fluent-api`
- Property name conflict resolution
- Package mapping to `org.rutebanken.netex.model`
- Package mapping to `org.entur.netex2.model`

**Schema validation**: `NeTExValidator` supports validation against NeTEx versions 1.07 through 2.0.

Expand Down
12 changes: 6 additions & 6 deletions bindings.xjb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

<jxb:bindings>
<jxb:globalBindings underscoreBinding="asCharInWord">
<xjc:javaType name="java.time.LocalDateTime" xmlType="xs:dateTime" adapter="org.rutebanken.netex.util.LocalDateTimeISO8601XmlAdapter" />
<xjc:javaType name="java.time.LocalTime" xmlType="xs:time" adapter="org.rutebanken.netex.util.LocalTimeISO8601XmlAdapter" />
<xjc:javaType name="java.time.LocalDateTime" xmlType="xs:date" adapter="org.rutebanken.netex.util.LocalDateXmlAdapter" />
<xjc:javaType name="java.time.LocalDateTime" xmlType="xs:dateTime" adapter="org.entur.netex2.util.LocalDateTimeISO8601XmlAdapter" />
<xjc:javaType name="java.time.LocalTime" xmlType="xs:time" adapter="org.entur.netex2.util.LocalTimeISO8601XmlAdapter" />
<xjc:javaType name="java.time.LocalDate" xmlType="xs:date" adapter="org.entur.netex2.util.LocalDateXmlAdapter" />
<xjc:javaType name="java.time.Duration" xmlType="xs:duration" adapter="io.github.threetenjaxb.core.DurationXmlAdapter" />
</jxb:globalBindings>
</jxb:bindings>

<!-- See the script bin/version_updater.sh It updates version in schema locations-->

| <jxb:bindings schemaLocation="./src/main/resources/xsd/2.0/NeTEx_publication.xsd">
<jxb:bindings schemaLocation="./src/main/resources/xsd/2.0/NeTEx_publication.xsd">
<jxb:schemaBindings>
<jxb:package name="org.rutebanken.netex.model" />
<jxb:package name="org.entur.netex2.model" />
</jxb:schemaBindings>
</jxb:bindings>

Expand Down Expand Up @@ -53,7 +53,7 @@
<jxb:bindings
schemaLocation="./src/main/resources/xsd/2.0/netex_framework/netex_responsibility/netex_version_support.xsd">
<jxb:bindings node="//xsd:simpleType[@name = 'VersionIdType']">
<xjc:javaType name="java.lang.String" adapter="org.rutebanken.netex.util.VersionXmlAdapter" />
<xjc:javaType name="java.lang.String" adapter="org.entur.netex2.util.VersionXmlAdapter" />
</jxb:bindings>
<jxb:bindings node="//xsd:attributeGroup[@name = 'BasicModificationDetailsGroup']/xsd:attribute[@name = 'status']">
<jxb:property name="status_BasicModificationDetailsGroup" />
Expand Down
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.entur</groupId>
<artifactId>netex-java-model</artifactId>
<artifactId>netex2-java-model</artifactId>
<version>3.0.0-SNAPSHOT</version>

<name>netex-java-model</name>
<name>netex2-java-model</name>
<description>Generates Java model from NeTEx XSDs using JAXB.</description>
<url>https://github.com/entur/netex-java-model</url>
<organization>
Expand Down Expand Up @@ -519,7 +519,7 @@
<extensionArg>-no-header</extensionArg>
<extensionArg>-Xbug986</extensionArg>
<extensionArg>-Xfluent-api</extensionArg>
<extensionArg>-Xts:style:org.rutebanken.netex.OmitNullsToStringStyle.INSTANCE
<extensionArg>-Xts:style:org.entur.netex2.OmitNullsToStringStyle.INSTANCE
</extensionArg>
</extensionArgs>
</xsdOption>
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
module org.entur.netex.java.model {
module org.entur.netex2 {

Check warning on line 1 in src/main/java/module-info.java

View workflow job for this annotation

GitHub Actions / maven-verify

module name component netex2 should avoid terminal digits
requires transitive jakarta.xml.bind;
requires transitive java.xml;
requires transitive org.apache.commons.lang3;
requires io.github.threetenjaxb.core;
requires org.slf4j;

exports org.rutebanken.netex;
exports org.rutebanken.netex.client;
exports org.rutebanken.netex.validation;
exports org.rutebanken.netex.model;
exports org.rutebanken.netex.util;
exports org.entur.netex2;
exports org.entur.netex2.client;
exports org.entur.netex2.validation;
exports org.entur.netex2.model;
exports org.entur.netex2.util;
exports net.opengis.gml._3;
exports uk.org.siri.siri;

opens org.rutebanken.netex.model to jakarta.xml.bind, org.glassfish.jaxb.runtime, org.apache.commons.lang3;
opens org.entur.netex2.model to jakarta.xml.bind, org.glassfish.jaxb.runtime, org.apache.commons.lang3;

Check warning on line 16 in src/main/java/module-info.java

View workflow job for this annotation

GitHub Actions / maven-verify

module not found: org.glassfish.jaxb.runtime
opens net.opengis.gml._3 to jakarta.xml.bind, org.glassfish.jaxb.runtime, org.apache.commons.lang3;

Check warning on line 17 in src/main/java/module-info.java

View workflow job for this annotation

GitHub Actions / maven-verify

module not found: org.glassfish.jaxb.runtime
opens uk.org.siri.siri to jakarta.xml.bind, org.glassfish.jaxb.runtime, org.apache.commons.lang3;

Check warning on line 18 in src/main/java/module-info.java

View workflow job for this annotation

GitHub Actions / maven-verify

module not found: org.glassfish.jaxb.runtime
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the Licence.
*/

package org.rutebanken.netex;
package org.entur.netex2;

import org.apache.commons.lang3.builder.ToStringStyle;

Expand All @@ -26,7 +26,7 @@
public static final ToStringStyle INSTANCE = new OmitNullsToStringStyle();

public OmitNullsToStringStyle() {
this.setUseClassName(false);

Check warning on line 29 in src/main/java/org/entur/netex2/OmitNullsToStringStyle.java

View workflow job for this annotation

GitHub Actions / maven-verify

possible 'this' escape before subclass is fully initialized
this.setUseIdentityHashCode(false);
this.setUseFieldNames(true);
this.setContentStart("[");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
* limitations under the Licence.
*/

package org.rutebanken.netex.client;
package org.entur.netex2.client;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
import jakarta.xml.bind.Marshaller;
import jakarta.xml.bind.Unmarshaller;
import org.rutebanken.netex.model.ObjectFactory;
import org.rutebanken.netex.model.PublicationDeliveryStructure;
import org.rutebanken.netex.validation.NeTExValidator;
import org.entur.netex2.model.ObjectFactory;
import org.entur.netex2.model.PublicationDeliveryStructure;
import org.entur.netex2.validation.NeTExValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.xml.sax.SAXException;
Expand Down Expand Up @@ -73,7 +73,7 @@
marshaller.setSchema(neTExValidator.getSchema());
}

URL url = new URL(publicationDeliveryUrl);

Check warning on line 76 in src/main/java/org/entur/netex2/client/PublicationDeliveryClient.java

View workflow job for this annotation

GitHub Actions / maven-verify

URL(java.lang.String) in java.net.URL has been deprecated
HttpURLConnection connection = null;
try {
connection = (HttpURLConnection) url.openConnection();
Expand All @@ -89,7 +89,7 @@
LOGGER.info("Got response code {} after posting publication delivery to URL : {}", responseCode, url);

InputStream inputStream = connection.getInputStream();
JAXBElement<PublicationDeliveryStructure> element = (JAXBElement<PublicationDeliveryStructure>) unmarshaller.unmarshal(inputStream);

Check warning on line 92 in src/main/java/org/entur/netex2/client/PublicationDeliveryClient.java

View workflow job for this annotation

GitHub Actions / maven-verify

unchecked cast

return element.getValue();
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the Licence.
*/

package org.rutebanken.netex.util;
package org.entur.netex2.util;

import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import java.time.LocalDateTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,33 @@
* limitations under the Licence.
*/

package org.rutebanken.netex.util;
package org.entur.netex2.util;

import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import java.time.LocalDateTime;
import java.time.OffsetDateTime;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.temporal.ChronoField;

public class LocalDateXmlAdapter extends XmlAdapter<String, LocalDateTime> {
private static final DateTimeFormatter formatter = new DateTimeFormatterBuilder().appendPattern("yyyy-MM-dd")
/**
* Maps xs:date to {@link LocalDate}. An optional trailing time zone offset (allowed by xs:date) is
* accepted when unmarshalling and ignored; dates are always marshalled without an offset.
*/
public class LocalDateXmlAdapter extends XmlAdapter<String, LocalDate> {

private static final DateTimeFormatter PARSER = new DateTimeFormatterBuilder()
.append(DateTimeFormatter.ISO_LOCAL_DATE)
.optionalStart().appendPattern("XXXXX").optionalEnd()
.parseDefaulting(ChronoField.HOUR_OF_DAY, 0)
.parseDefaulting(ChronoField.MINUTE_OF_HOUR, 0)
.parseDefaulting(ChronoField.SECOND_OF_MINUTE, 0)
.parseDefaulting(ChronoField.OFFSET_SECONDS,OffsetDateTime.now().getLong(ChronoField.OFFSET_SECONDS) )
.toFormatter();
.toFormatter();

@Override
public LocalDateTime unmarshal(String inputDate) {
return LocalDateTime.parse(inputDate, formatter);
public LocalDate unmarshal(String inputDate) {
return LocalDate.parse(inputDate, PARSER);
}

@Override
public String marshal(LocalDateTime inputDate) {
if(inputDate != null) {
return formatter.format(inputDate);
public String marshal(LocalDate inputDate) {
if (inputDate != null) {
return DateTimeFormatter.ISO_LOCAL_DATE.format(inputDate);
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the Licence.
*/

package org.rutebanken.netex.util;
package org.entur.netex2.util;

import jakarta.xml.bind.annotation.adapters.XmlAdapter;
import java.time.LocalTime;
Expand All @@ -21,7 +21,7 @@
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.temporal.ChronoField;
import java.util.HashMap;

Check warning on line 24 in src/main/java/org/entur/netex2/util/LocalTimeISO8601XmlAdapter.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this unused import 'java.util.HashMap'.

See more on https://sonarcloud.io/project/issues?id=entur_netex-java-model&issues=AaE0PHK2dyNZUgBD_c6C&open=AaE0PHK2dyNZUgBD_c6C&pullRequest=312
import java.util.concurrent.ConcurrentHashMap;

public class LocalTimeISO8601XmlAdapter extends XmlAdapter<String, LocalTime> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the Licence.
*/

package org.rutebanken.netex.util;
package org.entur.netex2.util;

import jakarta.xml.bind.annotation.adapters.XmlAdapter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the Licence.
*/

package org.rutebanken.netex.validation;
package org.entur.netex2.validation;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -44,7 +44,7 @@
v1_13 ("1.13"),
v1_14 ("1.14"),
v1_15 ("1.15"),
v1_16 ("1.16"),

Check failure on line 47 in src/main/java/org/entur/netex2/validation/NeTExValidator.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this constant name to match the regular expression '^[A-Z][A-Z0-9]*(_[A-Z0-9]+)*$'.

See more on https://sonarcloud.io/project/issues?id=entur_netex-java-model&issues=AaE0PHG2dyNZUgBD_c6B&open=AaE0PHG2dyNZUgBD_c6B&pullRequest=312
v2_0 ("2.0");

private final String folderName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the Licence.
*/

package org.rutebanken.netex.validation;
package org.entur.netex2.validation;

import org.w3c.dom.ls.LSInput;
import org.w3c.dom.ls.LSResourceResolver;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the Licence.
*/

package org.rutebanken.netex.model;
package org.entur.netex2.model;

import jakarta.xml.bind.JAXBContext;
import jakarta.xml.bind.JAXBException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the Licence.
*/

package org.rutebanken.netex.model;
package org.entur.netex2.model;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -415,7 +415,7 @@ void blockRoundTrip() throws JAXBException {

@Test
void fragmentShouldNotContainNetexNamespace() throws Exception {
JAXBContext netexJaxBContext = JAXBContext.newInstance("net.opengis.gml._3:org.rutebanken.netex.model:uk.org.siri.siri");
JAXBContext netexJaxBContext = JAXBContext.newInstance("net.opengis.gml._3:org.entur.netex2.model:uk.org.siri.siri");
Marshaller marshaller = netexJaxBContext.createMarshaller();

marshaller.setProperty(jakarta.xml.bind.Marshaller.JAXB_ENCODING, StandardCharsets.UTF_8.name());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the Licence.
*/

package org.rutebanken.netex.model;
package org.entur.netex2.model;

import org.junit.jupiter.api.Test;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the Licence.
*/

package org.rutebanken.netex.model;
package org.entur.netex2.model;

import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* limitations under the Licence.
*/

package org.rutebanken.netex.model;
package org.entur.netex2.model;

import jakarta.xml.bind.JAXBElement;
import jakarta.xml.bind.JAXBException;
Expand Down
Loading
Loading