LOG.debug("DXB or OMDB is found");
}
}
//flagDxbStn = false;
EntDbAirportWeather entMET = null;
String createdUser = msg.substring(20, 21).trim();
String observeTime = msg.substring(11, 17).trim();
String weatherRemark = msg.substring(17, 20).trim();
String validStart = msg.substring(21, 27).trim();
String validEnd = msg.substring(27, 33).trim();
String weatherText = msg.substring(33, msg.length());
if (HpUfisUtils.isNullOrEmptyStr(observeTime)) {
LOG.debug("ObserveTime is null or empty, skipped");
continue;
}
if (HpUfisUtils.isNullOrEmptyStr(createdUser)) {
LOG.debug("CreatedUser is null or empty, skipped");
continue;
}
if (HpUfisUtils.isNullOrEmptyStr(weatherText)) {
LOG.debug("WeatherText is null or empty, skipped");
continue;
}
LOG.info("Create User Code: {}", createdUser);
switch(createdUser){
case "A" : createdUser = HpEKConstants.A_INPUT_OFFICE; break;
case "C" : createdUser = HpEKConstants.C_INPUT_OFFICE; break;
case "D" : createdUser = HpEKConstants.D_INPUT_OFFICE; break;
case "I" : createdUser = HpEKConstants.I_INPUT_OFFICE; break;
case "L" : createdUser = HpEKConstants.L_INPUT_OFFICE; break;
case "M" : createdUser = HpEKConstants.M_INPUT_OFFICE; break;
case "S" : createdUser = HpEKConstants.S_INPUT_OFFICE; break;
case "T" : createdUser = HpEKConstants.T_INPUT_OFFICE; break;
default : {
LOG.debug("Input Office for CreatedUser is unknown. Default value LIDO is set.");
createdUser = HpEKConstants.LIDO_SOURCE; break;
}
}
LOG.info("Create User info: {}", createdUser);
//check icao and iata from Master data table APTTAB
List<EntDbApttab> aptList = clsEntStartUpInitSingleton.getCacheApt();
//to decide input icao and iata are correct checking with MD table APTTAB
boolean flag = false;
if (aptList != null) {
for (int i = 0; i < aptList.size(); i++) {
EntDbApttab entity = aptList.get(i);
if (icao.equals(entity.getApc4())) {
flag = true;
break;
}
}
}
if(!flag){
LOG.debug("Input ICAO is unknown(Not exist in APTTAB). Skipped input icao <{}>.", icao);
continue;
}
//if append = false, insert or update; append = true, only insert
EntDbAirportWeather weather = null;
UfisASCommands cmd = UfisASCommands.URT;
LOG.debug("Append: {}", isAppend);
if(!isAppend){
entMET = clsDlAirportWeather.findExistingByIcaoWeatherIndent(icao, weatherIndent);
if(entMET == null){
//entMET = new EntDbAirportWeather();
weather = new EntDbAirportWeather();
weather.setCreatedDate(HpUfisCalendar.getCurrentUTCTime());
weather.setCreatedUser(createdUser);
cmd = UfisASCommands.IRT;
}else {
weather = EntDbAirportWeather.valueOf(entMET);
weather.setUpdatedDate(HpUfisCalendar.getCurrentUTCTime());
weather.setUpdatedUser(HpEKConstants.LIDO_SOURCE);
}
}
else{
// no matter data existing or not, directly store in db
weather = new EntDbAirportWeather();
weather.setCreatedDate(HpUfisCalendar.getCurrentUTCTime());
weather.setCreatedUser(createdUser);
cmd = UfisASCommands.IRT;
}
weather.setMsgSendDate(convertFlDateToUTC(_input.getMeta().getMessageTime()));
weather.setAirportCodeIata(iata);
weather.setAirportCodeIcao(icao);
weather.setWeatherIndent(weatherIndent);
weather.setObserveTime(observeTime);
weather.setWeatherRemark(weatherRemark);
weather.setValidStart(validStart);
weather.setValidEnd(validEnd);
weather.setWeatherText(weatherText);
weather.setDataSource(HpEKConstants.LIDO_SOURCE);
//merge the input airport weather value to db
EntDbAirportWeather entity = clsDlAirportWeather.merge(weather);
LOG.info("Airport Weather for icao : <{}> has been processed.", icao);
// notification
if (HpUfisUtils.isNotEmptyStr(HpCommonConfig.notifyTopic)) {
// send notification message to topic