//convert the string for flight "EK" to ufis ceda flight num format
ffltNo = _input.getFlightID().getFFltNo().substring(0,2) + " " +
HpUfisUtils.formatCedaFltn(_input.getFlightID().getFFltNo().substring(2, _input.getFlightID().getFFltNo().length()));
/**** For input UTC ******/
HpUfisCalendar inputFlDate = new HpUfisCalendar(_input.getFlightID().getFltDate());
fltDate = inputFlDate.getCedaString();
/**** For input LOCAL ****/
//fltDate = convertFlDateToUTC_Lounge(_input.getFlightID().getFltDate());
if(HpEKConstants.EK_HOPO.equals(_input.getFlightID().getArrStn())
&& HpEKConstants.EK_HOPO.equals(_input.getFlightID().getDepStn())){// ArrStn = DepStn = DXB
entFlight = clsAfttabBeanLocal.findFlightForReturn(ffltNo, fltDate);
}else if(HpEKConstants.EK_HOPO.equals(_input.getFlightID().getArrStn())){// ArrStn = DXB
entFlight = clsAfttabBeanLocal.findFlightForEKArr(ffltNo, fltDate);
}
else if(HpEKConstants.EK_HOPO.equals(_input.getFlightID().getDepStn())){// DepStn = DXB
entFlight = clsAfttabBeanLocal.findFlightForEKDept(ffltNo, fltDate);
}else{// ArrStn != DepStn != DXB
//search from VIAL
LOG.debug("Looking for the flight from its VIAL..");
entFlight = clsAfttabBeanLocal.findFlightFromVial(ffltNo, fltDate, _input.getFlightID().getDepStn(), _input.getFlightID().getArrStn());
}
//urno = (entFlight == null) ? new BigDecimal(0) : entFlight.getUrno();
EntDbLoadPax load_pax = null;
if(entFlight == null){
LOG.error("Flight flno <{}> is not found. Message dropped.", ffltNo);
addExptInfo(EnumExceptionCodes.ENOFL.name(), ffltNo);
return false;
}
else{
urno = entFlight.getUrno();
load_pax = clsDlPaxBean.getPaxWithPaxRefNum(_input.getPaxDetails().getSeqNo(), String.valueOf(urno));
}
/*if(intFlid != null){
//get the pax id
load_pax = clsDlPaxBean.getPaxForPaxLounge(_input.getPaxDetails().getSeqNo(), intFlid);
}*/
id_load_pax = (load_pax == null)? "0" : load_pax.getUuid();
//get lounge code id from cache
boolean isFound = false;
entLoungeCodeList = clsEntStartUpInitSingleton.getLoungeCodeList();
for(int i = 0; i < entLoungeCodeList.size() ; i ++ ){
if(entLoungeCodeList.get(i).getLoungeCode().trim().equals(_input.getPaxDetails().getLoungeCode().trim())){
id_md_lounge_code = entLoungeCodeList.get(i).getId();
isFound = true; break;
}
}
if(!isFound){
LOG.warn("Input LoungeCode is not in MD_LOUNGE_CODE table.");
addExptInfo(EnumExceptionCodes.WNOMD.name(), _input.getPaxDetails().getLoungeCode());
}
//Date scanInTimeUTC = null;
Date scanTimeUTC = null;
if(_input.getAudit().getScanTime() != null){
scanTime = convertFlDateToUTC_Lounge(_input.getAudit().getScanTime());
scanTimeUTC = new HpUfisCalendar(scanTime).getTime();
}
EntDbPaxLoungeMove oldEnt = null; String cmd = UfisASCommands.IRT.name();
//find existing pax lounge move only if the flight is not null.
EntDbPaxLoungeMove entPaxLoungeMove = clsDlPaxLoungeMoveBean.getPaxLoungeMove(_input.getPaxDetails().getRegKey(), urno);
if(entPaxLoungeMove == null){
entPaxLoungeMove = new EntDbPaxLoungeMove();
entPaxLoungeMove.setCreatedUser(HpEKConstants.OPERA_SOURCE);
entPaxLoungeMove.setCreatedDate(HpUfisCalendar.getCurrentUTCTime());
}
else{
oldEnt = new EntDbPaxLoungeMove(entPaxLoungeMove);
entPaxLoungeMove.setUpdatedUser(HpEKConstants.OPERA_SOURCE);
entPaxLoungeMove.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
cmd = UfisASCommands.URT.name();
}
entPaxLoungeMove.setPaxRegnKey(_input.getPaxDetails().getRegKey());
entPaxLoungeMove.setIdFlight(urno);
entPaxLoungeMove.setIdLoadPax(id_load_pax);
entPaxLoungeMove.setIdMdLoungeCode(id_md_lounge_code);
if(_input.getMeta().getMessageTime() != null)
entPaxLoungeMove.setMsgSentDate(new HpUfisCalendar(
_input.getMeta().getMessageTime().toGregorianCalendar().getTime()).getTime());
entPaxLoungeMove.setMsgId(new BigDecimal(_input.getMeta().getMessageID()));
entPaxLoungeMove.setFlightNumber(ffltNo);
entPaxLoungeMove.setDepNum((_input.getFlightID().getDepNo()== null)? null : String.valueOf(_input.getFlightID().getDepNo()));