.getFlightDate());
LOG.debug("flightNumber: " + flightNumber + " FlightDate:"
+ fltDate);
/* Change */
EntDbAfttab criteriaParams = new EntDbAfttab();
criteriaParams.setFlno(flightNumber);
criteriaParams.setFlda(fltDate);
// criteriaParams.setAdid('D');
if (HpUfisUtils.isNullOrEmptyStr(bagDetails.getFlightInfo()
.getArrivalAirport())) {
urno = _afttabBean.getUrnoByFldaFlnoAdid(criteriaParams,
null, bagDetails.getFlightInfo()
.getDepartureAirport());
} else {
urno = _afttabBean.getUrnoByFldaFlnoAdid(criteriaParams,
bagDetails.getFlightInfo().getArrivalAirport(),
bagDetails.getFlightInfo().getDepartureAirport());
}
if (urno == null || String.valueOf(urno) == null
|| urno.isEmpty()) {
// populate ID_FLIGHT as ZERO
urno = new Long(0).toString();
LOG.error(
"No flight is available in AFTTAB with the Flight details:"
+ "BagTag = {}, " + "flight Number = {}, "
+ "Flight Date= {}, ", new Object[] {
bagDetails.getBagInfo().getBagTag(),
flightNumber, fltDate });
if (!HpUfisUtils.isNullOrEmptyStr(bagDetails
.getFlightInfo().getArrivalAirport())) {
if (logLevel
.equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
.name())) {
if (!msgLogged) {
irmtabRef = _irmfacade.storeRawMsg(message,
dtflStr);
msgLogged = Boolean.TRUE;
}
}
if (irmtabRef > 0) {
sendErrInfo(EnumExceptionCodes.ENOFL,
"FLight not found.Bag Tag:"
+ bagDetails.getBagInfo()
.getBagTag()
+ " Flight Number:"
+ bagDetails.getFlightInfo()
.getFullFlightNumber()
+ " Flight Date:"
+ bagDetails.getFlightInfo()
.getFlightDate(), irmtabRef);
}
}
}
// long idFlight = (urno != null && (String.valueOf(urno) !=
// null) && (!urno
// .isEmpty())) ? Long.parseLong(urno) : 0;
long idFlight = Long.parseLong(urno);
List<EntDbLoadBag> loadBagDetailsList = new ArrayList<EntDbLoadBag>();
String recStatus = " ";
if (bagDetails.getMeta().getMessageSubtype().value()
.equalsIgnoreCase(MsgSubType.DEL.value())) {
// if
// (!HpUfisUtils.isNullOrEmptyStr(bagDetails.getBagInfo().getPassengerSeqNo()))
// {
startTime = new Date().getTime();
if (idFlight != 0) {
if (!HpUfisUtils.isNullOrEmptyStr(bagDetails
.getBagInfo().getPassengerSeqNo())) {
// loadBagDetailsList =
// _loadBagUpdate.getBagMoveDetails(
// bagDetails.getBagInfo().getBagTag(), bagDetails
// .getBagInfo().getPassengerSeqNo(),
// flightNumber, fltDate, bagDetails
// .getFlightInfo().getArrivalAirport());
loadBagDetailsList = _loadBagUpdate
.getBagMoveDetailsByBagtagPax(
idFlight,
bagDetails.getBagInfo().getBagTag(),
bagDetails.getBagInfo()
.getPassengerSeqNo());
} else {
loadBagDetailsList = _loadBagUpdate
.getBagMoveDetailsByBagTag(idFlight,
bagDetails.getBagInfo().getBagTag());
}
}
LOG.debug(
"Total Duration on loading bag details (in ms): {}",
new Date().getTime() - startTime);
// }
if (loadBagDetailsList.size() == 1) {
if (loadBagDetailsList.get(0).getBagClassify() != null
&& (loadBagDetailsList.get(0).getBagClassify()
.equalsIgnoreCase("RUSH"))) {
oldLoadBag = loadBagDetailsList.get(0).getClone();
loadBagDetailsList.get(0).setRecStatus("X");
loadBagDetailsList.get(0).setUpdatedUser(
HpEKConstants.BELT_SOURCE);
loadBagDetailsList.get(0).setUpdatedDate(
HpUfisCalendar.getCurrentUTCTime());
loadBagStat = _loadBagUpdate
.updateLoadedBag(loadBagDetailsList.get(0));
LOG.info(
"One Record found and Deleting the record, Marking status as('X'):"
+ "BagTag = {}, "
+ "flight Number = {}, "
+ "Flight Date= {}, ",
new Object[] {
bagDetails.getBagInfo().getBagTag(),
flightNumber, fltDate });
if (loadBagStat != null) {
/*
* sendLoadBagUpdateToCedaInJson(loadBagStat,
* oldLoadBag, UfisASCommands.URT.name(), true);
*/
if (HpUfisUtils
.isNotEmptyStr(HpCommonConfig.notifyTopic)) {
// send notification message to topic
ufisTopicProducer.sendNotification(true,
UfisASCommands.DRT, String
.valueOf(loadBagStat
.getId_Flight()),
oldLoadBag, loadBagStat);
}
if (HpUfisUtils
.isNotEmptyStr(HpCommonConfig.notifyQueue)) {
// if topic not defined, send notification
// to queue
ufisQueueProducer.sendNotification(true,
UfisASCommands.DRT, String
.valueOf(loadBagStat
.getId_Flight()),
oldLoadBag, loadBagStat);
}
LOG.debug("Bag Record change has beed communicated to Ceda.");
}
} else {
oldLoadBag = loadBagDetailsList.get(0);
loadBagDetailsList.get(0).setRecStatus("I");
loadBagDetailsList.get(0).setUpdatedUser(
HpEKConstants.BELT_SOURCE);
loadBagDetailsList.get(0).setUpdatedDate(
HpUfisCalendar.getCurrentUTCTime());
loadBagStat = _loadBagUpdate
.updateLoadedBag(loadBagDetailsList.get(0));
LOG.info(
"One Record found but it is not RUSH bag updating the record status('I'):"
+ "BagTag = {}, "
+ "flight Number = {}, "
+ "Flight Date= {}, ",
new Object[] {
bagDetails.getBagInfo().getBagTag(),
flightNumber, fltDate });
if (loadBagStat != null) {
/*
* sendLoadBagUpdateToCedaInJson(loadBagStat,
* oldLoadBag, UfisASCommands.URT.name(), true);
*/
if (HpUfisUtils
.isNotEmptyStr(HpCommonConfig.notifyTopic)) {
// send notification message to topic
ufisTopicProducer.sendNotification(true,
UfisASCommands.URT, String
.valueOf(loadBagStat
.getId_Flight()),
oldLoadBag, loadBagStat);
}
if (HpUfisUtils
.isNotEmptyStr(HpCommonConfig.notifyQueue)) {
// if topic not defined, send notification
// to queue
ufisQueueProducer.sendNotification(true,
UfisASCommands.URT, String
.valueOf(loadBagStat
.getId_Flight()),
oldLoadBag, loadBagStat);
}
LOG.debug("Bag Record change has beed communicated to Ceda.");
}
}
} else if (loadBagDetailsList.size() > 1) {
boolean isLast = false;
for (EntDbLoadBag bagRecs : loadBagDetailsList) {
if (bagRecs.equals(loadBagDetailsList
.get(loadBagDetailsList.size() - 1))) {
isLast = true;
}
oldLoadBag = bagRecs.getClone();
if (!bagRecs.getRecStatus().equalsIgnoreCase("R")) {
bagRecs.setRecStatus("R");
bagRecs.setUpdatedUser(HpEKConstants.BELT_SOURCE);
bagRecs.setUpdatedDate(HpUfisCalendar
.getCurrentUTCTime());
loadBagStat = _loadBagUpdate
.updateLoadedBag(bagRecs);
if (loadBagStat != null) {
/*
* sendLoadBagUpdateToCedaInJson(loadBagStat,
* oldLoadBag, UfisASCommands.URT.name(),
* true);
*/
if (HpUfisUtils
.isNotEmptyStr(HpCommonConfig.notifyTopic)) {
// send notification message to topic
ufisTopicProducer.sendNotification(
isLast, UfisASCommands.URT,
String.valueOf(loadBagStat
.getId_Flight()),
oldLoadBag, loadBagStat);
}
if (HpUfisUtils
.isNotEmptyStr(HpCommonConfig.notifyQueue)) {
// if topic not defined, send
// notification to queue
ufisQueueProducer.sendNotification(
isLast, UfisASCommands.URT,
String.valueOf(loadBagStat
.getId_Flight()),
oldLoadBag, loadBagStat);
}
LOG.debug("Bag Record change has beed communicated to Ceda.");
}
}
}
LOG.info(
"Multiple records found related to bagdetails. Updating existing recStatus as 'R'. Ignoring the message."
+ "BagTag = {}, "
+ "flight Number = {}, "
+ "Flight Date= {}, ", new Object[] {
bagDetails.getBagInfo().getBagTag(),
flightNumber, fltDate });
} else {
LOG.info("Record not found .Message Details::"
+ "BagTag = {}, " + "flight Number = {}, "
+ "Flight Date= {}, ", new Object[] {
bagDetails.getBagInfo().getBagTag(),
flightNumber, fltDate });
if (logLevel
.equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
.name())) {
if (!msgLogged) {
irmtabRef = _irmfacade.storeRawMsg(message,
dtflStr);
msgLogged = Boolean.TRUE;
}
}
if (irmtabRef > 0) {
sendErrInfo(EnumExceptionCodes.ENOBG,
"Rec not found in LOAD_BAG.Bag Tag:"
+ bagDetails.getBagInfo()
.getBagTag()
+ " Flight Number:"
+ bagDetails.getFlightInfo()
.getFullFlightNumber()
+ " Flight Date:"
+ bagDetails.getFlightInfo()
.getFlightDate(), irmtabRef);
}
return Boolean.TRUE;
}
}
if (_startupInitSingleton.isMdBagTypeOn()
&& allBagTypes.isEmpty()) {
allBagTypes = _startupInitSingleton.getMdBagTypeList();
for (EntDbMdBagType bagTypeRec : allBagTypes) {
if ((bagTypeRec.getRecStatus() != null)
&& !bagTypeRec.getRecStatus().equalsIgnoreCase(
"X")) {
masterBagTypes.add(bagTypeRec.getBagTypeCode());
}
}
}
if (_startupInitSingleton.isMdBagTypeOn()
&& (masterBagTypes.isEmpty() || !(masterBagTypes
.contains(bagDetails.getBagInfo().getBagType()
.value())))) {
LOG.error(
"Dropping the message .Master Data BagTypes doesn't contain the specified value for the Flight :"
+ "BagTag = {}, "
+ "flight Number = {}, "
+ "Flight Date= {}, ",
new Object[] {
bagDetails.getBagInfo().getBagTag(),
bagDetails.getFlightInfo()
.getFlightNumber(),
bagDetails.getFlightInfo().getFlightDate() });
if (logLevel
.equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
.name())) {
if (!msgLogged) {
irmtabRef = _irmfacade
.storeRawMsg(message, dtflStr);
msgLogged = Boolean.TRUE;
}
}
if (irmtabRef > 0) {
sendErrInfo(EnumExceptionCodes.ENOMD,
"BagType not in MasterData.Bag Type: "
+ bagDetails.getBagInfo().getBagType()
.value()
+ " Bag Tag:"
+ bagDetails.getBagInfo().getBagTag()
+ " Flight Number:"
+ bagDetails.getFlightInfo()
.getFullFlightNumber()
+ " Flight Date:"
+ bagDetails.getFlightInfo()
.getFlightDate(), irmtabRef);
}
return false;
}
if (_startupInitSingleton.isMdBagClassifyOn()
&& allBagClassifications.isEmpty()) {
allBagClassifications = _startupInitSingleton
.getMdBagClassifyList();
for (EntDbMdBagClassify bagClassifyRec : allBagClassifications) {
if ((bagClassifyRec.getRecStatus() != null)
&& !bagClassifyRec.getRecStatus()
.equalsIgnoreCase("X")) {
masterBagClassify.add(bagClassifyRec
.getBagClassify());
}
}
}
if (bagDetails.getBagInfo().getBagClassification() != null
&& (_startupInitSingleton.isMdBagClassifyOn() && (masterBagClassify
.isEmpty() || (!(masterBagClassify
.contains(bagDetails.getBagInfo()
.getBagClassification())))))) {
// LOG.error("Dropping the message .Master Data Bag Classify doesn't contain the specified value for the Flight :"
// + "BagTag = {}, "
// + "flight Number = {}, " + "Flight Date= {}, ", new
// Object[]{bagDetails.getBagInfo().getBagTag(),
// bagDetails.getFlightInfo().getFlightNumber(),
// bagDetails.getFlightInfo().getFlightDate()});
LOG.warn(
"BagClassification is not found in Master Data.Populating the value for the Flight :"
+ "BagTag = {}, "
+ "flight Number = {}, "
+ "Flight Date= {}, ",
new Object[] {
bagDetails.getBagInfo().getBagTag(),
bagDetails.getFlightInfo()
.getFlightNumber(),
bagDetails.getFlightInfo().getFlightDate() });
if (logLevel
.equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
.name())) {
if (!msgLogged) {
irmtabRef = _irmfacade
.storeRawMsg(message, dtflStr);
msgLogged = Boolean.TRUE;
}
}
if (irmtabRef > 0) {
sendErrInfo(EnumExceptionCodes.WNOMD,
"Bag Classification not in MasterData.Bag Classify: "
+ bagDetails.getBagInfo()
.getBagClassification()
+ " Bag Tag:"
+ bagDetails.getBagInfo().getBagTag()
+ " Flight Number:"
+ bagDetails.getFlightInfo()
.getFullFlightNumber()
+ " Flight Date:"
+ bagDetails.getFlightInfo()
.getFlightDate(), irmtabRef);
}
// return false;
}
// loadBag.setIdFlight(idFlight);
loadBag.setId_Flight(new BigDecimal(idFlight));
// loadBag.setFlightNumber(flightNumber);
loadBag.setBagFlno(flightNumber);
// loadBag.setFltDate(fltDate);
loadBag.setFlt_Date(fltDate);
loadBag.setMsgSendDate(convertDateToUTC(bagDetails.getMeta()
.getMessageTime()));
// loadBag.setFltOrigin3(bagDetails.getFlightInfo()
// .getDepartureAirport());
loadBag.setFlt_Origin3(bagDetails.getFlightInfo()
.getDepartureAirport());
// loadBag.setFltDest3(bagDetails.getFlightInfo()
// .getArrivalAirport());
loadBag.setFlt_Dest3(bagDetails.getFlightInfo()
.getArrivalAirport());
loadBag.setBagTag(bagDetails.getBagInfo().getBagTag());
if (HpUfisUtils.isNotEmptyStr(loadBag.getBagTag())
&& loadBag.getBagTag().length() > 4) {
airLineCode = getAirLineFromCode(loadBag.getBagTag()
.substring(1, 4));
//LOG.info("Airline Code:"+airLineCode);
if (airLineCode != null
&& bagDetails.getFlightInfo().getArrivalAirport() != null) {
loadBag.setBagTagStr(airLineCode.concat(
loadBag.getBagTag().substring(4)).concat(
bagDetails.getFlightInfo().getArrivalAirport()));
}
/*
* loadBag.setBagTagStr(airLineCode != null ? airLineCode :
* null);
*/
}
if (bagDetails.getBagInfo().getBagType() != null) {
loadBag.setBagType(bagDetails.getBagInfo().getBagType()
.value());
}
if (bagDetails.getBagInfo().getBagClassification() != null) {
loadBag.setBagClassify(bagDetails.getBagInfo()
.getBagClassification());
}
if (!HpUfisUtils.isNullOrEmptyStr(bagDetails.getBagInfo()
.getBagClass())) {
if (!HpBeltConfig.getBusinessClassBagList().isEmpty()
&& HpBeltConfig.getBusinessClassBagList().contains(
bagDetails.getBagInfo().getBagClass())) {
loadBag.setBagClass("J");
} else if (!HpBeltConfig.getFirstClassBagList().isEmpty()
&& HpBeltConfig.getFirstClassBagList().contains(
bagDetails.getBagInfo().getBagClass())) {
loadBag.setBagClass("F");
} else if (!HpBeltConfig.getEconomyClassBagList().isEmpty()
&& HpBeltConfig.getEconomyClassBagList().contains(
bagDetails.getBagInfo().getBagClass())) {
loadBag.setBagClass("Y");
} else {
LOG.info(
"Specified Bag Class is not in configured list for the Flight :"
+ "BagTag = {}, "
+ "flight Number = {}, "
+ "Flight Date= {}, ", new Object[] {
bagDetails.getBagInfo().getBagTag(),
bagDetails.getFlightInfo()
.getFlightNumber(),
bagDetails.getFlightInfo()
.getFlightDate() });
if (logLevel
.equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
.name())) {
if (!msgLogged) {
irmtabRef = _irmfacade.storeRawMsg(message,
dtflStr);
msgLogged = Boolean.TRUE;
}
}
if (irmtabRef > 0) {
sendErrInfo(EnumExceptionCodes.WBGCL,
"Bag Class not in config list.Bag Class: "
+ bagDetails.getBagInfo()
.getBagClass()
+ " Bag Tag:"
+ bagDetails.getBagInfo()
.getBagTag()
+ " Flight Number:"
+ bagDetails.getFlightInfo()
.getFullFlightNumber()
+ " Flight Date:"
+ bagDetails.getFlightInfo()
.getFlightDate(), irmtabRef);
}
loadBag.setBagClass(bagDetails.getBagInfo()
.getBagClass());
}
}
loadBag.setPaxName(bagDetails.getBagInfo().getPassengerName());
loadBag.setPaxRefNum(bagDetails.getBagInfo()
.getPassengerSeqNo());
LOG.debug("Pax Seq Num:"
+ bagDetails.getBagInfo().getPassengerSeqNo());
if (HpUfisUtils.isNullOrEmptyStr(bagDetails.getBagInfo()
.getPassengerSeqNo())) {
LOG.warn(
"Pax (Passenger SeqNO is null) is not available in LOAD_PAX. Flight details:"
+ "BagTag = {}, " + "PaxRef Number = {}, "
+ "flight Number = {}, "
+ "Flight Date= {}, ",
new Object[] {
bagDetails.getBagInfo().getBagTag(),
bagDetails.getBagInfo().getPassengerSeqNo(),
bagDetails.getFlightInfo()
.getFlightNumber(),
bagDetails.getFlightInfo().getFlightDate() });
/*
* if (logLevel
* .equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
* .name())) { if (!msgLogged) { irmtabRef = _irmfacade
* .storeRawMsg(message, dtflStr); msgLogged = Boolean.TRUE;
* } } if (irmtabRef > 0) {
* sendErrInfo(EnumExceptionCodes.WNOPX,
* "Pax num not specified.PaxRefNum: " +
* bagDetails.getBagInfo() .getPassengerSeqNo() +
* " Bag Tag:" + bagDetails.getBagInfo().getBagTag() +
* " Flight Number:" + bagDetails.getFlightInfo()
* .getFullFlightNumber() + " Flight Date:" +
* bagDetails.getFlightInfo() .getFlightDate(), irmtabRef);
*
* }
*/
} else {
startTime = new Date().getTime();
EntDbLoadPax entLoadPax = _paxBean.getPaxWithPaxRefNum(
bagDetails.getBagInfo().getPassengerSeqNo(), urno);
LOG.debug(
"Total Duration on searching for pax details (in ms): {}",
new Date().getTime() - startTime);
if (entLoadPax == null
|| HpUfisUtils.isNullOrEmptyStr(entLoadPax
.getUuid())) {
LOG.warn(
"Pax details are not available in LOAD_PAX. Flight details:"
+ "BagTag = {}, "
+ "PaxRef Number = {}, "
+ "flight Number = {}, "
+ "Flight Date= {}, ", new Object[] {
bagDetails.getBagInfo().getBagTag(),
bagDetails.getBagInfo()
.getPassengerSeqNo(),
bagDetails.getFlightInfo()
.getFlightNumber(),
bagDetails.getFlightInfo()
.getFlightDate() });
/*
* if (logLevel
* .equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev
* .LOG_ERR .name())) { if (!msgLogged) { irmtabRef =
* _irmfacade.storeRawMsg(message, dtflStr); msgLogged =
* Boolean.TRUE; } } if (irmtabRef > 0) {
* sendErrInfo(EnumExceptionCodes.WNOPX,
* "Pax not found.PaxRefNum: " + bagDetails.getBagInfo()
* .getPassengerSeqNo() + " Bag Tag:" +
* bagDetails.getBagInfo() .getBagTag() +
* " Flight Number:" + bagDetails.getFlightInfo()
* .getFullFlightNumber() + " Flight Date:" +
* bagDetails.getFlightInfo() .getFlightDate(),
* irmtabRef);
*
* }
*/
// return false;
} else {
loadBag.setIdLoadPax(entLoadPax.getUuid());
}
}
loadBag.setChangeDate(chgStringToDate(
chgStringToFltDate(bagDetails.getBagInfo()
.getChangeDate()), bagDetails.getBagInfo()
.getChangeTime()));
if (bagDetails.getInboundFlight() != null) {
String inboundUrno = null;
if (HpUfisUtils.isNullOrEmptyStr(bagDetails
.getInboundFlight().getCarrierCode())
|| HpUfisUtils.isNullOrEmptyStr(bagDetails
.getInboundFlight().getFlightNumber())
|| HpUfisUtils.isNullOrEmptyStr(bagDetails
.getInboundFlight().getFlightDate())) {
LOG.warn(
"Inbound Flight details are not sufficient to search in AFTTAB. The Inbound Flight details:"
+ "BagTag = {}, "
+ "Arrival flight Number = {}, "
+ "Arrival Flight Date= {}, ",
new Object[] {
bagDetails.getBagInfo().getBagTag(),
bagDetails.getInboundFlight()
.getFlightNumber(),
bagDetails.getInboundFlight()
.getFlightDate() });
String arrFltNumb = bagDetails.getInboundFlight()
.getCarrierCode() == null ? " " : bagDetails
.getInboundFlight().getCarrierCode()
.substring(0, 2)
+ " "
+ HpUfisUtils.formatCedaFltn(String
.valueOf(bagDetails.getInboundFlight()
.getFlightNumber()))
+ (bagDetails.getInboundFlight()
.getFlightSuffix() == null ? ""
: bagDetails.getInboundFlight()
.getFlightSuffix());
String arrFltDate = chgStringToFltDate(bagDetails
.getInboundFlight().getFlightDate());
// loadBag.setArrFlightNumber(arrFltNumb);
loadBag.setBagConxFlno(arrFltNumb);
// loadBag.setArrFltDate(arrFltDate);
loadBag.setConxFltDate(arrFltDate);
} else {
String arrFltNumb = bagDetails.getInboundFlight()
.getCarrierCode() == null ? " " : bagDetails
.getInboundFlight().getCarrierCode()
.substring(0, 2)
+ " "
+ HpUfisUtils.formatCedaFltn(String
.valueOf(bagDetails.getInboundFlight()
.getFlightNumber()))
+ (bagDetails.getInboundFlight()
.getFlightSuffix() == null ? ""
: bagDetails.getInboundFlight()
.getFlightSuffix());
String arrFltDate = chgStringToFltDate(bagDetails
.getInboundFlight().getFlightDate());
LOG.debug("flightNumber: " + arrFltNumb
+ " FlightDate:" + arrFltDate);
startTime = new Date().getTime();
// Change
EntDbAfttab criteriaParam = new EntDbAfttab();
// startTime = new Date().getTime();
criteriaParam.setFlno(arrFltNumb);
criteriaParam.setFlda(arrFltDate);
// criteriaParam.setAdid('A');
inboundUrno = _afttabBean.getUrnoByFldaFlnoAdid(
criteriaParam, null, bagDetails
.getInboundFlight()
.getDepartureAirport());