Skip to content

Commit 5469209

Browse files
Ivan AladjoffIvan Aladjoff
authored andcommitted
moved validity times to transitInfo
1 parent c44740b commit 5469209

File tree

4 files changed

+52
-26
lines changed

4 files changed

+52
-26
lines changed

application/src/main/java/org/opentripplanner/apis/transmodel/TransmodelGraphQLSchemaFactory.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
import org.opentripplanner.apis.transmodel.model.framework.ServerInfoType;
6767
import org.opentripplanner.apis.transmodel.model.framework.StreetModeDurationInputType;
6868
import org.opentripplanner.apis.transmodel.model.framework.SystemNoticeType;
69+
import org.opentripplanner.apis.transmodel.model.framework.TransitInfoType;
6970
import org.opentripplanner.apis.transmodel.model.framework.TransmodelDirectives;
7071
import org.opentripplanner.apis.transmodel.model.framework.TransmodelScalars;
7172
import org.opentripplanner.apis.transmodel.model.framework.ValidityPeriodType;
@@ -219,6 +220,7 @@ private GraphQLSchema createDefault() {
219220
GraphQLOutputType systemNoticeType = SystemNoticeType.create();
220221
GraphQLOutputType linkGeometryType = PointsOnLinkType.create();
221222
GraphQLOutputType serverInfoType = ServerInfoType.create();
223+
GraphQLOutputType transitInfoType = TransitInfoType.create(validityPeriodType);
222224
GraphQLOutputType authorityType = authorityTypeFactory.create(
223225
LineType.REF,
224226
PtSituationElementType.REF
@@ -1533,6 +1535,14 @@ private GraphQLSchema createDefault() {
15331535
.dataFetcher(e -> projectInfo())
15341536
.build()
15351537
)
1538+
.field(
1539+
GraphQLFieldDefinition.newFieldDefinition()
1540+
.name("transitInfo")
1541+
.description("Get information about the transit data available in the system.")
1542+
.type(new GraphQLNonNull(transitInfoType))
1543+
.dataFetcher(e -> new Object())
1544+
.build()
1545+
)
15361546
.field(datedServiceJourneyQueryFactory.createGetById(datedServiceJourneyType))
15371547
.field(datedServiceJourneyQueryFactory.createQuery(datedServiceJourneyType))
15381548
.build();

application/src/main/java/org/opentripplanner/apis/transmodel/model/framework/ServerInfoType.java

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -119,28 +119,6 @@ public static GraphQLOutputType create() {
119119
.dataFetcher(e -> Runtime.getRuntime().availableProcessors())
120120
.build()
121121
)
122-
.field(
123-
GraphQLFieldDefinition.newFieldDefinition()
124-
.name("transitServiceValidityEnd")
125-
.description("End date of the transit data validity period")
126-
.type(TransmodelScalars.DATE_SCALAR)
127-
.dataFetcher(e -> {
128-
var zonedDateTime = GqlUtil.getTransitService(e).getTransitServiceEnds();
129-
return zonedDateTime != null ? zonedDateTime.toLocalDate() : null;
130-
})
131-
.build()
132-
)
133-
.field(
134-
GraphQLFieldDefinition.newFieldDefinition()
135-
.name("transitServiceValidityStart")
136-
.description("Start date of the transit data validity period")
137-
.type(TransmodelScalars.DATE_SCALAR)
138-
.dataFetcher(e -> {
139-
var zonedDateTime = GqlUtil.getTransitService(e).getTransitServiceStarts();
140-
return zonedDateTime != null ? zonedDateTime.toLocalDate() : null;
141-
})
142-
.build()
143-
)
144122
.build();
145123
}
146124
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package org.opentripplanner.apis.transmodel.model.framework;
2+
3+
import graphql.schema.GraphQLFieldDefinition;
4+
import graphql.schema.GraphQLObjectType;
5+
import graphql.schema.GraphQLOutputType;
6+
import org.opentripplanner.apis.transmodel.model.siri.sx.ValidityPeriod;
7+
import org.opentripplanner.apis.transmodel.support.GqlUtil;
8+
9+
public class TransitInfoType {
10+
11+
public static GraphQLOutputType create(GraphQLObjectType validityPeriodType) {
12+
return GraphQLObjectType.newObject()
13+
.name("TransitInfo")
14+
.description("Information about the transit data available in the system.")
15+
.field(
16+
GraphQLFieldDefinition.newFieldDefinition()
17+
.name("validityPeriod")
18+
.description("The validity period for the transit data currently loaded in the system.")
19+
.type(validityPeriodType)
20+
.dataFetcher(environment -> {
21+
var transitService = GqlUtil.getTransitService(environment);
22+
var startTime = transitService.getTransitServiceStarts();
23+
var endTime = transitService.getTransitServiceEnds();
24+
25+
Long startMillis = startTime != null ? startTime.toInstant().toEpochMilli() : null;
26+
Long endMillis = endTime != null ? endTime.toInstant().toEpochMilli() : null;
27+
28+
return new ValidityPeriod(startMillis, endMillis);
29+
})
30+
.build()
31+
)
32+
.build();
33+
}
34+
}

application/src/main/resources/org/opentripplanner/apis/transmodel/schema.graphql

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -808,6 +808,8 @@ type QueryType {
808808
"MultiModalMode for query. To control whether multi modal parent stop places, their mono modal children or both are included in the response. Does not affect mono modal stop places that do not belong to a multi modal stop place."
809809
multiModalMode: MultiModalMode = parent
810810
): [StopPlace]! @timingData
811+
"Get information about the transit data available in the system."
812+
transitInfo: TransitInfo!
811813
"Input type for executing a travel search for a trip between two locations. Returns trip patterns describing suggested alternatives for the trip."
812814
trip(
813815
"Time and cost penalty on access/egress modes."
@@ -1186,10 +1188,6 @@ type ServerInfo {
11861188
otpSerializationVersionId: String
11871189
"The 'configVersion' of the router-config.json file."
11881190
routerConfigVersion: String
1189-
"End date of the transit data validity period"
1190-
transitServiceValidityEnd: Date
1191-
"Start date of the transit data validity period"
1192-
transitServiceValidityStart: Date
11931191
"Maven version"
11941192
version: String
11951193
}
@@ -1382,6 +1380,12 @@ type TimetabledPassingTime {
13821380
timingPoint: Boolean!
13831381
}
13841382

1383+
"Information about the transit data available in the system."
1384+
type TransitInfo {
1385+
"The validity period for the transit data currently loaded in the system."
1386+
validityPeriod: ValidityPeriod
1387+
}
1388+
13851389
"Used to specify board and alight slack for a given modes."
13861390
type TransportModeSlackType {
13871391
modes: [TransportMode!]!

0 commit comments

Comments
 (0)