}
return true;
}
public EntDbLoadPax readStorePax(PaxDetails paxDetails, long irmtabRef) {
EntDbLoadPax result = null;
if (paxDetails != null) {
logLevel = entStartupInitSingleton.getIrmLogLev();
msgLogged = Boolean.FALSE;
if (irmtabRef > 0) {
msgLogged = Boolean.TRUE;
}
HpUfisCalendar ufisCalendar = new HpUfisCalendar();
ufisCalendar.setCustomFormat(HpEKConstants.MACS_TIME_FORMAT); // 2012-12-18 00:00:00
SimpleDateFormat macsTimeFormat = new SimpleDateFormat(HpEKConstants.MACS_TIME_FORMAT);
EntDbLoadPax edpiod = new EntDbLoadPax();
LoadPaxPK paxPk = new LoadPaxPK();
// check as it's a mandatory field
if (paxDetails.getMFLID() != null
&& !paxDetails.getMFLID().isEmpty()) {
paxPk.setIntflid(paxDetails.getMFLID());
} else {
LOG.info("Mandatory field MFL_ID is null or empty, PaxDetails Message is rejected");
sendErroNotification(EnumExceptionCodes.EMAND,irmtabRef);
return null;
}
// check as it's a mandatory field
if (paxDetails.getREFERENCENUMBER() != null
&& !paxDetails.getREFERENCENUMBER().isEmpty()) {
paxPk.setIntrefnumber(paxDetails.getREFERENCENUMBER());
} else {
LOG.info("Mandatory field REFERENCE_NUMBER is null or empty, PaxDetails Message is rejected");
sendErroNotification(EnumExceptionCodes.EMAND,irmtabRef);
return null;
}
// check wrong paxType condition when infant indicator have value I (added new logic by 2013-12-2)
if ("C".equalsIgnoreCase(paxDetails.getPAXTYPE()) && "I".equalsIgnoreCase(paxDetails.getINFANTINDICATOR())){
LOG.info("wrong paxType 'C' when infant indicator have value 'I', PaxDetails Message is rejected");
sendErroNotification(EnumExceptionCodes.EWPTY,irmtabRef);
return null;
}
// paxPk.setIntSystem("MACS");
edpiod.setIntSystem(HpEKConstants.MACS_PAX_DATA_SOURCE);
edpiod.setPKId(paxPk);
// edpiod.setpKId(paxPk);
// check as it's a mandatory field
if (paxDetails.getPAXID() != null
&& !paxDetails.getPAXID().isEmpty()) {
edpiod.setIntId(paxDetails.getPAXID());
} else {
LOG.info("Mandatory field PAX_ID is null or empty, PaxDetails Message is rejected");
sendErroNotification(EnumExceptionCodes.EMAND,irmtabRef);
return null;
}
edpiod.setDestination(paxDetails.getDESTINATION());
if (paxDetails.getPAXNAME() != null) {
String paxName = paxDetails.getPAXNAME().replaceAll("/", " ");
edpiod.setPaxName(paxName);
}
edpiod.setCabinClass(paxDetails.getCABINCLASS());
edpiod.setBookedClass(paxDetails.getBOOKEDCLASS());
edpiod.setPaxType(paxDetails.getPAXTYPE());
edpiod.setPaxGroupCode(paxDetails.getPAXGROUPCODE());
edpiod.setHandicapped(paxDetails.getHANDICAPPED());
edpiod.setUnAccompaniedMinor(paxDetails.getUNACCOMPANIEDMINOR());
edpiod.setPriorityPax(paxDetails.getPRIORITYPAX());
edpiod.setBoardingPassprint(paxDetails.getBOARDINGPASSPRINT());
// edpiod.setBagTagPrint(paxDetails.get); !!!! there is no this tag
// in current xsd
if(!Arrays.asList(bookingStatusList).contains(paxDetails.getPAXBOOKINGSTATUS())){
// blIrmtabFacade.updateIRMStatus(PaxProcessSingleton.nextUrno, "WNOMD");
LOG.warn("bookingStatus {} is not in the possible values from paxDetails msg and updated to IRMTAB, intId {}", paxDetails.getPAXBOOKINGSTATUS(), paxDetails.getPAXID());
sendErroNotification(EnumExceptionCodes.WENUM,irmtabRef);
}
edpiod.setPaxBookingStatus(paxDetails.getPAXBOOKINGSTATUS());
edpiod.setTravelledClass(paxDetails.getTRAVELLEDCLASS());
edpiod.setBagTagInfo(paxDetails.getVARIABLEDATA());
edpiod.setScanLocation(paxDetails.getSCANNEDLOCATION());
// set bag weight and piece, original data: e.g 002/0053/00
String bagPicAndWeight = "";
if (paxDetails.getNUMBEROFPCSWEIGHT() != null) {
bagPicAndWeight = paxDetails.getNUMBEROFPCSWEIGHT();
}
String numberOfBag = "0";
String weightOfBag = "0";
int tagIndex = bagPicAndWeight.indexOf("/");
int tagIndex2 = bagPicAndWeight.indexOf("/", tagIndex + 1);
if (bagPicAndWeight != null && !"".equals(bagPicAndWeight)
&& tagIndex > 0 && tagIndex2 > 0) {
numberOfBag = bagPicAndWeight.substring(0, tagIndex);
weightOfBag = bagPicAndWeight
.substring(tagIndex + 1, tagIndex2);
}
edpiod.setBagWeight(new BigDecimal(weightOfBag));
edpiod.setBagNoOfPieces(new BigDecimal(numberOfBag));
// // set check in date time
// String cheInDate = "";
// if (paxDetails.getCHECKINDATE() != null){
// cheInDate = paxDetails.getCHECKINDATE();
// }
// String cheInTime = paxDetails.getCHECKINTIME();
// String cheInDateTime = "";
// Date cheInDateTimeD = null;
//
// int spaceIndex = cheInDate.indexOf(" ");
//
// if (spaceIndex > 0 && cheInTime.length() >= 4){
// cheInDate = cheInDate.substring(0, spaceIndex);
// cheInDateTime = cheInDate +
// " "+cheInTime.substring(0,2)+":"+cheInTime.substring(2,4)+":00";
// try {
// cheInDateTimeD = new
// SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(cheInDateTime);
// edpiod.setCheckInDateTime(cheInDateTimeD);
// } catch (ParseException e) {
// LOG.debug("set cheInDateTime "+e.toString());
// }
// }
// set check in date time
if (paxDetails.getCHECKINDATE() != null
&& !paxDetails.getCHECKINDATE().isEmpty()) {
ufisCalendar.setTime(paxDetails.getCHECKINDATE(),
ufisCalendar.getCustomFormat());
if (paxDetails.getCHECKINTIME().length() >= 4) {
int hour = 0;
int min = 0;
try {
hour = Integer.parseInt(paxDetails.getCHECKINTIME()
.substring(0, 2));
min = Integer.parseInt(paxDetails.getCHECKINTIME()
.substring(2, 4));
} catch (Exception e) {
LOG.info("PaxDetails message Checking Time parse erro");
}
ufisCalendar.DateAdd(hour, EnumTimeInterval.Hours);
ufisCalendar.DateAdd(min, EnumTimeInterval.Minutes);
}
edpiod.setCheckInDateTime(ufisCalendar.getTime());
}
// // set scan date time
// String scanDate = "";
// if (paxDetails.getSCANNEDLOCALDATE() != null){
// scanDate = paxDetails.getSCANNEDLOCALDATE();
// }
// String scanTime = paxDetails.getSCANNEDLOCALTIME();
// String scanDateTime = "";
// Date scanDateTimeD = null;
//
// int scanSpaceIndex = scanDate.indexOf(" ");
//
// if (scanSpaceIndex > 0 && scanTime.length() >= 4){
// scanDate = scanDate.substring(0, scanSpaceIndex);
// scanDateTime = scanDate +
// " "+scanTime.substring(0,2)+":"+scanTime.substring(2,4)+":00";
// try {
// scanDateTimeD = new
// SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(scanDateTime);
// edpiod.setScanDateTime(scanDateTimeD);
// } catch (ParseException e) {
// LOG.debug("set scanDateTime "+e.toString());
// }
// }
//
edpiod.setBoardingStatus(paxDetails.getBOARDINGSTATUS());
edpiod.setCancelled(paxDetails.getCANCELLED());
edpiod.setOffLoadedPax(paxDetails.getOFFLOADEDPAX());
edpiod.setEtkType(paxDetails.getETKTYPE());
// set scan date time
if (paxDetails.getSCANNEDLOCALDATE() != null
&& !paxDetails.getSCANNEDLOCALDATE().isEmpty()) {
ufisCalendar.setTime(paxDetails.getSCANNEDLOCALDATE(),
ufisCalendar.getCustomFormat());
if (paxDetails.getCHECKINTIME().length() >= 4) {
int hour = 0;
int min = 0;
try {
hour = Integer.parseInt(paxDetails
.getSCANNEDLOCALTIME().substring(0, 2));
min = Integer.parseInt(paxDetails.getSCANNEDLOCALTIME()
.substring(2, 4));
} catch (Exception e) {
LOG.info("PaxDetails message Scanned Time parse erro");
}
ufisCalendar.DateAdd(hour, EnumTimeInterval.Hours);
ufisCalendar.DateAdd(min, EnumTimeInterval.Minutes);
}
edpiod.setScanDateTime(ufisCalendar.getTime());
}
// set date of birth
Date dob = null;
try {
String dobString = paxDetails.getDATEOFBIRTH();
if (dobString != null && !dobString.isEmpty()) {
dob = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
.parse(dobString);
}
edpiod.setDob(dob);
} catch (ParseException e) {
LOG.info("PaxDetails Message, dob parse erro");
}
edpiod.setNationality(paxDetails.getNATIONALITY());
edpiod.setGender(paxDetails.getGENDER());
if (Arrays.asList(statusOnBoardList).contains(paxDetails.getSTATUSONBOARD())){
// blIrmtabFacade.updateIRMStatus(PaxProcessSingleton.nextUrno, "WNOMD");
LOG.warn("statusOnBoard {} is not in the possible values from paxDetails msg and updated to IRMTAB, intId {}", paxDetails.getSTATUSONBOARD(), paxDetails.getPAXID());
sendErroNotification(EnumExceptionCodes.WENUM,irmtabRef);
}
edpiod.setStatusOnboard(paxDetails.getSTATUSONBOARD());
edpiod.setInfantIndicator(paxDetails.getINFANTINDICATOR());
edpiod.setCheckInAgentCode(paxDetails.getCHECKINAGENTCODE());
edpiod.setCheckInHandlingAgent(paxDetails.getCHECKINHANDLINGAGENT());
edpiod.setCheckInSequence(paxDetails.getCHECKINSEQUENCE());
edpiod.setCheckInCity(paxDetails.getCHECKINCITY());
edpiod.setBoardingAgentCode(paxDetails.getBOARDINGAGENTCODE());
edpiod.setBoardingHandlingAgent(paxDetails
.getBOARDINGHANDLINGAGENT());
// // set boarding datetime
// String boardingDate = "";
// if (paxDetails.getCHECKINDATE() != null){
// boardingDate = paxDetails.getBOARDINGDATE();
// }
// String boardingTime = paxDetails.getBOARDINGTIME();
// String boardingDateTime = "";
// Date boardingDateTimeD = null;
//
// int boardSpaceIndex = boardingDate.indexOf(" ");
//
// if (boardSpaceIndex > 0 && boardingTime.length() >= 4){
// boardingDate = boardingDate.substring(0, boardSpaceIndex);
// boardingDateTime = boardingDate +
// " "+boardingTime.substring(0,2)+":"+boardingTime.substring(2,4)+":00";
// try {
// boardingDateTimeD = new
// SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(boardingDateTime);
// edpiod.setBoardingDateTime(boardingDateTimeD);
// } catch (ParseException e) {
// LOG.debug("set boardingDateTime "+e.toString());
// }
// }
// set boarding datetime
if (paxDetails.getBOARDINGDATE() != null
&& !paxDetails.getBOARDINGDATE().isEmpty()) {
ufisCalendar.setTime(paxDetails.getBOARDINGDATE(),
ufisCalendar.getCustomFormat());
if (paxDetails.getBOARDINGTIME().length() >= 4) {
int hour = 0;
int min = 0;
try {
hour = Integer.parseInt(paxDetails.getBOARDINGTIME()
.substring(0, 2));
min = Integer.parseInt(paxDetails.getBOARDINGTIME()
.substring(2, 4));
} catch (Exception e) {
LOG.info("PaxDetails message Boarding Time parse erro");
}
ufisCalendar.DateAdd(hour, EnumTimeInterval.Hours);
ufisCalendar.DateAdd(min, EnumTimeInterval.Minutes);
}
edpiod.setBoardingDateTime(ufisCalendar.getTime());
}
// added by 2013.10.01 according to the new design document
edpiod.setUpgradeIndicator(paxDetails.getUPGRADEINDICATOR());
edpiod.setTransitIndicator(paxDetails.getTRANSITINDICATOR());
edpiod.setSeatNumber(paxDetails.getSEATNUMBER());
edpiod.setJtopPax(paxDetails.getJTOPPAXRELATION());
edpiod.setTransitBagIndicator(paxDetails.getTRANSITBAG());
edpiod.setETickedId(paxDetails.getETKID());
edpiod.setTicketNumber(paxDetails.getTICKETNUMBER());
// edpiod .setChkDigit(paxDetails.getch) !!! there is no CHKDIGIT tag in ICD
edpiod.setCouponNumber(paxDetails.getCOUPONNUMBER());
edpiod.setApdType(paxDetails.getAPDTYPE());
edpiod.setDocumentType(paxDetails.getDOCUMENTTYPE());
edpiod.setDocumentIssuedCountry(paxDetails.getCOUNTRYOFISSUE());
edpiod.setCountryOfBirth(paxDetails.getCOUNTRYOFBIRTH());
edpiod.setCountryOfResidence(paxDetails.getCOUNTRYOFRESIDENCE());
edpiod.setItnEmbarkation(paxDetails.getITNEMBARKATION());
edpiod.setItnDisembarkation(paxDetails.getITNDISEMBARKATION());
// edpiod.setScanStation(paxDetails.getSCANNEDLOCATION());
// "scan_station" or scan_location ?
// edpiod.setScanTerminal(paxDetails.getscan)
// edpiod.setScanTransferArea(scanTransferArea);
// edpiod.setScannerId(scannerId);
edpiod.setPaxStatus(paxDetails.getSTATUS());
try {
if(paxDetails.getEXPIRYDATE() != null && !"".equals(paxDetails.getEXPIRYDATE().trim())){
edpiod.setDocumentExpiryDate(macsTimeFormat.parse(paxDetails.getEXPIRYDATE()));
}
} catch (ParseException e) {
LOG.error("Erro when parsing the expire date from string to date, {}",e);
}
try {
if (paxDetails.getDATEOFISSUE() != null && !"".equals(paxDetails.getDATEOFISSUE())){
edpiod.setDocumentIssuedDate(macsTimeFormat.parse(paxDetails.getDATEOFISSUE()));
}
} catch (ParseException e) {
LOG.error("Erro when parsing the issue date from string date, {}",e);
}
// SimpleDateFormat dateOfBirthDf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");