Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix board slack list mapping in Transmodel API #5420

Merged

Conversation

vpaturet
Copy link
Contributor

@vpaturet vpaturet commented Oct 11, 2023

Summary

When specifying a board slack by mode in a Transmodel query:

{
  trip(
    from: {
      place: "NSR:StopPlace:58481"
    },
    to: {
      place: "NSR:StopPlace:58482"
    },
    modes: {
      transportModes: {
        transportMode: water
        transportSubModes: localPassengerFerry
      }
    },
    numTripPatterns: 3,

    arriveBy: true,
    boardSlackList: {
      slack: 10
      modes: water
    },
    locale: us,
    timetableView: true
  ) {
    tripPatterns {
      distance
    }
    fromPlace {
      name
      quay {
        estimatedCalls(
          arrivalDeparture: departures,

          whiteListedModes: water,
          numberOfDepartures: 10
        ) {
          actualDepartureTime
          aimedDepartureTime
          date
          expectedDepartureTime
          destinationDisplay {
            frontText
            via
          }
          occupancyStatus
          realtimeState
          stopPositionInPattern
          datedServiceJourney {
            estimatedCalls {
              actualDepartureTime
              aimedDepartureTime
              expectedDepartureTime
              stopPositionInPattern
            }
            journeyPattern {
              directionType
              name
            }
            operatingDay
          }
        }
        stopType
      }
      flexibleArea
    }
    dateTime
    debugOutput {
      totalTime
    }
  }
}

an exception is thrown:

Exception while fetching data (/trip) : class java.util.Collections$SingletonList cannot be cast to class java.lang.Integer (java.util.Collections$SingletonList and java.lang.Integer are in module java.base of loader 'bootstrap')
java.lang.ClassCastException: class java.util.Collections$SingletonList cannot be cast to class java.lang.Integer (java.util.Collections$SingletonList and java.lang.Integer are in module java.base of loader 'bootstrap')
	at org.opentripplanner.ext.transmodelapi.support.DataFetcherDecorator.call(DataFetcherDecorator.java:46)
	at org.opentripplanner.ext.transmodelapi.support.DataFetcherDecorator.argument(DataFetcherDecorator.java:21)
	at org.opentripplanner.ext.transmodelapi.mapping.preferences.TransitPreferencesMapper.lambda$mapTransitPreferences$1(TransitPreferencesMapper.java:21)
	at org.opentripplanner.routing.api.request.framework.DurationForEnum$Builder.apply(DurationForEnum.java:181)
	at org.opentripplanner.routing.api.request.preference.TransitPreferences$Builder.withBoardSlack(TransitPreferences.java:263)
	at org.opentripplanner.ext.transmodelapi.mapping.preferences.TransitPreferencesMapper.mapTransitPreferences(TransitPreferencesMapper.java:19)
	at org.opentripplanner.ext.transmodelapi.mapping.PreferencesMapper.lambda$mapPreferences$4(PreferencesMapper.java:27)
	at org.opentripplanner.routing.api.request.preference.TransitPreferences$Builder.apply(TransitPreferences.java:326)
	at org.opentripplanner.routing.api.request.preference.RoutingPreferences$Builder.withTransit(RoutingPreferences.java:146)
	at org.opentripplanner.ext.transmodelapi.mapping.PreferencesMapper.mapPreferences(PreferencesMapper.java:27)
	at org.opentripplanner.ext.transmodelapi.mapping.TripRequestMapper.lambda$createRequest$12(TripRequestMapper.java:114)
	at org.opentripplanner.routing.api.request.preference.RoutingPreferences$Builder.apply(RoutingPreferences.java:239)
	at org.opentripplanner.routing.api.request.RouteRequest.withPreferences(RouteRequest.java:104)
	at org.opentripplanner.ext.transmodelapi.mapping.TripRequestMapper.createRequest(TripRequestMapper.java:113)
	at org.opentripplanner.ext.transmodelapi.TransmodelGraphQLPlanner.plan(TransmodelGraphQLPlanner.java:31)
	at org.opentripplanner.ext.transmodelapi.model.plan.TripQuery.lambda$create$0(TripQuery.java:565)
	at graphql.execution.ExecutionStrategy.invokeDataFetcher(ExecutionStrategy.java:311)
	at graphql.execution.ExecutionStrategy.fetchField(ExecutionStrategy.java:287)
	at graphql.execution.ExecutionStrategy.resolveFieldWithInfo(ExecutionStrategy.java:213)
	at graphql.execution.AsyncExecutionStrategy.execute(AsyncExecutionStrategy.java:55)
	at graphql.execution.Execution.executeOperation(Execution.java:161)
	at graphql.execution.Execution.execute(Execution.java:103)
	at graphql.GraphQL.execute(GraphQL.java:565)
	at graphql.GraphQL.lambda$parseValidateAndExecute$12(GraphQL.java:484)
	at java.base/java.util.concurrent.CompletableFuture.uniComposeStage(CompletableFuture.java:1187)
	at java.base/java.util.concurrent.CompletableFuture.thenCompose(CompletableFuture.java:2309)
	at graphql.GraphQL.parseValidateAndExecute(GraphQL.java:479)
	at graphql.GraphQL.executeAsync(GraphQL.java:438)
	at graphql.GraphQL.execute(GraphQL.java:365)
	at org.opentripplanner.ext.transmodelapi.TransmodelGraph.executeGraphQL(TransmodelGraph.java:67)
	at org.opentripplanner.ext.transmodelapi.TransmodelAPI.getGraphQL(TransmodelAPI.java:122)

This PR fixes this regression.

Issue

No

Unit tests

Documentation

No

@vpaturet vpaturet added bug Regression This feature is no longer working. labels Oct 11, 2023
@vpaturet vpaturet self-assigned this Oct 11, 2023
@vpaturet vpaturet changed the title Fix board slack list mapping in Tansmodel API Fix board slack list mapping in Transmodel API Oct 11, 2023
@vpaturet vpaturet marked this pull request as ready for review October 11, 2023 08:31
@vpaturet vpaturet requested a review from a team as a code owner October 11, 2023 08:31
@t2gran t2gran added this to the 2.5 (next release) milestone Oct 12, 2023
@vpaturet vpaturet merged commit 951cc4d into opentripplanner:dev-2.x Oct 13, 2023
5 checks passed
t2gran pushed a commit that referenced this pull request Oct 13, 2023
@vpaturet vpaturet deleted the fix_board_slack_list_mapping branch October 16, 2023 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Regression This feature is no longer working.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants