Package ek.proveo.telemetryDataMessage

Examples of ek.proveo.telemetryDataMessage.EventTypes


  public boolean routeMessage(Message inMessage, String message,
      InterfaceConfig interfaceConfig, Long irmtabRef) {
    long startTime = new Date().getTime();
    TelemetryDataMessages proveoMessage = new TelemetryDataMessages();
    List<TelemetryDataMessage> telemetryMsgList = Collections.EMPTY_LIST;
    EventTypes eventType = null;
    EntDbEquipPos equipPosIns;
    String dtflString = _startupInitSingleton.getDtflStr();
    msgLogged = Boolean.FALSE;
    logLevel = _startupInitSingleton.getIrmLogLev();
    // List<EntDbEquipPos> equipPosPersistRecs = new
    // ArrayList<EntDbEquipPos>();
    // String cmdForBroadcasting = null;
    EntDbEquipPos equipPosPersistRec = null;
    Boolean isLast = Boolean.FALSE;
    if (irmtabRef > 0) {
      msgLogged = Boolean.TRUE;
    }
    try {
      JAXBElement<TelemetryDataMessages> data = _um.unmarshal(
          new StreamSource(new StringReader(message)),
          TelemetryDataMessages.class);
      proveoMessage = (TelemetryDataMessages) data.getValue();
      if (proveoMessage == null) {
        LOG.info(
            " Dropping the message. Message is NOT Valid. MSG : {}",
            message);
        if (logLevel
            .equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
                .name())) {
          if (!msgLogged) {
            irmtabRef = _irmfacade.storeRawMsg(inMessage,
                dtflString);
            msgLogged = Boolean.TRUE;
          }
        }
        if (irmtabRef > 0) {
          sendErrInfo(EnumExceptionCodes.EXSDF, irmtabRef,
              "Invalid Message");

        }
        return false;
      }
      if (proveoMessage.getTelemetryDataMessage().isEmpty()) {
        LOG.info(
            "Dropping the message. No TelemetryDataMessages are defined in the MSG: {}",
            message);
        if (logLevel
            .equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
                .name())) {
          if (!msgLogged) {
            irmtabRef = _irmfacade.storeRawMsg(inMessage,
                dtflString);
            msgLogged = Boolean.TRUE;
          }
        }
        if (irmtabRef > 0) {
          sendErrInfo(EnumExceptionCodes.EXSDF, irmtabRef,
              "No TelemetryDataMessage defined");

        }
        return false;
      }
      if (proveoMessage.getEventType() == null) {
        LOG.info(
            "Dropping the message. Event Type is either not specified or an Invalid value(NOT in GEO,STATE,NOTIFY) in the MSG : {}",
            message);
        if (logLevel
            .equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
                .name())) {
          if (!msgLogged) {
            irmtabRef = _irmfacade.storeRawMsg(inMessage,
                dtflString);
            msgLogged = Boolean.TRUE;
          }
        }
        if (irmtabRef > 0) {
          sendErrInfo(EnumExceptionCodes.EWEVT, irmtabRef,
              "Event Type is NULL(Invalid Or Not Specified)");

        }
        return false;
      }
      if (mdEquipMap.isEmpty()) {
        LOG.info("Loading masterdata EntDbMdEquip into Map");
        // List<EntDbMdEquip> equipMasterdataList =
        // _startupInitSingleton.getMdEquipList();
        // for (EntDbMdEquip equipEnt : equipMasterdataList) {
        // mdEquipMap.put(equipEnt.getEquipNum(), equipEnt);
        // }
        mdEquipMap = _startupInitSingleton.getMdEquipList();
      }
      if (mdEquipLocMap.isEmpty()) {
        LOG.info("Loading masterdata EntDbMdEquipLoc into Map");
        // List<EntDbMdEquipLoc> equipMasterdataList =
        // _startupInitSingleton.getMdEquipLocList();
        // for (EntDbMdEquipLoc equipEntLoc : equipMasterdataList) {
        // mdEquipLocMap.put(equipEntLoc.getEquipArea(), equipEntLoc);
        // }
        mdEquipLocMap = _startupInitSingleton.getMdEquipLocList();
      }

      if ((_startupInitSingleton.isMdEquipLocOn() && mdEquipLocMap
          .isEmpty())
          || (_startupInitSingleton.isMdEquipOn() && mdEquipMap
              .isEmpty())) {
        LOG.error("Either of Master data(MD_EQUIP/MD_EQUIP_LOC) is EMPTY");
      }
      telemetryMsgList = proveoMessage.getTelemetryDataMessage();
      eventType = proveoMessage.getEventType();
      LOG.info("Total TelemetryDataMessages : {}",
          telemetryMsgList.size() + "   Time For Mandatory Checks:"
              + (new Date().getTime() - startTime));
      int size = telemetryMsgList.size();
      for (TelemetryDataMessage teleMsg : telemetryMsgList) {

        if (teleMsg.equals(telemetryMsgList.get(size - 1))) {
          isLast = Boolean.TRUE;
        }
        LOG.debug("ISLAST:{}", isLast);
        long startTime1 = new Date().getTime();
        // LOG.info("Processing TelemetryDataMessages : {}",
        // (startTime1));
        if (HpUfisUtils.isNullOrEmptyStr(teleMsg.getMessageId())) {
          LOG.info(
              "Dropping the message.Mandatory Field Message ID is not Specified in the TeleMessage. Tele Message ID:{}",
              teleMsg.getMessageId());
          if (logLevel
              .equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
                  .name())) {
            if (!msgLogged) {
              irmtabRef = _irmfacade.storeRawMsg(inMessage,
                  dtflString);
              msgLogged = Boolean.TRUE;
            }
          }
          if (irmtabRef > 0) {
            sendErrInfo(
                EnumExceptionCodes.EMAND,
                irmtabRef,
                ("Message Id(Mandatory Field) is Null. Tele Message ID:" + teleMsg
                    .getMessageId()));
          }
          continue;
        }
        if (HpUfisUtils.isNullOrEmptyStr(teleMsg.getProveoId())
            || HpUfisUtils.isNullOrEmptyStr(teleMsg.getUnitName())) {
          LOG.info(
              "Dropping the message.Mandatory Field (Proveo ID/Unit Name) is not Specified in the message. Tele Message ID:{}",
              teleMsg.getMessageId());
          if (logLevel
              .equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
                  .name())) {
            if (!msgLogged) {
              irmtabRef = _irmfacade.storeRawMsg(inMessage,
                  dtflString);
              msgLogged = Boolean.TRUE;
            }
          }
          if (irmtabRef > 0) {
            sendErrInfo(
                EnumExceptionCodes.EMAND,
                irmtabRef,
                ("Either Proveo Id OR Unit Name(Mandatory Fields) is Null.Tele Message ID:" + teleMsg
                    .getMessageId()));

          }
          // return false;
          continue;
        }

        equipPosIns = new EntDbEquipPos();
        equipPosIns.setTrackNum(teleMsg.getProveoId());
        // Look into master data for the equip Number
        if (!mdEquipMap.isEmpty()) {
          if (!mdEquipMap.contains(teleMsg.getUnitName()
              .toUpperCase())) {
            LOG.error(
                "Incoming equipment name not matched with Master data. MSG ID: {}",
                teleMsg.getMessageId());
            // startTime = new Date().getTime();
            if (logLevel
                .equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
                    .name())) {
              if (!msgLogged) {
                irmtabRef = _irmfacade.storeRawMsg(inMessage,
                    dtflString);
                msgLogged = Boolean.TRUE;
              }
            }
            if (irmtabRef > 0) {
              sendErrInfo(
                  EnumExceptionCodes.WNOMD,
                  irmtabRef,
                  ("Equip Name: "
                      + teleMsg.getUnitName()
                          .toUpperCase()
                      + " not in Master Table.Tele Message ID:" + teleMsg
                      .getMessageId()));

            }
          }
        }
        equipPosIns.setUnitName(teleMsg.getUnitName());
        equipPosIns.setUnitModel(teleMsg.getModelType());
        equipPosIns.setIdArrFlight(new BigDecimal(0));
        equipPosIns.setIdDepFlight(new BigDecimal(0));
        equipPosIns.setRecStatus(" ");
        if (eventType.value().equalsIgnoreCase(EventTypes.GEO.value())) {
          if (!HpUfisUtils.isNullOrEmptyStr(teleMsg.getGeo()
              .getLong())) {
            equipPosIns.setLongitutde(toDouble(teleMsg.getGeo()
                .getLong()));
          }
          if (!HpUfisUtils
              .isNullOrEmptyStr(teleMsg.getGeo().getLat())) {
            equipPosIns.setLatitude(toDouble(teleMsg.getGeo()
                .getLat()));
          }
          if (!HpUfisUtils.isNullOrEmptyStr(teleMsg.getGeo().getX())) {
            equipPosIns.setX(toDouble(teleMsg.getGeo().getX()));
          }
          if (!HpUfisUtils.isNullOrEmptyStr(teleMsg.getGeo().getY())) {
            equipPosIns.setY(toDouble(teleMsg.getGeo().getY()));
          }
          if (!mdEquipLocMap.isEmpty()) {
            if (!mdEquipLocMap.contains(teleMsg.getGeo().getArea()
                .toUpperCase())) {
              LOG.error(
                  "Incoming equipment Area/Loc not matched with Master data. MSG ID: {}",
                  teleMsg.getMessageId());
              if (logLevel
                  .equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
                      .name())) {
                if (!msgLogged) {
                  irmtabRef = _irmfacade.storeRawMsg(
                      inMessage, dtflString);
                  msgLogged = Boolean.TRUE;
                }
              }
              if (irmtabRef > 0) {
                sendErrInfo(
                    EnumExceptionCodes.WNOMD,
                    irmtabRef,
                    ("Equip Area/Loc: "
                        + teleMsg.getGeo().getArea()
                            .toUpperCase()
                        + " not in Master Table. Tele Message ID:" + teleMsg
                        .getMessageId()));

              }
            }
          }
          equipPosIns.setUserDefineArea(teleMsg.getGeo().getArea());
          // LOG.debug("Info Update Time(Timestamp): {}",
          // chgStringToDate(teleMsg.getGeo().getTimestamp()));
          equipPosIns.setInfoUpdTime(convertStringToDate(teleMsg
              .getGeo().getTimestamp()));
        } else if (eventType.value().equalsIgnoreCase(
            EventTypes.STATE.value())) {
          equipPosIns.setInfoValue(teleMsg.getState().getName());
          equipPosIns.setInfoType(getInfoTypeFromStateMap(teleMsg
              .getState().getName()));
          // LOG.debug("Curr Status Date(Current Begin Time): {}",
          // chgStringToDate(teleMsg.getState().getCurrBeginTime()));
          equipPosIns.setCurrStatusDate(convertStringToDate(teleMsg
              .getState().getCurrBeginTime()));
          if (!mdEquipLocMap.isEmpty()) {
            if (!mdEquipLocMap.contains(teleMsg.getState()
                .getCurrArea().toUpperCase())) {
              LOG.error(
                  "Incoming equipment Area/Loc not matched with Master data. MSG ID: {}",
                  teleMsg.getMessageId());
              if (logLevel
                  .equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
                      .name())) {
                if (!msgLogged) {
                  irmtabRef = _irmfacade.storeRawMsg(
                      inMessage, dtflString);
                  msgLogged = Boolean.TRUE;
                }
              }
              if (irmtabRef > 0) {
                sendErrInfo(
                    EnumExceptionCodes.WNOMD,
                    irmtabRef,
                    ("Equip Area/Loc: "
                        + teleMsg.getState()
                            .getCurrArea()
                            .toUpperCase()
                        + " not in Master Table. Tele Message ID:" + teleMsg
                        .getMessageId()));

              }
            }
          }
          equipPosIns.setCurrUnitArea(teleMsg.getState()
              .getCurrArea());
          equipPosIns.setCurrValue(teleMsg.getState().getCurrValue());
          if (equipPosIns.getInfoType() != null) {
            equipPosIns.setCurrValueCode(getStCurrValueCodeFromMap(
                equipPosIns.getInfoType(), teleMsg.getState()
                    .getCurrValue()));
          }

          // search in AFTTAB for validity of flight
          equipPosIns.setCurrArrFltnum(formatFltNum(teleMsg
              .getState().getCurrFLNInb()));
          EntDbAfttab criteriaParams = new EntDbAfttab();
          // startTime = new Date().getTime();
          if (_startupInitSingleton.isAfttabOn()
              && !HpUfisUtils.isNullOrEmptyStr(equipPosIns
                  .getCurrArrFltnum())) {
            criteriaParams.setFlno(equipPosIns.getCurrArrFltnum());
            /*
             * criteriaParams
             * .setFlno(HpUfisUtils.formatCedaFltn(equipPosIns
             * .getCurrArrFltnum()));
             * LOG.info("Curr Arr Flight Number: {}", HpUfisUtils
             * .formatCedaFltn(equipPosIns.getCurrArrFltnum()));
             */
            // get the configurable time range offset
            short from = 0;
            short to = 0;
            from = HpProveoConfig.getAfttabRangeFromOffset();
            to = HpProveoConfig.getAfttabRangeToOffset();
            LOG.info("FLNO: " + equipPosIns.getCurrArrFltnum()
                + "  from: " + from + "   To:" + to);
            // find flight from afttab
            // BigDecimal uaft =
            // aftBean.getUrnoByCriteriaQuery(criteriaParams, type,
            // adid);
            BigDecimal urno = aftBean.getUrnoByFilterQuery(
                criteriaParams, ADID.A, from, to);

            if (urno == null) {
              // drop message
              LOG.error("PROVEO Inbound(Arrival) Flight not found from afttab. Dropping the message.");
              if (logLevel
                  .equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
                      .name())) {
                if (!msgLogged) {
                  irmtabRef = _irmfacade.storeRawMsg(
                      inMessage, dtflString);
                  msgLogged = Boolean.TRUE;
                }
              }
              if (irmtabRef > 0) {
                sendErrInfo(
                    EnumExceptionCodes.ENOFL,
                    irmtabRef,
                    "FltNum: "
                        + equipPosIns
                            .getCurrArrFltnum()
                        + (" Date Range: " + from
                            + "  to: " + to
                            + ". Tele Message ID:" + teleMsg
                              .getMessageId()));

              }
              LOG.error("Message Dropped: TeleMSG Message ID:{}",
                  teleMsg.getMessageId());
              // return false;
              continue;
            } else {
              LOG.info("Inbound Flight Found in AFTTAB. URNO:"
                  + urno);
              equipPosIns.setIdArrFlight(urno);
            }
            // LOG.info("Total Duration on searching inBound flight from AFTTAB (in ms): {}",
            // new Date().getTime() - startTime);
          }
          equipPosIns.setCurrDepFltnum(formatFltNum(teleMsg
              .getState().getCurrFLNOutb()));
          if (_startupInitSingleton.isAfttabOn()
              && !HpUfisUtils.isNullOrEmptyStr(equipPosIns
                  .getCurrDepFltnum())) {
            /*
             * LOG.info("Current Dept Flight Number : {}",
             * HpUfisUtils
             * .formatCedaFltn(equipPosIns.getCurrDepFltnum()));
             */
            /*
             * criteriaParams
             * .setFlno(HpUfisUtils.formatCedaFltn(equipPosIns
             * .getCurrDepFltnum()));
             */
            criteriaParams.setFlno(equipPosIns.getCurrDepFltnum());

            // find flight from afttab
            // BigDecimal uaft =
            // aftBean.getUrnoByCriteriaQuery(criteriaParams, type,
            // adid);
            short from = 0;
            short to = 0;
            from = HpProveoConfig.getAfttabRangeFromOffset();
            to = HpProveoConfig.getAfttabRangeToOffset();
            LOG.info("FLNO: " + equipPosIns.getCurrDepFltnum()
                + "  from: " + from + "   To:" + to);
            // startTime = new Date().getTime();
            BigDecimal urnoD = aftBean.getUrnoByFilterQuery(
                criteriaParams, ADID.D, from, to);
            if (urnoD == null) {
              // drop message
              LOG.error("PROVEO OutBound(Departure) Flight not found from afttab.");
              if (logLevel
                  .equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
                      .name())) {
                if (!msgLogged) {
                  irmtabRef = _irmfacade.storeRawMsg(
                      inMessage, dtflString);
                  msgLogged = Boolean.TRUE;
                }
              }
              if (irmtabRef > 0) {
                sendErrInfo(
                    EnumExceptionCodes.ENOFL,
                    irmtabRef,
                    ("Flno: "
                        + equipPosIns
                            .getCurrDepFltnum()
                        + " Date Range: " + from
                        + "  to: " + to
                        + ". Tele Message ID:" + teleMsg
                        .getMessageId()));

              }
              LOG.error("Message Dropped.TeleMSG Message ID:{}",
                  teleMsg.getMessageId());
              // return false;
              continue;
            } else {
              LOG.info("Outbound Flight Found in AFTTAB. URNO:"
                  + urnoD);
              equipPosIns.setIdDepFlight(urnoD);
            }
            // LOG.info("Total Duration on searching out bound flight from AFTTAB (in ms): {}",
            // new Date().getTime() - startTime);
          }

          equipPosIns.setPrevStatusDate(convertStringToDate(teleMsg
              .getState().getPrevBeginTime()));
          equipPosIns.setPrevUnitArea(teleMsg.getState()
              .getPrevArea());
          equipPosIns.setPrevValue(teleMsg.getState().getPrevValue());
          equipPosIns.setPrevValueCode(getStCurrValueCodeFromMap(
              equipPosIns.getInfoType(), teleMsg.getState()
                  .getPrevValue()));
        } else if (eventType.value().equalsIgnoreCase(
            EventTypes.NOTIFY.value())) {
          LOG.warn("Notification message is being ignored.");
          LOG.warn("Dropping the notification message. Message: {}",
              message);
          if (logLevel
View Full Code Here

TOP

Related Classes of ek.proveo.telemetryDataMessage.EventTypes

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.