From 9a65a99e81b32d68fc6e59bb74a3f9508271c6bd Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Wed, 8 May 2024 07:26:57 +0300 Subject: [PATCH 1/5] Remove duplicate of feedImpl typeWiring --- .../java/org/opentripplanner/apis/gtfs/GtfsGraphQLIndex.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLIndex.java b/src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLIndex.java index 1fd78765a07..53d53b9bc4b 100644 --- a/src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLIndex.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/GtfsGraphQLIndex.java @@ -129,7 +129,6 @@ protected static GraphQLSchema buildSchema() { .type(typeWiring.build(DepartureRowImpl.class)) .type(typeWiring.build(elevationProfileComponentImpl.class)) .type(typeWiring.build(FeedImpl.class)) - .type(typeWiring.build(FeedImpl.class)) .type(typeWiring.build(GeometryImpl.class)) .type(typeWiring.build(ItineraryImpl.class)) .type(typeWiring.build(LegImpl.class)) From 0ba5df5269168b86cf5819e94d45fe895135970a Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Wed, 8 May 2024 07:28:57 +0300 Subject: [PATCH 2/5] Data fetchers for publisherName and publisherUrl of FeedInfo class --- .../apis/gtfs/datafetchers/FeedImpl.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/FeedImpl.java b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/FeedImpl.java index 7d7c62136b6..6cf8d27b262 100644 --- a/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/FeedImpl.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/datafetchers/FeedImpl.java @@ -64,6 +64,22 @@ public DataFetcher feedId() { return this::getSource; } + @Override + public DataFetcher publisherName() { + return environment -> { + String id = getSource(environment); + return getTransitService(environment).getFeedInfo(id).getPublisherName(); + }; + } + + @Override + public DataFetcher publisherUrl() { + return environment -> { + String id = getSource(environment); + return getTransitService(environment).getFeedInfo(id).getPublisherUrl(); + }; + } + private List getAgencies(DataFetchingEnvironment environment) { String id = getSource(environment); return getTransitService(environment) From c43b8d56ecaab1a164500f6fd16d4add58a04669 Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Wed, 8 May 2024 07:30:59 +0300 Subject: [PATCH 3/5] Update gtfs graphql schema --- .../resources/org/opentripplanner/apis/gtfs/schema.graphqls | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls b/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls index 56f3528d6e3..b81ebdff4c7 100644 --- a/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls +++ b/src/main/resources/org/opentripplanner/apis/gtfs/schema.graphqls @@ -984,6 +984,12 @@ type Feed { """List of agencies which provide data to this feed""" agencies: [Agency] + """Name of feed publisher""" + publisherName: String! + + """Web address of feed publisher""" + publisherUrl: String! + """ Alerts relevant for the feed. """ From 4b9b06592b2c433357d637683d45e7ae96682a93 Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Wed, 8 May 2024 07:49:16 +0300 Subject: [PATCH 4/5] Update generated GraphQLDataFetchers.java --- .../apis/gtfs/generated/GraphQLDataFetchers.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java b/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java index 559acac920d..6a2e398cd91 100644 --- a/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java +++ b/src/main/java/org/opentripplanner/apis/gtfs/generated/GraphQLDataFetchers.java @@ -380,6 +380,10 @@ public interface GraphQLFeed { public DataFetcher> alerts(); public DataFetcher feedId(); + + public DataFetcher publisherName(); + + public DataFetcher publisherUrl(); } public interface GraphQLGeometry { From 119927ea79af4a4ee511de71309da9d29a30f140 Mon Sep 17 00:00:00 2001 From: Vesa Meskanen Date: Wed, 8 May 2024 12:43:55 +0300 Subject: [PATCH 5/5] Add test for feedinfo query --- .../apis/gtfs/GraphQLIntegrationTest.java | 14 ++++++++++++++ .../apis/gtfs/expectations/feedinfo.json | 16 ++++++++++++++++ .../apis/gtfs/queries/feedinfo.graphql | 10 ++++++++++ 3 files changed, 40 insertions(+) create mode 100644 src/test/resources/org/opentripplanner/apis/gtfs/expectations/feedinfo.json create mode 100644 src/test/resources/org/opentripplanner/apis/gtfs/queries/feedinfo.graphql diff --git a/src/test/java/org/opentripplanner/apis/gtfs/GraphQLIntegrationTest.java b/src/test/java/org/opentripplanner/apis/gtfs/GraphQLIntegrationTest.java index fcc59af845f..614c8778c6b 100644 --- a/src/test/java/org/opentripplanner/apis/gtfs/GraphQLIntegrationTest.java +++ b/src/test/java/org/opentripplanner/apis/gtfs/GraphQLIntegrationTest.java @@ -43,6 +43,7 @@ import org.opentripplanner.framework.i18n.I18NString; import org.opentripplanner.framework.i18n.NonLocalizedString; import org.opentripplanner.framework.model.Grams; +import org.opentripplanner.model.FeedInfo; import org.opentripplanner.model.fare.FareMedium; import org.opentripplanner.model.fare.FareProduct; import org.opentripplanner.model.fare.ItineraryFares; @@ -84,6 +85,7 @@ import org.opentripplanner.transit.model.framework.FeedScopedId; import org.opentripplanner.transit.model.network.BikeAccess; import org.opentripplanner.transit.model.network.TripPattern; +import org.opentripplanner.transit.model.organization.Agency; import org.opentripplanner.transit.model.site.RegularStop; import org.opentripplanner.transit.model.site.StopLocation; import org.opentripplanner.transit.model.timetable.RealTimeTripTimes; @@ -151,6 +153,18 @@ static void setup() { transitModel.addTripPattern(id("pattern-1"), pattern); + var feedId = "testfeed"; + var feedInfo = FeedInfo.dummyForTest(feedId); + transitModel.addFeedInfo(feedInfo); + + var agency = Agency + .of(new FeedScopedId(feedId, "agency-xx")) + .withName("speedtransit") + .withUrl("www.otp-foo.bar") + .withTimezone("Europe/Berlin") + .build(); + transitModel.addAgency(agency); + transitModel.initTimeZone(ZoneIds.BERLIN); transitModel.index(); var routes = Arrays diff --git a/src/test/resources/org/opentripplanner/apis/gtfs/expectations/feedinfo.json b/src/test/resources/org/opentripplanner/apis/gtfs/expectations/feedinfo.json new file mode 100644 index 00000000000..a3dbe43b0f1 --- /dev/null +++ b/src/test/resources/org/opentripplanner/apis/gtfs/expectations/feedinfo.json @@ -0,0 +1,16 @@ +{ + "data" : { + "feeds" : [ + { + "agencies" : [ + { + "name" : "speedtransit", + "url" : "www.otp-foo.bar" + } + ], + "publisherUrl" : "www.z.org", + "publisherName" : "publisher" + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/org/opentripplanner/apis/gtfs/queries/feedinfo.graphql b/src/test/resources/org/opentripplanner/apis/gtfs/queries/feedinfo.graphql new file mode 100644 index 00000000000..f0737202786 --- /dev/null +++ b/src/test/resources/org/opentripplanner/apis/gtfs/queries/feedinfo.graphql @@ -0,0 +1,10 @@ +{ + feeds { + agencies { + name + url + } + publisherUrl + publisherName + } +} \ No newline at end of file