Skip to content

[ext-fintraffic] Persist and expose parking availabilityConditions - #430

Open
teppope wants to merge 30 commits into
entur:masterfrom
tmfg:feat/ext-fintraffic-parking-opening-hours
Open

[ext-fintraffic] Persist and expose parking availabilityConditions#430
teppope wants to merge 30 commits into
entur:masterfrom
tmfg:feat/ext-fintraffic-parking-opening-hours

Conversation

@teppope

@teppope teppope commented Jul 21, 2026

Copy link
Copy Markdown
Collaborator

Note: Depends on PR #429 (lighting/cycle-storage) being merged first. This branch is based on feat/ext-fintraffic-parking-lighting.

Follow-up: Once entur/netex-parser-java#309 is merged and a new version is published, bump the netex-parser-java version in any consumer repo that needs the new AvailabilityCondition index (e.g. digitraffic-tis-parking-netex-migration). Tiamat does its own JAXB unmarshalling and is unaffected.

Summary

Persist and expose parking AvailabilityCondition elements (opening hours) in the Fintraffic ext layer.

What

  • FintrafficParkingAvailabilityCondition (@Embeddable): stores dayTypeRef, isAvailable, startTime, endTime.
  • FintrafficParking: new @ElementCollection field availabilityConditions backed by parking_availability_conditions table.
  • V7 Flyway migration: creates parking_availability_conditions table + index on parking_id.
  • Mapper import (FintrafficParkingMapperContributor): reads AvailabilityCondition elements from validityConditions, extracts day type ref, isAvailable, and first Timeband start/end; ignores non-AvailabilityCondition entries.
  • Mapper export (FintrafficParkingMapperContributor): rebuilds AvailabilityCondition JAXBElements in the output Parking's validityConditions, appended after any existing ValidBetween entries.
  • Merge importer (FintrafficMergingParkingImporter): copies availabilityConditions from existing record when merging so data is not lost.
  • GraphQL (FintrafficParkingGraphQLTypeContributor): exposes availabilityConditions as a list of FintrafficAvailabilityConditionDto objects queryable via fintrafficParking { availabilityConditions { dayTypeRef isAvailable startTime endTime } }.
  • Updater (FintrafficParkingUpdater): preserves existing conditions on updates.

Notes

  • Ext-only change — no upstream Tiamat files are modified.
  • AvailabilityConditions coexist with ValidBetween (soft-delete end date) in validityConditions.
  • Tests: 58 ext tests pass (all Fintraffic* test classes).

Follow-up fix: NeTEx export failure for availability conditions

mapAvailabilityConditionsToNetex is invoked twice per export for the same target
Parking (a pre-existing Tiamat export-pipeline behavior). Two bugs surfaced as a result:

  1. Wrong JAXB wrapping/type for Timeband/AvailabilityCondition elements — fixed to
    use the correct element type and wrapping expected by the XSD.
  2. Duplicate ids from the double invocation — the method appended to the existing
    ValidityConditions_RelStructure list rather than replacing its own previously-added
    entries, so the second invocation duplicated entries with identical deterministic ids,
    violating the XSD's versioned-key uniqueness constraint. Fixed by removing any
    previously-added AvailabilityCondition entries before re-appending fresh ones
    (idempotent), while leaving unrelated entries (e.g. ValidBetween) untouched.

Verified with a real end-to-end regression test: GraphQL mutation sets
availabilityConditions, then the parent StopPlace is exported via the real
GET /api/services/stop_places/netex?idList= endpoint (the same one Kooste/PETI's
publication pipeline uses), confirming no 500 and correct XML content.

Follow-up fix (merged forward): Parking never appears in the Read API cache / NeTEx export failure for vehicle entrances

Brings in the fixes from #422 and #425:

  • ReadApiNetexMarshallingService derived the Read API cache's type column from the
    runtime class name ("FintrafficParking") instead of the correct NeTEx element type
    name ("Parking"), making every new Parking permanently invisible to Read API queries.
  • vehicleEntrances NeTEx export built elements without an id/version, violating the
    versioned-key XSD requirement.
  • A test-only fix for a nested @TestConfiguration leaking into unrelated tests' contexts
    via the shared @ComponentScan, resolved by gating it with
    @Profile("fintraffic-read-api").

teppope and others added 21 commits July 17, 2026 08:45
Implements the extension hook infrastructure from feat/parking-extension-hooks
to persist and expose paymentMethods on the Fintraffic Parking entity:

- FintrafficParking: @entity subclass with @ElementCollection paymentMethods
- FintrafficParkingEntityFactory: produces FintrafficParking instances
- FintrafficMergingParkingImporter: copies paymentMethods into the persisted entity
- FintrafficParkingGraphQLTypeContributor: adds paymentMethods to the GraphQL schema
- FintrafficParkingUpdater: populates and preserves paymentMethods on GraphQL mutations
- FintrafficParkingMapperContributor: bridges paymentMethods between NeTEx and Tiamat enums
- V3__FintrafficParkingExtensions: Flyway migration adding dtype column and payment methods table
- Full test coverage: unit + integration tests for all components

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…Factory

Orika cannot auto-map paymentMethods because the NeTEx and Tiamat enum
types differ. The FintrafficParkingMapperContributor already handles the
conversion explicitly, so including paymentMethods in the Orika classmap
was redundant and confusing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…xtProvider static field

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… core tests

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…t completeness

- Add UNIQUE (parking_id, day_type_ref) constraint to V7 migration
- Importer deduplicates by dayTypeRef (warn + keep last) to prevent DB constraint violations
- GraphQL updater rejects duplicate dayTypeRef with IllegalArgumentException
- parseLocalTime validates input; handles 24:00->midnight; throws IllegalArgumentException on bad values
- Timeband created on export when either startTime or endTime is non-null
- Tests for deduplication in importer and error paths in GraphQL updater

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Guard against empty first token after split in parseLocalTime (e.g. input ':')
- Add export test for endTime-only timeband (startTime null)
- Error-path tests verify no parking is persisted on duplicate dayTypeRef or invalid time

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…cognized JPA entity

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
teppope and others added 8 commits July 27, 2026 15:59
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…ntraffic-parking-opening-hours

# Conflicts:
#	src/ext-test/java/org/rutebanken/tiamat/ext/fintraffic/rest/graphql/FintrafficGraphQLParkingIntegrationTest.java
#	src/ext/java/org/rutebanken/tiamat/ext/fintraffic/importer/FintrafficParkingMapperContributor.java
@teppope teppope changed the title Persist and expose parking opening hours (AvailabilityConditions) [ext-fintraffic] Persist and expose parking availabilityConditions Jul 28, 2026
@teppope
teppope marked this pull request as ready for review July 30, 2026 06:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant