if (isValid) {
long start = System.currentTimeMillis();
// find arrival and departure flight from afttab
EntDbAfttab flight = afttabBean.findFlightForConxByUrno(Long.parseLong(idFlight));
EntDbAfttab conxFlight = afttabBean.findFlightForConxByUrno(Long.parseLong(idConxFlight));
LOG.debug("Search Flight from afttab used: {}", (System.currentTimeMillis() - start));
// Main flight and conx flight must be existing in afttab
if (flight == null) {
LOG.warn("Flight not found for urno: {}", idFlight);
return null;
}
if (conxFlight == null) {
LOG.warn("Conx Flight not found for urno: {}", idConxFlight);
return null;
}
// Main flight and conx flight must be either arrival or departure flight
if (ADID_ARRIVAL != flight.getAdid() && ADID_DEPARTURE != flight.getAdid()) {
LOG.warn("Main flight must be arrival or departure flight");
LOG.warn("ADID={} for main flight={}", flight.getAdid(), flight.getUrno());
return null;
}
if (ADID_ARRIVAL != conxFlight.getAdid() && ADID_DEPARTURE != conxFlight.getAdid()) {
LOG.warn("Conx flight must be arrival or departure flight");
LOG.warn("ADID={} for conx flight={}", conxFlight.getAdid(), conxFlight.getUrno());
return null;
}
// calculate the time span between main and connect flight
BigDecimal idArrFlight = null;
BigDecimal idDepFlight = null;
HpUfisCalendar tifa = null;
HpUfisCalendar tifd = null;
if (ADID_ARRIVAL == flight.getAdid()) {
tifa = new HpUfisCalendar(flight.getTifa());
tifd = new HpUfisCalendar(conxFlight.getTifd());
idArrFlight = flight.getUrno();
idDepFlight = conxFlight.getUrno();
} else {
tifa = new HpUfisCalendar(conxFlight.getTifd());
tifd = new HpUfisCalendar(flight.getTifa());
idArrFlight = conxFlight.getUrno();
idDepFlight = flight.getUrno();
}
int timeDiff = (int) tifa.timeDiff(tifd, EnumTimeInterval.Minutes, false);
LOG.debug("Time Difference between main flight and conx flight: {} mins", timeDiff);