use of org.opentripplanner.ext.legacygraphqlapi.LegacyGraphQLRequestContext in project OpenTripPlanner by opentripplanner.
the class LegacyGraphQLQueryTypeImpl method node.
@Override
public DataFetcher<Object> node() {
return environment -> {
var args = new LegacyGraphQLTypes.LegacyGraphQLQueryTypeNodeArgs(environment.getArguments());
String type = args.getLegacyGraphQLId().getType();
String id = args.getLegacyGraphQLId().getId();
RoutingService routingService = environment.<LegacyGraphQLRequestContext>getContext().getRoutingService();
BikeRentalStationService bikerentalStationService = routingService.getBikerentalStationService();
switch(type) {
case "Agency":
return routingService.getAgencyForId(FeedScopedId.parseId(id));
case "Alert":
// TODO
return null;
case "BikePark":
return bikerentalStationService == null ? null : bikerentalStationService.getBikeParks().stream().filter(bikePark -> bikePark.id.equals(id)).findAny().orElse(null);
case "BikeRentalStation":
return bikerentalStationService == null ? null : bikerentalStationService.getBikeRentalStations().stream().filter(bikeRentalStation -> bikeRentalStation.id.equals(id)).findAny().orElse(null);
case "CarPark":
// TODO
return null;
case "Cluster":
// TODO
return null;
case "DepartureRow":
return PatternAtStop.fromId(routingService, id);
case "Pattern":
return routingService.getTripPatternForId(FeedScopedId.parseId(id));
case "placeAtDistance":
{
String[] parts = id.split(";");
Relay.ResolvedGlobalId internalId = new Relay().fromGlobalId(parts[1]);
Object place = node().get(DataFetchingEnvironmentImpl.newDataFetchingEnvironment(environment).source(new Object()).arguments(Map.of("id", internalId)).build());
return new PlaceAtDistance(place, Double.parseDouble(parts[0]));
}
case "Route":
return routingService.getRouteForId(FeedScopedId.parseId(id));
case "Stop":
return routingService.getStopForId(FeedScopedId.parseId(id));
case "Stoptime":
// TODO
return null;
case "stopAtDistance":
{
String[] parts = id.split(";");
Stop stop = routingService.getStopForId(FeedScopedId.parseId(parts[1]));
// TODO: Add geometry
return new StopAtDistance(stop, Integer.parseInt(parts[0]), null, null, null);
}
case "TicketType":
// TODO
return null;
case "Trip":
return routingService.getTripForId().get(FeedScopedId.parseId(id));
default:
return null;
}
};
}
Aggregations