Skip to content

[ext-fintraffic] Add FintrafficParking extension with persisted paymentMethods - #422

Open
teppope wants to merge 11 commits into
entur:masterfrom
tmfg:feat/ext-fintraffic-parking-entity-factory
Open

[ext-fintraffic] Add FintrafficParking extension with persisted paymentMethods#422
teppope wants to merge 11 commits into
entur:masterfrom
tmfg:feat/ext-fintraffic-parking-entity-factory

Conversation

@teppope

@teppope teppope commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

This is the first increment of the Fintraffic parking extension, focused on paymentMethods. Further fields (e.g. vehicleEntrances, availability conditions) will follow in subsequent PRs once the underlying data model and import pipeline are in place.

Implements the Fintraffic parking extension on top of the feat/parking-extension-hooks infrastructure (#421).

  • FintrafficParking — JPA subclass of Parking with a paymentMethods column (stored as a PostgreSQL array via Hibernate's @JdbcTypeCode(SqlTypes.ARRAY)). A Flyway migration (V3__FintrafficParkingExtensions) adds the backing column.
  • FintrafficParkingEntityFactory@Primary factory that instantiates FintrafficParking and registers FintrafficParking.class with Orika. paymentMethods is kept in the exclusion list; enum conversion is handled by the contributor instead.
  • FintrafficParkingMapperContributor — translates paymentMethods between org.rutebanken.netex.model.PaymentMethodEnumeration and org.rutebanken.tiamat.model.PaymentMethodEnumeration in both import and export directions. Unknown enum values are silently skipped.
  • FintrafficMergingParkingImporter — extends the mergeExtendedFields hook to persist paymentMethods from the incoming entity onto the existing DB entity.
  • FintrafficParkingGraphQLTypeContributor — adds paymentMethods as a [PaymentMethodsEnumeration] field to both the parking output and input GraphQL types, including enum type registration.
  • FintrafficParkingUpdater — extends the mutation hook to copy paymentMethods from the GraphQL input onto the Tiamat entity before save.

All components are activated by the fintraffic Spring profile.

Type of change

  • New feature (non-breaking change which adds functionality)

Dependencies

Depends on #421 — that branch must be merged first (or this PR rebased onto master after that merge).

Tests

  • FintrafficParkingIntegrationTest — NeTEx import round-trip: verifies paymentMethods survives import and is present on the persisted entity.
  • FintrafficGraphQLParkingIntegrationTest — GraphQL mutation and query: verifies paymentMethods can be set via mutation and read back via parking(id: "...").
  • FintrafficParkingMapperContributorTest — unit tests for enum conversion in both directions, including unknown value handling.
  • FintrafficMergingParkingImporterTest — verifies merge behaviour: values copied from incoming to existing entity.
  • FintrafficParkingEntityFactoryTest — verifies correct class, exclusion list, and instance type.

Follow-up fix (added after initial review)

Added FintrafficEntityScanConfig — an ext-only, @Profile("fintraffic")-guarded
@Configuration that registers org.rutebanken.tiamat.ext.fintraffic.model for JPA
entity scanning via Spring's additive EntityScanPackages.register(). TiamatApplication's
@EntityScan(basePackageClasses = {StopPlace.class, ...}) only covers
org.rutebanken.tiamat.model, so without this, Hibernate never registered
FintrafficParking as an entity and every mutateParking/parking GraphQL operation
failed under the fintraffic profile with "... is not an entity". This does not modify
TiamatApplication.java — the registration is purely additive.

This fix has also been merged forward into every dependent branch in the stack
(feat/ext-fintraffic-info-links, feat/ext-fintraffic-vehicle-entrances,
feat/ext-fintraffic-parking-lighting, feat/ext-fintraffic-parking-opening-hours)
so their PRs remain buildable/testable independently of merge order.

Follow-up fix: Parking never appears in the Read API cache

ReadApiNetexMarshallingService.createEntityRecord derived the Read API cache table's
type column via entity.getClass().getSimpleName(). Under the fintraffic profile,
every Parking is actually persisted/loaded as a FintrafficParking instance (this
branch's subclass), so the column got "FintrafficParking" instead of "Parking"
never matching the repository's type IN (...) query filter. The row was written
successfully (no exception), but was permanently invisible to every Read API query.

Fixed by adding an entityTypeName(EntityInVersionStructure) helper that maps the known
Tiamat model supertypes (StopPlace, Parking, TopographicPlace, FareZone) to their
NeTEx element type name via instanceof checks, instead of relying on the runtime class
name. Verified end-to-end with a new ReadApiParkingIncrementalSyncIntegrationTest that
activates the real fintraffic-read-api Spring profile (not mocked) and asserts the new
Parking is both written with type='Parking' and returned by the real
streamStopPlaces query used by the Read API.

@teppope
teppope force-pushed the feat/ext-fintraffic-parking-entity-factory branch 6 times, most recently from f64166a to 15410c6 Compare July 17, 2026 05:43
teppope and others added 7 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>
@teppope
teppope force-pushed the feat/ext-fintraffic-parking-entity-factory branch from 15410c6 to de576f5 Compare July 17, 2026 05:54
…cognized JPA entity

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
teppope and others added 2 commits July 28, 2026 08:52
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@teppope teppope changed the title Add Fintraffic parking extension: paymentMethods (increment 1) [ext-fintraffic] Add FintrafficParking extension with persisted paymentMethods Jul 28, 2026
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