boolean isTotalBagWeightSet = false;
for (int i = 0; i < bagTagList.length; i++) {
if (bagTagList[i] != null && !"".equals(bagTagList[i].trim())) {
EntDbLoadBag entDbLoadBag = null;
boolean isLastBagRecord = false;
// int intSize = loadBagList.size();
for (int j = 0; j < loadBagList.size();) {
if (loadBagList.size() == 1){
isLastBagRecord = true;
}
if (bagTagList[i].equalsIgnoreCase(loadBagList.get(j)
.getBagTagStr())) {
entDbLoadBag = loadBagList.get(j);
loadBagList.remove(j);
break;
} else {
j++;
}
}
// pase bag tag str to bag tag info
String bagTagStr = bagTagList[i];
String bagTag = "000";
// 2013-11-14 updated by JGO - According to Jira: UFIS-3041
/*boolean isConvertionFoundFromMd = false;
Map<String, String> airlineCodeConvertMap = entStartupInitSingleton.getAirlineCodeCnvertMap();
Iterator airlineCodeConvertMapIt = airlineCodeConvertMap.entrySet().iterator();
if (bagTagStr != null && bagTagStr.length() > 10) {
bagTagStr = bagTagStr.trim();
String codeStr = bagTagStr.substring(0, 2);
LOG.info("airline code from bagTag info : {} , start to searching from master table",
codeStr);
while (airlineCodeConvertMapIt.hasNext()) {
Map.Entry<String, String> pairs = (Entry<String, String>) airlineCodeConvertMapIt
.next();
if (codeStr.equals(pairs.getKey())) {
bagTag = pairs.getValue()
+ bagTagStr.substring(2, 8);
isConvertionFoundFromMd = true;
LOG.info(
"airline code {} found from MD and convert to {}",
pairs.getKey(), pairs.getValue());
}
}
if (!isConvertionFoundFromMd) {
LOG.info(
"aline code {} not found in MD cache and set bagTag = 0",
codeStr);
}
// if ("EK".equalsIgnoreCase(codeStr)){
// bagTag = "0176" + bagTagStr.substring(2,8);
// }else{
// LOG.warn("Attention !, Unknown Bag Tag Info {}",
// bagTagStr);
// }
} else {
LOG.warn(
"Attention !, incorrect bag tag information {}",
bagTagStr);
}*/
String airline = null;
String iataNum = null;
if (bagTagStr != null && bagTagStr.length() > 10) {
bagTagStr = bagTagStr.trim();
airline = bagTagStr.substring(0, 2);
LOG.info("Airline code from bagTag info : {}", airline);
// find airline iata number
if (airlineIataNumber != null) {
iataNum = airlineIataNumber.get(airline);
} else {
LOG.warn("No ALTTAB info found, will manually mapping IATA code for known airline");
// if ALTTAB master data is empty or null, check airline code from tag
if ("EK".equalsIgnoreCase(airline)) {
iataNum = "0176";
} else {
LOG.warn("No Setting found for airline: {}", airline);
}
}
LOG.debug("IATA number for airline={} is: {}", airline, iataNum);
} else {
LOG.warn("Invalid bag tag information: {}", bagTagStr);
}
if (iataNum != null) {
bagTag = iataNum + bagTagStr.substring(2,8);
} else {
bagTag += bagTagStr.substring(2,8);
}
startTime = System.currentTimeMillis();
if (entDbLoadBag == null) {
entDbLoadBag = new EntDbLoadBag();
entDbLoadBag.setBagTagStr(bagTagStr); //
entDbLoadBag.setBagTag(bagTag);
entDbLoadBag.setBagType(bagType);
entDbLoadBag.setBagClassify("GATE");
// added by 2014-01-03
entDbLoadBag.setId_Flight(new BigDecimal(idFlight));
entDbLoadBag.setIdConxFlight(new BigDecimal(idConnFlight));
if ("A".equalsIgnoreCase(adid.toString())) {
entDbLoadBag.setIdArrFlight(idFlight);
// added by 2013.10.22
entDbLoadBag.setArrFlightNumber(mainFlightNumber);
entDbLoadBag.setFlightNumber(connFlightNumber);
entDbLoadBag.setArrFltDate(mainFlightDate);
entDbLoadBag.setFltDate(connFLightDate);
entDbLoadBag.setArrFltOrigin3(mainOrigin3);
entDbLoadBag.setFltOrigin3(connOrigin3);
entDbLoadBag.setArrFltDest3(mainDest3);
entDbLoadBag.setFltDest3(connDest3);
entDbLoadBag.setIdFlight(idConnFlight); // added by 2013-12-20
} else if ("D".equalsIgnoreCase(adid.toString())) {
entDbLoadBag.setIdFlight(idFlight);
// added by 2013.10.22
entDbLoadBag.setArrFlightNumber(connFlightNumber);
entDbLoadBag.setFlightNumber(mainFlightNumber);
entDbLoadBag.setArrFltDate(connFLightDate);
entDbLoadBag.setFltDate(mainFlightDate);
entDbLoadBag.setArrFltOrigin3(connOrigin3);
entDbLoadBag.setFltOrigin3(mainOrigin3);
entDbLoadBag.setArrFltDest3(connDest3);
entDbLoadBag.setFltDest3(mainDest3);
entDbLoadBag.setIdArrFlight(idConnFlight); // added by 2013-12-20
}
// added by 2013.12.10
if (isPaxCancelled){
entDbLoadBag.setRecStatus("I");
}
// added by 2013.10.22 2:19
if (entDbLoadPax.getTravelledClass() != null) {
entDbLoadBag.setBagClass(entDbLoadPax
.getTravelledClass());
} else {
entDbLoadBag.setBagClass(entDbLoadPax
.getBookedClass());
}
// added by 2013.10.22
if (!isTotalBagWeightSet) {
entDbLoadBag.setBagWeight(entDbLoadPax
.getBagWeight());
isTotalBagWeightSet = true;
} else {
entDbLoadBag.setBagWeight(new BigDecimal(0));
}
entDbLoadBag.setPaxRefNum(refNum);
entDbLoadBag.setPaxName(paxName);
entDbLoadBag.setIdLoadPax(idLoadPax);
if ("OF".equalsIgnoreCase(entDbLoadPax.getPaxStatus())){
entDbLoadBag.setRecStatus("X");
}else{
entDbLoadBag.setRecStatus(" ");
}
entDbLoadBag.setId((UUID.randomUUID()).toString());
dlLoadBagUpdateLocal.saveLoadBagMove(entDbLoadBag);
entDbLoadBag.setCreatedUser(HpEKConstants.MACS_PAX_DATA_SOURCE);
entDbLoadBag.setCreatedDate(HpUfisCalendar.getCurrentUTCTime());
entDbLoadBag
.setDataSource(HpEKConstants.MACS_PAX_DATA_SOURCE);
LOG.info(
"1.2.6 insert records to loadBag table for paxDetails Msg, takes {} ms",
(System.currentTimeMillis() - startTime));
if (isLastBagRecord){
// send notification
ufisTopicProducer.sendNotification(true, UfisASCommands.IRT,
String.valueOf(entDbLoadBag.getIdFlight()), null, entDbLoadBag);
}else{
// send notification
ufisTopicProducer.sendNotification(false, UfisASCommands.IRT,
String.valueOf(entDbLoadBag.getIdFlight()), null, entDbLoadBag);
}
} else if (entDbLoadBag != null) {
EntDbLoadBag oldEntDbLoadBag = (EntDbLoadBag)SerializationUtils.clone(entDbLoadBag);
// EntDbLoadBag entDbLoadBag = loadBagTagList.get(0);
entDbLoadBag.setBagTagStr(bagTagStr); //
entDbLoadBag.setBagTag(bagTag);
// entDbLoadBag.setIdFlight(idFlight);
entDbLoadBag.setPaxRefNum(refNum);
entDbLoadBag.setPaxName(paxName);
// entDbLoadBag.setIdLoadPax(idLoadPax);
entDbLoadBag.setRecStatus(" ");
// added by 2014-01-03
entDbLoadBag.setId_Flight(new BigDecimal(idFlight));
entDbLoadBag.setIdConxFlight(new BigDecimal(idConnFlight));
if ("A".equalsIgnoreCase(adid.toString())) {
entDbLoadBag.setIdArrFlight(idFlight);
// added by 2013.10.22
entDbLoadBag.setArrFlightNumber(mainFlightNumber);
entDbLoadBag.setFlightNumber(connFlightNumber);
entDbLoadBag.setArrFltDate(mainFlightDate);
entDbLoadBag.setFltDate(connFLightDate);
entDbLoadBag.setArrFltOrigin3(mainOrigin3);
entDbLoadBag.setFltOrigin3(connOrigin3);
entDbLoadBag.setArrFltDest3(mainDest3);
entDbLoadBag.setFltDest3(connDest3);
entDbLoadBag.setIdFlight(idConnFlight); // added by 2013-12-20
} else if ("D".equalsIgnoreCase(adid.toString())) {
entDbLoadBag.setIdFlight(idFlight);
// added by 2013.10.22
entDbLoadBag.setArrFlightNumber(connFlightNumber);
entDbLoadBag.setFlightNumber(mainFlightNumber);
entDbLoadBag.setArrFltDate(connFLightDate);
entDbLoadBag.setFltDate(mainFlightDate);
entDbLoadBag.setArrFltOrigin3(connOrigin3);
entDbLoadBag.setFltOrigin3(mainOrigin3);
entDbLoadBag.setArrFltDest3(connDest3);
entDbLoadBag.setFltDest3(mainDest3);
entDbLoadBag.setIdArrFlight(idConnFlight); // added by 2013-12-20
}
// added by 2013.10.22
if (!isTotalBagWeightSet) {
entDbLoadBag.setBagWeight(entDbLoadPax
.getBagWeight());
isTotalBagWeightSet = true;
} else {
entDbLoadBag.setBagWeight(new BigDecimal(0));
}
// dlLoadBagUpdateLocal.updateLoadedBag(entDbLoadBag);
entDbLoadBag.setUpdatedDate(HpUfisCalendar
.getCurrentUTCTime());
entDbLoadBag
.setUpdatedUser(HpEKConstants.MACS_PAX_DATA_SOURCE);
entDbLoadBag
.setDataSource(HpEKConstants.MACS_PAX_DATA_SOURCE);
entDbLoadBag.setUpdatedDate(HpUfisCalendar
.getCurrentUTCTime());
LOG.info(
"1.2.6 update records to loadBag table for paxDetails Msg, takes {} ms",
(System.currentTimeMillis() - startTime));
if (isLastBagRecord){
// send notification
ufisTopicProducer.sendNotification(true, UfisASCommands.URT,
String.valueOf(entDbLoadBag.getIdFlight()), oldEntDbLoadBag, entDbLoadBag);
}else{
// send notification
ufisTopicProducer.sendNotification(false, UfisASCommands.URT,
String.valueOf(entDbLoadBag.getIdFlight()), oldEntDbLoadBag, entDbLoadBag);
}
}
}
}
}
startTime = System.currentTimeMillis();
// update those deleted message
if (loadBagList != null && loadBagList.size() > 0) {
Iterator<EntDbLoadBag> loadBagIt = loadBagList.iterator();
while (loadBagIt.hasNext()) {
EntDbLoadBag loadBag = loadBagIt.next();
loadBag.setRecStatus("X");
loadBag.setUpdatedDate(new Date());
// dlLoadBagUpdateLocal.updateLoadedBag(loadBag);
loadBag.setUpdatedUser(HpEKConstants.MACS_PAX_DATA_SOURCE);
loadBag.setDataSource(HpEKConstants.MACS_PAX_DATA_SOURCE);
loadBag.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
if (loadBagIt.hasNext()){
// send notification
ufisTopicProducer.sendNotification(false, UfisASCommands.DRT,