HpUfisCalendar nowUtc = new HpUfisCalendar(new Date());
nowUtc.DateAdd(HpUfisAppConstants.OFFSET_LOCAL_UTC, EnumTimeInterval.Hours);
// TODO update event ???
//EntDbFevtab fevRecord = _fevBean.getFevtab(aftFlight.getUrno(), flightData.getFlightStatus());
EntDbFevtab fevRecord = _fevBean.getMacsFlightEvent(flightData.getMflId(), flightData.getFlightStatus());
if (fevRecord == null) {
fevRecord = new EntDbFevtab();
// 2013-12-30 updated by JGO - Change urno to uuid
// get id from jnotab
//fevRecord.setURNO(new BigDecimal(HpUfisUtils.formatJavaFevUrno(_jnoBean.getNextValueByKey("FEV-URNO", 1))));
// cdat
fevRecord.setCDAT(nowUtc.getCedaString());
// usec
fevRecord.setUSEC(MSGIF);
// intSystem and intFlid
fevRecord.setINAM(MSGIF);
fevRecord.setIFID(flightData.getMflId());
// ------------------------------------------------------
fevRecord.setUAFT(aftFlight.getUrno());
fevRecord.setSTNM("FLIGHT_STATUS");
fevRecord.setSTCO(flightData.getFlightStatus());
fevRecord.setSTTM(nowUtc.getCedaString());
fevRecord.setSTFL("");
//fevRecord.setSTRM("FLIGHT_STATUS");
//fevRecord.setUSEU(INTSYSTEM_MACS_FLT);
// 2013-12-26 updated by JGO - Changed tag
if (HpUfisUtils.isNotEmptyStr(flightData.getChanged())) {
HpUfisCalendar cal = new HpUfisCalendar(flightData.getChanged(),
HpEKConstants.MACS_TIME_FORMAT);
fevRecord.setLSTU(cal.getCedaString());
}
_fevBean.persist(fevRecord);
} else {
fevRecord.setUSEU(MSGIF);
fevRecord.setSTTM(nowUtc.getCedaString());
// 2013-12-26 updated by JGO - Changed tag
if (HpUfisUtils.isNotEmptyStr(flightData.getChanged())) {
HpUfisCalendar cal = new HpUfisCalendar(flightData.getChanged(),
HpEKConstants.MACS_TIME_FORMAT);
fevRecord.setLSTU(cal.getCedaString());
}
//fevRecord.setLSTU(nowUtc.getCedaString());
_fevBean.update(fevRecord);
}
} else {
// when afttab record is not found, use intsystem and intflid to insert event
HpUfisCalendar nowUtc = new HpUfisCalendar(new Date());
nowUtc.DateAdd(HpUfisAppConstants.OFFSET_LOCAL_UTC, EnumTimeInterval.Hours);
// TODO need to know whether same flight different event got different mflid
EntDbFevtab fevRecord = _fevBean.getFevtab(MSGIF, flightData.getMflId());
if (fevRecord == null) {
fevRecord = new EntDbFevtab();
// get id from jnotab
//fevRecord.setURNO(new BigDecimal(HpUfisUtils.formatJavaFevUrno(_jnoBean.getNextValueByKey("FEV-URNO", 1))));
// cdat
fevRecord.setCDAT(nowUtc.getCedaString());
// usec
fevRecord.setUSEC(MSGIF);
// intSystem and intFlid
fevRecord.setINAM(MSGIF);
fevRecord.setIFID(flightData.getMflId());
// ------------------------------------------------------
//fevRecord.setUAFT(result_entDbAfttab.getUrno());
fevRecord.setSTNM("FLIGHT_STATUS");
fevRecord.setSTCO(flightData.getFlightStatus());
fevRecord.setSTTM(nowUtc.getCedaString());
fevRecord.setSTFL("");
//fevRecord.setSTRM("FLIGHT_STATUS");
//fevRecord.setUSEU(INTSYSTEM_MACS_FLT);
//fevRecord.setLSTU(nowUtc.getCedaString());
_fevBean.persist(fevRecord);
}