Skip to content

Commit

Permalink
Merge branch 'dev-2.x' into fix-departureArrivalStopTime-npe
Browse files Browse the repository at this point in the history
  • Loading branch information
miklcct committed Nov 14, 2024
2 parents d3d283f + da95e7a commit a7dc78e
Show file tree
Hide file tree
Showing 500 changed files with 6,244 additions and 1,583 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/cibuild.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ on:
- master
- dev-1.x
- dev-2.x
env:
# Since version 3.9.0 of Maven it will automatically understand this environment variable.
# However, as of 2024-11 the latest versions of Ubuntu and Debian were on 3.8.8 so it will take some
# time until we can remove the $MAVEN_ARGS below.
MAVEN_ARGS: "--no-transfer-progress -Dstyle.color=always"

jobs:
build-linux:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -46,22 +52,29 @@ jobs:
# https://github.com/actions/runner-images/issues/1499
# we set nodePath and npmPath to skip downloading the node binary, which frequently times out
run: |
mvn --batch-mode jacoco:prepare-agent test jacoco:report -P prettierCheck -Dprettier.nodePath=node -Dprettier.npmPath=npm
mvn --batch-mode package -Dmaven.test.skip -P prettierSkip
mvn $MAVEN_ARGS jacoco:prepare-agent test jacoco:report -P prettierCheck -Dprettier.nodePath=node -Dprettier.npmPath=npm
mvn $MAVEN_ARGS package -Dmaven.test.skip -P prettierSkip
- name: Send coverage data to codecov.io
if: github.repository_owner == 'opentripplanner'
uses: codecov/codecov-action@v4
with:
files: target/site/jacoco/jacoco.xml
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true

- name: Upload test results to Codecov
# always upload test results, even when failed
if: ${{ !cancelled() }}
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: "*TEST-*.xml"

- name: Deploy to Github Package Registry
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev-1.x' || github.ref == 'refs/heads/dev-2.x')
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: mvn --batch-mode deploy --settings maven-settings.xml -DskipTests -DGITHUB_REPOSITORY=$GITHUB_REPOSITORY -P prettierSkip -P deployGitHub
run: mvn $MAVEN_ARGS deploy --settings maven-settings.xml -DskipTests -DGITHUB_REPOSITORY=$GITHUB_REPOSITORY -P prettierSkip -P deployGitHub

build-windows:
timeout-minutes: 20
Expand All @@ -79,7 +92,7 @@ jobs:
- name: Configure Windows Pagefile
uses: al-cheb/[email protected]
- name: Run tests
run: mvn --batch-mode test -P prettierSkip
run: mvn $MAVEN_ARGS test -P prettierSkip

docs:
if: github.repository_owner == 'opentripplanner'
Expand Down Expand Up @@ -192,7 +205,7 @@ jobs:
distribution: temurin
cache: maven
- name: Compile Java code
run: mvn --batch-mode compile -DskipTests -P prettierSkip
run: mvn $MAVEN_ARGS compile -DskipTests -P prettierSkip

container-image:
if: github.repository_owner == 'opentripplanner' && github.event_name == 'push' && (github.ref == 'refs/heads/dev-2.x' || github.ref == 'refs/heads/master')
Expand Down Expand Up @@ -237,4 +250,4 @@ jobs:
MAVEN_SKIP_ARGS="-P prettierSkip -Dmaven.test.skip=true -Dmaven.source.skip=true"
mvn --batch-mode $MAVEN_SKIP_ARGS package com.google.cloud.tools:jib-maven-plugin:build -Djib.to.tags=latest,$image_version
mvn $MAVEN_ARGS $MAVEN_SKIP_ARGS package com.google.cloud.tools:jib-maven-plugin:build -Djib.to.tags=latest,$image_version
5 changes: 5 additions & 0 deletions application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
<artifactId>otp-utils</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>otp-raptor</artifactId>
<version>${project.version}</version>
</dependency>

<!-- 3rd party dependencies -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ void carHail() {
@Test
void carHailWithTransit() {
var modeSet = new QualifiedModeSet("CAR_HAIL,BUS,RAIL");
assertEquals(Set.of(COACH, BUS, RAIL), Set.copyOf(modeSet.getTransitModes()));
assertEquals(Set.of(BUS, RAIL), Set.copyOf(modeSet.getTransitModes()));

assertEquals(WALK, modeSet.getRequestModes().directMode);
assertEquals(CAR_HAILING, modeSet.getRequestModes().accessMode);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.opentripplanner.ext.sorlandsbanen;

import org.opentripplanner.raptor.api.model.RaptorAccessEgress;
import org.opentripplanner.raptor.api.model.RaptorCostConverter;
import org.opentripplanner.raptor.api.model.RaptorTransferConstraint;
import org.opentripplanner.raptor.spi.RaptorCostCalculator;
import org.opentripplanner.routing.algorithm.raptoradapter.transit.TripSchedule;
import org.opentripplanner.routing.algorithm.raptoradapter.transit.cost.RaptorCostConverter;
import org.opentripplanner.transit.model.basic.TransitMode;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ public enum ApiRequestMode {
TRAM(TransitMode.TRAM),
SUBWAY(TransitMode.SUBWAY),
RAIL(TransitMode.RAIL),
BUS(TransitMode.BUS, TransitMode.COACH),
BUS(TransitMode.BUS),
COACH(TransitMode.COACH),
FERRY(TransitMode.FERRY),
CABLE_CAR(TransitMode.CABLE_CAR),
GONDOLA(TransitMode.GONDOLA),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import org.opentripplanner.routing.graphfinder.PatternAtStop;
import org.opentripplanner.routing.graphfinder.PlaceAtDistance;
import org.opentripplanner.routing.graphfinder.PlaceType;
import org.opentripplanner.routing.services.TransitAlertService;
import org.opentripplanner.routing.vehicle_parking.VehicleParking;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingService;
import org.opentripplanner.service.vehiclerental.VehicleRentalService;
Expand Down Expand Up @@ -394,7 +395,7 @@ public DataFetcher<Object> node() {
case "Agency":
return transitService.getAgencyForId(FeedScopedId.parse(id));
case "Alert":
return null; //TODO
return transitService.getTransitAlertService().getAlertById(FeedScopedId.parse(id));
case "BikePark":
var bikeParkId = FeedScopedId.parse(id);
return vehicleParkingService == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1815,6 +1815,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 +2077,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 +2843,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 +2925,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 +3159,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 +3421,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 +3472,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 +3491,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 +3545,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 +3596,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 a7dc78e

Please sign in to comment.