vehicleRentalStation() {
return vehicleRentalStationService
.getVehicleRentalStations()
.stream()
- .filter(vehicleRentalStation ->
- OTPFeature.GtfsGraphQlApiRentalStationFuzzyMatching.isOn()
- ? stationIdFuzzyMatches(vehicleRentalStation, id)
- : stationIdMatches(vehicleRentalStation, id)
- )
+ .filter(vehicleRentalStation -> stationIdMatches(vehicleRentalStation, id))
.findAny()
.orElse(null);
};
@@ -968,21 +975,6 @@ private boolean stationIdMatches(VehicleRentalStation station, String feedScoped
return station.getId().toString().equals(feedScopedId);
}
- /**
- * This matches station's feedScopedId to the given string if the string is feed scoped (i.e
- * contains a `:` separator) or only matches the station's id without the feed to the given
- * string. This approach can lead to a random station matching the criteria if there are multiple
- * stations with the same id in different feeds.
- *
- * TODO this can be potentially removed after a while, only used by Digitransit as of now.
- */
- private boolean stationIdFuzzyMatches(VehicleRentalStation station, String idWithoutFeed) {
- if (idWithoutFeed != null && idWithoutFeed.contains(":")) {
- return stationIdMatches(station, idWithoutFeed);
- }
- return station.getId().getId().equals(idWithoutFeed);
- }
-
private TransitService getTransitService(DataFetchingEnvironment environment) {
return environment.getContext().transitService();
}
diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RealTimeEstimateImpl.java b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RealTimeEstimateImpl.java
new file mode 100644
index 00000000000..fbbf5226691
--- /dev/null
+++ b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/RealTimeEstimateImpl.java
@@ -0,0 +1,25 @@
+package org.opentripplanner.apis.gtfs.datafetchers;
+
+import graphql.schema.DataFetcher;
+import graphql.schema.DataFetchingEnvironment;
+import java.time.Duration;
+import java.time.OffsetDateTime;
+import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers;
+import org.opentripplanner.model.plan.LegRealTimeEstimate;
+
+public class RealTimeEstimateImpl implements GraphQLDataFetchers.GraphQLRealTimeEstimate {
+
+ @Override
+ public DataFetcher delay() {
+ return environment -> getSource(environment).delay();
+ }
+
+ @Override
+ public DataFetcher time() {
+ return environment -> getSource(environment).time().toOffsetDateTime();
+ }
+
+ private LegRealTimeEstimate getSource(DataFetchingEnvironment environment) {
+ return environment.getSource();
+ }
+}
diff --git a/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopCallImpl.java b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopCallImpl.java
new file mode 100644
index 00000000000..4d3ede74c76
--- /dev/null
+++ b/application/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/StopCallImpl.java
@@ -0,0 +1,76 @@
+package org.opentripplanner.apis.gtfs.datafetchers;
+
+import static org.opentripplanner.apis.gtfs.GraphQLUtils.stopTimeToInt;
+
+import graphql.schema.DataFetcher;
+import graphql.schema.DataFetchingEnvironment;
+import java.time.ZonedDateTime;
+import org.opentripplanner.apis.gtfs.GraphQLRequestContext;
+import org.opentripplanner.apis.gtfs.generated.GraphQLDataFetchers;
+import org.opentripplanner.apis.gtfs.model.ArrivalDepartureTime;
+import org.opentripplanner.apis.gtfs.model.CallRealTime;
+import org.opentripplanner.apis.gtfs.model.CallSchedule;
+import org.opentripplanner.model.TripTimeOnDate;
+import org.opentripplanner.transit.model.timetable.EstimatedTime;
+import org.opentripplanner.transit.service.TransitService;
+import org.opentripplanner.utils.time.ServiceDateUtils;
+
+public class StopCallImpl implements GraphQLDataFetchers.GraphQLStopCall {
+
+ @Override
+ public DataFetcher realTime() {
+ return environment -> {
+ var tripTime = getSource(environment);
+ if (!tripTime.isRealtime()) {
+ return null;
+ }
+ var scheduledArrival = getZonedDateTime(environment, tripTime.getScheduledArrival());
+ var estimatedArrival = scheduledArrival == null
+ ? null
+ : EstimatedTime.of(scheduledArrival, tripTime.getArrivalDelay());
+ var scheduledDeparture = getZonedDateTime(environment, tripTime.getScheduledDeparture());
+ var estimatedDeparture = scheduledDeparture == null
+ ? null
+ : EstimatedTime.of(scheduledDeparture, tripTime.getDepartureDelay());
+ return new CallRealTime(estimatedArrival, estimatedDeparture);
+ };
+ }
+
+ @Override
+ public DataFetcher schedule() {
+ return environment -> {
+ var tripTime = getSource(environment);
+ var scheduledArrival = getZonedDateTime(environment, tripTime.getScheduledArrival());
+ var scheduledDeparture = getZonedDateTime(environment, tripTime.getScheduledDeparture());
+ return new CallSchedule(
+ new ArrivalDepartureTime(
+ scheduledArrival == null ? null : scheduledArrival.toOffsetDateTime(),
+ scheduledDeparture == null ? null : scheduledDeparture.toOffsetDateTime()
+ )
+ );
+ };
+ }
+
+ @Override
+ public DataFetcher