Package com.ufis_as.ufisapp.lib.time

Examples of com.ufis_as.ufisapp.lib.time.HpUfisCalendar


       * .getADID() == ' ')) { LOG.info(
       * "Search for Flight cannot proceed in FULL mode as few values are missing."
       * ); return result; } }
       */

      HpUfisCalendar ufisCalendarFrom = new HpUfisCalendar();
      HpUfisCalendar ufisCalendarTo = new HpUfisCalendar();

      ufisCalendarFrom.setTime(ufisCalendarFrom.getCurrentUTCTime());
      ufisCalendarTo.setTime(ufisCalendarTo.getCurrentUTCTime());
      LOG.debug("ufisCalendarFrom={}", ufisCalendarFrom.getCedaString());
      LOG.debug("ufisCalendarTo={}", ufisCalendarTo.getCedaString());
      // range
      ufisCalendarFrom.DateAdd(fltFrom, EnumTimeInterval.Minutes);
      ufisCalendarTo.DateAdd(fltTo, EnumTimeInterval.Minutes);
      LOG.info("ufisCalendarFrom After adding Offset:"
          + ufisCalendarFrom.getCedaString()
          + "  ufisCalendarTo after adding Offset:"
          + ufisCalendarTo.getCedaString());
      CriteriaBuilder cb = em.getCriteriaBuilder();
      CriteriaQuery<Tuple> cq = cb.createTupleQuery();
      Root<EntDbAfttab> root = cq.from(EntDbAfttab.class);

      cq.multiselect(root.get("urno").alias("urno"), root.get("org3")
          .alias("org3"), root.get("org4").alias("org4"),
          root.get("des3").alias("des3"),
          root.get("des4").alias("des4"),
          root.get("flda").alias("flda"),
          root.get("regn").alias("regn"),
          root.get("stoa").alias("stoa"),
          root.get("stod").alias("stod"));
      List<Predicate> filters = new LinkedList<>();
      // LOG.info("FLNO:" + params.getFlno());
      // flno
      filters.add(cb.equal(
          cb.trim(Trimspec.BOTH, ' ', root.<String> get("flno")),
          params.getFLNO().trim()));
      if (HpUfisUtils.isNotEmptyStr(params.getFLDA())) {
        filters.add(cb.equal(
            cb.trim(Trimspec.BOTH, ' ', root.<String> get("flda")),
            params.getFLDA().trim()));
      }
      if (HpUfisUtils.isNotEmptyStr(Character.toString(params.getADID()))
          && CharUtils.toString(params.getADID()) != null) {
        filters.add(cb.equal(root.<String> get("adid"),
            params.getADID()));
      }
      if (HpUfisUtils.isNotEmptyStr(params.getREGN())) {
        filters.add(cb.or(cb.equal(
            cb.trim(Trimspec.BOTH, ' ', root.<String> get("regn")),
            params.getREGN().trim()), cb.equal(
            root.<String> get("regn"), "            ")));
      }
      if (HpUfisUtils.isNotEmptyStr(params.getORG3())) {
        filters.add(cb.equal(
            cb.trim(Trimspec.BOTH, ' ', root.<String> get("org3")),
            params.getORG3().trim()));
      }
      if (HpUfisUtils.isNotEmptyStr(params.getDES3())) {
        filters.add(cb.equal(
            cb.trim(Trimspec.BOTH, ' ', root.<String> get("des3")),
            params.getDES3().trim()));
      }
      if (HpUfisUtils.isNotEmptyStr(params.getALC3())) {
        filters.add(cb.equal(
            cb.trim(Trimspec.BOTH, ' ', root.<String> get("alc3")),
            params.getALC3().trim()));
      }
      if (HpUfisUtils.isNotEmptyStr(params.getFLTN())) {
        filters.add(cb.equal(
            cb.trim(Trimspec.BOTH, ' ', root.<String> get("fltn")),
            params.getFLTN().trim()));
      }
      if (HpUfisUtils.isNotEmptyStr(params.getFLNS())) {
        filters.add(cb.equal(
            cb.trim(Trimspec.BOTH, ' ', root.<String> get("flns")),
            params.getFLNS().trim()));
      }
      if (HpUfisUtils.isNotEmptyStr(params.getFLUT())) {
        filters.add(cb.equal(
            cb.trim(Trimspec.BOTH, ' ', root.<String> get("flut")),
            params.getFLUT().trim()));
      }
      if (HpUfisUtils.isNotEmptyStr(params.getSTDT())) {
        filters.add(cb.equal(
            cb.trim(Trimspec.BOTH, ' ', root.<String> get("stdt")),
            params.getSTDT().trim()));
      }
      if (HpUfisUtils.isNotEmptyStr(params.getSTOA())) {
        filters.add(cb.equal(
            cb.trim(Trimspec.BOTH, ' ', root.<String> get("stoa")),
            params.getSTOA().trim()));
      }
      if (HpUfisUtils.isNotEmptyStr(params.getSTOD())) {
        filters.add(cb.equal(
            cb.trim(Trimspec.BOTH, ' ', root.<String> get("stod")),
            params.getSTOD().trim()));
      }
      filters.add(cb.between(root.<String> get("tifd"),
          ufisCalendarFrom.getCedaString(),
          ufisCalendarTo.getCedaString()));
      filters.add(cb.not(cb.in(root.get("ftyp")).value('T').value('G')));

      cq.where(cb.and(filters.toArray(new Predicate[0])));
      cq.orderBy(cb.desc(root.<String> get("regn")));
      Query query = em.createQuery(cq);
View Full Code Here


      LOG.warn("Outgoing raw message is null. The raw message will not be inserted.");
      return;
    }
   
    try {
      HpUfisCalendar ufisCal = new HpUfisCalendar(new Date());
      ufisCal.DateAdd(HpUfisAppConstants.OFFSET_LOCAL_UTC, EnumTimeInterval.Hours);

      EntDbOrmtab entDbOrmtab = new EntDbOrmtab();
      // composite pkey
      entDbOrmtab.setId(new EntDbOrmCompositeId(ormNextUrno, dtfl));
      entDbOrmtab.setData(outgoingMessage);
      entDbOrmtab.setCdat(ufisCal.getTime());
      entDbOrmtab.setQnam(dest);
      em.persist(entDbOrmtab);
      LOG.info("Outgoing message has been inserted into ORMTAB.");
      // cache the maximum urno
      ormNextUrno += 1;
View Full Code Here

        try {
            StringWriter writer = new StringWriter();

            _ms.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);

            HpUfisCalendar ufisCalendar = new HpUfisCalendar(TimeZone.getTimeZone("UTC"));

            MSG msg = new MSG();
            MSG.MSGSTREAMIN msgstream_in = new MSG.MSGSTREAMIN();

            INFOBJGENERIC infobjgeneric = infGeneric;
            if (HpUfisUtils.isNullOrEmptyStr(infobjgeneric.getURNO())
                && msgobjects.getINFOBJFLIGHT() != null) {
              if (infobjgeneric.getADID() == null) {
                infobjgeneric.setADID(msgobjects.getINFOBJFLIGHT().getADID());
              }
              if (HpUfisUtils.isNullOrEmptyStr(infobjgeneric.getFLNO())) {
                infobjgeneric.setFLNO(
                    msgobjects.getINFOBJFLIGHT().getALC2() + " " + msgobjects.getINFOBJFLIGHT().getFLTN());
              }
              if (HpUfisUtils.isNullOrEmptyStr(infobjgeneric.getFLNS())) {
                infobjgeneric.setFLNS(msgobjects.getINFOBJFLIGHT().getFLNS());
              }
//              if (HpUfisUtils.isNullOrEmptyStr(infobjgeneric.getFLDA())) {
//                infobjgeneric.setFLDA(msgobjects.getINFOBJFLIGHT().getFLDA());
//              }
               
                if (msgobjects.getINFOBJFLIGHT().getADID() != null) {
                  if (ADID.A.equals(msgobjects.getINFOBJFLIGHT().getADID())) {
                    //infobjgeneric.setSTDT(msgobjects.getINFOBJFLIGHT().getSTOD());
                      if (HpUfisUtils.isNullOrEmptyStr(infobjgeneric.getDES3())) {
                        infobjgeneric.setDES3(msgobjects.getINFOBJFLIGHT().getDES3());
                      }
                      if (HpUfisUtils.isNullOrEmptyStr(infobjgeneric.getDES4())) {
                        infobjgeneric.setDES4(msgobjects.getINFOBJFLIGHT().getDES4());
                      }
                    } else {
                    //infobjgeneric.setSTDT(msgobjects.getINFOBJFLIGHT().getSTOA());
                    if (HpUfisUtils.isNullOrEmptyStr(infobjgeneric.getORG3())) {
                      infobjgeneric.setORG3(msgobjects.getINFOBJFLIGHT().getORG3())
                    }
                    if (HpUfisUtils.isNullOrEmptyStr(infobjgeneric.getORG4())) {
                      infobjgeneric.setORG4(msgobjects.getINFOBJFLIGHT().getORG4())
                    }
                    }
                }
            }
            infobjgeneric.setACTIONTYPE(_msgActionType);
            infobjgeneric.setMESSAGEORIGIN(_msgOrigin);
            infobjgeneric.setMESSAGETYPE(_msgOriginType);
            infobjgeneric.setTIMEID(TIMEID.UTC);
            infobjgeneric.setTIMESTAMP(ufisCalendar.getCedaString());
            msgstream_in.setMSGOBJECTS(msgobjects);
            msgstream_in.setINFOBJGENERIC(infobjgeneric);
            msg.setMSGSTREAMIN(msgstream_in);

            _ms.marshal(msg, writer);
View Full Code Here

    private void initialCache() {
      if (globalFlightEvent == null) {
        globalFlightEvent = new ArrayList<>();
      }
     
        HpUfisCalendar fromDate = new HpUfisCalendar(utcTz);
        HpUfisCalendar toDate = new HpUfisCalendar(utcTz);

        fromDate.DateAdd(startOffset, EnumTimeInterval.Days);
        toDate.DateAdd(endOffset, EnumTimeInterval.Days);
     
    Query query = _em.createQuery(
        "SELECT e " +
        "FROM EntDbAfttab e " +
        "WHERE (e.alc2 = 'EK' OR e.alc3 = 'UAE') " +
        "AND ((e.tifa BETWEEN :startDate AND :endDate ) OR (e.tifd BETWEEN :startDate AND :endDate ))");
    query.setParameter("startDate", fromDate.getCedaString());
    query.setParameter("endDate", toDate.getCedaString());
    try {
      LOG.info("Loading EK flights into cahce from afttab...");
      List<EntDbAfttab> result = query.getResultList();
      if (result != null && result.size() > 0) {
        LOG.info("{} EK flight record found", result.size());
        FlightEvent flight = null;
        FlightId flightId = null;
        FltDate fltDate = null;
        HpUfisCalendar ufisCalendar = new HpUfisCalendar();
        ufisCalendar.setCustomFormat("yyyyMMdd");
        for (EntDbAfttab entity : result) {
          flight = new FlightEvent();
          flightId = new FlightId();
          fltDate = new FltDate();
          // carrier, boardpoint, destination, flight date, suffix
          flightId.setCxCd(entity.getAlc2() == null ? entity.getAlc3() : entity.getAlc2());
          flightId.setDepStn(entity.getOrg3());
          flightId.setArrStn(entity.getDes3());
          if (HpUfisUtils.isNotEmptyStr(entity.getFlda())) {
            ufisCalendar.setTime(entity.getFlda(), ufisCalendar.getCustomFormat());
            fltDate.setValue(HpUfisUtils.chgDateToXMLGregorianCalendar(ufisCalendar.getTime()));
            flightId.setFltDate(fltDate);
          }
          flightId.setFltNum(entity.getFltn());
          if (entity.getFlns() != null
              && !"".equals(String.valueOf(entity.getFlns()).trim())) {
View Full Code Here

    this.globalFlightEvent = globalFlightEvent;
  }
 
  public void removeExpiredCache(int exp) {
    // current datetime in UTC
    HpUfisCalendar utcNow = new HpUfisCalendar(utcTz);
   
    // currently only keep past 2 days cache
    if (globalFlightEvent != null) {
      Iterator<FlightEvent> it = globalFlightEvent.iterator();
      while (it.hasNext()) {
        FlightEvent event = it.next();
        if (event.getFlightId() != null
            && event.getFlightId().getFltDate() != null) {
          long offset = new HpUfisCalendar(event.getFlightId().getFltDate().getValue()).
              timeDiff(utcNow, EnumTimeInterval.Days, true);
          if (offset > exp) {
            it.remove();
          }
        }
View Full Code Here

   */
  private void sendSummaryToCedaInXmlFormat(String tab, String idFlight, int criticalCount) {
    try {
      StringWriter writer = new StringWriter();
      _ms.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
      HpUfisCalendar ufisCalendar = new HpUfisCalendar(TimeZone.getTimeZone("UTC"));

      MSG msg = new MSG();
      MSG.MSGSTREAMIN msgstream_in = new MSG.MSGSTREAMIN();

      // HEADER
      INFOBJGENERIC infobjgeneric = new INFOBJGENERIC();
      infobjgeneric.setACTIONTYPE(ACTIONTYPE.U);
      infobjgeneric.setMESSAGETYPE(HpEKConstants.JCEDA_SOURCE);
      infobjgeneric.setMESSAGEORIGIN(HpEKConstants.FLT_CONX_SOURCE);
      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);
View Full Code Here

            return false;
        }
    }

    private boolean tranformFlight(ek.dmis.towdetails.Root towDetails) {
        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
         */
 
View Full Code Here

        return true;
    }
   
    private boolean transformFlight(Root towDelay) {
      HpUfisCalendar ufisCalendar = new HpUfisCalendar();
        ufisCalendar.setCustomFormat(HpEKConstants.DMIS_TOW_TIME_FORMAT);
       
        INFOBJGENERIC infobjgeneric = new INFOBJGENERIC();
        //INFOBJFLIGHT infobjFlight = new INFOBJFLIGHT();
       
        String flno = towDelay.getFLIGHTNUMBER();
        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);
       
        //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 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;
        }
        if (HpUfisUtils.isNotEmptyStr(towDelay.getFLIGHTSTASTD())) {
            ufisCalendar.setTime(towDelay.getFLIGHTSTASTD(), ufisCalendar.getCustomFormat());
            infobjgeneric.setSTDT(ufisCalendar.getCedaString());
            //infobjgeneric.setSTOA(ufisCalendar.getCedaString());
            //infobjgeneric.setSTOD(ufisCalendar.getCedaString());
        }
        infobjgeneric.setFLNO(alc2 + " " + fltn);
        infobjgeneric.setORG3(HpEKConstants.HOPO);
View Full Code Here

       
        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);
View Full Code Here

        msgLogged = Boolean.FALSE;
        if (irmtabRef > 0) {
          msgLogged = Boolean.TRUE;
        }
     
      HpUfisCalendar ufisCalendar = new HpUfisCalendar();
      ufisCalendar.setCustomFormat(HpEKConstants.MACS_TIME_FORMAT); // 2012-12-18 00:00:00
      SimpleDateFormat macsTimeFormat = new SimpleDateFormat(HpEKConstants.MACS_TIME_FORMAT);

      EntDbLoadPax edpiod = new EntDbLoadPax();
      LoadPaxPK paxPk = new LoadPaxPK();

      // check as it's a mandatory field
      if (paxDetails.getMFLID() != null
          && !paxDetails.getMFLID().isEmpty()) {
        paxPk.setIntflid(paxDetails.getMFLID());
      } else {
        LOG.info("Mandatory field MFL_ID is null or empty, PaxDetails Message is rejected");
        sendErroNotification(EnumExceptionCodes.EMAND,irmtabRef);
         return null;
      }

      // check as it's a mandatory field
      if (paxDetails.getREFERENCENUMBER() != null
          && !paxDetails.getREFERENCENUMBER().isEmpty()) {
        paxPk.setIntrefnumber(paxDetails.getREFERENCENUMBER());
      } else {
        LOG.info("Mandatory field REFERENCE_NUMBER is null or empty, PaxDetails Message is rejected");
        sendErroNotification(EnumExceptionCodes.EMAND,irmtabRef);
         return null;
      }
     
      // check wrong paxType condition when infant indicator have value I (added new logic by 2013-12-2)
      if ("C".equalsIgnoreCase(paxDetails.getPAXTYPE()) && "I".equalsIgnoreCase(paxDetails.getINFANTINDICATOR())){
        LOG.info("wrong paxType 'C' when infant indicator have value 'I', PaxDetails Message is rejected");
        sendErroNotification(EnumExceptionCodes.EWPTY,irmtabRef);
         return null;
      }
     
//      paxPk.setIntSystem("MACS");
      edpiod.setIntSystem(HpEKConstants.MACS_PAX_DATA_SOURCE);
      edpiod.setPKId(paxPk);
      // edpiod.setpKId(paxPk);

      // check as it's a mandatory field
      if (paxDetails.getPAXID() != null
          && !paxDetails.getPAXID().isEmpty()) {
        edpiod.setIntId(paxDetails.getPAXID());
      } else {
        LOG.info("Mandatory field PAX_ID is null or empty, PaxDetails Message is rejected");
        sendErroNotification(EnumExceptionCodes.EMAND,irmtabRef);
         return null;
      }

      edpiod.setDestination(paxDetails.getDESTINATION());

      if (paxDetails.getPAXNAME() != null) {
        String paxName = paxDetails.getPAXNAME().replaceAll("/", " ");
        edpiod.setPaxName(paxName);
      }

      edpiod.setCabinClass(paxDetails.getCABINCLASS());
      edpiod.setBookedClass(paxDetails.getBOOKEDCLASS());
      edpiod.setPaxType(paxDetails.getPAXTYPE());
      edpiod.setPaxGroupCode(paxDetails.getPAXGROUPCODE());
      edpiod.setHandicapped(paxDetails.getHANDICAPPED());
      edpiod.setUnAccompaniedMinor(paxDetails.getUNACCOMPANIEDMINOR());
      edpiod.setPriorityPax(paxDetails.getPRIORITYPAX());
      edpiod.setBoardingPassprint(paxDetails.getBOARDINGPASSPRINT());
      // edpiod.setBagTagPrint(paxDetails.get); !!!! there is no this tag
      // in current xsd
      if(!Arrays.asList(bookingStatusList).contains(paxDetails.getPAXBOOKINGSTATUS())){
//        blIrmtabFacade.updateIRMStatus(PaxProcessSingleton.nextUrno, "WNOMD");
        LOG.warn("bookingStatus {} is not in the possible values from paxDetails msg and updated to IRMTAB, intId {}", paxDetails.getPAXBOOKINGSTATUS(), paxDetails.getPAXID());
        sendErroNotification(EnumExceptionCodes.WENUM,irmtabRef);
      }
      edpiod.setPaxBookingStatus(paxDetails.getPAXBOOKINGSTATUS());
      edpiod.setTravelledClass(paxDetails.getTRAVELLEDCLASS());
      edpiod.setBagTagInfo(paxDetails.getVARIABLEDATA());
      edpiod.setScanLocation(paxDetails.getSCANNEDLOCATION());

      // set bag weight and piece, original data: e.g 002/0053/00
      String bagPicAndWeight = "";
      if (paxDetails.getNUMBEROFPCSWEIGHT() != null) {
        bagPicAndWeight = paxDetails.getNUMBEROFPCSWEIGHT();
      }
      String numberOfBag = "0";
      String weightOfBag = "0";
      int tagIndex = bagPicAndWeight.indexOf("/");
      int tagIndex2 = bagPicAndWeight.indexOf("/", tagIndex + 1);
      if (bagPicAndWeight != null && !"".equals(bagPicAndWeight)
          && tagIndex > 0 && tagIndex2 > 0) {
        numberOfBag = bagPicAndWeight.substring(0, tagIndex);
        weightOfBag = bagPicAndWeight
            .substring(tagIndex + 1, tagIndex2);
      }
      edpiod.setBagWeight(new BigDecimal(weightOfBag));
      edpiod.setBagNoOfPieces(new BigDecimal(numberOfBag));

      // // set check in date time
      // String cheInDate = "";
      // if (paxDetails.getCHECKINDATE() != null){
      // cheInDate = paxDetails.getCHECKINDATE();
      // }
      // String cheInTime = paxDetails.getCHECKINTIME();
      // String cheInDateTime = "";
      // Date cheInDateTimeD = null;
      //
      // int spaceIndex = cheInDate.indexOf(" ");
      //
      // if (spaceIndex > 0 && cheInTime.length() >= 4){
      // cheInDate = cheInDate.substring(0, spaceIndex);
      // cheInDateTime = cheInDate +
      // " "+cheInTime.substring(0,2)+":"+cheInTime.substring(2,4)+":00";
      // try {
      // cheInDateTimeD = new
      // SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(cheInDateTime);
      // edpiod.setCheckInDateTime(cheInDateTimeD);
      // } catch (ParseException e) {
      // LOG.debug("set cheInDateTime "+e.toString());
      // }
      // }

      // set check in date time
      if (paxDetails.getCHECKINDATE() != null
          && !paxDetails.getCHECKINDATE().isEmpty()) {
        ufisCalendar.setTime(paxDetails.getCHECKINDATE(),
            ufisCalendar.getCustomFormat());
        if (paxDetails.getCHECKINTIME().length() >= 4) {
          int hour = 0;
          int min = 0;
          try {
            hour = Integer.parseInt(paxDetails.getCHECKINTIME()
                .substring(0, 2));
            min = Integer.parseInt(paxDetails.getCHECKINTIME()
                .substring(2, 4));
          } catch (Exception e) {
            LOG.info("PaxDetails message Checking Time parse erro");
          }
          ufisCalendar.DateAdd(hour, EnumTimeInterval.Hours);
          ufisCalendar.DateAdd(min, EnumTimeInterval.Minutes);
        }
        edpiod.setCheckInDateTime(ufisCalendar.getTime());
      }

      // // set scan date time
      // String scanDate = "";
      // if (paxDetails.getSCANNEDLOCALDATE() != null){
      // scanDate = paxDetails.getSCANNEDLOCALDATE();
      // }
      // String scanTime = paxDetails.getSCANNEDLOCALTIME();
      // String scanDateTime = "";
      // Date scanDateTimeD = null;
      //
      // int scanSpaceIndex = scanDate.indexOf(" ");
      //
      // if (scanSpaceIndex > 0 && scanTime.length() >= 4){
      // scanDate = scanDate.substring(0, scanSpaceIndex);
      // scanDateTime = scanDate +
      // " "+scanTime.substring(0,2)+":"+scanTime.substring(2,4)+":00";
      // try {
      // scanDateTimeD = new
      // SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(scanDateTime);
      // edpiod.setScanDateTime(scanDateTimeD);
      // } catch (ParseException e) {
      // LOG.debug("set scanDateTime "+e.toString());
      // }
      // }
      //
     
      edpiod.setBoardingStatus(paxDetails.getBOARDINGSTATUS());
      edpiod.setCancelled(paxDetails.getCANCELLED());
      edpiod.setOffLoadedPax(paxDetails.getOFFLOADEDPAX());
      edpiod.setEtkType(paxDetails.getETKTYPE());

      // set scan date time
      if (paxDetails.getSCANNEDLOCALDATE() != null
          && !paxDetails.getSCANNEDLOCALDATE().isEmpty()) {
        ufisCalendar.setTime(paxDetails.getSCANNEDLOCALDATE(),
            ufisCalendar.getCustomFormat());
        if (paxDetails.getCHECKINTIME().length() >= 4) {
          int hour = 0;
          int min = 0;
          try {
            hour = Integer.parseInt(paxDetails
                .getSCANNEDLOCALTIME().substring(0, 2));
            min = Integer.parseInt(paxDetails.getSCANNEDLOCALTIME()
                .substring(2, 4));
          } catch (Exception e) {
            LOG.info("PaxDetails message Scanned Time parse erro");
          }
          ufisCalendar.DateAdd(hour, EnumTimeInterval.Hours);
          ufisCalendar.DateAdd(min, EnumTimeInterval.Minutes);
        }
        edpiod.setScanDateTime(ufisCalendar.getTime());
      }

      // set date of birth
      Date dob = null;
      try {
        String dobString = paxDetails.getDATEOFBIRTH();
        if (dobString != null && !dobString.isEmpty()) {
          dob = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
              .parse(dobString);
        }
        edpiod.setDob(dob);
      } catch (ParseException e) {
        LOG.info("PaxDetails Message, dob parse erro");
      }

      edpiod.setNationality(paxDetails.getNATIONALITY());
      edpiod.setGender(paxDetails.getGENDER());
      if (Arrays.asList(statusOnBoardList).contains(paxDetails.getSTATUSONBOARD())){
//        blIrmtabFacade.updateIRMStatus(PaxProcessSingleton.nextUrno, "WNOMD");
        LOG.warn("statusOnBoard {} is not in the possible values from paxDetails msg and updated to IRMTAB, intId {}", paxDetails.getSTATUSONBOARD(), paxDetails.getPAXID());
        sendErroNotification(EnumExceptionCodes.WENUM,irmtabRef);
      }
      edpiod.setStatusOnboard(paxDetails.getSTATUSONBOARD());
      edpiod.setInfantIndicator(paxDetails.getINFANTINDICATOR());
      edpiod.setCheckInAgentCode(paxDetails.getCHECKINAGENTCODE());
      edpiod.setCheckInHandlingAgent(paxDetails.getCHECKINHANDLINGAGENT());
      edpiod.setCheckInSequence(paxDetails.getCHECKINSEQUENCE());
      edpiod.setCheckInCity(paxDetails.getCHECKINCITY());
      edpiod.setBoardingAgentCode(paxDetails.getBOARDINGAGENTCODE());
      edpiod.setBoardingHandlingAgent(paxDetails
          .getBOARDINGHANDLINGAGENT());

      // // set boarding datetime
      // String boardingDate = "";
      // if (paxDetails.getCHECKINDATE() != null){
      // boardingDate = paxDetails.getBOARDINGDATE();
      // }
      // String boardingTime = paxDetails.getBOARDINGTIME();
      // String boardingDateTime = "";
      // Date boardingDateTimeD = null;
      //
      // int boardSpaceIndex = boardingDate.indexOf(" ");
      //
      // if (boardSpaceIndex > 0 && boardingTime.length() >= 4){
      // boardingDate = boardingDate.substring(0, boardSpaceIndex);
      // boardingDateTime = boardingDate +
      // " "+boardingTime.substring(0,2)+":"+boardingTime.substring(2,4)+":00";
      // try {
      // boardingDateTimeD = new
      // SimpleDateFormat("yyyy-MM-dd hh:mm:ss").parse(boardingDateTime);
      // edpiod.setBoardingDateTime(boardingDateTimeD);
      // } catch (ParseException e) {
      // LOG.debug("set boardingDateTime "+e.toString());
      // }
      // }

      // set boarding datetime
      if (paxDetails.getBOARDINGDATE() != null
          && !paxDetails.getBOARDINGDATE().isEmpty()) {
        ufisCalendar.setTime(paxDetails.getBOARDINGDATE(),
            ufisCalendar.getCustomFormat());
        if (paxDetails.getBOARDINGTIME().length() >= 4) {
          int hour = 0;
          int min = 0;
          try {
            hour = Integer.parseInt(paxDetails.getBOARDINGTIME()
                .substring(0, 2));
            min = Integer.parseInt(paxDetails.getBOARDINGTIME()
                .substring(2, 4));
          } catch (Exception e) {
            LOG.info("PaxDetails message Boarding Time parse erro");
          }
          ufisCalendar.DateAdd(hour, EnumTimeInterval.Hours);
          ufisCalendar.DateAdd(min, EnumTimeInterval.Minutes);
        }
        edpiod.setBoardingDateTime(ufisCalendar.getTime());
      }

      // added by 2013.10.01 according to the new design document
      edpiod.setUpgradeIndicator(paxDetails.getUPGRADEINDICATOR());
      edpiod.setTransitIndicator(paxDetails.getTRANSITINDICATOR());
View Full Code Here

TOP

Related Classes of com.ufis_as.ufisapp.lib.time.HpUfisCalendar

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.