Skip to content

Trip planning: migrate OTP1 request-building off the vendored POJOs#1787

Merged
bmander merged 1 commit into
mainfrom
otp1-pojos-request-side
Jul 11, 2026
Merged

Trip planning: migrate OTP1 request-building off the vendored POJOs#1787
bmander merged 1 commit into
mainfrom
otp1-pojos-request-side

Conversation

@bmander

@bmander bmander commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Summary

TripRequestBuilder/TripPlanRepository still built the outgoing OTP /plan request with the vendored, unpublished edu.usf.cutr.opentripplanner.android:opentripplanner-pojos:1.0.0-SNAPSHOT jar (org.opentripplanner.api.ws.Request/Message, org.opentripplanner.routing.core.OptimizeType/TraverseMode) even after #1782 migrated the response side onto the app-owned TripItinerary domain model.

  • Retargets request-building onto app-owned types — TripPlanRequest (an OTP /plan query-parameter map) and OtpErrorId (the OTP wire error-id vocabulary) — placed in api/contract/OtpPlanModels.kt alongside the existing OtpResponseDto/OtpErrorDto family, matching this codebase's existing layering.
  • Reuses the existing TripMode enum (already used for the response side) instead of TraverseMode for building the OTP mode query parameter.
  • OptimizeType is gone entirely — replaced by the two literal wire values ("QUICK"/"TRANSFERS") it ever produced.

Bug fix found along the way: the pre-1.0-OTP-server bike-rental URL rewrite in TripPlanRepository.requestPlan() has been dead code since the bikeshare feature shipped in 2017 — nothing ever called the vendored Request.setBikeRental(true), since bikeshare mode has always been requested via the BICYCLE_RENT mode-string token instead (a completely separate mechanism). A user selecting bikeshare mode against a region running a pre-1.0 OTP server would send a mode string that server can't parse. Now derives the flag by checking for that token's presence in the built mode query string — the one source of truth valid on both the direct UI-build path and the trip-plan-monitor's bundle-restore path (initFromBundleSimple never repopulates mModeId).

The opentripplanner-pojos dependency itself stays in build.gradle: bikeshare (BikeRentalStation) is still a live consumer, tracked separately in #1779. Once that lands, the dependency can be removed entirely.

Tracking: #1778

Test plan

  • ./gradlew :onebusaway-android:compileObaGoogleDebugKotlin -PwarningsAsErrors=true — clean
  • ./gradlew :onebusaway-android:testObaGoogleDebugUnitTest -PwarningsAsErrors=true — all pass, including new OtpErrorIdTest (pins the 18 transcribed wire error-ids against the vendored jar) and ModeStringRequestsBikeRentalTest (pins the bike-rental-detection fix)
  • Lint (lintObaGoogleDebug) not run locally per this repo's convention — left to CI
  • On-device manual trip-planning verification not performed in this environment

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Updated trip planning requests to use the app’s internal request format.
    • Added support for clearer handling of trip-planning error responses.
    • Preserved bike-rental trip planning while using the updated request format.
  • Bug Fixes

    • Improved detection of bike-rental modes in trip-planning requests.
  • Tests

    • Added coverage for error-code mappings and bike-rental mode detection.

TripRequestBuilder/TripPlanRepository still built the outgoing OTP `/plan`
request with the vendored, unpublished org.opentripplanner.api.ws.Request/
Message and routing.core.OptimizeType/TraverseMode types even after #1782
migrated the response side. Retargets request-building onto app-owned types
(TripPlanRequest, OtpErrorId in api/contract/OtpPlanModels.kt) alongside the
existing OtpResponseDto family, reusing the existing TripMode enum instead of
TraverseMode.

Also fixes a real bug found while doing this: the pre-1.0-OTP-server
bike-rental URL rewrite in TripPlanRepository.requestPlan() has been dead
since the bikeshare feature shipped in 2017 — nothing ever called the
vendored Request.setBikeRental(true), since bikeshare mode has always been
requested via the BICYCLE_RENT mode-string token instead. Now derives the
flag from that token's presence in the built mode string, the one source of
truth valid on both the direct UI-build path and the trip-plan-monitor's
bundle-restore path.

The opentripplanner-pojos dependency itself stays in build.gradle: bikeshare
(BikeRentalStation) is still a live consumer, tracked separately in #1779.

Tracking: #1778

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Trip planning now uses app-owned request and error contracts. TripRequestBuilder creates parameter maps, while TripPlanRepository handles mode detection, OTP execution, parsing, and error mapping without the vendored OTP request and message types.

Changes

OTP trip planning migration

Layer / File(s) Summary
App-owned plan contracts and error IDs
onebusaway-android/src/main/java/.../api/contract/OtpPlanModels.kt, onebusaway-android/src/test/.../api/contract/OtpErrorIdTest.kt, onebusaway-android/build.gradle
Adds TripPlanRequest and explicit OtpErrorId wire mappings, tests their IDs, and documents the remaining vendored POJO usage.
Trip plan request construction
onebusaway-android/src/main/java/.../directions/util/TripRequestBuilder.kt
Builds OTP /plan parameters as a TripPlanRequest, including optimization, modes, dates, times, accessibility, walking distance, and bikeshare options.
Repository execution and bike-rental handling
onebusaway-android/src/main/java/.../ui/tripplan/TripPlanRepository.kt, onebusaway-android/src/test/.../ui/tripplan/ModeStringRequestsBikeRentalTest.kt
Uses app-owned request and error types, detects bike-rental mode tokens, and maps timeout and response errors through OtpErrorId.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TripRequestBuilder
  participant TripPlanRepository
  participant OtpWebService
  participant OtpPlanParser
  TripRequestBuilder->>TripPlanRepository: provide TripPlanRequest
  TripPlanRepository->>OtpWebService: execute /plan request
  OtpWebService-->>TripPlanRepository: return OTP response
  TripPlanRepository->>OtpPlanParser: parse response
  OtpPlanParser-->>TripPlanRepository: return parsed result or error
Loading

Possibly related issues

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: migrating OTP1 request-building away from vendored POJOs.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch otp1-pojos-request-side

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@bmander
bmander merged commit 3d0057b into main Jul 11, 2026
3 checks passed
@bmander
bmander deleted the otp1-pojos-request-side branch July 11, 2026 18:24
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