Skip to content

Commit

Permalink
Separate code into method
Browse files Browse the repository at this point in the history
  • Loading branch information
habrahamsson-skanetrafiken committed Dec 18, 2023
1 parent f2241c9 commit 2c86a46
Showing 1 changed file with 25 additions and 26 deletions.
51 changes: 25 additions & 26 deletions src/main/java/org/opentripplanner/netex/mapping/NetexMapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -463,35 +463,34 @@ private void mapTripPatterns(Map<String, FeedScopedId> serviceIds) {
.localValues()) {
tripPatternMapper
.mapTripPattern(journeyPattern)
.ifPresent(result -> {
var journeyPatternExists = transitBuilder
.getTripPatterns()
.get(result.tripPattern().getStopPattern())
.stream()
.anyMatch(tripPattern -> result.tripPattern().getId().equals(tripPattern.getId()));
if (journeyPatternExists) {
issueStore.add(
"DuplicateJourneyPattern",
"Duplicate of JourneyPattern %s found",
journeyPattern.getId()
);
}
.ifPresent(this::applyTripPatternMapperResult);
}
}

for (Map.Entry<Trip, List<StopTime>> it : result.tripStopTimes().entrySet()) {
transitBuilder.getStopTimesSortedByTrip().put(it.getKey(), it.getValue());
transitBuilder.getTripsById().add(it.getKey());
}
private void applyTripPatternMapperResult(TripPatternMapperResult result) {
var stopPattern = result.tripPattern().getStopPattern();
var journeyPatternExists = transitBuilder
.getTripPatterns()
.get(stopPattern)
.stream()
.anyMatch(tripPattern -> result.tripPattern().getId().equals(tripPattern.getId()));
if (journeyPatternExists) {
issueStore.add(
"DuplicateJourneyPattern",
"Duplicate of JourneyPattern %s found",
result.tripPattern().getId().getId()
);
}

transitBuilder
.getTripPatterns()
.put(result.tripPattern().getStopPattern(), result.tripPattern());
currentMapperIndexes.addStopTimesByNetexId(result.stopTimeByNetexId());
groupMapper.scheduledStopPointsIndex.putAll(
Multimaps.asMap(result.scheduledStopPointsIndex())
);
transitBuilder.getTripOnServiceDates().addAll(result.tripOnServiceDates());
});
for (Map.Entry<Trip, List<StopTime>> it : result.tripStopTimes().entrySet()) {
transitBuilder.getStopTimesSortedByTrip().put(it.getKey(), it.getValue());
transitBuilder.getTripsById().add(it.getKey());
}

transitBuilder.getTripPatterns().put(stopPattern, result.tripPattern());
currentMapperIndexes.addStopTimesByNetexId(result.stopTimeByNetexId());
groupMapper.scheduledStopPointsIndex.putAll(Multimaps.asMap(result.scheduledStopPointsIndex()));
transitBuilder.getTripOnServiceDates().addAll(result.tripOnServiceDates());
}

private void mapNoticeAssignments() {
Expand Down

0 comments on commit 2c86a46

Please sign in to comment.