From 300c4e1e4e7645ec47b875631d94aae2f8873778 Mon Sep 17 00:00:00 2001 From: Jon Date: Mon, 28 Jun 2021 12:55:25 -0400 Subject: [PATCH] Refactored part of flighthistory request -Removed erroneous fields from booking detail history -Adjusted query to consider a date recall limit on how far the history reaches (set to 1 year tentatively), also considers flight direction. -added datetime to history call to pass to new query --- .../gov/gtas/repository/BookingDetailRepository.java | 11 ++++++++--- .../java/gov/gtas/services/PassengerServiceImpl.java | 4 +++- .../src/main/java/gov/gtas/util/PaxDetailVoUtil.java | 9 --------- 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/gtas-parent/gtas-commons/src/main/java/gov/gtas/repository/BookingDetailRepository.java b/gtas-parent/gtas-commons/src/main/java/gov/gtas/repository/BookingDetailRepository.java index 3dc5ab81bd..0f71801fd9 100644 --- a/gtas-parent/gtas-commons/src/main/java/gov/gtas/repository/BookingDetailRepository.java +++ b/gtas-parent/gtas-commons/src/main/java/gov/gtas/repository/BookingDetailRepository.java @@ -22,10 +22,15 @@ public interface BookingDetailRepository extends CrudRepository :dateLimit) " + + "OR (f.direction ='I' AND mf.eta > :dateLimit ) " + + "OR (f.direction = 'A' AND (mf.etd > :dateLimit " + + "OR mf.eta > :dateLimit))" + + "AND pax.id IN (" + "SELECT pxtag.pax_id FROM PassengerIDTag pxtag WHERE pxtag.idTag IN (SELECT p.idTag FROM PassengerIDTag p WHERE p.pax_id = (:pax_id) ))") - List getBookingDetailsByPassengerIdTag(@Param("pax_id") Long pax_id); + List getBookingDetailsByPassengerIdTag(@Param("pax_id") Long pax_id, @Param("dateLimit") Date dateLimit); @Query("SELECT pax FROM Passenger pax " + "left join fetch pax.passengerDetails " + "left join fetch pax.bookingDetails " diff --git a/gtas-parent/gtas-commons/src/main/java/gov/gtas/services/PassengerServiceImpl.java b/gtas-parent/gtas-commons/src/main/java/gov/gtas/services/PassengerServiceImpl.java index 7d24bf4800..0fb2bde1a6 100644 --- a/gtas-parent/gtas-commons/src/main/java/gov/gtas/services/PassengerServiceImpl.java +++ b/gtas-parent/gtas-commons/src/main/java/gov/gtas/services/PassengerServiceImpl.java @@ -18,6 +18,7 @@ import gov.gtas.vo.passenger.PassengerGridItemVo; import gov.gtas.vo.passenger.FlightPaxVo; import org.apache.commons.lang3.tuple.Pair; +import org.joda.time.DateTime; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.BeanUtils; @@ -239,6 +240,7 @@ public List getTravelHistoryNotByItinerary(Long paxId, Long pnrId, Strin @Override @Transactional public List getBookingDetailHistoryByPaxID(Long pId) { + DateTime dateLimitForRecall = new DateTime().minusYears(1); //1 year recall limit List tamrIdMatches; if (tamrEnabled && tamrResolvePassengerHistory) { tamrIdMatches = bookingDetailRepository.getBookingDetailsByTamrId(pId); @@ -252,7 +254,7 @@ public List getBookingDetailHistoryByPaxID(Long pId) { // If there are no tamrId matches, this means the tamrId must be // NULL or Tamr history resolving is disabled. In that case, just // do normal matching. - return bookingDetailRepository.getBookingDetailsByPassengerIdTag(pId); + return bookingDetailRepository.getBookingDetailsByPassengerIdTag(pId, dateLimitForRecall.toDate()); } } diff --git a/gtas-parent/gtas-commons/src/main/java/gov/gtas/util/PaxDetailVoUtil.java b/gtas-parent/gtas-commons/src/main/java/gov/gtas/util/PaxDetailVoUtil.java index 9e9ff99744..82a5dbc6fe 100644 --- a/gtas-parent/gtas-commons/src/main/java/gov/gtas/util/PaxDetailVoUtil.java +++ b/gtas-parent/gtas-commons/src/main/java/gov/gtas/util/PaxDetailVoUtil.java @@ -193,11 +193,6 @@ public static void deleteAndMaskPIIFromHitDetailVo(HitDetailVo hitDetailVo, Pass public static void populateFlightVoWithFlightDetail(Flight source, FlightVo target) { try { - - target.setFlightNumber(source.getFlightNumber()); - target.setCarrier(source.getCarrier()); - target.setEtaDate(source.getMutableFlightDetails().getEtaDate()); - target.setEtdDate(source.getEtdDate()); target.setOriginCountry(source.getOriginCountry()); target.setOrigin(source.getOrigin()); target.setDestinationCountry(source.getDestinationCountry()); @@ -205,10 +200,6 @@ public static void populateFlightVoWithFlightDetail(Flight source, FlightVo targ target.setEtd(source.getMutableFlightDetails().getEtd()); target.setEta(source.getMutableFlightDetails().getEta()); target.setFullFlightNumber(source.getFullFlightNumber()); - target.setFlightId(source.getId().toString()); - target.setIdTag(source.getIdTag()); - target.setPassengerCount(source.getFlightPassengerCount().getPassengerCount()); - target.setDirection(source.getDirection()); } catch (Exception e) { logger.error("error populating flight vo", e); }