if (!mandatoryValid) {
return false;
}
HpUfisCalendar ufisCalendar = new HpUfisCalendar();
//ufisCalendar.setCustomFormat(HpEKConstants.DMIS_TIME_FORMAT);
INFOBJGENERIC infobjgeneric = new INFOBJGENERIC();
INFOBJFLIGHT infobjFlight = new INFOBJFLIGHT();
INFOJXAFTAB infojxaftab = new INFOJXAFTAB();
FlightInfo flightInfo = null;
String adid = "";
String patkingT = "";
String dubaiOrigin = "N";
String viaRoutes = "";
String arrivalStation = "";
String departureStation = "";
boolean isXafFound = false;
if (flightEvent.getFlightInfo() != null) {
flightInfo = flightEvent.getFlightInfo();
// Format the flno as ufis format
String alc2 = "";
String fltn = "";
String flns = "";
String flno = "";
if (flightInfo.getFlightNumber() != null && flightInfo.getFlightNumber().length() > 5) {
alc2 = flightInfo.getFlightNumber().substring(0, 2);
fltn = flightInfo.getFlightNumber().substring(2, 6);
fltn = HpUfisUtils.formatCedaFltn(fltn);
if ("".equals(fltn)) {
LOG.debug("FlightNumber should follow format as IATA airline code + 4 digits number + 1 digit suffix(optional) ");
//LOG.debug("Message dropped: \n{}", _flightXml);
addExptInfo(EnumExceptionCodes.EWFMT.name(),
"FlightNumber should follow format as IATA airline code + 4 digits number + 1 digit suffix(optional)");
return false;
}
// flns
if (flightInfo.getFlightNumber().length() == 7) {
flns = flightInfo.getFlightNumber().substring(6);
}
} else {
LOG.error("Wrong format of flight number");
addExptInfo(EnumExceptionCodes.EWVAL.name(),
"FlightNumber should follow format as IATA airline code + 4 digits number + 1 digit suffix(optional)");
return false;
}
infobjFlight.setALC2(alc2);
infobjFlight.setFLTN(fltn);
flno = HpUfisUtils.formatCedaFlno(alc2, fltn, flns);
infobjFlight.setFLNO(flno);
infobjgeneric.setFLNO(flno);
//Get the Suffix
if (flightInfo.getFlightNumber() != null && flightInfo.getFlightNumber().length() > 6) {
infobjFlight.setFLNS(flightInfo.getFlightNumber().substring(6));
}
// adid
adid = flightInfo.getArrivalDepartureFlag();
// schedule date in UTC from message
//if (flightInfo.getScheduledDate() != null) {
if (HpUfisUtils.isNotEmptyStr(flightInfo.getScheduledDate())) {
if (flightInfo.getScheduledDate().matches(DT_LOC_SS)) {
try {
xmlGregCal = DatatypeFactory.newInstance()
.newXMLGregorianCalendar(flightInfo.getScheduledDate());
//ufisCalendar.setTime(flightInfo.getScheduledDate(), ufisCalendar.getCustomFormat());
ufisCalendar.setTime(xmlGregCal);
// flda in utc
//infobjFlight.setFLUT(ufisCalendar.getCedaDateString());
infobjFlight.setFLUT(DF_CEDADATE.format(ufisCalendar.getTime()));
// STDT
//infobjgeneric.setSTDT(ufisCalendar.getCedaString());
infobjgeneric.setSTDT(DF_CEDA.format(ufisCalendar.getTime()));
// flda in local
ufisCalendar.DateAdd(HpUfisAppConstants.OFFSET_UTC_LOCAL, EnumTimeInterval.Hours);
//infobjFlight.setFLDA(ufisCalendar.getCedaDateString());
infobjFlight.setFLDA(DF_CEDADATE.format(ufisCalendar.getTime()));
} catch (DatatypeConfigurationException e) {
LOG.error("DatatypeConfigurationException: {}", e);
//LOG.debug("Dropped Message details: \n{}", _flightXml);
addExptInfo(EnumExceptionCodes.EWVAL.name(),
EnumExceptionCodes.EWVAL.toString());
return false;
}
} else {
LOG.error("ScheduledDate format not matched with patten={}", DT_LOC_SS);
LOG.error("ScheduledDate correct format should like: yyyy-MM-ddTHH:mm:ss[+-]hh:mm");
//LOG.debug("Dropped Message details: \n{}", _flightXml);
addExptInfo(EnumExceptionCodes.EWFMT.name(),
EnumExceptionCodes.EWFMT.toString());
return false;
}
} else {
LOG.error("ScheduledDate with wrong format or NULL");
//LOG.debug("Dropped Message details: \n{}", _flightXml);
addExptInfo(EnumExceptionCodes.EWFMT.name(),
EnumExceptionCodes.EWFMT.toString());
return false;
}
// For aircraft type processing, igore data from aircraftype tag
// intead of using aircraft type include in regn (handle by Ceda)
// if not EK or QF flight, then drop
/*if (!"EK".equalsIgnoreCase(alc2) && !"QF".equalsIgnoreCase(alc2)) {
LOG.debug("DMIS Flight message has been dropped due to non-EK and non-QF flights");
//LOG.debug("Dropped Message details: \n{}", _flightXml);
addExptInfo(EnumExceptionCodes.EWALC.name(),
"Non EK or QF flight found");
return false;
} else*/
if ("EK".equalsIgnoreCase(alc2)) {
// ===========================
// EK flights
// ===========================
// action type
_msgActionType = ACTIONTYPE.U;
// schedule date
//ufisCalendar.setTime(flightInfo.getScheduledDate(), ufisCalendar.getCustomFormat());
infobjFlight.setFLNO(null);
infobjFlight.setALC2(null);
infobjFlight.setFLTN(null);
infobjFlight.setFLDA(null);
infobjFlight.setFLUT(null);
switch (adid) {
case "A":
//infobjFlight.setSTOA(ufisCalendar.getCedaString());
//infobjFlight.setADID(ADID.A);
infobjgeneric.setADID(ADID.A);
if (flightInfo.getBayNumber() != null && flightInfo.getBayNumber().getValue() != null) {
infobjFlight.setPSTA(flightInfo.getBayNumber().getValue());
}
if (flightInfo.getGateNumber() != null && flightInfo.getGateNumber().getValue() != null) {
infobjFlight.setGTA1(flightInfo.getGateNumber().getValue());
}
break;
case "D":
//infobjFlight.setSTOD(ufisCalendar.getCedaString());
//infobjFlight.setADID(ADID.D);
infobjgeneric.setADID(ADID.D);
if (flightInfo.getBayNumber() != null && flightInfo.getBayNumber().getValue() != null) {
infobjFlight.setPSTD(flightInfo.getBayNumber().getValue());
}
if (flightInfo.getGateNumber() != null && flightInfo.getGateNumber().getValue() != null) {
infobjFlight.setGTD1(flightInfo.getGateNumber().getValue());
}
break;
}
// short final date
if (HpUfisUtils.isNotEmptyStr(flightInfo.getShortFinalDate())) {
//ufisCalendar.setTime(flightInfo.getShortFinalDate(), ufisCalendar.getCustomFormat());
//infobjFlight.setSFIN(ufisCalendar.getCedaString());
if (flightInfo.getShortFinalDate().matches(DT_LOC_SS)) {
try {
xmlGregCal = DatatypeFactory.newInstance()
.newXMLGregorianCalendar(flightInfo.getShortFinalDate());
ufisCalendar.setTime(xmlGregCal);
infobjFlight.setSFIN(DF_CEDA.format(ufisCalendar.getTime()));
} catch (DatatypeConfigurationException e) {
LOG.error("DatatypeConfigurationException: {}", e.getMessage());
}
} else {
LOG.error("ShortFinalDate format not matched with patten={}", DT_LOC_SS);
LOG.error("ShortFinalDate correct format should like: yyyy-MM-ddTHH:mm:ss[+-]hh:mm");
}
}
} else {
// ===========================
// QF flights
// ===========================
if (flightInfo.getParkingTerminal() != null && flightInfo.getParkingTerminal().getValue() != null) {
patkingT = flightInfo.getParkingTerminal().getValue().toString();
}
if (flightInfo.getDubaiOrigin() != null && flightInfo.getDubaiOrigin().getValue() != null) {
dubaiOrigin = flightInfo.getDubaiOrigin().getValue().toString();
}
LOG.info("DubaiOrigin {}", dubaiOrigin);
//Manipulate arrivalStation / DepartureStation
//Split by /
viaRoutes = flightInfo.getViaRoutes();
// 2013-12-27 updated by JGO - adding ROUT(AFTTAB) to store the routes info
infobjFlight.setROUT(viaRoutes.replaceAll("/", "|"));
arrivalStation = flightInfo.getArrivalStation();
departureStation = flightInfo.getDepartureStation();
switch (adid) {
case "A":
//infobjFlight.setSTOA(ufisCalendar.getCedaString());
infobjFlight.setSTOA(infobjgeneric.getSTDT());
infobjFlight.setADID(ADID.A);
infobjFlight.setTRMA(patkingT);
infobjFlight.setDES3(HpEKConstants.HOPO);
if (flightInfo.getEstimatedDate() != null
&& HpUfisUtils.isNotEmptyStr(flightInfo.getEstimatedDate().getValue())) {
//ufisCalendar.setTime(flightInfo.getEstimatedDate().getValue(), ufisCalendar.getCustomFormat());
//infobjFlight.setEIBR(ufisCalendar.getCedaString());
if (flightInfo.getEstimatedDate().getValue().matches(DT_LOC_SS)) {
try {
xmlGregCal = DatatypeFactory.newInstance()
.newXMLGregorianCalendar(flightInfo.getEstimatedDate().getValue());
ufisCalendar.setTime(xmlGregCal);
infobjFlight.setEIBD(DF_CEDA.format(ufisCalendar.getTime()));
} catch (DatatypeConfigurationException e) {
LOG.error("DatatypeConfigurationException: {}", e.getMessage());
}
} else {
LOG.error("EstimatedDate format not matched with patten={}", DT_LOC_SS);
LOG.error("EstimatedDate correct format should like: yyyy-MM-ddTHH:mm:ss[+-]hh:mm");
}
}
if (flightInfo.getLatestDate() != null
&& HpUfisUtils.isNotEmptyStr(flightInfo.getLatestDate().getValue())) {
//ufisCalendar.setTime(flightInfo.getLatestDate().getValue(), ufisCalendar.getCustomFormat());
//infobjFlight.setTLDR(ufisCalendar.getCedaString());
if (flightInfo.getLatestDate().getValue().matches(DT_LOC_SS)) {
try {
xmlGregCal = DatatypeFactory.newInstance()
.newXMLGregorianCalendar(flightInfo.getLatestDate().getValue());
ufisCalendar.setTime(xmlGregCal);
infobjFlight.setTLDD(DF_CEDA.format(ufisCalendar.getTime()));
} catch (DatatypeConfigurationException e) {
LOG.error("DatatypeConfigurationException: {}", e.getMessage());
}
} else {
LOG.error("LatestDate format not matched with patten={}", DT_LOC_SS);
LOG.error("LatestDate correct format should like: yyyy-MM-ddTHH:mm:ss[+-]hh:mm");
}
}
/*if (HpUfisUtils.isNotEmptyStr(flightInfo.getActualDate().getValue())) {
ufisCalendar.setTime(flightInfo.getActualDate().getValue(), ufisCalendar.getCustomFormat());
//ufisCalendar.setTime(flightInfo.getTouchdownAirborneDate().getValue());
}*/
if (HpUfisUtils.isNotEmptyStr(flightInfo.getTouchdownAirborneDate())) {
//ufisCalendar.setTime(flightInfo.getTouchdownAirborneDate(), ufisCalendar.getCustomFormat());
//infobjFlight.setALDR(ufisCalendar.getCedaString());
if (flightInfo.getTouchdownAirborneDate().matches(DT_LOC_SS)) {
try {
xmlGregCal = DatatypeFactory.newInstance()
.newXMLGregorianCalendar(flightInfo.getTouchdownAirborneDate());
ufisCalendar.setTime(xmlGregCal);
infobjFlight.setALDD(DF_CEDA.format(ufisCalendar.getTime()));
} catch (DatatypeConfigurationException e) {
LOG.error("DatatypeConfigurationException: {}", e.getMessage());
}
} else {
LOG.error("TouchdownAirborneDate format not matched with patten={}", DT_LOC_SS);
LOG.error("TouchdownAirborneDate correct format should like: yyyy-MM-ddTHH:mm:ss[+-]hh:mm");
}
}
if (flightInfo.getBayNumber() != null && flightInfo.getBayNumber().getValue() != null) {
infobjFlight.setPSTA(flightInfo.getBayNumber().getValue());
}
if (flightInfo.getGateNumber() != null && flightInfo.getGateNumber().getValue() != null) {
infobjFlight.setGTA1(flightInfo.getGateNumber().getValue());
}
if (flightInfo.getBaggageBeltNumber() !=
null && flightInfo.getBaggageBeltNumber().getValue() != null) {
infobjFlight.setBLT1(flightInfo.getBaggageBeltNumber().getValue());
}
//Set ORG3 base on depStation
//Split with /
if (viaRoutes != null && viaRoutes.contains("/")) {
String[] splitviaRoutes = viaRoutes.split("/");
for (int i = 0; i < splitviaRoutes.length; i++) {
if (i == 0) {
infobjFlight.setORG3(splitviaRoutes[i]);
}
if (i == 1) {
//infobjFlight.setVIA3(splitviaRoutes[i]);
if (HpUfisUtils.isNotEmptyStr(splitviaRoutes[i])) {
infobjFlight.setVIAN("1");
infobjFlight.setVIAL(formatVial(splitviaRoutes[i]));
}
}
}
} else {
infobjFlight.setORG3(departureStation);
}
break;
case "D":
//infobjFlight.setSTOD(ufisCalendar.getCedaString());
infobjFlight.setSTOD(infobjgeneric.getSTDT());
infobjFlight.setADID(ADID.D);
infobjFlight.setTRMD(patkingT);
infobjFlight.setORG3(HpEKConstants.HOPO);
if (flightInfo.getEstimatedDate() != null
&& HpUfisUtils.isNotEmptyStr(flightInfo.getEstimatedDate().getValue())) {
//ufisCalendar.setTime(flightInfo.getEstimatedDate().getValue(), ufisCalendar.getCustomFormat());
//infobjFlight.setEOBR(ufisCalendar.getCedaString());
if (flightInfo.getEstimatedDate().getValue().matches(DT_LOC_SS)) {
try {
xmlGregCal = DatatypeFactory.newInstance()
.newXMLGregorianCalendar(flightInfo.getEstimatedDate().getValue());
ufisCalendar.setTime(xmlGregCal);
infobjFlight.setEOBD(DF_CEDA.format(ufisCalendar.getTime()));
} catch (DatatypeConfigurationException e) {
LOG.error("DatatypeConfigurationException: {}", e.getMessage());
}
} else {
LOG.error("EstimatedDate format not matched with patten={}", DT_LOC_SS);
LOG.error("EstimatedDate correct format should like: yyyy-MM-ddTHH:mm:ss[+-]hh:mm");
}
}
if (flightInfo.getLatestDate() != null
&& HpUfisUtils.isNotEmptyStr(flightInfo.getLatestDate().getValue())) {
//ufisCalendar.setTime(flightInfo.getLatestDate().getValue(), ufisCalendar.getCustomFormat());
//infobjFlight.setTLDR(ufisCalendar.getCedaString());
if (flightInfo.getLatestDate().getValue().matches(DT_LOC_SS)) {
try {
xmlGregCal = DatatypeFactory.newInstance()
.newXMLGregorianCalendar(flightInfo.getLatestDate().getValue());
ufisCalendar.setTime(xmlGregCal);
infobjFlight.setTLDD(DF_CEDA.format(ufisCalendar.getTime()));
} catch (DatatypeConfigurationException e) {
LOG.error("DatatypeConfigurationException: {}", e.getMessage());
}
} else {
LOG.error("LatestDate format not matched with patten={}", DT_LOC_SS);
LOG.error("LatestDate correct format should like: yyyy-MM-ddTHH:mm:ss[+-]hh:mm");
}
}
/*if (HpUfisUtils.isNotEmptyStr(flightInfo.getActualDate().getValue())) {
ufisCalendar.setTime(flightInfo.getActualDate().getValue(), ufisCalendar.getCustomFormat());
//ufisCalendar.setTime(flightInfo.getTouchdownAirborneDate().getValue());
}*/
if (HpUfisUtils.isNotEmptyStr(flightInfo.getTouchdownAirborneDate())) {
//ufisCalendar.setTime(flightInfo.getTouchdownAirborneDate(), ufisCalendar.getCustomFormat());
//infobjFlight.setATOR(ufisCalendar.getCedaString());
if (flightInfo.getTouchdownAirborneDate().matches(DT_LOC_SS)) {
try {
xmlGregCal = DatatypeFactory.newInstance()
.newXMLGregorianCalendar(flightInfo.getTouchdownAirborneDate());
ufisCalendar.setTime(xmlGregCal);
infobjFlight.setATOD(DF_CEDA.format(ufisCalendar.getTime()));
} catch (DatatypeConfigurationException e) {
LOG.error("DatatypeConfigurationException: {}", e.getMessage());
}
} else {
LOG.error("TouchdownAirborneDate format not matched with patten={}", DT_LOC_SS);
LOG.error("TouchdownAirborneDate correct format should like: yyyy-MM-ddTHH:mm:ss[+-]hh:mm");
}
}
if (flightInfo.getBayNumber() != null && flightInfo.getBayNumber().getValue() != null) {
infobjFlight.setPSTD(flightInfo.getBayNumber().getValue());
}
if (flightInfo.getGateNumber() != null && flightInfo.getGateNumber().getValue() != null) {
infobjFlight.setGTD1(flightInfo.getGateNumber().getValue());
}
//Set DES3 base on arrivalStation
if (viaRoutes != null && viaRoutes.contains("/")) {
String[] splitviaRoutes = viaRoutes.split("/");
for (int i = 0; i < splitviaRoutes.length; i++) {
if (i == 0) {
//infobjFlight.setVIA3(splitviaRoutes[i]);
if (HpUfisUtils.isNotEmptyStr(splitviaRoutes[i])) {
infobjFlight.setVIAN("1");
infobjFlight.setVIAL(formatVial(splitviaRoutes[i]));
}
}
if (i == splitviaRoutes.length - 1) {
infobjFlight.setDES3(splitviaRoutes[i]);
}
}
} else {
infobjFlight.setDES3(arrivalStation);
}
break;
}
//Aircraft Type Code Eg. A330200
//Need to format and break into 2 fields
if (flightInfo.getAircraftType() != null
&& flightInfo.getAircraftType().getValue() != null) {
infobjFlight.setACT3(flightInfo.getAircraftType().getValue().substring(0, 3));
infobjFlight.setACT5(flightInfo.getAircraftType().getValue().substring(3));
}
if (flightInfo.getRegistrationNumber() != null
&& flightInfo.getRegistrationNumber().getValue() != null) {
infobjFlight.setREGN(flightInfo.getRegistrationNumber().getValue());
}
//Airline
if (flightInfo.getAirlineCode() != null
&& flightInfo.getAirlineCode().getValue() != null) {
if (flightInfo.getAirlineCode().getValue().length() == 2) {
infobjFlight.setALC2(flightInfo.getAirlineCode().getValue());
} else if (flightInfo.getAirlineCode().getValue().length() == 3) {
infobjFlight.setALC3(flightInfo.getAirlineCode().getValue());
}
}
//Handling Terminal
if (flightInfo.getHandlingTerminal() != null
&& flightInfo.getHandlingTerminal().getValue() != null) {
String stev = flightInfo.getHandlingTerminal().getValue().toString();
Matcher m = p.matcher(stev);
stev = m.replaceAll("");
infobjFlight.setSTEV(stev);
}
//Code Share fixed len
//A3 1808 LG 1561 SK 3215 TP 7962 UA 9524
StringBuilder codeShareBuilder = new StringBuilder();
int codeShareCount = 0;
boolean codeShareEnable = false;
if (codeShareEnable == true) {
if (flightInfo.getCodeshareFlight1() != null
&& flightInfo.getCodeshareFlight1().getValue() != null
&& flightInfo.getCodeshareFlight1().getValue().length() > 1) {
codeShareBuilder.append(String.format("%-" + CODESHARESPACE + "s", flightInfo.getCodeshareFlight1().getValue()));
codeShareCount++;
}
if (flightInfo.getCodeshareFlight2() != null
&& flightInfo.getCodeshareFlight2().length() > 1) {
codeShareBuilder.append(String.format("%-" + CODESHARESPACE + "s", flightInfo.getCodeshareFlight2()));
codeShareCount++;
}
if (flightInfo.getCodeshareFlight3() != null
&& flightInfo.getCodeshareFlight3().length() > 1) {
codeShareBuilder.append(String.format("%-" + CODESHARESPACE + "s", flightInfo.getCodeshareFlight3()));
codeShareCount++;
}
if (flightInfo.getCodeshareFlight4() != null
&& flightInfo.getCodeshareFlight4().length() > 1) {
codeShareBuilder.append(String.format("%-" + CODESHARESPACE + "s", flightInfo.getCodeshareFlight4()));
codeShareCount++;
}
if (flightInfo.getCodeshareFlight5() != null
&& flightInfo.getCodeshareFlight5().length() > 1) {
codeShareBuilder.append(String.format("%-" + CODESHARESPACE + "s", flightInfo.getCodeshareFlight5()));
codeShareCount++;
}
if (codeShareCount > 0) {
infobjFlight.setJFNO(codeShareBuilder.toString());
infobjFlight.setJCNT(Integer.toString(codeShareCount));
}
}
// short final date
if (HpUfisUtils.isNotEmptyStr(flightInfo.getShortFinalDate())) {
//ufisCalendar.setTime(flightInfo.getShortFinalDate(), ufisCalendar.getCustomFormat());
//infobjFlight.setSFIN(ufisCalendar.getCedaString());
if (flightInfo.getShortFinalDate().matches(DT_LOC_SS)) {
try {
xmlGregCal = DatatypeFactory.newInstance()
.newXMLGregorianCalendar(flightInfo.getShortFinalDate());
ufisCalendar.setTime(xmlGregCal);
infobjFlight.setSFIN(DF_CEDA.format(ufisCalendar.getTime()));
} catch (DatatypeConfigurationException e) {
LOG.error("DatatypeConfigurationException: {}", e.getMessage());
}
} else {
LOG.error("ShortFinalDate format not matched with patten={}", DT_LOC_SS);
LOG.error("ShortFinalDate correct format should like: yyyy-MM-ddTHH:mm:ss[+-]hh:mm");
}
}
// choksOn
if (HpUfisUtils.isNotEmptyStr(flightInfo.getChoksOnDate())) {
if (flightInfo.getChoksOnDate().matches(DT_LOC_SS)) {
try {
xmlGregCal = DatatypeFactory.newInstance()
.newXMLGregorianCalendar(flightInfo.getChoksOnDate());
ufisCalendar.setTime(xmlGregCal);
infobjFlight.setAIBD(DF_CEDA.format(ufisCalendar.getTime()));
} catch (DatatypeConfigurationException e) {
LOG.error("DatatypeConfigurationException: {}", e.getMessage());
}
} else {
LOG.error("ChoksOnDate format not matched with patten={}", DT_LOC_SS);
LOG.error("ChoksOnDate correct format should like: yyyy-MM-ddTHH:mm:ss[+-]hh:mm");
}
}
// choksOff
if (HpUfisUtils.isNotEmptyStr(flightInfo.getChoksOffDate())) {
if (flightInfo.getChoksOffDate().matches(DT_LOC_SS)) {
try {
xmlGregCal = DatatypeFactory.newInstance()
.newXMLGregorianCalendar(flightInfo.getChoksOffDate());
ufisCalendar.setTime(xmlGregCal);
infobjFlight.setAOBD(DF_CEDA.format(ufisCalendar.getTime()));
} catch (DatatypeConfigurationException e) {
LOG.error("DatatypeConfigurationException: {}", e.getMessage());
}
} else {
LOG.error("ChoksOnDate format not matched with patten={}", DT_LOC_SS);