Package com.ufis_as.ufisapp.server.oldflightdata.entities

Examples of com.ufis_as.ufisapp.server.oldflightdata.entities.EntFlightSearchObj


  }

  private void fillIdFlightFromMsg(Message inMessage, String message,
      Long irmtabRef, Boolean msgLogged2, EntDbMsgTelex msgTelex,
      String msgSource, String msgType) {
    EntFlightSearchObj flightSearchObj = new EntFlightSearchObj();
    try {
      Pattern regexCPM = Pattern
          .compile("((?m)^\\.{1}([A-Z]{7})\\s([0-9]{6}).*\\s*)?\\n\\s*([A-Z]{3})\\s*\\n([A-Z]{2,3})([0-9]{3,4})[/]([0-9]{2})\\.{1}([A-Z]{1}[0-9]{1}[A-Z]{3}|\\s+)(\\b*)");
      Pattern regexACARSMacs = Pattern
          .compile("(?m)(^\\.([A-Z]{7})\\s+([0-9]{6})).*\\s*\\n*(?s).*LOADSHEET\\s*\\n[A-Z]*[0-9]*\\s([A-Z]{2,3})\\s*([0-9]{3,4})[/]([0-9]{2})\\s+([A-Z]{6,7})?\\s([A-Z]{1}[0-9]{1}[A-Z]{3})?\\s*([0-9]{2}[A-Z]{3}[0-9]{2})?(\\s*\\b*)");
      // .compile("(?m)(^\\.([A-Z]{7})\\s+([0-9]{6}))\\s*\\n*(?s).*LOADSHEET\\s*\\n([A-Z]*[0-9]*)\\s([A-Z]{2,3})([0-9]{3,4})[/]([0-9]{2})\\s+([A-Z]{6,7})\\s([A-Z]{1}[0-9]{1}[A-Z]{3})\\s+([0-9]{2}[A-Z]{3}[0-9]{2})(\\b*)");
      Pattern regexACARSSalt = Pattern
          .compile("(?m)(^\\.([A-Z]{7})\\s+([0-9]{6}))?.*\\s*\\n*(?s).*LOADSHEET\\s*\\n[A-Z]*[0-9]*\\s([A-Z]{2,3})\\s*([0-9]{3,4})[/]([0-9]{2})\\s+([A-Z]{6,7})?\\s([A-Z]{1}[0-9]{1}[A-Z]{3})?\\s*([0-9]{2}[A-Z]{3}[0-9]{2})?(\\s*\\b*)");
      // .compile("(?m)(^\\.([A-Z]{7})\\s+([0-9]{6}))?\\s*\\n*(?s).*LOADSHEET\\s*\\n([A-Z]*[0-9]*)\\s([A-Z]{2,3})([0-9]{3,4})[/]([0-9]{2})\\s+([A-Z]{6,7})\\s([A-Z]{1}[0-9]{1}[A-Z]{3})\\s+([0-9]{2}[A-Z]{3}[0-9]{2})(\\b*)");
      // "(?m)^\\.{0,1}(([A-Z]{7})\\s+([0-9]{6}))*\\s*\\n*(?s).*LOADSHEET\\s*\\n([A-Z]*[0-9]*)\\s([A-Z]{2,3})([0-9]{3,4})[/]([0-9]{2})\\s+([A-Z]{6,7})\\s([A-Z]{1}[0-9]{1}[A-Z]{3})\\s+([0-9]{2}[A-Z]{3}[0-9]{2})(\\b*)");
      /*
       * Pattern regexLIR = Pattern .compile(
       * "(?m)^\\.{1}([A-Z]{7})\\s([0-9]{6})\\s*\\n(LOADING INSTRUCTION/REPORT)(?s).*\\n([A-Z]{3,4})\\s([A-Z]{3,4})\\s([A-Z]{2,3})\\s([0-9]{3,4})\\s+([A-Z]{1}[0-9]{1}[A-Z]{3})\\s+.[^\\n]*\\s*([0-9]{2}[A-Z]{3}[0-9]{2})\\s+([0-9]{4})(\\n)"
       * );
       */
      Pattern regexLIR = Pattern
          .compile("(?m)^\\.{1}(([A-Z]{7})\\s([0-9]{6})\\s*)?.*\\n*\\s*LOADING INSTRUCTION/REPORT(?s).*\\n([A-Z]{3,4})?\\s+([A-Z]{3,4})?\\s+([A-Z]{2,3})\\s*([0-9]{3,4})\\s+(([A-Z]{1}[0-9]{1}\\-{0,1}[A-Z]{3}))?\\s+.[^\\n]*\\s*([0-9]{2}[A-Z]{3}[0-9]{2})\\s+(([0-9]{4}))?(\\s*\\b*)");
      Matcher regexMatcher = regexCPM.matcher(message);
      boolean foundMatch = regexMatcher.find();
      // boolean foundMatch1 = regexMatcher.matches();
      if (foundMatch) {
        LOG.info("Group count: {}", regexMatcher.groupCount());
        /*
         * for (int i = 0; i < regexMatcher.groupCount(); i++) {
         *
         * Group count:9 0.Group :.DXBKLEK 270613 CPM EK432/05.A6EBB
         * 1.Group :.DXBKLEK 270613 2.Group :DXBKLEK 3.Group :270613
         * 4.Group :CPM 5.Group :EK 6.Group :432 7.Group :05 8.Group
         * :A6EBB
         *
         *
         * //LOG.info("Group :" + regexMatcher.group(i)); }
         */
        if (regexMatcher.group(4) == null) {
          LOG.error("Message Type not specified in the Message Details Section.Dropping the message.");
          if (logLevel
              .equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
                  .name())) {
            if (!msgLogged) {
              irmtabRef = _irmfacade.storeRawMsg(inMessage,
                  dtflStr);
              msgLogged = Boolean.TRUE;
            }
          }
          if (irmtabRef > 0) {
            sendErrInfo(EnumExceptionCodes.EWFMT,
                "Message Type not specified in Msg Details",
                irmtabRef);
          }
          return;
        }
        msgTelex.setMsgType(regexMatcher.group(4));

        if (msgTelex.getMsgType() != null
            && !msgType.equalsIgnoreCase(msgTelex.getMsgType())) {
          LOG.error("Message Type not match.Dropping the message.");
          if (logLevel
              .equalsIgnoreCase(HpUfisAppConstants.IrmtabLogLev.LOG_ERR
                  .name())) {
            if (!msgLogged) {
              irmtabRef = _irmfacade.storeRawMsg(inMessage,
                  dtflStr);
              msgLogged = Boolean.TRUE;
            }
          }
          if (irmtabRef > 0) {
            sendErrInfo(EnumExceptionCodes.EWVAL,
                "Message Type not match with Msg Details",
                irmtabRef);
          }
          return;
        }

        msgTelex.setMsgFltno(HpUfisUtils.formatCedaFlno(
            regexMatcher.group(5), regexMatcher.group(6), null));
        msgTelex.setMsgFltDay(regexMatcher.group(7));       
         msgTelex.setLoadingPt(regexMatcher.group(2)!=null ? regexMatcher.group(2).substring(0,3):null);
        if (HpUfisUtils.isNotEmptyStr(msgTelex.getLoadingPt())) {
          msgTelex.setArrDepFlag(msgTelex.getLoadingPt()
              .equalsIgnoreCase(HpEKConstants.EK_HOPO) ? "D"
              : "A");
        }
        msgTelex.setSendRecvFlag("R");
        msgTelex.setMsgSender(regexMatcher.group(2) == null ? " "
            : regexMatcher.group(2));
        if (HpUfisUtils.isNotEmptyStr(regexMatcher.group(3))) {
          msgTelex.setMsgSendDay(regexMatcher.group(3)
              .substring(0, 2));
          msgTelex.setMsgSendTime(regexMatcher.group(3).substring(2));
        } else {
          msgTelex.setMsgSendDay(" ");
          msgTelex.setMsgSendTime(" ");
        }
        flightSearchObj.setREGN(regexMatcher.group(8));
        // Flight search
      } else {

        regexMatcher = regexACARSMacs.matcher(message);
        boolean regexMatched = regexMatcher.find();
        if (!regexMatched) {
          regexMatcher = regexACARSSalt.matcher(message);
          regexMatched = regexMatcher.find();
        }

        if (regexMatched) {

          LOG.info("Group count: {}", regexMatcher.groupCount());
          /*
           * for (int i = 0; i < regexMatcher.groupCount(); i++) {
           *
           * Group count:10 0.Group :.HDQKMEK 120440 AGM AN A6-EED/MA
           * LSHA - LOADSHEET FINAL EK 001/12 DXBLHR A6EED 12MAY13
           *
           * 1.Group :.HDQKMEK 120440 2.Group :HDQKMEK 3.Group :120440
           * 4.Group :EK 5.Group :001 6.Group :12 7.Group :DXBLHR
           * 8.Group :A6EED 9.Group :12MAY13
           *
           *
           *
           * // To-DO //LOG.info("Group :" + regexMatcher.group(i)); }
           */

          msgTelex.setMsgType("ACARS"); // check
          msgTelex.setMsgFltno(HpUfisUtils.formatCedaFlno(
              regexMatcher.group(4), regexMatcher.group(5), null));
          msgTelex.setMsgFltDay(regexMatcher.group(6));
          msgTelex.setLoadingPt(regexMatcher.group(7) != null ? regexMatcher
              .group(7).substring(0, 3) : "");// Can
          // be
          // of
          // length
          // 4
          // as
          // well
          if (HpUfisUtils.isNotEmptyStr(msgTelex.getLoadingPt())) { // ???
            msgTelex.setArrDepFlag(msgTelex.getLoadingPt()
                .equalsIgnoreCase(HpEKConstants.EK_HOPO) ? "D"
                : "A");
          }
          msgTelex.setSendRecvFlag("R");
          msgTelex.setMsgSender((regexMatcher.group(2) == null) ? " "
              : regexMatcher.group(2));
          // msgTelex.setMsgSender(" ");
          if (regexMatcher.group(3) != null) {
            msgTelex.setMsgSendDay(regexMatcher.group(3).substring(
                0, 2));
            msgTelex.setMsgSendTime(regexMatcher.group(3)
                .substring(2));
          } else {
            msgTelex.setMsgSendDay(" ");
            msgTelex.setMsgSendTime(" ");
          }
          flightSearchObj.setREGN(regexMatcher.group(8));
          if (HpUfisUtils.isNotEmptyStr(regexMatcher.group(9))) {
            flightSearchObj.setFLUT(formatfltDate(regexMatcher
                .group(9)));
          }
          /*flightSearchObj
              .setDES3(regexMatcher.group(7) != null ? regexMatcher
                  .group(7).substring(3) : null);*/
          flightSearchObj.setORG3(msgTelex.getLoadingPt());

        } else {
          regexMatcher = regexLIR.matcher(message);
          if (regexMatcher.find()) {

            LOG.info("Group count: {}", regexMatcher.groupCount());
            /*
             * for (int i = 0; i < regexMatcher.groupCount(); i++) {
             *
             * Group count:13 0.Group :.HDQKMEK 070301 LOADING
             * INSTRUCTION/REPORT PREPARED BY EDNO ALL WEIGHTS IN
             * KILOS ABBASS 2 FROM/TO FLIGHT A/C REG VERSION GAT TAR
             * STD DATE TIME DXB LHR EK 0001 A6EDX 14F76J427Y B15
             * F19 0745 07MAY13 0701
             *
             * 1.Group :HDQKMEK 070301
             *
             * 2.Group :HDQKMEK 3.Group :070301 4.Group :DXB 5.Group
             * :LHR 6.Group :EK 7.Group :0001 8.Group :A6EDX 9.Group
             * :A6EDX 10.Group :07MAY13 11.Group :0701 12.Group
             * :0701
             *
             *
             * // To-DO LOG.info("Group :" + regexMatcher.group(i));
             * }
             */
            msgTelex.setMsgType("LIR"); // check
            msgTelex.setMsgFltno(HpUfisUtils.formatCedaFlno(
                regexMatcher.group(6), regexMatcher.group(7),
                null));
            msgTelex.setMsgFltDay(regexMatcher.group(10).substring(
                0, 2));
            msgTelex.setLoadingPt(regexMatcher.group(4));// Can
            // be
            // of
            // length
            // 4
            // as
            // well
            // ???
            msgTelex.setArrDepFlag(msgTelex.getLoadingPt()
                .equalsIgnoreCase(HpEKConstants.EK_HOPO) ? "D"
                : "A");
            msgTelex.setSendRecvFlag("R");
            // msgTelex.setMsgSender(regexMatcher.group(1)); //?????

            msgTelex.setMsgSender(regexMatcher.group(2) != null ? regexMatcher
                .group(2) : " ");
            if (HpUfisUtils.isNotEmptyStr(regexMatcher.group(3))) {
              msgTelex.setMsgSendDay(regexMatcher.group(3)
                  .substring(0, 2));
              msgTelex.setMsgSendTime(regexMatcher.group(3)
                  .substring(2));
            }
            flightSearchObj.setREGN(regexMatcher.group(9));
            flightSearchObj.setFLUT(formatfltDate(regexMatcher
                .group(10)));
            //flightSearchObj.setDES3(regexMatcher.group(5));
            flightSearchObj.setORG3(msgTelex.getLoadingPt());

          } else {
            LOG.info("Invalid Message.Dropping the Message.");
            return;
          }
        }
      }
      // flightSearchObj.setORG3(msgTelex.getLoadingPt());
      flightSearchObj.setFLNO(msgTelex.getMsgFltno());
      if (HpUfisUtils.isNotEmptyStr(msgTelex.getArrDepFlag())) {
        flightSearchObj.setADID(msgTelex.getArrDepFlag().charAt(0));
      }
      // calling for flight serach
      msgTelex.setIdFlight(afttabBean.findFlightByMultipleParams(
          flightSearchObj, false, msgTelex.getMsgType(),
          HpCommonConfig.fromOffset, HpCommonConfig.toOffset));
View Full Code Here

TOP

Related Classes of com.ufis_as.ufisapp.server.oldflightdata.entities.EntFlightSearchObj

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.