Skip to content

openTdataCH/ojp-adapter

Repository files navigation

Author: Peter Hirzel (Software Architect SBB Journey Planner), 2023
Licence: Apache License, Version 2.0

About OJP-Adapter

The project contains 2 targets:

  1. a simple OJPAdapter library to request Public-Transportation queries against the swiss public Open Journey-Planner (SKI) based on OJP Specification OJP.xsd.
  2. a RESTful OJPController with a Transmodel implemenation of a Journey-Planner interface

Remark about OJP SKI+

Goals

Abstracting the complex VDV OJP.xsd Schema by Java POJOs, map response properly and provide low-level error-handling.

Anyone (for e.g. public transport-organisation) who plans to use the Swiss OJP router (or other european OJP instances supporting the same protocol version) may try this library to setup a quick working starting point.

The vdv ojp XSD might be quite complex and JAXB POJO generation therefore too!
Besides, understanding the OJP semantics may mean a steep learning curve for non-insiders.

The author hopes using this OJP-Adapter library may "abstract" the above steps massively, though the resulting OJP model may still be complex to deal with (perhaps check the returned data for a more intuitive understanding as well).

Known usage

This Software was originally developed for SBB AG Switzerland, Personenverkehr, CustomerInformation by Peter Hirzel (Software Architect Journey-Planner) for experimental reasons:

Targets

OJPAdapter library

Contains:

The provided OJPAdapter is able to query Swiss SKI+ OJP instances, if configured well (by means your own access token):

  • use OJPAadapter for raw native XML handling in conversation with OJP protocol.
  • Use of Swiss SKI+ OJP 2.0 API.
  • Demonstration of easy filters and response analysis by OJPAdapterAccessTest

See:

OJPController RESTful Service

Contains:

  • OJP/Transmodel mapping
  • SpringBoot OJPWebApplication
  • Transmodel like implementation model as used by SBB Customer Information
  • Covers Place, Trip, DatedVehicleJourney (including Departures/Arrivals)

Run it

OJP-Adapter

  1. Download repository
  2. mvn clean install
  3. copy ojp-adapter-integration/src/main/resources/ojp-SAMPLE.properties to ojp.properties and add your own key for SKI+ OJP Instance from opentransportdata.swiss passive instance v2 "Manage the API key"
  4. run swiss.opentransportdata.ojp.adapter.**.OJPAdapterAccessTest (to try out native OJP XML based request/response)

OJPWebApplication

  1. clone ojp-adapter-service/main/resources/application.yml to application-local.yml and set 'ojp.authorization'
  2. run swiss.opentransportdata.ojp.adapter.service.application.OJPWebApplication with 'VM Options'=-Dspring.profiles.active=local
  3. open OpenAPI 3 Swagger-UI

Remark:

  • At least the OJP passive key should be easy to get.
  • For the OJP active instance key you probably need to contact the operation-responsibles.
  • If your just interested in Open API 3 Swagger-UI resulting out of ojp-adapter-service/../OJPController, see JSON-specification

History

OJP v1.0 implementation (DEPRECATED)

See OJP-Adapter v0.9.0-beta

  • Checkout if you need to acces SKI+ OJP active instance, which supports only OJP v1.*

  • Currently, OJPAdapter deals with one SINGLE Journey-Planner request at a time, though MULTIPLE requests could be performed at once.

  • Complete OJP set of request-filters (currently the most relevant filters are adapted).

  • Complete OJP response mapping (currently the most relevant properties are implemented).

  • Quality tests for correctly mapped output should be verified and confirmed by SKI+.