Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev-2.x' into upstream-merge-2…
Browse files Browse the repository at this point in the history
…024-11-13
  • Loading branch information
leonardehrenfried committed Nov 13, 2024
2 parents 08f3833 + 3d633b9 commit a1df3a2
Show file tree
Hide file tree
Showing 62 changed files with 2,345 additions and 1,166 deletions.
4 changes: 2 additions & 2 deletions application/src/client/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
<link rel="icon" type="image/svg+xml" href="/img/otp-logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>OTP Debug Client</title>
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/11/2024-11-04T12:49/assets/index-DPdUtdaa.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/11/2024-11-04T12:49/assets/index-CaBThmWm.css">
<script type="module" crossorigin src="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/11/2024-11-12T14:16/assets/index-D5yznI0k.js"></script>
<link rel="stylesheet" crossorigin href="https://cdn.jsdelivr.net/gh/opentripplanner/debug-client-assets@main/2024/11/2024-11-12T14:16/assets/index-CaBThmWm.css">
</head>
<body>
<div id="root"></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.opentripplanner.apis.gtfs.model.StopOnRouteModel;
import org.opentripplanner.apis.gtfs.model.StopOnTripModel;
import org.opentripplanner.apis.gtfs.model.UnknownModel;
import org.opentripplanner.framework.graphql.GraphQLUtils;
import org.opentripplanner.framework.i18n.I18NString;
import org.opentripplanner.framework.i18n.TranslatedString;
import org.opentripplanner.routing.alertpatch.EntitySelector;
Expand Down Expand Up @@ -65,11 +66,11 @@ public DataFetcher<GraphQLTypes.GraphQLAlertCauseType> alertCause() {
public DataFetcher<String> alertDescriptionText() {
return environment -> {
var alert = getSource(environment);
return alert
.descriptionText()
.or(alert::headerText)
.map(t -> t.toString(environment.getLocale()))
.orElse(FALLBACK_EMPTY_STRING);
var descriptionText = GraphQLUtils.getTranslation(
alert.descriptionText().or(alert::headerText).orElse(null),
environment
);
return descriptionText != null ? descriptionText : FALLBACK_EMPTY_STRING;
};
}

Expand Down Expand Up @@ -103,11 +104,11 @@ public DataFetcher<Integer> alertHash() {
public DataFetcher<String> alertHeaderText() {
return environment -> {
var alert = getSource(environment);
return alert
.headerText()
.or(alert::descriptionText)
.map(h -> h.toString(environment.getLocale()))
.orElse(FALLBACK_EMPTY_STRING);
var headerText = GraphQLUtils.getTranslation(
alert.headerText().or(alert::descriptionText).orElse(null),
environment
);
return headerText != null ? headerText : FALLBACK_EMPTY_STRING;
};
}

Expand All @@ -125,7 +126,7 @@ public DataFetcher<GraphQLAlertSeverityLevelType> alertSeverityLevel() {
@Override
public DataFetcher<String> alertUrl() {
return environment ->
getSource(environment).url().map(u -> u.toString(environment.getLocale())).orElse(null);
GraphQLUtils.getTranslation(getSource(environment).url().orElse(null), environment);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public DataFetcher<Integer> stopPosition() {
return environment -> getSource(environment).getGtfsSequence();
}

@Override
public DataFetcher<Integer> stopPositionInPattern() {
return environment -> getSource(environment).getStopIndex();
}

@Override
public DataFetcher<Long> serviceDay() {
return environment -> getSource(environment).getServiceDayMidnight();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1095,6 +1095,8 @@ public interface GraphQLStoptime {

public DataFetcher<Integer> stopPosition();

public DataFetcher<Integer> stopPositionInPattern();

public DataFetcher<Boolean> timepoint();

public DataFetcher<Trip> trip();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,63 @@ public enum GraphQLAgencyAlertType {
ROUTE_TYPES,
}

public static class GraphQLAlertAlertDescriptionTextArgs {

private String language;

public GraphQLAlertAlertDescriptionTextArgs(Map<String, Object> args) {
if (args != null) {
this.language = (String) args.get("language");
}
}

public String getGraphQLLanguage() {
return this.language;
}

public void setGraphQLLanguage(String language) {
this.language = language;
}
}

public static class GraphQLAlertAlertHeaderTextArgs {

private String language;

public GraphQLAlertAlertHeaderTextArgs(Map<String, Object> args) {
if (args != null) {
this.language = (String) args.get("language");
}
}

public String getGraphQLLanguage() {
return this.language;
}

public void setGraphQLLanguage(String language) {
this.language = language;
}
}

public static class GraphQLAlertAlertUrlArgs {

private String language;

public GraphQLAlertAlertUrlArgs(Map<String, Object> args) {
if (args != null) {
this.language = (String) args.get("language");
}
}

public String getGraphQLLanguage() {
return this.language;
}

public void setGraphQLLanguage(String language) {
this.language = language;
}
}

/** Cause of a alert */
public enum GraphQLAlertCauseType {
ACCIDENT,
Expand Down Expand Up @@ -1815,6 +1872,35 @@ public void setGraphQLTransitOnly(Boolean transitOnly) {
}
}

public static class GraphQLPlanPassThroughViaLocationInput {

private String label;
private List<String> stopLocationIds;

public GraphQLPlanPassThroughViaLocationInput(Map<String, Object> args) {
if (args != null) {
this.label = (String) args.get("label");
this.stopLocationIds = (List<String>) args.get("stopLocationIds");
}
}

public String getGraphQLLabel() {
return this.label;
}

public List<String> getGraphQLStopLocationIds() {
return this.stopLocationIds;
}

public void setGraphQLLabel(String label) {
this.label = label;
}

public void setGraphQLStopLocationIds(List<String> stopLocationIds) {
this.stopLocationIds = stopLocationIds;
}
}

public static class GraphQLPlanPreferencesInput {

private GraphQLAccessibilityPreferencesInput accessibility;
Expand Down Expand Up @@ -2048,6 +2134,75 @@ public void setGraphQLTransit(List<GraphQLPlanTransitModePreferenceInput> transi
}
}

public static class GraphQLPlanViaLocationInput {

private GraphQLPlanPassThroughViaLocationInput passThrough;
private GraphQLPlanVisitViaLocationInput visit;

public GraphQLPlanViaLocationInput(Map<String, Object> args) {
if (args != null) {
this.passThrough =
new GraphQLPlanPassThroughViaLocationInput((Map<String, Object>) args.get("passThrough"));
this.visit = new GraphQLPlanVisitViaLocationInput((Map<String, Object>) args.get("visit"));
}
}

public GraphQLPlanPassThroughViaLocationInput getGraphQLPassThrough() {
return this.passThrough;
}

public GraphQLPlanVisitViaLocationInput getGraphQLVisit() {
return this.visit;
}

public void setGraphQLPassThrough(GraphQLPlanPassThroughViaLocationInput passThrough) {
this.passThrough = passThrough;
}

public void setGraphQLVisit(GraphQLPlanVisitViaLocationInput visit) {
this.visit = visit;
}
}

public static class GraphQLPlanVisitViaLocationInput {

private String label;
private java.time.Duration minimumWaitTime;
private List<String> stopLocationIds;

public GraphQLPlanVisitViaLocationInput(Map<String, Object> args) {
if (args != null) {
this.label = (String) args.get("label");
this.minimumWaitTime = (java.time.Duration) args.get("minimumWaitTime");
this.stopLocationIds = (List<String>) args.get("stopLocationIds");
}
}

public String getGraphQLLabel() {
return this.label;
}

public java.time.Duration getGraphQLMinimumWaitTime() {
return this.minimumWaitTime;
}

public List<String> getGraphQLStopLocationIds() {
return this.stopLocationIds;
}

public void setGraphQLLabel(String label) {
this.label = label;
}

public void setGraphQLMinimumWaitTime(java.time.Duration minimumWaitTime) {
this.minimumWaitTime = minimumWaitTime;
}

public void setGraphQLStopLocationIds(List<String> stopLocationIds) {
this.stopLocationIds = stopLocationIds;
}
}

public enum GraphQLPropulsionType {
COMBUSTION,
COMBUSTION_DIESEL,
Expand Down Expand Up @@ -2745,6 +2900,7 @@ public static class GraphQLQueryTypePlanArgs {
private List<GraphQLTransportModeInput> transportModes;
private GraphQLInputTriangleInput triangle;
private GraphQLInputUnpreferredInput unpreferred;
private List<GraphQLPlanViaLocationInput> via;
private Double waitAtBeginningFactor;
private Double waitReluctance;
private Integer walkBoardCost;
Expand Down Expand Up @@ -2826,6 +2982,9 @@ public GraphQLQueryTypePlanArgs(Map<String, Object> args) {
this.triangle = new GraphQLInputTriangleInput((Map<String, Object>) args.get("triangle"));
this.unpreferred =
new GraphQLInputUnpreferredInput((Map<String, Object>) args.get("unpreferred"));
if (args.get("via") != null) {
this.via = (List<GraphQLPlanViaLocationInput>) args.get("via");
}
this.waitAtBeginningFactor = (Double) args.get("waitAtBeginningFactor");
this.waitReluctance = (Double) args.get("waitReluctance");
this.walkBoardCost = (Integer) args.get("walkBoardCost");
Expand Down Expand Up @@ -3057,6 +3216,10 @@ public GraphQLInputUnpreferredInput getGraphQLUnpreferred() {
return this.unpreferred;
}

public List<GraphQLPlanViaLocationInput> getGraphQLVia() {
return this.via;
}

public Double getGraphQLWaitAtBeginningFactor() {
return this.waitAtBeginningFactor;
}
Expand Down Expand Up @@ -3315,6 +3478,10 @@ public void setGraphQLUnpreferred(GraphQLInputUnpreferredInput unpreferred) {
this.unpreferred = unpreferred;
}

public void setGraphQLVia(List<GraphQLPlanViaLocationInput> via) {
this.via = via;
}

public void setGraphQLWaitAtBeginningFactor(Double waitAtBeginningFactor) {
this.waitAtBeginningFactor = waitAtBeginningFactor;
}
Expand Down Expand Up @@ -3362,6 +3529,7 @@ public static class GraphQLQueryTypePlanConnectionArgs {
private GraphQLPlanLabeledLocationInput origin;
private GraphQLPlanPreferencesInput preferences;
private java.time.Duration searchWindow;
private List<GraphQLPlanViaLocationInput> via;

public GraphQLQueryTypePlanConnectionArgs(Map<String, Object> args) {
if (args != null) {
Expand All @@ -3380,6 +3548,9 @@ public GraphQLQueryTypePlanConnectionArgs(Map<String, Object> args) {
this.preferences =
new GraphQLPlanPreferencesInput((Map<String, Object>) args.get("preferences"));
this.searchWindow = (java.time.Duration) args.get("searchWindow");
if (args.get("via") != null) {
this.via = (List<GraphQLPlanViaLocationInput>) args.get("via");
}
}
}

Expand Down Expand Up @@ -3431,6 +3602,10 @@ public java.time.Duration getGraphQLSearchWindow() {
return this.searchWindow;
}

public List<GraphQLPlanViaLocationInput> getGraphQLVia() {
return this.via;
}

public void setGraphQLAfter(String after) {
this.after = after;
}
Expand Down Expand Up @@ -3478,6 +3653,10 @@ public void setGraphQLPreferences(GraphQLPlanPreferencesInput preferences) {
public void setGraphQLSearchWindow(java.time.Duration searchWindow) {
this.searchWindow = searchWindow;
}

public void setGraphQLVia(List<GraphQLPlanViaLocationInput> via) {
this.via = via;
}
}

public static class GraphQLQueryTypeRentalVehicleArgs {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public static RouteRequest toRouteRequest(
callWith.argument("from", (Map<String, Object> v) -> request.setFrom(toGenericLocation(v)));
callWith.argument("to", (Map<String, Object> v) -> request.setTo(toGenericLocation(v)));

mapViaLocations(request, environment);

request.setDateTime(
environment.getArgument("date"),
environment.getArgument("time"),
Expand Down Expand Up @@ -255,6 +257,12 @@ public static RouteRequest toRouteRequest(
return request;
}

static void mapViaLocations(RouteRequest request, DataFetchingEnvironment env) {
var args = env.getArgument("via");
var locs = ViaLocationMapper.mapToViaLocations((List<Map<String, Map<String, Object>>>) args);
request.setViaLocations(locs);
}

private static <T> boolean hasArgument(Map<String, T> m, String name) {
return m.containsKey(name) && m.get(name) != null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

import graphql.schema.DataFetchingEnvironment;
import java.time.Instant;
import java.util.List;
import java.util.Map;
import org.opentripplanner.apis.gtfs.GraphQLRequestContext;
import org.opentripplanner.apis.gtfs.generated.GraphQLTypes;
import org.opentripplanner.framework.graphql.GraphQLUtils;
Expand Down Expand Up @@ -63,6 +65,8 @@ public static RouteRequest toRouteRequest(

setModes(request.journey(), args.getGraphQLModes(), environment);

// sadly we need to use the raw collection because it is cast to the wrong type
mapViaPoints(request, environment.getArgument("via"));
return request;
}

Expand Down Expand Up @@ -178,4 +182,8 @@ private static GenericLocation parseGenericLocation(
coordinate.getGraphQLLongitude()
);
}

static void mapViaPoints(RouteRequest request, List<Map<String, Map<String, Object>>> via) {
request.setViaLocations(ViaLocationMapper.mapToViaLocations(via));
}
}
Loading

0 comments on commit a1df3a2

Please sign in to comment.