Skip to content

Commit

Permalink
refactor(Addressed unused params and methods. Updated Swagger docs.):
Browse files Browse the repository at this point in the history
  • Loading branch information
br648 committed Dec 9, 2024
1 parent 75f44c8 commit 926f994
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.opentripplanner.middleware.tripmonitor.jobs;

import com.mongodb.lang.Nullable;
import org.opentripplanner.middleware.i18n.Message;
import org.opentripplanner.middleware.models.ItineraryExistence;
import org.opentripplanner.middleware.models.MonitoredTrip;
Expand All @@ -27,6 +26,7 @@
import org.slf4j.LoggerFactory;
import org.slf4j.MDC;

import javax.annotation.Nullable;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
Expand Down Expand Up @@ -261,26 +261,6 @@ public void processLegTransition(List<NotificationType> legTransitionTypes , Tra
sendNotifications();
}

/**
* Get the position of the next leg within the itinerary.
*/
private int getLegIndex(Leg nextLeg) {
return IntStream
.range(0, trip.itinerary.legs.size())
.filter(i -> ItineraryUtils.legsMatch(nextLeg, trip.itinerary.legs.get(i)))
.findFirst()
.orElse(-1);
}

/**
* Confirm that the OTP response contains an itinerary that matches the trip itinerary.
*/
private boolean hasMatchingItinerary(OtpResponse otpResponse) {
return otpResponse.plan.itineraries
.stream()
.anyMatch(i -> ItineraryUtils.itinerariesMatch(trip.itinerary, i));
}

/**
* Find and set the matching itinerary from the OTP response that matches the monitored trip's stored itinerary if a
* match exists.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.opentripplanner.middleware.triptracker;

import org.opentripplanner.middleware.models.MonitoredTrip;
import org.opentripplanner.middleware.models.OtpUser;
import org.opentripplanner.middleware.models.TrackedJourney;
import org.opentripplanner.middleware.otp.response.Itinerary;
Expand All @@ -13,7 +12,6 @@

import static org.opentripplanner.middleware.triptracker.ManageLegTraversal.getExpectedLeg;
import static org.opentripplanner.middleware.triptracker.ManageLegTraversal.getNextLeg;
import static org.opentripplanner.middleware.triptracker.ManageLegTraversal.getPreviousLeg;
import static org.opentripplanner.middleware.triptracker.ManageLegTraversal.getSegmentFromPosition;
import static org.opentripplanner.middleware.utils.GeometryUtils.getDistanceFromLine;
import static org.opentripplanner.middleware.utils.ItineraryUtils.getFirstLeg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,10 @@ public static boolean legsMatch(Leg referenceItineraryLeg, Leg candidateItinerar
// - The leg has the same interlining qualities with the previous leg
if (
!equalsOrReferenceWasNull(referenceItineraryLeg.mode, candidateItineraryLeg.mode) ||
!agenciesMatch(referenceItineraryLeg.agency, candidateItineraryLeg.agency) ||
!routesMatch(referenceItineraryLeg.route, candidateItineraryLeg.route) ||
!equalsIgnoreCaseOrReferenceWasEmpty(referenceItineraryLeg.headsign, candidateItineraryLeg.headsign) ||
(referenceItineraryLeg.interlineWithPreviousLeg != candidateItineraryLeg.interlineWithPreviousLeg)
!agenciesMatch(referenceItineraryLeg.agency, candidateItineraryLeg.agency) ||
!routesMatch(referenceItineraryLeg.route, candidateItineraryLeg.route) ||
!equalsIgnoreCaseOrReferenceWasEmpty(referenceItineraryLeg.headsign, candidateItineraryLeg.headsign) ||
(referenceItineraryLeg.interlineWithPreviousLeg != candidateItineraryLeg.interlineWithPreviousLeg)
) {
return false;
}
Expand Down Expand Up @@ -245,8 +245,8 @@ private static boolean stopsMatch(Place stopA, Place stopB) {
// stop code must match
if (
stopA.stop != null &&
stopB.stop != null &&
!equalsIgnoreCaseOrReferenceWasEmpty(stopA.stop.code, stopB.stop.code)
stopB.stop != null &&
!equalsIgnoreCaseOrReferenceWasEmpty(stopA.stop.code, stopB.stop.code)
) {
return false;
}
Expand All @@ -270,8 +270,8 @@ private static boolean stopsMatch(Place stopA, Place stopB) {
private static boolean agenciesMatch(Agency agencyA, Agency agencyB) {
return (
agencyA != null &&
agencyB != null &&
equalsIgnoreCaseOrReferenceWasEmpty(agencyA.name, agencyB.name)
agencyB != null &&
equalsIgnoreCaseOrReferenceWasEmpty(agencyA.name, agencyB.name)
);
}

Expand All @@ -281,9 +281,9 @@ private static boolean agenciesMatch(Agency agencyA, Agency agencyB) {
private static boolean routesMatch(Route routeA, Route routeB) {
return (
routeA != null &&
routeB != null &&
equalsIgnoreCaseOrReferenceWasEmpty(routeA.longName, routeB.longName) &&
equalsIgnoreCaseOrReferenceWasEmpty(routeA.shortName, routeB.shortName)
routeB != null &&
equalsIgnoreCaseOrReferenceWasEmpty(routeA.longName, routeB.longName) &&
equalsIgnoreCaseOrReferenceWasEmpty(routeA.shortName, routeB.shortName)
);
}

Expand Down
10 changes: 5 additions & 5 deletions src/main/resources/latest-spark-swagger-output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1686,10 +1686,10 @@ paths:
"200":
description: "Successful operation"
examples: {}
responseSchema:
$ref: "#/definitions/MobilityProfileLite"
schema:
$ref: "#/definitions/MobilityProfileLite"
responseSchema:
$ref: "#/definitions/MobilityProfileLite"
"400":
description: "The request was not formed properly (e.g., some required parameters\
\ may be missing). See the details of the returned response to determine\
Expand Down Expand Up @@ -2376,9 +2376,9 @@ definitions:
- "ALERT_FOUND"
- "ITINERARY_NOT_FOUND"
- "INITIAL_REMINDER"
- "MODE_CHANGE"
- "ORIGIN_CHANGE"
- "DESTINATION_CHANGE"
- "MODE_CHANGE_NOTIFICATION"
- "DEPARTED_NOTIFICATION"
- "ARRIVED_NOTIFICATION"
body:
type: "string"
EncodedPolyline:
Expand Down

0 comments on commit 926f994

Please sign in to comment.