Package com.ufis_as.exco

Examples of com.ufis_as.exco.MSGOBJECTS


    try {
      HpUfisCalendar ufisCalendar = new HpUfisCalendar();
      ufisCalendar.setCustomFormat(HpEKConstants.EDGS_TIME_FORMAT);
 
      INFOBJFLIGHT infobjFlight = new INFOBJFLIGHT();
      MSGOBJECTS msgobjects = new MSGOBJECTS();
      INFOBJGENERIC infobjgeneric = new INFOBJGENERIC();
      INFOJXAFTAB infojxaftab = new INFOJXAFTAB();
      INFOBJFUELSTATUS infofuelstatus = new INFOBJFUELSTATUS();
      INFOJFEVTABLIST  infojfevtablist = new INFOJFEVTABLIST();
      Boolean xafFound = false;
      Boolean fevFound = false;
     
      /*
       * REGN Java program has to trim the hyphen char '-'
       */
      infobjFlight.setREGN(aftFlight.getRegn());
     
      /*
       * Change to number for both in order to compare when use to search
       * flight
       */
      //infobjFlight.setFLTN(flightEvent.getEGDSBODY().getFNR());
      infobjFlight.setALC2(aftFlight.getAlc2());
      infobjFlight.setALC3(aftFlight.getAlc3());
      infobjFlight.setFLDA(aftFlight.getFlda());
 
      infobjFlight.setFLTN(aftFlight.getFltn());
      infobjFlight.setORG3(flightEvent.getEGDSBODY().getDEP());
      if ("DXB".equals(flightEvent.getEGDSBODY().getDEP()) && "DXB".equals(flightEvent.getEGDSBODY().getARR())) {
        infobjFlight.setADID(ADID.B);
      } else if ("DXB".equals(flightEvent.getEGDSBODY().getDEP())) {
        infobjFlight.setADID(ADID.D);
      } else {
        infobjFlight.setADID(ADID.fromValue(aftFlight.getAdid().toString()));
      }
 
      // according to type settle down return message
      if (flightEvent.getEGDSBODY().getTYPE() != null) {
        switch (flightEvent.getEGDSBODY().getTYPE()) {
        case MVT:
          /* 
           * OUT -> AOBN
           * OFF -> ATON
           * ON  -> ALDN
           * IN  -> AIBN
           */
          if (HpUfisUtils.isNotEmptyStr(flightEvent.getEGDSBODY().getTRIGEVT())) {
            String trigevt = flightEvent.getEGDSBODY().getTRIGEVT();
            if (trigevt.contains("OUT")) {
              infobjFlight.setAOBN(flightEvent.getEGDSBODY().getATA());
            } else if (trigevt.contains("OFF")) {
              infobjFlight.setATON(flightEvent.getEGDSBODY().getATA());
            } else if (trigevt.contains("ON")) {
              infobjFlight.setALDN(flightEvent.getEGDSBODY().getATA());
            } else if (trigevt.contains("IN")) {
              infobjFlight.setAIBN(flightEvent.getEGDSBODY().getATA());
            }
          }
         
          if (HpUfisUtils.isNotEmptyStr(flightEvent.getEGDSBODY().getFOB())) {
            infojxaftab.setFUOB(flightEvent.getEGDSBODY().getFOB());
            xafFound = true;
          }
         
          // Cargo Door closed and Cabin Door closed
          if (HpUfisUtils.isNotEmptyStr(flightEvent.getEGDSBODY().getCARD())) {
            ufisCalendar.setTime(flightEvent.getEGDSBODY().getCARD(), ufisCalendar.getCustomFormat());
            INFOJFEVTAB cargoDoor = new INFOJFEVTAB();
            cargoDoor.setSTNM("CARGO DOOR CLOSED");
            cargoDoor.setSTTM(ufisCalendar.getCedaString());
            infojfevtablist.getINFOJFEVTAB().add(cargoDoor);
            fevFound = true;
          }
          if (HpUfisUtils.isNotEmptyStr(flightEvent.getEGDSBODY().getCABD())) {
            ufisCalendar.setTime(flightEvent.getEGDSBODY().getCABD(), ufisCalendar.getCustomFormat());
            INFOJFEVTAB cabinDoor = new INFOJFEVTAB();
            cabinDoor.setSTNM("CABIN DOOR CLOSED");
            cabinDoor.setSTTM(ufisCalendar.getCedaString());
            infojfevtablist.getINFOJFEVTAB().add(cabinDoor);
            fevFound = true;
          }
          break;
         
        case PROGRESSREPORT:
//          if (HpUfisUtils.isNotEmptyStr(flightEvent.getEGDSBODY().getETA())) {
//            infobjFlight.setELDN(flightEvent.getEGDSBODY().getETA());
//          }
          infobjFlight.setEIBN(flightEvent.getEGDSBODY().getETA());
          break;
         
        case LOADACC:
          infojxaftab.setLSHT(flightEvent.getEGDSBODY().getLOADSHEET());
//          if (HpUfisUtils.isNotEmptyStr(flightEvent.getEGDSBODY().getZFW())) {
//            infojxaftab.setZFWT(flightEvent.getEGDSBODY().getZFW());
//            xafFound = true;
//          }
//          if (HpUfisUtils.isNotEmptyStr(flightEvent.getEGDSBODY().getTOW())) {
//            infojxaftab.setTOWT(flightEvent.getEGDSBODY().getTOW());
//            xafFound = true;
//          }
          break;
         
        case ROUTE:
          // confirm message from pilot that crew is on board
          // due to if NON-EK need to ignore whole message
          infobjgeneric.setALC2("EK");
          if (HpUfisUtils.isNotEmptyStr(flightEvent.getEGDSHEADER().getTIMESTAMP())) {
            ufisCalendar.setTime(flightEvent.getEGDSHEADER().getTIMESTAMP(), ufisCalendar.getCustomFormat());
            INFOJFEVTAB route = new INFOJFEVTAB();
            route.setSTNM("Route Request");
            route.setSTRM("<ACR>");
            route.setSTTM(ufisCalendar.getCedaString());
            infojfevtablist.getINFOJFEVTAB().add(route);
            fevFound = true;
          }
          break;
         
        case FUEL:
          // message send datetime
          ufisCalendar.setTime(flightEvent.getEGDSHEADER().getTIMESTAMP(), ufisCalendar.getCustomFormat());
          infofuelstatus.setMSGSENDDATE(ufisCalendar.getCedaString());
          // regn
          infofuelstatus.setFLTREGN(aftFlight.getRegn());
          // alc2
          infofuelstatus.setAIRLINECODE2(aftFlight.getAlc2());
          // org3
          infofuelstatus.setFLTORIGIN3(aftFlight.getOrg3());
          // des3
          infofuelstatus.setFLTDEST3(aftFlight.getDes3());
          // trip_fuel
          infofuelstatus.setTRIPFUEL(flightEvent.getEGDSBODY().getTripFuel());
          // taxi_fuel
          infofuelstatus.setTAXIFUEL(flightEvent.getEGDSBODY().getTaxiFuel());
          // ramp_fuel
          infofuelstatus.setRAMPFUEL(flightEvent.getEGDSBODY().getRampFuel());
          // trm
          infofuelstatus.setTRM(flightEvent.getEGDSBODY().getTRM());
          // den
          infofuelstatus.setDEN(flightEvent.getEGDSBODY().getDEN());
          // rtw
          infofuelstatus.setRTW(flightEvent.getEGDSBODY().getRTW());
          break;
        }
      }
 
      /*
       * Set the fields that uniquely identify a flight the rest are done in
       * the UfisMarshal
       */
      infobjgeneric.setDEPN(infobjFlight.getDEPN());
      infobjgeneric.setREGN(infobjFlight.getREGN());
      msgobjects.setINFOBJFLIGHT(infobjFlight);
      if (xafFound) {
        msgobjects.setINFOJXAFTAB(infojxaftab);
      }
      if (fevFound) {
        //msgobjects.setINFOJFEVTAB(infojfevtab);
        msgobjects.setINFOJFEVTABLIST(infojfevtablist);
      }
 
      UfisMarshal ufisMarshal = new UfisMarshal(_ms, _msgActionType, MSGIF, _interfaceConfig);
      _returnXML = ufisMarshal.marshalFlightEvent(infobjgeneric, msgobjects);
      isTransferred = true;
View Full Code Here


                        }
                    }
                }
            }
           
            MSGOBJECTS msgobjects = new MSGOBJECTS();
            INFOBJGENERIC infobjgeneric = new INFOBJGENERIC();
            /* Set the fields that uniquely identify a flight
             * the rest are done in the UfisMarshal
             */
            infobjgeneric.setDEPN(infobjFlight.getDEPN());
            msgobjects.setINFOBJFLIGHT(infobjFlight);
            //msgobjects.setINFOJFEVTAB(infojfevtab);
            //msgobjects.setINFOJFEVTABLIST(infojfevtablist);
            msgobjects.setINFOJXAFTAB(infojxaftab);
            msgobjects.setINFOJDCFTABLIST(infojdcftablist);
            UfisMarshal ufisMarshal = new UfisMarshal(_ms, _msgActionType, MSGIF, _interfaceConfig);
            _returnXML = ufisMarshal.marshalFlightEvent(infobjgeneric, msgobjects);
            return true;
            //marshalFlightEvent(infobjFlight, msgobjects);
        }
View Full Code Here

    try {
      HpUfisCalendar ufisCalendar = new HpUfisCalendar();
      ufisCalendar.setCustomFormat(HpEKConstants.EDGS_TIME_FORMAT);
 
      INFOBJFLIGHT infobjFlight = new INFOBJFLIGHT();
      MSGOBJECTS msgobjects = new MSGOBJECTS();
      INFOBJGENERIC infobjgeneric = new INFOBJGENERIC();
      INFOJXAFTAB infojxaftab = new INFOJXAFTAB();
      //INFOBJFUELSTATUS infofuelstatus = new INFOBJFUELSTATUS();
      INFOJFEVTABLIST  infojfevtablist = new INFOJFEVTABLIST();
      Boolean xafFound = false;
      Boolean fevFound = false;
     
      boolean isValid = true;
      // Header and body are mandatory
      if (message.getEGDSHEADER() == null || message.getEGDSBODY() == null) {
        LOG.error("EGDS header and body are mandatory, cannot be null");
        //LOG.error("Message Dropped: \n{}", _flightXml);
        isValid = false;
      }
     
      // if non-EK flight, drop
        if (!HpEKConstants.EK_ALC3.equals(message.getEGDSBODY().getCRR())
            && !HpEKConstants.EK_ALC2.equals(message.getEGDSBODY().getCRR())) {
          LOG.debug("EGDS message dropped due to it's non-EK flight message");
          //LOG.error("Message Dropped: \n{}", _flightXml);
          isValid = false;
        }
       
        // timestamp
        if (HpUfisUtils.isNullOrEmptyStr(message.getEGDSHEADER().getTIMESTAMP())) {
          LOG.debug("EGDS message dropped due to timestamp(header) is null or empty");
          //LOG.error("Message Dropped: \n{}", _flightXml);
          isValid = false;
        }
       
        // egds message type
        MSGTYPE type = message.getEGDSBODY().getTYPE();
        if (type == null) {
          LOG.debug("EGDS message dropped due to type field is null");
          //LOG.error("Message Dropped: \n{}", _flightXml);
          isValid = false;
        }
       
        // flight number and registration number
        String fltn = HpUfisUtils.formatCedaFltn(message.getEGDSBODY().getFNR());
        String regn = message.getEGDSBODY().getACR().replaceAll("-", "");
        // regn should be less than 6 digits
        if (HpUfisUtils.isNullOrEmptyStr(regn) || regn.length() > 6) {
          LOG.debug("EGDS message dropped due to regn is either empty(or null), or length greater than 6 digits");
          //LOG.error("Message Dropped: \n{}", _flightXml);
          isValid = false;
        }
       
        if (!isValid) {
          addExptInfo(EnumExceptionCodes.EMAND.name(), EnumExceptionCodes.EMAND.toString());
          return false;
        }
       
        // org3
        String org3 = message.getEGDSBODY().getDEP();
       
        // des3
        String des3 = message.getEGDSBODY().getARR();
       
        // adid
        ADID adid = null;
        if (HOPO.equals(message.getEGDSBODY().getDEP()) && HOPO.equals(message.getEGDSBODY().getARR())) {
          adid = ADID.B;
      } else if (HOPO.equals(message.getEGDSBODY().getDEP())) {
        adid = ADID.D;
      } else if (HOPO.equals(message.getEGDSBODY().getARR())) {
        adid = ADID.A;
      }
     
        /*
         * 2013-07-02 updated by JGO - departure and arrival station changed to non-mandatory in ICD
         * else {
        if (MSGTYPE.ROUTE != type) {
          LOG.debug("EGDS message dropped due to cannot identify flight adid by ARR tag and DEP tag");
          LOG.error("Message Dropped: \n{}", _flightXml);
              return false;
        }
      }
      */
       
        // According to type, build afttab flight search criteria and parameters
        EntDbAfttab criteriaParams = new EntDbAfttab();
        criteriaParams.setFltn(fltn);
        criteriaParams.setRegn(regn);
       
        // get the configurable time range offset
        int from = 0;
        int to = 0;
        if (MSGTYPE.MVT == type) {
          from = HpEgdsConfig.getEgdsMvtFromOffset();
          to = HpEgdsConfig.getEgdsMvtToOffset();
        } else {
          from = HpEgdsConfig.getEgdsDefFromOffset();
          to = HpEgdsConfig.getEgdsDefToOffset();
        }
       
        // find flight from afttab
      //BigDecimal uaft = aftBean.getUrnoByCriteriaQuery(criteriaParams, type, adid);
        long start = System.currentTimeMillis();
      Tuple tuple = aftBean.getUrnoByCriteriaQuery(criteriaParams, type, adid, from, to);
      LOG.debug("EGDS search flight from afttab cost: {}ms", (System.currentTimeMillis() - start));
      if (tuple == null) {
          // drop message
          LOG.debug("EGDS message dropped due to cannot find flight from afttab");
          //LOG.error("Message Dropped: \n{}", _flightXml);
          addExptInfo(EnumExceptionCodes.ENOFL.name(), EnumExceptionCodes.ENOFL.toString());
            return false;
          }
         
          // uaft
          BigDecimal uaft = tuple.get("urno", BigDecimal.class);
         
          // tifa
          String tifa = tuple.get("tifa", String.class);
         
          // tifd
          String tifd = tuple.get("tifd", String.class);
         
          // adid
          Character aftAdid = tuple.get("adid", Character.class);
          if (adid == null && aftAdid != null) {
            adid = ADID.fromValue(aftAdid.toString());
          }
         
          // flag: continue to process message or not
          boolean isContinue = true;
         
          // flt fuel info
          EntDbFlightFuelStatus oldData = null;
          EntDbFlightFuelStatus data = null;
         
          start = System.currentTimeMillis();
          // according to type settle down return message
          UfisASCommands cmd = UfisASCommands.URT;
      switch (type) {
      case MVT:
        /* 
         * OUT -> AOBN
         * OFF -> ATON
         * ON  -> ALDN
         * IN  -> AIBN
         */
        String trigevt = message.getEGDSBODY().getTRIGEVT();
        String ata = message.getEGDSBODY().getATA();
        if (HpUfisUtils.isNotEmptyStr(trigevt) && ata != null) {
          if (ata.matches(TIME_PATTERN)) {
           
            // HHmm or HH:mm -> HHMM
            ata = String.format(TIME_FORMATTER, Integer.parseInt(ata.replaceAll(SYMB_COLON, "")));
            if (ADID.A == adid) {
              ata = HpUfisUtils.guessTheDate(tifa, ata);
            } else {
              ata = HpUfisUtils.guessTheDate(tifd, ata);
            }
           
            if (trigevt.contains("OUT")) {
              infobjFlight.setAOBN(ata);
            } else if (trigevt.contains("OFF")) {
              infobjFlight.setATON(ata);
            } else if (trigevt.contains("ON")) {
              infobjFlight.setALDN(ata);
            } else if (trigevt.contains("IN")) {
              infobjFlight.setAIBN(ata);
            }
          } else {
            LOG.debug("EGDS: ATA<{}> format is not match with HH:MM or HHMM", ata);
          }
         
          // onboard fuel
          //if (trigevt.contains("IN") && (message.getEGDSBODY().getFOB() != null)) {
          if (message.getEGDSBODY().getFOB() != null) {
            infojxaftab.setFUOB(message.getEGDSBODY().getFOB());
            xafFound = true;
          }
        } else {
          LOG.debug("EGDS: cannot process ATA due to TRIGEVT<{}> or ATA<{}> is null or empty", trigevt, ata);
        }
       
        // Cargo Door closed and Cabin Door closed
        if (HpUfisUtils.isNotEmptyStr(message.getEGDSBODY().getCARD())) {
          ufisCalendar.setTime(message.getEGDSBODY().getCARD(), ufisCalendar.getCustomFormat());
          INFOJFEVTAB cargoDoor = new INFOJFEVTAB();
          cargoDoor.setSTNM("CARGO DOOR CLOSED");
          cargoDoor.setSTTM(ufisCalendar.getCedaString());
          infojfevtablist.getINFOJFEVTAB().add(cargoDoor);
          fevFound = true;
        }
        if (HpUfisUtils.isNotEmptyStr(message.getEGDSBODY().getCABD())) {
          ufisCalendar.setTime(message.getEGDSBODY().getCABD(), ufisCalendar.getCustomFormat());
          INFOJFEVTAB cabinDoor = new INFOJFEVTAB();
          cabinDoor.setSTNM("CABIN DOOR CLOSED");
          cabinDoor.setSTTM(ufisCalendar.getCedaString());
          infojfevtablist.getINFOJFEVTAB().add(cabinDoor);
          fevFound = true;
        }
       
        // if contains FOB
        if (xafFound) {
          try {
            oldData = fltFuelStatusBean.findByIdFlight(uaft);
            if (oldData == null) {
              // Prepare notification data (dat)
              data = new EntDbFlightFuelStatus();
              // id flight
              data.setIdFlight(uaft);
              // flight number
              data.setFlightNumber(fltn);
              // flight date
              //fuelStatus.setFltDate(aftFlight.getFlda());
              // regn
              data.setFltRegn(regn);
              // alc2
              data.setAirlineCode2(HpEKConstants.EK_ALC2);
              // org3
              data.setFltOrigin3(org3);
              // dep3
              data.setFltDest3(des3);
              data.setCreatedUser(MSGIF);
              data.setDataSource(MSGIF);
              // msg send date
              if (HpUfisUtils.isNotEmptyStr(message.getEGDSHEADER().getTIMESTAMP())) {
                ufisCalendar.setTime(message.getEGDSHEADER().getTIMESTAMP(), ufisCalendar.getCustomFormat());
                data.setMsgSendDate(ufisCalendar.getTime());
              }
              fltFuelStatusBean.persist(data);
              LOG.info("EGDS MVT: created flight fuel record={} for flight={}", data.getId(), uaft);
              cmd = UfisASCommands.IRT;
            }

           
            if (UfisASCommands.URT == cmd) {
              data = EntDbFlightFuelStatus.valueOf(oldData);
              String fob = message.getEGDSBODY().getFOB().isEmpty() ?
                  "0" : message.getEGDSBODY().getFOB();
              float onBoardFuel = Float.parseFloat(fob);
              // new value
              data.setOnboardFuel(onBoardFuel);

              // msg send date
              if (HpUfisUtils.isNotEmptyStr(message.getEGDSHEADER().getTIMESTAMP())) {
                ufisCalendar.setTime(message.getEGDSHEADER().getTIMESTAMP(),
                    ufisCalendar.getCustomFormat());
                data.setMsgSendDate(ufisCalendar.getTime());
              }
              data.setRecStatus(' ');
              data.setUpdatedUser(MSGIF);
              fltFuelStatusBean.update(data);
              LOG.info("EGDS MVT: updated flight fuel record={} for flight={}", data.getId(), uaft);
            }
           
            if (HpUfisUtils.isNotEmptyStr(HpCommonConfig.notifyTopic)) {
              // send notification message to topic
              ufisTopicProducer.sendNotification(true, cmd, String.valueOf(uaft), oldData, data);
            } else {
              // if topic not defined, send notification to queue
              ufisQueueProducer.sendNotification(true, cmd, String.valueOf(uaft), oldData, data);
            }
           
            // onboard fuel
            /*Float oldOnBoardFuel = 0f;
            if (message.getEGDSBODY().getFOB() != null) {
              String fob = message.getEGDSBODY().getFOB().isEmpty() ?
                  "0" : message.getEGDSBODY().getFOB();
              float onBoardFuel = Float.parseFloat(fob);
              // if fuel changed, update and notify
              if (onBoardFuel != fuelStatus.getOnboardFuel()) {
                // old value
                oldOnBoardFuel = fuelStatus.getOnboardFuel();
                // new value
                fuelStatus.setOnboardFuel(onBoardFuel);

                // msg send date
                if (HpUfisUtils.isNotEmptyStr(message.getEGDSHEADER().getTIMESTAMP())) {
                  ufisCalendar.setTime(message.getEGDSHEADER().getTIMESTAMP(),
                      ufisCalendar.getCustomFormat());
                  fuelStatus.setMsgSendDate(ufisCalendar.getTime());
                }
                fuelStatus.setRecStatus(' ');
                fuelStatus.setUpdatedUser(MSGIF);
                fltFuelStatusBean.update(fuelStatus);

                // notify flag
                isNofified = true;
              }
            }*/
           
            // notify change or not
            /*if (isNofified) {
              EntUfisMsgDTO msgObj = new EntUfisMsgDTO();
              // Header: id flight
              notifyHeader.getIdFlight().clear();
              notifyHeader.getIdFlight().add(String.valueOf(uaft));
              notifyHeader.setReqt(HpUfisCalendar.getCurrentUTCTimeString());
              msgObj.setHead(notifyHeader);
             
              // Body
              EntUfisMsgBody notifyBody = new EntUfisMsgBody();
              EntUfisMsgACT act = new EntUfisMsgACT();
              if (isInsert) {
                act.setCmd(HpUfisAppConstants.UfisASCommands.IRT.toString());
              } else {
                act.setCmd(HpUfisAppConstants.UfisASCommands.URT.toString());
              }
              act.setTab(TAB);
              act.getFld().add(NOTIFY_FOB);
              act.getData().add(message.getEGDSBODY().getFOB());
              act.getOdat().add(oldOnBoardFuel.toString());
              act.getId().add(fuelStatus.getId());
              act.setSel("WHERE id = " + "\"" + fuelStatus.getId() + "\"");
              notifyBody.getActs().add(act);
              msgObj.setBody(notifyBody);
             
              // json message
              String jsonNotifyMsg = mapper.writeValueAsString(msgObj);
              //bcMessaging.sendBroadcastMessage(jsonNotifyMsg);
              ufisTopicProducer.sendMessage(jsonNotifyMsg);
              LOG.debug("EGDS notification for changes: \n{}", jsonNotifyMsg);
            }*/
          } catch (Exception e) {
            LOG.error("Cannot transform egds message: {}", e.getMessage());
            //LOG.error("Message Dropped: \n{}", _flightXml);
          }
        }
        break;
       
      case PROGRESSREPORT:
        String eta = message.getEGDSBODY().getETA();
        if (HpUfisUtils.isNullOrEmptyStr(eta)) {
          // 2013-12-02 updated by JGO - ETA is optional in latest ICD
          // drop message
          /*LOG.debug("EGDS message dropped due to eta is null or empty");
            //LOG.error("Message Dropped: \n{}", _flightXml);
            addExptInfo(EnumExceptionCodes.EMAND.name(), EnumExceptionCodes.EMAND.toString());*/
            isContinue = false;
        }

        if (eta.matches(TIME_PATTERN)) {
          eta = String.format(TIME_FORMATTER, Integer.parseInt(eta.replaceAll(SYMB_COLON, "")));
          eta = HpUfisUtils.guessTheDate(tifa, eta);
          infobjFlight.setEIBN(eta);
        } else {
          LOG.debug("EGDS: ETA<{}> format is not match with HH:MM or HHMM", eta);
          addExptInfo(EnumExceptionCodes.EWVAL.name(), "ETA format not match with HH:MM or HHMM");
          isContinue = false;
        }
        break;
       
      case LOADACC:
        // aft
        //infobjFlight.setELDN(message.getEGDSBODY().getLOADSHEET());
        // xaf
        infojxaftab.setLSHT(message.getEGDSBODY().getLOADSHEET());
        infojxaftab.setZFWT(message.getEGDSBODY().getZFW());
        infojxaftab.setTOWT(message.getEGDSBODY().getTOW());
        // 2013-11-22 updated by JGO - Save LADT
        if (HpUfisUtils.isNotEmptyStr(message.getEGDSHEADER().getTIMESTAMP())) {
          ufisCalendar.setTime(message.getEGDSHEADER().getTIMESTAMP(), ufisCalendar.getCustomFormat());
          infojxaftab.setLADT(ufisCalendar.getCedaString());
        }
        xafFound = true;
        break;
       
      case ROUTE:
        // confirm message from pilot that crew is on board
        //infobjgeneric.setALC2("EK");
        if (HpUfisUtils.isNotEmptyStr(message.getEGDSHEADER().getTIMESTAMP())) {
          ufisCalendar.setTime(message.getEGDSHEADER().getTIMESTAMP(), ufisCalendar.getCustomFormat());
          INFOJFEVTAB route = new INFOJFEVTAB();
          route.setSTNM("Route Request");
          route.setSTRM(regn);
          route.setSTTM(ufisCalendar.getCedaString());
          infojfevtablist.getINFOJFEVTAB().add(route);
          fevFound = true;
        }
        break;
       
      case FUEL:
        oldData = fltFuelStatusBean.findByIdFlight(uaft);
        if (oldData == null) {
          data = new EntDbFlightFuelStatus();
          // msg send date
          if (HpUfisUtils.isNotEmptyStr(message.getEGDSHEADER().getTIMESTAMP())) {
            ufisCalendar.setTime(message.getEGDSHEADER().getTIMESTAMP(), ufisCalendar.getCustomFormat());
            data.setMsgSendDate(ufisCalendar.getTime());
          }
          // id flight
          data.setIdFlight(uaft);
          // flight number
          data.setFlightNumber(fltn);
          // flight date
          //fuelStatus.setFltDate(aftFlight.getFlda());
          // regn
          data.setFltRegn(regn);
          // alc2
          data.setAirlineCode2(HpEKConstants.EK_ALC2);
          // org3
          data.setFltOrigin3(org3);
          // dep3
          data.setFltDest3(des3);
         
          // trip fuel
          if (HpUfisUtils.isNotEmptyStr(message.getEGDSBODY().getTripFuel())) {
            data.setTripFuel(Float.parseFloat(message.getEGDSBODY().getTripFuel()));
          }
          // taxi fuel
          if (HpUfisUtils.isNotEmptyStr(message.getEGDSBODY().getTaxiFuel())) {
            data.setTaxiFuel(Float.parseFloat(message.getEGDSBODY().getTaxiFuel()));
          }
          // ramp fuel
          if (HpUfisUtils.isNotEmptyStr(message.getEGDSBODY().getRampFuel())) {
            data.setRampFuel(Float.parseFloat(message.getEGDSBODY().getRampFuel()));
          }
//          // onboard fuel
//          //if (HpUfisUtils.isNotEmptyStr(message.getEGDSBODY().getFOB())) {
//          if (message.getEGDSBODY().getFOB() != null) {
//            //fuelStatus.setOnboardFuel(Float.parseFloat(message.getEGDSBODY().getFOB()));
//            String fob = message.getEGDSBODY().getFOB().isEmpty() ? "0"
//                : message.getEGDSBODY().getFOB();
//            float onBoardFuel = Float.parseFloat(fob);
//            if (onBoardFuel != fuelStatus.getOnboardFuel()) {
//              fuelStatus.setOnboardFuel(onBoardFuel);
//              isNofified = true;
//            }
//          }
          data.setTrm(message.getEGDSBODY().getTRM());
          data.setDen(message.getEGDSBODY().getDEN());
          data.setRtw(message.getEGDSBODY().getRTW());
          data.setCreatedUser(MSGIF);
          data.setDataSource(MSGIF);
          fltFuelStatusBean.persist(data);
          LOG.info("EGDS FUEL: created flight fuel record={} for flight={}", data.getId(), uaft);
          cmd = UfisASCommands.IRT;
        }
       
        if (UfisASCommands.URT == cmd) {
          data = EntDbFlightFuelStatus.valueOf(oldData);
          // trip fuel
          if (HpUfisUtils.isNotEmptyStr(message.getEGDSBODY().getTripFuel())) {
            data.setTripFuel(Float.parseFloat(message.getEGDSBODY().getTripFuel()));
          }
          // taxi fuel
          if (HpUfisUtils.isNotEmptyStr(message.getEGDSBODY().getTaxiFuel())) {
            data.setTaxiFuel(Float.parseFloat(message.getEGDSBODY().getTaxiFuel()));
          }
          // ramp fuel
          if (HpUfisUtils.isNotEmptyStr(message.getEGDSBODY().getRampFuel())) {
            data.setRampFuel(Float.parseFloat(message.getEGDSBODY().getRampFuel()));
          }
          data.setTrm(message.getEGDSBODY().getTRM());
          data.setDen(message.getEGDSBODY().getDEN());
          data.setRtw(message.getEGDSBODY().getRTW());

          // msg send date
          if (HpUfisUtils.isNotEmptyStr(message.getEGDSHEADER().getTIMESTAMP())) {
            ufisCalendar.setTime(message.getEGDSHEADER().getTIMESTAMP(),
                ufisCalendar.getCustomFormat());
            data.setMsgSendDate(ufisCalendar.getTime());
          }
          data.setRecStatus(' ');
          data.setUpdatedUser(MSGIF);
          fltFuelStatusBean.update(data);
          LOG.info("EGDS FUEL: updated flight fuel record={} for flight={}", data.getId(), uaft);
        }
       
        if (HpUfisUtils.isNotEmptyStr(HpCommonConfig.notifyTopic)) {
          // send notification message to topic
          ufisTopicProducer.sendNotification(true, cmd, String.valueOf(uaft), oldData, data);
        } else {
          // if topic not defined, send notification to queue
          ufisQueueProducer.sendNotification(true, cmd, String.valueOf(uaft), oldData, data);
        }
       
        // fuel message handled by Java adapter no need to pass back to ceda
        isContinue = false;
        break;
      }
      LOG.debug("EGDS message process base on TYPE cost: {}ms", (System.currentTimeMillis() - start));

      // check whether need to pass it back to ceda or not
      if (!isContinue) {
        return false;
      }
 
      /*
       * Set the fields that uniquely identify a flight the rest are done in
       * the UfisMarshal
       */
      //infobjgeneric.setDEPN(infobjFlight.getDEPN());
      //infobjgeneric.setREGN(regn);
      infobjgeneric.setURNO(String.valueOf(uaft));
      msgobjects.setINFOBJFLIGHT(infobjFlight);
      if (xafFound) {
        msgobjects.setINFOJXAFTAB(infojxaftab);
      }
      if (fevFound) {
        //msgobjects.setINFOJFEVTAB(infojfevtab);
        msgobjects.setINFOJFEVTABLIST(infojfevtablist);
      }
 
      UfisMarshal ufisMarshal = new UfisMarshal(_ms, _msgActionType, MSGIF, null);
      _returnXML = ufisMarshal.marshalFlightEvent(infobjgeneric, msgobjects);
      isTransferred = true;
View Full Code Here

      infobjgeneric.setURNO(idFlight);
      infobjgeneric.setTIMEID(TIMEID.UTC);
      infobjgeneric.setTIMESTAMP(ufisCalendar.getCedaString());

      // BODY
      MSGOBJECTS msgObjects = new MSGOBJECTS();
      INFOBJFLIGHT infobjFlight = new INFOBJFLIGHT();
      String cxCount = Integer.toString(criticalCount);
      String sxCount = Integer.toString(shortCount);
      //infobjFlight.setCXPX(cxpx);
      if (HpUfisAppConstants.CON_LOAD_BAG_SUMMARY.equalsIgnoreCase(tab)) {
        infobjFlight.setCXBG(cxCount);
        infobjFlight.setSXBG(sxCount);
      } else if (HpUfisAppConstants.CON_LOAD_PAX_SUMMARY.equalsIgnoreCase(tab)) {
        infobjFlight.setCXPX(cxCount);
        infobjFlight.setSXPX(sxCount);
      } else if (HpUfisAppConstants.CON_LOAD_ULD_SUMMARY.equalsIgnoreCase(tab)) {
        infobjFlight.setCXUD(cxCount);
        infobjFlight.setSXUD(sxCount);
      }
      msgObjects.setINFOBJFLIGHT(infobjFlight);

      // set HEADER and BODY to MSG
      msgstream_in.setINFOBJGENERIC(infobjgeneric);
      msgstream_in.setMSGOBJECTS(msgObjects);
      msg.setMSGSTREAMIN(msgstream_in);
View Full Code Here

        HpUfisCalendar ufisCalendar = new HpUfisCalendar();
        ufisCalendar.setCustomFormat(HpEKConstants.DMIS_TOW_TIME_FORMAT); //03/08/2012 02:30:00


        //INFOBJFLIGHT infobjFlight = new INFOBJFLIGHT();
        MSGOBJECTS msgobjects = new MSGOBJECTS();
        INFOBJGENERIC infobjgeneric = new INFOBJGENERIC();

        /*Towing */
        MSGOBJECTS.INFOBJTOWING towings = new MSGOBJECTS.INFOBJTOWING();

        // inforgenerics
        infobjgeneric.setDES3(HpEKConstants.HOPO);
        infobjgeneric.setORG3(HpEKConstants.HOPO);
        //infobjgeneric.setADID(ADID.B);
        //infobjgeneric.setFTYP(TOWFTYP);

        String flno = towDetails.getHEADER().getFLIGHTNUMBER();
        // Format the flno as ufis format
        String alc2 = "";
        String fltn = "";
        if (flno != null && flno.length() > 5) {
            alc2 = flno.substring(0, 2);
            fltn = flno.substring(2, 6);
            fltn = HpUfisUtils.formatCedaFltn(fltn);
        } 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);
        //infobjFlight.setFLNO(alc2 + " " + fltn);
        infobjgeneric.setFLNO(alc2 + " " + fltn);
       
        //Get the Suffix
        if (flno != null && flno.length() > 6) {
            //infobjFlight.setFLNS(flno.substring(6));
            infobjgeneric.setFLNS(flno.substring(6));
        }
       
        // if not EK or QF flight, then drop
        if (!"EK".equalsIgnoreCase(alc2) && !"QF".equalsIgnoreCase(alc2)) {
          LOG.debug("DMIS 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;
        }
       
        if (towDetails.getHEADER().getFLIGHTSTASTD() != null) {
            ufisCalendar.setTime(towDetails.getHEADER().getFLIGHTSTASTD(), ufisCalendar.getCustomFormat());
            infobjgeneric.setSTDT(ufisCalendar.getCedaString());
            // flda in utc -> Flut
            towings.setFLUT(ufisCalendar.getCedaDateString());
            // convert to local for update flda
            ufisCalendar.DateAdd(HpUfisAppConstants.OFFSET_UTC_LOCAL, EnumTimeInterval.Hours);
            towings.setFLDA(ufisCalendar.getCedaDateString());
            //infobjgeneric.setSTOA(ufisCalendar.getCedaString());
            //infobjgeneric.setSTOD(ufisCalendar.getCedaString());
        }
        //infobjgeneric.setREGN(towDetails.getDETAILS().getREGISTRATIONNUMBER());

        // towing details
        //towings.setTOID(towDetails.getDETAILS().getJOBID());
        towings.setDEPN(towDetails.getDETAILS().getJOBID());
        towings.setREGN(towDetails.getDETAILS().getREGISTRATIONNUMBER());
        //towings.setTWTP(TOWFTYP);
        // Plan
        if (HpUfisUtils.isNotEmptyStr(towDetails.getDETAILS().getPLANFROMBAY())) {
          towings.setPFRB(towDetails.getDETAILS().getPLANFROMBAY());
        }
        if (HpUfisUtils.isNotEmptyStr(towDetails.getDETAILS().getPLANTOBAY())) {
            towings.setPTOB(towDetails.getDETAILS().getPLANTOBAY());
        }
        if (HpUfisUtils.isNotEmptyStr(towDetails.getDETAILS().getPLANSTART())) {
            ufisCalendar.setTime(towDetails.getDETAILS().getPLANSTART(), ufisCalendar.getCustomFormat());
            // 2013-12-27 updated by JGO - Change to STOD
            // towings.setPABS(ufisCalendar.getCedaString());
            towings.setSTOD(ufisCalendar.getCedaString());
        }
        if (HpUfisUtils.isNotEmptyStr(towDetails.getDETAILS().getPLANEND())) {
            ufisCalendar.setTime(towDetails.getDETAILS().getPLANEND(), ufisCalendar.getCustomFormat());
            // 2013-12-27 updated by JGO - Change to STOA
            //towings.setPAES(ufisCalendar.getCedaString());
            towings.setSTOA(ufisCalendar.getCedaString());
        }
       
        // Actual
        if (HpUfisUtils.isNotEmptyStr(towDetails.getDETAILS().getACTUALFROMBAY())) {
            towings.setPSTD(towDetails.getDETAILS().getACTUALFROMBAY());
        }
        if (HpUfisUtils.isNotEmptyStr(towDetails.getDETAILS().getACTUALTOBAY())) {
            towings.setPSTA(towDetails.getDETAILS().getACTUALTOBAY());
        }
        if (HpUfisUtils.isNotEmptyStr(towDetails.getDETAILS().getACTUALSTART())) {
            ufisCalendar.setTime(towDetails.getDETAILS().getACTUALSTART(), ufisCalendar.getCustomFormat());
            // 2013-12-27 updated by JGO - Change to AOBD
            //towings.setPABA(ufisCalendar.getCedaString());
            //towings.setAOBG(ufisCalendar.getCedaString());
            towings.setAOBD(ufisCalendar.getCedaString());
        }
        if (HpUfisUtils.isNotEmptyStr(towDetails.getDETAILS().getACTUALEND())) {
            ufisCalendar.setTime(towDetails.getDETAILS().getACTUALEND(), ufisCalendar.getCustomFormat());
            // 2013-12-27 updated by JGO - Change to AIBD
            //towings.setPAEA(ufisCalendar.getCedaString());
            //towings.setAIBG(ufisCalendar.getCedaString());
            towings.setAIBD(ufisCalendar.getCedaString());
        }

        /* Set the fields that uniquely identify a flight
         * the rest are done in the UfisMarshal
         */
        //msgobjects.setINFOBJFLIGHT(infobjFlight);
        msgobjects.setINFOBJTOWING(towings);

        UfisMarshal ufisMarshal = new UfisMarshal(_ms, null, MSGIF + MSGIF_SUBSYS, null);
        _returnXML = ufisMarshal.marshalFlightEvent(infobjgeneric, msgobjects);

        return true;
View Full Code Here

        //infobjgeneric.setADID(ADID.B);
       
        //infobjFlight.setFTYP(TOWFTYP);
        //infobjFlight.setADID(ADID.B);
       
        MSGOBJECTS msgobjects = new MSGOBJECTS();
        MSGOBJECTS.INFOBJTOWINGDELAY delay = new INFOBJTOWINGDELAY();
       
        delay.setDURN(towDelay.getDELAYCODE());
        // format duration to 4-char, e.g. 0020
        String dura = towDelay.getDELAYDURATION();
        if (HpUfisUtils.isNotEmptyStr(dura)) {
          dura = String.format("%1$04d", Integer.parseInt(dura));
        }
        delay.setDURA(dura);
        delay.setREMA(towDelay.getDELAYREMARKS());
        //msgobjects.setINFOBJFLIGHT(infobjFlight);
        msgobjects.setINFOBJTOWINGDELAY(delay);
       
        UfisMarshal ufisMarshal = new UfisMarshal(_ms, null, MSGIF + MSGIF_SUBSYS, null);
        _returnXML = ufisMarshal.marshalFlightEvent(infobjgeneric, msgobjects);
      return true;
    }
View Full Code Here

                    //infobjFlight.setREM2(flightInfo.getFlightRemarks());
                  infobjFlight.setRRMK(flightInfo.getFlightRemarks());
                }
            }
        }
        MSGOBJECTS msgobjects = new MSGOBJECTS();
        /* Set the fields that uniquely identify a flight
         * the rest are done in the UfisMarshal
         */
        msgobjects.setINFOBJFLIGHT(infobjFlight);
        if (isXafFound) {
          msgobjects.setINFOJXAFTAB(infojxaftab);
        }
        UfisMarshal ufisMarshal = new UfisMarshal(_ms, _msgActionType, MSGIF, null);
        _returnXML = ufisMarshal.marshalFlightEvent(infobjgeneric, msgobjects);

        return true;
View Full Code Here

      infobjgeneric.setURNO(idFlight);
      infobjgeneric.setTIMEID(TIMEID.UTC);
      infobjgeneric.setTIMESTAMP(ufisCalendar.getCedaString());

      // BODY
      MSGOBJECTS msgObjects = new MSGOBJECTS();
      INFOBJFLIGHT infobjFlight = new INFOBJFLIGHT();
      String count = Integer.toString(criticalCount);
      //infobjFlight.setCXPX(cxpx);
      if (HpUfisAppConstants.CON_LOAD_BAG_SUMMARY.equalsIgnoreCase(tab)) {
        infobjFlight.setCXBG(count);
      } else if (HpUfisAppConstants.CON_LOAD_PAX_SUMMARY.equalsIgnoreCase(tab)) {
        infobjFlight.setCXPX(count);
      } else if (HpUfisAppConstants.CON_LOAD_ULD_SUMMARY.equalsIgnoreCase(tab)) {
        infobjFlight.setCXUD(count);
      }
      msgObjects.setINFOBJFLIGHT(infobjFlight);

      // set HEADER and BODY to MSG
      msgstream_in.setINFOBJGENERIC(infobjgeneric);
      msgstream_in.setMSGOBJECTS(msgObjects);
      msg.setMSGSTREAMIN(msgstream_in);
View Full Code Here

            ufisCalendar.setTime(flightEvent.getAudit().getTransDateTime());
            infobjFlight.setLSTU(df.format(ufisCalendar.getTime()));
          }
        }
       
        MSGOBJECTS msgobjects = new MSGOBJECTS();
        msgobjects.setINFOBJFLIGHT(infobjFlight);
        msgobjects.setINFOJFEVTABLIST(infojfevtablist);
        msgobjects.setINFOBJFLTDAILYLIST(infobjfltdailylist);
        if (isXafFound) {
          // flight daily id
          infojxaftab.setIDFD(fltDaily.getId());
          msgobjects.setINFOJXAFTAB(infojxaftab);
        }
        msgobjects.setINFOJDCFTABLIST(infojdcftablist);
        UfisMarshal ufisMarshal = new UfisMarshal(_ms, _msgActionType, MSGIF, null);
        _returnXML = ufisMarshal.marshalFlightEvent(infobjgeneric, msgobjects);
        return true;
    }
View Full Code Here

TOP

Related Classes of com.ufis_as.exco.MSGOBJECTS

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.