Skip to content

Commit

Permalink
Merge branch 'publisher-query' into dev-2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
vesameskanen committed May 8, 2024
2 parents e3dbb5e + 119927e commit 91c8396
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@ public DataFetcher<String> feedId() {
return this::getSource;
}

@Override
public DataFetcher<String> publisherName() {
return environment -> {
String id = getSource(environment);
return getTransitService(environment).getFeedInfo(id).getPublisherName();
};
}

@Override
public DataFetcher<String> publisherUrl() {
return environment -> {
String id = getSource(environment);
return getTransitService(environment).getFeedInfo(id).getPublisherUrl();
};
}

private List<Agency> getAgencies(DataFetchingEnvironment environment) {
String id = getSource(environment);
return getTransitService(environment)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ public interface GraphQLFeed {
public DataFetcher<Iterable<TransitAlert>> alerts();

public DataFetcher<String> feedId();

public DataFetcher<String> publisherName();

public DataFetcher<String> publisherUrl();
}

public interface GraphQLGeometry {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1174,6 +1174,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.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"data" : {
"feeds" : [
{
"agencies" : [
{
"name" : "speedtransit",
"url" : "www.otp-foo.bar"
}
],
"publisherUrl" : "www.z.org",
"publisherName" : "publisher"
}
]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
feeds {
agencies {
name
url
}
publisherUrl
publisherName
}
}

0 comments on commit 91c8396

Please sign in to comment.