Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/dev-2.x' into otp2_java17
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesj committed Mar 17, 2022
2 parents d11eea9 + 6f02121 commit 97489ee
Show file tree
Hide file tree
Showing 62 changed files with 220 additions and 3,023 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/close_stale_pr_and_issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: 'Close Stale issues'

on:
schedule:
- cron: '30 7 * * *'
workflow_dispatch:

permissions:
issues: write

jobs:
stale:
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
id: stale
with:
stale-issue-message: 'This issue is stale because it has been open 90 days with no activity. Remove stale label or comment or this will be closed in 30 days'
days-before-stale: 90
days-before-close: 30
operations-per-run: 6
exempt-issue-labels: 'Roadmap'
ascending: true
56 changes: 8 additions & 48 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,53 +85,6 @@
<directory>src/ext-test/resources</directory>
</testResource>
</testResources>
<pluginManagement>
<plugins>
<!-- m2eclipse lifecycle mapping configuration. This controls which Maven build goals should
be performed during incremental builds within the Eclipse IDE. There are sensible defaults
for most plugins, but some others require manual configuration with <action><ignore /> or
<action><execute /> filters. This section only affects incremental builds within Eclipse,
not command-line Maven builds. That's why it's a pluginManagement without an accompanying plugin. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<versionRange>[1.0,)</versionRange>
<goals>
<goal>copy-dependencies</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore />
</action>
</pluginExecution>
<pluginExecution>
<pluginExecutionFilter>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
<versionRange>5.0.0</versionRange>
<goals>
<goal>revision</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down Expand Up @@ -160,7 +113,7 @@
<plugin>
<groupId>com.webcohesion.enunciate</groupId>
<artifactId>enunciate-maven-plugin</artifactId>
<version>2.12.0</version>
<version>2.13.3</version>
<executions>
<execution>
<!-- override default binding to process-sources phase (enunciate generates web services). -->
Expand Down Expand Up @@ -220,6 +173,13 @@
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.11.0</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@ public Response getGraphQL(

Locale locale = headers.getAcceptableLanguages().size() > 0
? headers.getAcceptableLanguages().get(0)
: router.defaultRoutingRequest.locale;
: router.getDefaultLocale();

String query = (String) queryParameters.get("query");
Object queryVariables = queryParameters.getOrDefault("variables", null);
String operationName = (String) queryParameters.getOrDefault("operationName", null);
Map<String, Object> variables;

if (queryVariables instanceof Map) {
variables = (Map) queryVariables;
}
Expand Down Expand Up @@ -115,7 +116,7 @@ public Response getGraphQL(
) {
Locale locale = headers.getAcceptableLanguages().size() > 0
? headers.getAcceptableLanguages().get(0)
: router.defaultRoutingRequest.locale;
: router.getDefaultLocale();
return LegacyGraphQLIndex.getGraphQLResponse(
query,
router,
Expand All @@ -138,7 +139,7 @@ public Response getGraphQLBatch(
List<Callable<ExecutionResult>> futures = new ArrayList<>();
Locale locale = headers.getAcceptableLanguages().size() > 0
? headers.getAcceptableLanguages().get(0)
: router.defaultRoutingRequest.locale;
: router.getDefaultLocale();

for (HashMap<String, Object> query : queries) {
Map<String, Object> variables;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ public DataFetcher<Object> viewer() {
public DataFetcher<DataFetcherResult<RoutingResponse>> plan() {
return environment -> {
LegacyGraphQLRequestContext context = environment.<LegacyGraphQLRequestContext>getContext();
RoutingRequest request = context.getRouter().defaultRoutingRequest.clone();
RoutingRequest request = context.getRouter().copyDefaultRoutingRequest();

CallerWithEnvironment callWith = new CallerWithEnvironment(environment);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicLong;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.time.DurationFormatUtils;
Expand Down Expand Up @@ -339,9 +340,18 @@ public void receiveMessage(PubsubMessage message, AckReplyConsumer consumer) {
getTimeSinceStartupString());
}

saveResultOnGraph.execute(graph -> {
snapshotSource.applyEstimatedTimetable(graph, feedId, false, estimatedTimetableDeliveries);
});
var f = saveResultOnGraph.execute(graph ->
snapshotSource.applyEstimatedTimetable(graph, feedId, false, estimatedTimetableDeliveries)
);

if (!isPrimed()) {
try {
f.get();
}
catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
}

// Ack only after all work for the message is complete.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,9 @@ public DataFetcherResult<PlanResponse> plan(DataFetchingEnvironment environment)
PlanResponse response = new PlanResponse();
TransmodelRequestContext ctx = environment.getContext();
Router router = ctx.getRouter();
Locale locale = router.defaultRoutingRequest.locale;
RoutingRequest request = null;
try {
request = createRequest(environment);
locale = request.locale;

RoutingResponse res = ctx.getRoutingService().route(request, router);

Expand All @@ -75,6 +73,7 @@ public DataFetcherResult<PlanResponse> plan(DataFetchingEnvironment environment)
response.plan = TripPlanMapper.mapTripPlan(request, List.of());
response.messages.add(new RoutingError(RoutingErrorCode.SYSTEM_ERROR, null));
}
Locale locale = request == null ? router.getDefaultLocale() : request.locale;
return DataFetcherResult.<PlanResponse>newResult()
.data(response)
.localContext(Map.of("locale", locale))
Expand All @@ -99,10 +98,11 @@ private GenericLocation toGenericLocation(Map<String, Object> m) {
}

private RoutingRequest createRequest(DataFetchingEnvironment environment)
throws ParameterException {
throws ParameterException
{
TransmodelRequestContext context = environment.getContext();
Router router = context.getRouter();
RoutingRequest request = router.defaultRoutingRequest.clone();
RoutingRequest request = router.copyDefaultRoutingRequest();

DataFetcherDecorator callWith = new DataFetcherDecorator(environment);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import graphql.Scalars;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLNonNull;
import graphql.schema.GraphQLObjectType;
import org.opentripplanner.routing.alertpatch.AlertUrl;

Expand All @@ -12,7 +13,7 @@ public static GraphQLObjectType create() {
.name("infoLink")
.field(GraphQLFieldDefinition.newFieldDefinition()
.name("uri")
.type(Scalars.GraphQLString)
.type(new GraphQLNonNull(Scalars.GraphQLString))
.description("URI")
.dataFetcher(environment -> {
AlertUrl source = environment.getSource();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import graphql.Scalars;
import graphql.schema.GraphQLFieldDefinition;
import graphql.schema.GraphQLNonNull;
import graphql.schema.GraphQLObjectType;

import java.util.Map;
Expand All @@ -16,13 +17,13 @@ public static GraphQLObjectType create() {
.field(GraphQLFieldDefinition
.newFieldDefinition()
.name("value")
.type(Scalars.GraphQLString)
.type(new GraphQLNonNull(Scalars.GraphQLString))
.dataFetcher(environment -> ((Map.Entry<String, String>) environment.getSource()).getValue())
.build())
.field(GraphQLFieldDefinition
.newFieldDefinition()
.name("language")
.type(Scalars.GraphQLString)
.type(new GraphQLNonNull(Scalars.GraphQLString))
.dataFetcher(environment -> ((Map.Entry<String, String>) environment.getSource()).getKey())
.build())
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public static GraphQLObjectType create(
.build())
.field(GraphQLFieldDefinition.newFieldDefinition()
.name("infoLinks")
.type(new GraphQLList(infoLinkType))
.type(new GraphQLList(new GraphQLNonNull(infoLinkType)))
.description("Optional links to more information.")
.dataFetcher(environment -> {
TransitAlert alert = environment.getSource();
Expand Down
26 changes: 8 additions & 18 deletions src/main/java/org/opentripplanner/api/common/Message.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.opentripplanner.api.common;

import org.opentripplanner.util.Properties;
import org.opentripplanner.util.ResourceBundleAdaptor;

import java.util.Locale;

Expand Down Expand Up @@ -31,40 +31,30 @@ public enum Message {
TRIANGLE_VALUES_NOT_SET(373),
;

private Properties config = getConfig();
private final ResourceBundleAdaptor config = new ResourceBundleAdaptor(Message.class);
private final int m_id;

/** enum constructors are private -- see values above */
private Message(int id) {
Message(int id) {
m_id = id;
}

public int getId() {
return m_id;
}

/** simple checker / getter of the config */
public Properties getConfig() {
if(config == null) {
config = new Properties(Message.class);
}
return config;
}

public String get(String def, Locale l) {
public String get(Locale l) {
try {
getConfig();
return config.get(name(), l);
}
catch(Exception e) {
Properties.LOG.warn("No entry in Message.properties file could be found for string " + name());
ResourceBundleAdaptor.LOG.warn("No entry in Message.properties file could be found for string " + name());
return "";
}
return def;
}
public String get(Locale l) {
return get("", l);
}

public String get() {
return get("", Locale.getDefault());
return get(Locale.getDefault());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ public abstract class RoutingResource {
*/
protected RoutingRequest buildRequest(MultivaluedMap<String, String> queryParameters) throws ParameterException {
Router router = otpServer.getRouter();
RoutingRequest request = router.defaultRoutingRequest.clone();
RoutingRequest request = router.copyDefaultRoutingRequest();

// The routing request should already contain defaults, which are set when it is initialized or in the JSON
// router configuration and cloned. We check whether each parameter was supplied before overwriting the default.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.opentripplanner.api.json;

import com.bedatadriven.jackson.datatype.jts.JtsModule;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.databind.ObjectMapper;

Expand Down Expand Up @@ -57,6 +58,7 @@ public JSONObjectMapperProvider() {
// and named, versioned reusable modules.
mapper = new ObjectMapper()
.registerModule(FeedScopedIdSerializer.makeModule())
.registerModule(new JtsModule())
.setSerializationInclusion(Include.NON_NULL); // skip null fields
}

Expand Down
12 changes: 4 additions & 8 deletions src/main/java/org/opentripplanner/api/model/ApiRouterInfo.java
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
package org.opentripplanner.api.model;

import com.bedatadriven.jackson.datatype.jts.serialization.GeometrySerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Geometry;
import org.opentripplanner.api.mapping.TraverseModeMapper;
import org.opentripplanner.routing.vehicle_rental.VehicleRentalStationService;
import org.opentripplanner.routing.graph.Graph;
import org.opentripplanner.routing.vehicle_parking.VehicleParkingService;
import org.opentripplanner.routing.vehicle_rental.VehicleRentalStationService;
import org.opentripplanner.util.TravelOption;
import org.opentripplanner.util.TravelOptionsMaker;
import org.opentripplanner.util.WorldEnvelope;

import java.util.Date;
import java.util.List;
import java.util.Optional;

public class ApiRouterInfo {

public String routerId;

@JsonSerialize(using= GeometrySerializer.class)
public Geometry polygon;

public Date buildTime;
Expand Down
Loading

0 comments on commit 97489ee

Please sign in to comment.