org.opentripplanner.ext.legacygraphqlapi.datafetchers.LegacyGraphQLAgencyImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of otp Show documentation
Show all versions of otp Show documentation
The OpenTripPlanner multimodal journey planning system
package org.opentripplanner.ext.legacygraphqlapi.datafetchers;
import graphql.relay.Relay;
import graphql.schema.DataFetcher;
import graphql.schema.DataFetchingEnvironment;
import org.opentripplanner.ext.legacygraphqlapi.LegacyGraphQLRequestContext;
import org.opentripplanner.ext.legacygraphqlapi.generated.LegacyGraphQLDataFetchers;
import org.opentripplanner.model.Agency;
import org.opentripplanner.model.Route;
import org.opentripplanner.routing.RoutingService;
import org.opentripplanner.routing.alertpatch.TransitAlert;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
public class LegacyGraphQLAgencyImpl implements LegacyGraphQLDataFetchers.LegacyGraphQLAgency {
@Override
public DataFetcher id() {
return environment -> new Relay.ResolvedGlobalId("Agency",
getSource(environment).getId().toString()
);
}
@Override
public DataFetcher gtfsId() {
return environment -> getSource(environment).getId().toString();
}
@Override
public DataFetcher name() {
return environment -> getSource(environment).getName();
}
@Override
public DataFetcher url() {
return environment -> getSource(environment).getUrl();
}
@Override
public DataFetcher timezone() {
return environment -> getSource(environment).getTimezone();
}
@Override
public DataFetcher lang() {
return environment -> getSource(environment).getLang();
}
@Override
public DataFetcher phone() {
return environment -> getSource(environment).getPhone();
}
@Override
public DataFetcher fareUrl() {
return environment -> getSource(environment).getFareUrl();
}
@Override
public DataFetcher> routes() {
return environment -> getRoutingService(environment)
.getAllRoutes()
.stream()
.filter(route -> route.getAgency().equals(getSource(environment)))
.collect(Collectors.toList());
}
@Override
//TODO
public DataFetcher> alerts() {
return environment -> List.of();
}
private RoutingService getRoutingService(DataFetchingEnvironment environment) {
return environment.getContext().getRoutingService();
}
private Agency getSource(DataFetchingEnvironment environment) {
return environment.getSource();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy