// clear
data.clear();
// set urno of irmtab
irmtabUrno = irmtabRef;
ULDINFO _inputUldInfo = (ULDINFO) _um.unmarshal(new StreamSource(new StringReader(message)));
if(checkForMandatory(_inputUldInfo)){
LOG.error("Compulsory uld info are empty. Message dropped. ");
addExptInfo(EnumExceptionCodes.EMAND.name(), "");
return false;
}
//ignore if it's not EK flight
if(_inputUldInfo.getFLIGHTNO().contains("EK")){
String flno = null;
String connectedFlno = "0";
String flDate = null;
String connectedFlDate = null;
EntDbAfttab entFlight = null;
String act3 = null;
String act5 = null;
BigDecimal urno = null;
BigDecimal connectedUrno = null;
//convert the string for flight "EK" to ufis ceda flight num format
flno = _inputUldInfo.getFLIGHTNO().substring(0,2) + " " +
HpUfisUtils.formatCedaFltn(_inputUldInfo.getFLIGHTNO().substring(2, _inputUldInfo.getFLIGHTNO().length()));
if(HpUfisUtils.isNullOrEmptyStr(_inputUldInfo.getCONNFLIGHTNO()))
connectedFlno = "0";
else
connectedFlno = _inputUldInfo.getCONNFLIGHTNO().substring(0,2) + " "+
HpUfisUtils.formatCedaFltn(_inputUldInfo.getCONNFLIGHTNO().substring(2,_inputUldInfo.getCONNFLIGHTNO().length()));
flDate = convertFlDateToUTC(_inputUldInfo.getFLIGHTDATE());
if(!HpUfisUtils.isNullOrEmptyStr(_inputUldInfo.getCONNFLIGHTDATE()))
connectedFlDate = convertFlDateToUTC(_inputUldInfo.getCONNFLIGHTDATE());
//get the flight urno for arrival
if("A".equals(_inputUldInfo.getFLIGHTAD())){
entFlight = afttabBean.findUrnoForArr(flno, flDate);
if(connectedFlno != "0"){
//get the connected flight urno for arr which is not arrival
if(!HpUfisUtils.isNullOrEmptyStr(_inputUldInfo.getCONNFLIGHTNO()))
connectedUrno = afttabBean.findUrnoForNotArr(connectedFlno, connectedFlDate);
}
}
//get the flight urno for dept
else if("D".equals(_inputUldInfo.getFLIGHTAD())){
entFlight = afttabBean.findUrnoForDept(flno, flDate);
if(connectedFlno != "0"){
//get the connected flight urno for dept which is not dept
if(!HpUfisUtils.isNullOrEmptyStr(_inputUldInfo.getCONNFLIGHTNO()))
connectedUrno = afttabBean.findUrnoForNotDept(connectedFlno, connectedFlDate);
}
}
if(entFlight == null){
LOG.error("Message dropped.");
addExptInfo(EnumExceptionCodes.ENOFL.name(), flno);
return false;
}else{
urno = entFlight.getUrno();
act3 = entFlight.getAct3().trim();
act5 = entFlight.getAct5().trim();
}
connectedUrno = (connectedUrno == null) ? new BigDecimal(0) : connectedUrno;
EntDbLoadUld loadUld = null;
EntDbLoadUld oldLoadUld = null;
String cmdForBroadcasting = null;
//find existing record depending on IdFlight and UldNumber..
loadUld = _dlLoadUldBean.getUldNum(urno, _inputUldInfo.getULDNO());
if(loadUld == null){
if("Y".equals(_inputUldInfo.getULDISDELETED())){
LOG.error("ULD record does not exist to delete. Message dropped.");
addExptInfo(EnumExceptionCodes.ENOUD.name(), _inputUldInfo.getULDISDELETED());
return false;
}
loadUld = new EntDbLoadUld();
loadUld.setFltDate(new HpUfisCalendar(flDate).getTime());
loadUld.setUldCurrFltno(flno);
loadUld.setUldNumber(_inputUldInfo.getULDNO());
loadUld.setCreatedDate(HpUfisCalendar.getCurrentUTCTime());
loadUld.setCreatedUser(HpEKConstants.ULD_SOURCE);
cmdForBroadcasting = HpUfisAppConstants.UfisASCommands.IRT.name();
}
else{
oldLoadUld = new EntDbLoadUld(loadUld);
loadUld.setUpdatedUser(HpEKConstants.ULD_SOURCE);
loadUld.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
cmdForBroadcasting = HpUfisAppConstants.UfisASCommands.URT.name();
}
loadUld.setIdFlight(urno);
loadUld.setIdConxFlight(connectedUrno);
// only when the value is exist, check against the md value
if(!HpUfisUtils.isNullOrEmptyStr(_inputUldInfo.getULDPOSITION())){
//set the ULD Basic Data
List<EntDbMdUldPos> uldPosList = _BasicDataSingleton.getUldPosList();
boolean isFound = false;
if(!uldPosList.isEmpty()){
for(int i = 0; i < uldPosList.size(); i++){
//get uld pos according to act3, act5 and position name
if(entFlight != null){
if(uldPosList.get(i).getAircraftType3().trim().equals(act3) &&
uldPosList.get(i).getAircraftType5().trim().equals(act5) &&
uldPosList.get(i).getUldPosition().trim().equals(_inputUldInfo.getULDPOSITION())){
loadUld.setIdMdUldPos(uldPosList.get(i).getId());
isFound = true;
break;
}
}
}
}
if(!isFound){
LOG.warn("Master Data Uld Position is not match in MdUldPos.");
addExptInfo(EnumExceptionCodes.WNOMD.name(), String.format("ULD_POSITION => %s", _inputUldInfo.getULDPOSITION()));
}
} else
LOG.error("Input ULD_POSITION is empty/blank.");
loadUld = checkUldInfoMaterdata(_inputUldInfo, loadUld);//call to check MD
loadUld.setDataSource(HpEKConstants.ULD_SOURCE);
loadUld.setArrDepFlag(_inputUldInfo.getFLIGHTAD());
loadUld.setUldPosition(_inputUldInfo.getULDPOSITION());
loadUld.setUldType(_inputUldInfo.getULDTYPE());
loadUld.setUldSubtype(_inputUldInfo.getULDSUBTYPE());
loadUld.setUldItemtype(_inputUldInfo.getULDITEMTYPE());
loadUld.setUldWeight(_inputUldInfo.getULDWEIGHT());
loadUld.setUldDispLocCode(_inputUldInfo.getULDDISPATCHTOLOCCODE());
loadUld.setUldDispLocDesc(_inputUldInfo.getULDDISPATHCTOLOCDESC());
String status = " ";
if("Y".equals(_inputUldInfo.getULDISDELETED())){
status = "X";
cmdForBroadcasting = HpUfisAppConstants.UfisASCommands.DRT.toString();
}
loadUld.setRecFlag(status);
loadUld.setUldConxFlno(connectedFlno);
if(connectedFlDate != null)
loadUld.setConxFltDate(new HpUfisCalendar(connectedFlDate).getTime());
loadUld.setConxToUld(_inputUldInfo.getCONNULDNO());
if(!HpUfisUtils.isNullOrEmptyStr(_inputUldInfo.getRECORDSENDDATE()))
loadUld.setUldSentDate(new HpUfisCalendar(convertFlDateToUTC(_inputUldInfo.getRECORDSENDDATE())).getTime());
EntDbLoadUld resultUld = _dlLoadUldBean.merge(loadUld);
if(resultUld != null){
sendNotifyUldInfoToInJson(resultUld, oldLoadUld, cmdForBroadcasting);
}
}
else {
LOG.error("Wrong airline. Non EK flight. Message dropped");
addExptInfo(EnumExceptionCodes.EWALC.name(), _inputUldInfo.getFLIGHTNO());
return false;
}
} catch (JAXBException e) {
LOG.error("JAXBContext when unmarshalling... {}", e.getMessage());
addExptInfo(EnumExceptionCodes.EXSDF.name(), "");