Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't expose mutable tripOnServiceDates in TransitModel #5842

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/java/org/opentripplanner/netex/NetexModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void buildGraph() {
);
transitBuilder.limitServiceDays(transitPeriodLimit);
for (var tripOnServiceDate : transitBuilder.getTripOnServiceDates().values()) {
transitModel.getTripOnServiceDates().put(tripOnServiceDate.getId(), tripOnServiceDate);
transitModel.addTripOnServiceDate(tripOnServiceDate.getId(), tripOnServiceDate);
}
calendarServiceData.add(transitBuilder.buildCalendarServiceData());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,9 @@ public TripPattern getTripPatternForId(FeedScopedId id) {
return tripPatternForId.get(id);
}

public Map<FeedScopedId, TripOnServiceDate> getTripOnServiceDates() {
return tripOnServiceDates;
public void addTripOnServiceDate(FeedScopedId id, TripOnServiceDate tripOnServiceDate) {
invalidateIndex();
tripOnServiceDates.put(id, tripOnServiceDate);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,16 +87,14 @@ static void buildTransitService() {
calendarServiceData.putServiceDatesForServiceId(tripPattern.getId(), List.of(SERVICE_DATE));
transitModel.updateCalendarServiceData(true, calendarServiceData, DataImportIssueStore.NOOP);

transitModel
.getTripOnServiceDates()
.put(
TRIP_ON_SERVICE_DATE_ID,
TripOnServiceDate
.of(TRIP_ON_SERVICE_DATE_ID)
.withTrip(trip)
.withServiceDate(SERVICE_DATE)
.build()
);
transitModel.addTripOnServiceDate(
TRIP_ON_SERVICE_DATE_ID,
TripOnServiceDate
.of(TRIP_ON_SERVICE_DATE_ID)
.withTrip(trip)
.withServiceDate(SERVICE_DATE)
.build()
);

transitModel.index();

Expand Down
Loading