Package com.ufis_as.ek_if.core.entities

Examples of com.ufis_as.ek_if.core.entities.EntDbFlightDaily


  public DlFltDailyBean() {

  }

  public EntDbFlightDaily getFltDaily(EntFlightDailyDTO dto) {
    EntDbFlightDaily entity = null;
    try {
      Query query = em
          .createNamedQuery("EntDbFlightDaily.findByFlightInfo");
      query.setParameter("flno", dto.getFlightNumber());
      query.setParameter("org3", dto.getFltOrg3());
View Full Code Here


      dto.setFltOrg3(flightId.getDepStn());
      dto.setFltDes3(flightId.getArrStn());
      dto.setLegNum(String.valueOf(flightId.getLegNum()));
      dto.setFlut(fldaUtc);
      // query from flt_daily table to insert/update record (data store by event)
      EntDbFlightDaily fltDaily = fltDailyBean.getFltDaily(dto);
      if (fltDaily == null) {
        fltDaily = new EntDbFlightDaily();
        fltDaily.setCreatedUser(dtfl);
        fltDailyBean.persist(fltDaily);
      }
     
      // fill the via info
      String nexi = "";
        boolean isViaXafFound = false;
      if (!CONST_DELETE.equalsIgnoreCase(_actionType)) {
        fltDaily.setFltNumber(eventFlno);
          fltDaily.setFltOrigin3(event.getDepStn());
          fltDaily.setFltDest3(event.getArrStn());
          fltDaily.setDepNum(String.valueOf(event.getDepNum()));
          fltDaily.setLegNum(String.valueOf(event.getLegNum()));
          fltDaily.setFlut(eventFlut);
        fltDaily.setAct3(event.getAcSubType());
        fltDaily.setFltServiceType(event.getServiceType());
        fltDaily.setIsta(event.getFltStatus());
        fltDaily.setRecStatus(" ");
       
        // registration
        if (event.getTailNo() != null && event.getTailNo().getValue() != null) {
              if (event.getTailNo().getValue().matches(PATTERN_REGN)) {
                fltDaily.setFltRegn("");
              } else {
                fltDaily.setFltRegn(event.getTailNo().getValue());
              }
            } else {
              fltDaily.setFltRegn("");
            }
        // flda
        if (event.getFltDateLocal() != null) {
              ufisCalendar.setTime(event.getFltDateLocal().getValue());
              fltDaily.setFlda(ufisCalendar.getCedaDateString());
            } else {
              // if ADID is D, refer from STOD, others STOA (yyyyMMdd)
              if (ADID.D == infobjgeneric.getADID()) {
                if (HpUfisUtils.isNotEmptyStr(fldaFromStod)) {
                  fltDaily.setFlda(fldaFromStod);
                }
              } else {
                if (HpUfisUtils.isNotEmptyStr(fldaFromStoa)) {
                  fltDaily.setFlda(fldaFromStoa);
                }
              }
            }
        // flight duration (Duration from airborne to landing in minutes)
        if (event.getFltTime() != null && event.getFltTime().getValue() != null) {
        fltDaily.setFltDuration(new BigDecimal(event.getFltTime()
            .getValue()));
        }
        // schedule block time (off block to on block in minutes)
        if (event.getBlkTimeOrig() != null && event.getBlkTimeOrig().getValue() != null) {
        fltDaily.setScheOffOnblockDuration(new BigDecimal(event
            .getBlkTimeOrig().getValue()));
        }
        // actual block time (off block to on block in minutes)
            if (event.getBlkTimeAct() != null && event.getBlkTimeAct().getValue() != null) {
        fltDaily.setActualOffOnblockDuration(new BigDecimal(event
            .getBlkTimeAct().getValue()));
            }
            // TaxiOut/TaxiIn
            if (event.getTaxiOut() != null) {
                fltDaily.setExot(new BigDecimal(event.getTaxiOut().getValue()));
            }
            if (event.getTaxiIn() != null) {
                fltDaily.setExit(new BigDecimal(event.getTaxiIn().getValue()));
            }
            // flight remark
            StringBuilder viaRemark = new StringBuilder();
            for (FlightEvent.Events.Remark r : event.getRemark()) {
              viaRemark.append(r.getValue());
              viaRemark.append(" ");
            }
            fltDaily.setFltRemarks(viaRemark.toString());
            // supplement remark
            StringBuilder viaSiRemarkBuild = new StringBuilder();
          for (FlightEvent.Events.SiRemark remark : event.getSiRemark()) {
            viaSiRemarkBuild.append(remark.getValue());
            viaSiRemarkBuild.append(" ");
          }
          fltDaily.setFltSupplementRemarks(viaSiRemarkBuild.toString());
            // schedule block timing
          for (SchdDateTime schedule : event.getSchdDateTime()) {
            ufisCalendar.setTime(schedule.getValue());
            if ("Arrival".equalsIgnoreCase(schedule.getType())) {
              fltDaily.setSibtLoc(ufisCalendar.getTime());
              // Convert to UTC datetime
//          ufisCalendar.DateAdd(HpUfisAppConstants.OFFSET_LOCAL_UTC,
//              EnumTimeInterval.Hours);
//              fltDaily.setSibt(ufisCalendar.getTime());
              try {
            fltDaily.setSibt(df1.parse(df.format(ufisCalendar.getTime())));
          } catch (ParseException e) {
            LOG.warn("Cannot parse datetime: {}", e.getMessage());
          }
            } else if ("Departure".equalsIgnoreCase(schedule.getType())) {
              fltDaily.setSobtLoc(ufisCalendar.getTime());
              // Convert to UTC datetime
//          ufisCalendar.DateAdd(HpUfisAppConstants.OFFSET_LOCAL_UTC,
//              EnumTimeInterval.Hours);
//              fltDaily.setSobt(ufisCalendar.getTime());
              try {
            fltDaily.setSobt(df1.parse(df.format(ufisCalendar.getTime())));
          } catch (ParseException e) {
            LOG.warn("Cannot parse datetime: {}", e.getMessage());
          }
            }
          }
         
        // mvtDatetime
        for (FlightEvent.Events.MvtDateTime mvtDateTime : event.getMvtDateTime()) {
          String mvtType = mvtDateTime.getType();
                if (HpUfisUtils.isNullOrEmptyStr(mvtType)) {
                  continue;
                }
                Date tempDate = null;
                if (mvtDateTime.getValue() != null) {
                  ufisCalendar.setTime(mvtDateTime.getValue());
                 
                  // Convert to UTC datetime
//          ufisCalendar.DateAdd(HpUfisAppConstants.OFFSET_LOCAL_UTC,
//              EnumTimeInterval.Hours);
//          tempDate = ufisCalendar.getTime();
                  try {
                    tempDate = df1.parse(df.format(ufisCalendar.getTime()));
          } catch (ParseException e) {
            LOG.warn("Cannot parse datetime: {}", e.getMessage());
          }
                }
                switch (mvtType) {
                  case "AirborneEst":
                    // estimate airborne
                    fltDaily.setEtotLoc(ufisCalendar.getTime());
                    fltDaily.setEtot(tempDate);
                    break;
                    case "AirborneAct":
                      // actual airborne
                      fltDaily.setAtotLoc(ufisCalendar.getTime());
                      fltDaily.setAtot(tempDate);
                        break;
                    case "LandedEst":
                      // estimate landing
                      fltDaily.setEldtLoc(ufisCalendar.getTime());
                      fltDaily.setEldt(tempDate);
                      break;
                    case "LandedAct":
                      // actual landing
                      fltDaily.setAldtLoc(ufisCalendar.getTime());
                      fltDaily.setAldt(tempDate);
                        break;
                    case "OnBlocksEst":
                      // estimate in block
                      fltDaily.setEibtLoc(ufisCalendar.getTime());
                      fltDaily.setEibt(tempDate);
                        break;
                    case "OnBlocksAct":
                      // actual in block
                      fltDaily.setAibtLoc(ufisCalendar.getTime());
                      fltDaily.setAibt(tempDate);
                        break;
                    case "OffBlocksEst":
                      // estimate off block
                      fltDaily.setEobtLoc(ufisCalendar.getTime());
                      fltDaily.setEobt(tempDate);
                        break;
                    case "OffBlocksAct":
                      // actual off block
                      fltDaily.setAobtLoc(ufisCalendar.getTime());
                      fltDaily.setAobt(tempDate);
                        break;
                    case "StartTaxiAct":
                      // actual time of starting taxing
                      fltDaily.setAsttLoc(ufisCalendar.getTime());
                    fltDaily.setAstt(tempDate);
                        break;
                    case "NextInformation":
                      nexi = df.format(ufisCalendar.getTime());
                        isXafFound = true;
                        break;
                }
            }
      } else {
        fltDaily.setFltNumber(headFlno);
          fltDaily.setFltOrigin3(flightId.getDepStn());
          fltDaily.setFltDest3(flightId.getArrStn());
          fltDaily.setDepNum(String.valueOf(flightId.getDepNum()));
          fltDaily.setLegNum(String.valueOf(flightId.getLegNum()));
          fltDaily.setFlut(fldaUtc);
        fltDaily.setRecStatus("X");
      }
      fltDaily.setUpdatedUser(dtfl);
      fltDailyBean.update(fltDaily);
     
        // Event, Extension and DelayCode related table only store for non-Hopo by interface
        if (!HpEKConstants.HOPO.equalsIgnoreCase(flightId.getDepStn())
            && !HpEKConstants.HOPO.equalsIgnoreCase(flightId.getArrStn())) {
         
          if (!CONST_DELETE.equalsIgnoreCase(_actionType)) {
            // XAFTAB related info
                // AcOwner
              String acow = "";
              String acex = "";
                if (event.getAcOwner() != null) {
                  acow = event.getAcOwner();
                  isViaXafFound = true;
                }
                // AcVersion
                if (event.getAcVersion() != null) {
                  acex = event.getAcVersion();
                  isViaXafFound = true;
                }
            if (isViaXafFound) {
              // find via related xaftab info
                EntDbXaftab xaftab = xaftabBean.findByFltDailyId(fltDaily.getId());
                if (xaftab == null) {
                  xaftab = new EntDbXaftab();
                  xaftab.setIdfd(fltDaily.getId());
                  xaftabBean.persist(xaftab);
                }
                xaftab.setIdfd(fltDaily.getId());
                xaftab.setAcow(acow);
                xaftab.setAcex(acex);
                xaftab.setNexi(nexi);
                xaftabBean.update(xaftab);
            }
             
              // DCFTAB related info
              // Get Delays
              if (flightEvent.getDelays() != null) {
                for (FlightEvent.Delays.Delay delay : flightEvent.getDelays().getDelay()) {
                  EntDbDcftab dcftab = dcftabBean.findByFltDailyIdAndDelayCode(fltDaily.getId(), delay.getCode());
                  if (dcftab == null) {
                    dcftab = new EntDbDcftab();
                    dcftab.setUsec(dtfl);
                    dcftabBean.persist(dcftab);
                  }
                  dcftab.setIdfd(fltDaily.getId());
                      ufisCalendar.setTime(delay.getPostedOn());
                      dcftab.setCdat(ufisCalendar.getCedaString());
                      dcftab.setDeca(delay.getCode());
                      dcftab.setDura(String.format(FMT_DURA, delay.getAmount()));
                      dcftab.setUseu(dtfl);
                      dcftabBean.update(dcftab);
                  }
              }
             
              // FEVTAB related info
              // RTG
              if (event.getRtg() != null) {
                EntDbFevtab fevtab = fevtabBean.findByFltDailyId(fltDaily.getId());
                if (fevtab == null) {
                  fevtab = new EntDbFevtab();
                  fevtab.setUSEC(dtfl);
                  fevtabBean.persist(fevtab);
                }
                if (event.getRtg().getLastDoorCl() != null) {
                  ufisCalendar.setTime(event.getRtg().getLastDoorCl());
                  fevtab.setSTTM(df.format(ufisCalendar.getTime()));
                }
                fevtab.setSTNM("Ready to Go");
                fevtab.setSTFL(event.getRtg().getValue());
                fevtab.setSTRM("");
                fevtab.setUSEU(dtfl);
                fevtabBean.update(fevtab);
              }
          }
        }
       
        /**
       * 2013-12-26 updated by JGO - Adding fltDaily id to CEDA message
       */
      List<String> fltDailyIds = fltDailyBean.getFltDailyIds(dto);
      if (fltDailyIds != null && fltDailyIds.size() > 0) {
        for (String id : fltDailyIds) {
          INFOBJFLTDAILY infobjfltdaily = new INFOBJFLTDAILY();
          infobjfltdaily.setID(id);
          infobjfltdailylist.getINFOBJFLTDAILY().add(infobjfltdaily);
        }
      }

      // ============= infobjFlight ===============================
        // infobjFlight - flight info update
        // ============= infobjFlight ===============================
        if (!CONST_DELETE.equalsIgnoreCase(_actionType)) {
          // Airline
          String airline = event.getCxCd();
            if (airline.length() == 2) {
                infobjFlight.setALC2(airline);
            } else {
                infobjFlight.setALC3(airline);
            }
            // Flight number in Ceda format
            infobjFlight.setFLTN(HpUfisUtils.formatCedaFltn(event.getFltNum()));
            if (airline.length() == 3) {
              infobjFlight.setFLNO(airline + infobjFlight.getFLTN());
            } else {
              infobjFlight.setFLNO(airline + " " + infobjFlight.getFLTN());
            }
            // Suffix
            if (HpUfisUtils.isNotEmptyStr(event.getFltSuffix())) {
                infobjFlight.setFLNS(event.getFltSuffix());
                // 2013-08-19 updated by JGO - adding suffix info to flno as well
                if (fltn.length() == 5) {
                  infobjFlight.setFLNO(infobjFlight.getFLNO() + event.getFltSuffix());
              } else if (fltn.length() == 4) {
                infobjFlight.setFLNO(infobjFlight.getFLNO() + " " + event.getFltSuffix());
              } else if (fltn.length() == 3) {
                infobjFlight.setFLNO(infobjFlight.getFLNO() + " " + " " + event.getFltSuffix());
              }
            }

            /*// FLUT - Flight date in utc
            infobjFlight.setFLUT(fldaUtc);
            // FLDA(local) - if cannot find from tag, getting from schedule time
            if (event.getFltDateLocal() != null) {
              ufisCalendar.setTime(event.getFltDateLocal().getValue());
              infobjFlight.setFLDA(ufisCalendar.getCedaDateString());
            } else {
              // if ADID is D, refer from STOD, others STOA (yyyyMMdd)
              if (ADID.D == infobjgeneric.getADID()) {
                if (HpUfisUtils.isNotEmptyStr(fldaFromStoa)) {
                  infobjFlight.setFLDA(fldaFromStoa);
                }
                if (HpUfisUtils.isNotEmptyStr(fldaFromStod)) {
                  infobjFlight.setFLDA(fldaFromStod);
                }
              } else {
                if (HpUfisUtils.isNotEmptyStr(fldaFromStod)) {
                  infobjFlight.setFLDA(fldaFromStod);
                }
                if (HpUfisUtils.isNotEmptyStr(fldaFromStoa)) {
                  infobjFlight.setFLDA(fldaFromStoa);
                }
              }
            }*/
           
            // ADID
            if (HpEKConstants.HOPO.equalsIgnoreCase(event.getDepStn())
                && HpEKConstants.HOPO.equalsIgnoreCase(event.getArrStn())) {
                //Return Flight /TAxi
                infobjFlight.setADID(ADID.B);
                infobjFlight.setORG3(HpEKConstants.HOPO);
                infobjFlight.setDES3(HpEKConstants.HOPO);
                infobjFlight.setDEPN(String.valueOf(event.getDepNum()));

                // when body is return flight info, update to header
                infobjgeneric.setADID(ADID.B);
                infobjgeneric.setORG3(HpEKConstants.HOPO);
              infobjgeneric.setDES3(HpEKConstants.HOPO);
              // depNum
            } else if (HpEKConstants.HOPO.equalsIgnoreCase(event.getArrStn())) {
                //Arival
                infobjFlight.setADID(ADID.A);
                infobjFlight.setORG3(event.getDepStn());
                infobjFlight.setDES3(HpEKConstants.HOPO);
                // depNum
                infobjFlight.setDEPN(String.valueOf(event.getDepNum()));
            } else if (HpEKConstants.HOPO.equalsIgnoreCase(event.getDepStn())) {
                //Departure
                infobjFlight.setADID(ADID.D);
                infobjFlight.setORG3(HpEKConstants.HOPO);
                infobjFlight.setDES3(event.getArrStn());
                // depNum
                infobjFlight.setDEPN(String.valueOf(event.getDepNum()));
            }
           
          // only HOPO message will pass full info
          if (HpEKConstants.HOPO.equals(event.getArrStn())
            || HpEKConstants.HOPO.equals(event.getDepStn())) {
           
            // 2013-11-27 updated by JGO - flda and flut in infobj_flight only when hopo message
            // FLUT - Flight date in utc
                infobjFlight.setFLUT(fldaUtc);
               
                // FLDA(local) - if cannot find from tag, getting from schedule time
                if (event.getFltDateLocal() != null) {
                  ufisCalendar.setTime(event.getFltDateLocal().getValue());
                  infobjFlight.setFLDA(ufisCalendar.getCedaDateString());
                } else {
                  // if ADID is D, refer from STOD, others STOA (yyyyMMdd)
                  if (ADID.D == infobjgeneric.getADID()) {
                    /*if (HpUfisUtils.isNotEmptyStr(fldaFromStoa)) {
                      infobjFlight.setFLDA(fldaFromStoa);
                    }*/
                    if (HpUfisUtils.isNotEmptyStr(fldaFromStod)) {
                      infobjFlight.setFLDA(fldaFromStod);
                    }
                  } else {
                    /*if (HpUfisUtils.isNotEmptyStr(fldaFromStod)) {
                      infobjFlight.setFLDA(fldaFromStod);
                    }*/
                    if (HpUfisUtils.isNotEmptyStr(fldaFromStoa)) {
                      infobjFlight.setFLDA(fldaFromStoa);
                    }
                  }
                }
           
            // Service Type
                infobjFlight.setSTYP(event.getServiceType());
               
                // AcType
                // IATA aircraft subtype as per SSIM
                infobjFlight.setACT3(event.getAcSubType());
               
                // Registration
                // 2013-05-14 updated by JGO - if 4 digits regn, ignored
                // 2013-05-31 updated by JGO - if 4 digits or less, and all numeric regn, ignored
                if (event.getTailNo() != null && event.getTailNo().getValue() != null) {
                  //if (event.getTailNo().getValue().length() <= 4) {
                  if (event.getTailNo().getValue().matches(PATTERN_REGN)) {
                    infobjFlight.setREGN("");
                  } else {
                    infobjFlight.setREGN(event.getTailNo().getValue());
                  }
                } else {
                  // regn is null, clear value
                  //infobjFlight.setREGN("");
                }
               
                // schedule datetime
                infobjFlight.setSTOA(stoa);
                infobjFlight.setSTOD(stod);
               
                // TaxiOut/TaxiIn
                if (event.getTaxiOut() != null) {
                    infobjFlight.setEXOT(event.getTaxiOut().getValue().toString());
                }
                if (event.getTaxiIn() != null) {
                    infobjFlight.setEXIT(event.getTaxiIn().getValue().toString());
                }
               
                /**
                 * Flight Status(From CORE)
                 * CODE STATUS_DESCRIPTION
                 * 1 RTNG RETURNED, IN FLIGHT
                 * 2 DVTG DIVERTED, IN FLIGHT
                 * 3 PDEP NOT YET DEPARTED
                 * 4 OFBL TAXIING FOR TAKEOFF
                 * 5 ENRT IN FLIGHT
                 * 6 LAND LANDED AND TAXIING
                 * 7 ARVD ARRIVED
                 * 8 CNLD CANCELLED
                 * 9 DVTD ARRIVED DIVERSION AIRPORT
                 * 10 DNLD TAXIING DIVERSION AIRPORT
                 * 11 RROF REROUTED, TAXIING
                 * 12 RRTG REROUTED, IN FLIGHT
                 * 13 RRTD REROUTED, LANDED
                 * 14 RTDR RETURNED TO STAND
                 * 15 RTND RETURNED DEPARTURE AIRPORT
                 * 16 DLND DIVERTED
                 * 17 RRLD REROUTED AND LANDING
                 */
                String flightStatus = event.getFltStatus();
                infobjFlight.setISTA(flightStatus);
                infobjFlight.setFTYP(CONST_FTYP_O);
          switch (flightStatus) {
          case CONST_CANCEL:
            infobjFlight.setFTYP(CONST_FTYP_X);
            break;
          }
         
                // SiRemarks
                List<FlightEvent.Events.SiRemark> siRemarks = event.getSiRemark();
                StringBuilder siRemarkBuild = new StringBuilder();
                if (siRemarks != null) {
                  for (FlightEvent.Events.SiRemark remark : siRemarks) {
                    siRemarkBuild.append(remark.getValue());
                    siRemarkBuild.append(" ");
                  }
                }
                infobjFlight.setREM2(siRemarkBuild.toString());
               
                // 2013-11-22 updated by JGO - Adding Remark
                StringBuilder remarkBuild = new StringBuilder();
                for (FlightEvent.Events.Remark r : event.getRemark()) {
                  remarkBuild.append(r.getValue());
                  remarkBuild.append(" ");
                }
                //infobjFlight.setREM1(remarkBuild.toString());
                infobjFlight.setRRMK(remarkBuild.toString());
               
                // Cabin door and Cargo door events (clarify dorFlag and remark is for which field)
                // 2013-04-18 updated by JGO - change fevtab to fevtab list
                // 2013-05-15 updated by JGO - Remove these info
                /*
        if (event.getCABINDOORCLOSURE() != null) {
          INFOJFEVTAB cabinDoor = new INFOJFEVTAB();
          ufisCalendar.setTime(event.getCABINDOORCLOSURE().getValue());
          cabinDoor.setSTNM("CABIN DOOR CLOSURE");
          cabinDoor.setSTTM(ufisCalendar.getCedaString());
          cabinDoor.setSTFL(event.getDorFlag());
          cabinDoor.setSTRM(event.getDorRemark());
          infojfevtablist.getINFOJFEVTAB().add(cabinDoor);
        }
        if (event.getCARGODOORCLOSURE() != null) {
          INFOJFEVTAB cargoDoor = new INFOJFEVTAB();
          ufisCalendar.setTime(event.getCARGODOORCLOSURE().getValue());
          cargoDoor.setSTNM("CARGO DOOR CLOSURE");
          cargoDoor.setSTTM(ufisCalendar.getCedaString());
          cargoDoor.setSTFL(event.getDorFlag());
          cargoDoor.setSTRM(event.getDorRemark());
          infojfevtablist.getINFOJFEVTAB().add(cargoDoor);
        }
                */
               
                // Flight duration
                if (event.getFltTime() != null && event.getFltTime().getValue() != null) {
                  infobjFlight.setFDUR(event.getFltTime().getValue().toString());
                }
                // Schedule/Actual Block Time (min)
                if (event.getBlkTimeOrig() != null && event.getBlkTimeOrig().getValue() != null) {
                  infobjFlight.setSOOB(event.getBlkTimeOrig().getValue().toString());
                }
                if (event.getBlkTimeAct() != null && event.getBlkTimeAct().getValue() != null) {
                  infobjFlight.setAOOB(event.getBlkTimeAct().getValue().toString());
                }
               
                /**
                 *  <Fuel units="" type="" >xxxx</Fuel>
                 *  units not required
                 *  type required
                 *  value
                 * 
                 *  Design documents:
                 *  units -> FUEU
                 *  type  -> FUET
                 */
                // 2013-06-19 updated by JGO - Move fuel related into FLT_FUEL_STATUS
                /* 2013-06-23 updated by JGO - As discussed with Ritu(DTP),
                 *                  fuel info will get from EGDS, no Core fuel info will be used
                // find flt_fuel_status by flight info
                EntDbFlightFuelStatus fltFuelStatus = fltFuelStatusBean.findByFlight(
                    carrier,
                    fltn,
                    infobjgeneric.getFLNS(),
                    infobjgeneric.getFLDA());
                if (fltFuelStatus == null) {
                  fltFuelStatus = new EntDbFlightFuelStatus();
                  fltFuelStatus.setAirlineCode2(carrier);
                  fltFuelStatus.setFlightNumber(fltn);
                  if (HpUfisUtils.isNotEmptyStr(infobjgeneric.getFLNS())) {
                    fltFuelStatus.setFltSuffix(infobjgeneric.getFLNS().charAt(0));
                  }
                  fltFuelStatus.setFltDate(infobjgeneric.getFLDA());
                  fltFuelStatus.setDataSource(MSGIF);
                  fltFuelStatus.setRecStatus(' ');
                  fltFuelStatusBean.persist(fltFuelStatus);
                }
                // TODO check the default units
                // Units to measurement for the fuel
                List<FlightEvent.Events.Fuel> fuels = event.getFuel();
                boolean isFuelInfoIncluded = false;
              for (FlightEvent.Events.Fuel fuel : fuels) {
                    //infojxaftab.setFUEU(fuel.getUnits());
                    //infojxaftab.setFUET(fuel.getType());
                isFuelInfoIncluded = true;
          if (fuel.getType() != null) {
            float value = fuel.getValue().floatValue();
            // fuel units - need to convert to kg
                  if (HpUfisUtils.isNotEmptyStr(fuel.getUnits())) {
                    // convert to kg
                  }
                  // fule types
            switch (fuel.getType()) {
            case FUEL_TYPE_TOW:
              // take off weight
                    infojxaftab.setTOWT(String.valueOf(value));
              break;
            case FUEL_TYPE_ZFW:
              // zero fuel weight
                    infojxaftab.setZFWT(String.valueOf(value));
              break;
            case FUEL_TYPE_TOF:
              fltFuelStatus.setTakeoffFuel(value);
              break;
            case FUEL_TYPE_FOA:
              fltFuelStatus.setArrivalFuel(value);
              break;
            default:
              LOG.debug("Unexpected fuel type: {}", fuel.getType());
              break;
            }
          }
                }
             
              if (isFuelInfoIncluded) {
                fltFuelStatusBean.update(fltFuelStatus);
              }
                */
               
                // XAFTAB related info
                // AcOwner
                if (event.getAcOwner() != null) {
                  infojxaftab.setACOW(event.getAcOwner());
                  isXafFound = true;
                }
               
                // AcVersion
                if (event.getAcVersion() != null) {
                  infojxaftab.setACEX(event.getAcVersion());
                  isXafFound = true;
                }
               
                // MvtDatetimes - Local
                List<FlightEvent.Events.MvtDateTime> mvtDateTimes = event.getMvtDateTime();
                /**
                 * AirborneEst (Estimated Airborne time)      - ETON
                 * AirborneAct (Actual Aiborne time)          - ATON
                 * LandedEst (Estimated landing time)         - ELDN
                 * LandedAct (Actual landing time)            - ALDN
                 * OnBlocksEst (Estimated on block time)      - EIBN
                 * OnBlocksAct (Actual on block time)        - AIBN
                 * OffBlocksEst (Estimated off block time)     - EOBN
                 * OffBlocksAct (Actual off block time)       - AOBN
                 * StartTaxiAct (Actual time of start taxing) - ASTN
                 * NextInformation:                           - NEXI(XAFTAB)
                 *  (Time at which next information for the flight shall be made available)
                 *
                 */
                for (FlightEvent.Events.MvtDateTime mvtDateTime : mvtDateTimes) {
                    String mvtType = mvtDateTime.getType() == null ? "" : mvtDateTime.getType();
                    String cedaTime = "";
                    if (mvtDateTime.getValue() != null) {
                      ufisCalendar.setTime(mvtDateTime.getValue());
                      //cedaTime = ufisCalendar.getCedaString();
                      cedaTime = df.format(ufisCalendar.getTime());
                    }
                    switch (mvtType) {
                        case "AirborneAct":
                            infobjFlight.setATON(cedaTime);
                            break;
                        case "LandedEst":
                            infobjFlight.setELDN(cedaTime);
                            break;
                        case "LandedAct":
                            infobjFlight.setALDN(cedaTime);
                            break;
                        case "OnBlocksAct":
                          infobjFlight.setAIBN(cedaTime);
                            break;
                        case "OnBlocksEst":
                          infobjFlight.setEIBN(cedaTime);                           
                            break;
                        case "OffBlocksEst":
                            infobjFlight.setEOBN(cedaTime);
                            break;
                        case "OffBlocksAct":
                            infobjFlight.setAOBN(cedaTime);
                            break;
                        case "AirborneEst":
                            infobjFlight.setETON(cedaTime);
                            break;
                        case "StartTaxiAct":
                            infobjFlight.setASTN(cedaTime);
                            break;
                        case "NextInformation":
                            infobjFlight.setNXTI(cedaTime);
                            infojxaftab.setNEXI(cedaTime);
                            isXafFound = true;
                            break;
                    }
                }
               
                // RTG
                FlightEvent.Events.Rtg rtg = event.getRtg();
                if (rtg != null) {
                  INFOJFEVTAB fev = new INFOJFEVTAB();
                  if (rtg.getLastDoorCl() != null) {
                    ufisCalendar.setTime(rtg.getLastDoorCl());
                    //fev.setSTTM(ufisCalendar.getCedaString());
                    fev.setSTTM(df.format(ufisCalendar.getTime()));
                  }
                    fev.setSTNM("Ready to Go");
                    fev.setSTFL(rtg.getValue());
                    fev.setSTRM("");
                    // flight daily id
                    fev.setIDFD(fltDaily.getId());
                    infojfevtablist.getINFOJFEVTAB().add(fev);
                }
               
                // Get Delays
                if (flightEvent.getDelays() != null) {
                  List<FlightEvent.Delays.Delay> delays = flightEvent.getDelays().getDelay();
                  for (FlightEvent.Delays.Delay delay : delays) {
                        INFOJDCFTAB infojdcftab = new INFOJDCFTAB();
                        ufisCalendar.setTime(delay.getPostedOn());
                        infojdcftab.setCDAT(ufisCalendar.getCedaString());
                        infojdcftab.setDECA(delay.getCode());
                        infojdcftab.setDURA(String.format(FMT_DURA, delay.getAmount()));
                        // flight daily id
                        infojdcftab.setIDFD(fltDaily.getId());
                        infojdcftablist.getINFOJDCFTAB().add(infojdcftab);
                    }
//                } else {
//                  // if tags are null, clear all delay info from dcftab
//                  INFOJDCFTAB infojdcftab = new INFOJDCFTAB();
//                  infojdcftablist.getINFOJDCFTAB().add(infojdcftab);
                }
          }
        }
       
        if (ACTIONTYPE.D != _msgActionType) {
          // Handle Via for non-return flights
          StringBuilder vial = new StringBuilder();
          boolean isFirstMsg = true;
          if (msgChains != null && ADID.B != infobjgeneric.getADID()) {
            // Let Ceda decide insert or update
            _msgActionType = null;
           
              Iterator<EntDbCoreTmp> iter = msgChains.iterator();
              while (iter.hasNext()) {
                EntDbCoreTmp temp = iter.next();
                if (isFirstMsg) {
                  infobjFlight.setORG3(temp.getDepStn());
                  // 2013-12-30 updated by JGO - Set stoa as orign
                  infobjFlight.setSTOD(temp.getSchDep());
                    isFirstMsg = false;
                  }
                  // last record
                  if (!iter.hasNext()) {
                  infobjFlight.setDES3(temp.getArrStn());
                  // 2013-12-30 updated by JGO - Set stod as destination
                  infobjFlight.setSTOA(temp.getSchArr());
                    break;
                  }
                  // update vias
                    vial.append(createVia(temp, infobjgeneric.getADID(), ufisCalendar));
              }
              infobjFlight.setVIAN(Integer.toString(msgChains.size() -1));
              infobjFlight.setVIAL(vial.toString());
              if (ADID.A.equals(infobjFlight.getADID())) {
            LOG.info("VIA Found  {} {} {} {}",
                new Object[] { infobjFlight.getADID(), vial.toString(),
                    flightEvent.getFlightId().getDepStn(),
                    flightEvent.getFlightId().getArrStn() });
                } else {
            LOG.info(
                "VIA Found  {} {} {} {}",
                new Object[] { infobjFlight.getADID(),
                    flightEvent.getFlightId().getDepStn(),
                    flightEvent.getFlightId().getArrStn(),
                    vial.toString() });
                }
          }
        }
       
        // transUserId and transDatetime
        if (flightEvent.getAudit() != null) {
          infobjFlight.setUSEU(flightEvent.getAudit().getTransUserId());
          if (flightEvent.getAudit().getTransDateTime() != null) {
            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);
View Full Code Here

TOP

Related Classes of com.ufis_as.ek_if.core.entities.EntDbFlightDaily

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.