private void validateDates(AcScheduledFlightUploadErrorVo e) { AcScheduledFlightUpload u = e.getScheduledFlightUpload(); if (!u.hasStartLocalDt()) return; if (!u.hasEndLocalDt()) return; if (u.getStartLocalDt().isAfter(u.getEndLocalDt())) e.addError("Invalid Start/End date combination"); }
private JwList<AcScheduledFlightUploadErrorVo> fillErrors(JwList<AcScheduledFlightUpload> v) { JwList<AcScheduledFlightUploadErrorVo> r = new JwList<AcScheduledFlightUploadErrorVo>(v.size()); // we need some sort of starting "date" - we don't care what it is or what timezone it uses JwDate date = AcGlobals.nowUtc().getDate().getCopy(); JwMap<String, AcAirport> airportCache = new JwMap<String, AcAirport>(); for (AcScheduledFlightUpload o : v) { AcScheduledFlightUploadErrorVo e = new AcScheduledFlightUploadErrorVo(); e.setScheduledFlightUpload(o); validateDates(e); validateTimes(date, airportCache, e); r.add(e); } return r; }
private void validateTimes( JwDate date, JwMap<String, AcAirport> airportCache, AcScheduledFlightUploadErrorVo e) { JwDate date2 = date.getCopy(); date2.addDays(e.getScheduledFlightUploadDayOffset()); JwTimestamp departLocalTs = JwTimestamp.createTimestamp(date, e.getScheduledFlightUploadDepartureLocalTm()); JwTimestamp arriveLocalTs = JwTimestamp.createTimestamp(date2, e.getScheduledFlightUploadArrivalLocalTm()); AcAirport originAirport = getAirport(airportCache, e.getScheduledFlightUploadOriginAirportCode()); AcAirport destAirport = getAirport(airportCache, e.getScheduledFlightUploadDestinationAirportCode()); JwTimestamp departUtcTs = originAirport.toUtc(departLocalTs); if (departUtcTs == null) departUtcTs = departLocalTs; JwTimestamp arriveUtcTs = destAirport.toUtc(arriveLocalTs); if (arriveUtcTs == null) arriveUtcTs = arriveLocalTs; if (departUtcTs.isAfter(arriveUtcTs)) e.addError("Invalid Depart/Arrive time combination"); }