Пример #1
0
 private void createAlert(AcInputChannel channel) {
   AcReceivedFileAlert alert = _access.newReceivedFileAlert();
   alert.setInputChannelId(channel.getId());
   alert.setCreateUtcTs(_now);
   alert.setExpirationUtcTs(getAlertExpiration());
   _access.getReceivedFileAlertDb().insert(alert);
 }
Пример #2
0
 private JwList<AcReceivedFileRollup> getRollupData(
     AcInputChannel channel, JwTimestamp start, JwTimestamp end) {
   debug(
       "Retrieving rollup data for account %s, channel %s, start %s, end %s",
       _access.getAccountCode(), channel.getName(), start, end);
   return _access.getReceivedFileRollupDb().getAllBetweenUtc(channel.getId(), start, end);
 }
Пример #3
0
  protected AcFlight getDepartingFlight(Integer itemId) {
    AcActionTypeEnum[] types = {AcActionTypeEnum.LOAD_ITEM, AcActionTypeEnum.DEPART_ITEM};

    AcResult flightAction = _access.getResultDb().getLastByItemIdAndActionTypes(itemId, types);
    AcFlight f = null;
    if (flightAction != null) f = _access.getFlightDb().getFlight(flightAction.getFlightId());
    return f;
  }
Пример #4
0
  private void loadLatestModelsRelatedToGroups(
      JwMap<Integer, JwSet<Integer>> m, Integer bId, JwSet<Integer> groups) {
    enterMonitor("AcActionSnapshotLoader.loadGroups");
    try {
      JwList<AcBatchItem> is;
      JwList<AcBatchNest> ns;
      JwList<AcBatchAlias> as;
      JwList<AcBatchFlight> fs;

      JwTimestamp utcTs = _batch.getStartUtcTs();
      is = _access.getBatchItemDb().getLatestViewBeforeByBatchGroups(bId, groups, utcTs);
      ns = _access.getBatchNestDb().getLatestViewBeforeByBatchGroups(bId, groups, utcTs);
      as = _access.getBatchAliasDb().getLatestViewBeforeByBatchGroups(bId, groups, utcTs);
      fs = _access.getBatchFlightDb().getLatestViewBeforeByBatchGroups(bId, groups, utcTs);

      for (AcBatchItem e : is) {
        //                if ( e.hasItemId(DEBUG_ITEM_ID) )
        //                {
        //                    debug("x","Item "+ e.getItemId()+ " batch "+ e.getBatchId()+ " group
        // "+ e.getGroupCode());
        //                    Thread.dumpStack();
        //                }
        _items.putIfMissing(e.getItemId(), e);
        addBatchGroup(m, e.getBatchId(), e.getGroupCode());
      }
      for (AcBatchNest e : ns) {
        _nests.putIfMissing(e.getNestId(), e);
        addBatchGroup(m, e.getBatchId(), e.getGroupCode());
      }
      for (AcBatchAlias e : as) {
        _aliases.putIfMissing(e.getAliasId(), e);
        //                if ( _aliases.putIfMissing(e.getAliasId(), e) )
        //                {
        //                    if ( e.hasAliasId(DEBUG_ALIAS_ID) )
        //                    {
        //                        debug("x", "Alias "
        //                            + e.getAliasId()
        //                            + " batch "
        //                            + e.getBatchId()
        //                            + " group "
        //                            + e.getGroupCode());
        //                        Thread.dumpStack();
        //                    }
        //                }
        addBatchGroup(m, e.getBatchId(), e.getGroupCode());
      }
      for (AcBatchFlight e : fs) {
        _flights.putIfMissing(e.getFlightId(), e);
        addBatchGroup(m, e.getBatchId(), e.getGroupCode());
      }
    } finally {
      exitMonitor();
    }
  }
Пример #5
0
  // ##################################################
  // # reporting
  // ##################################################//
  private void reportNoCarditProcessed(AcInputChannel channel, JwTimestamp start, JwTimestamp end) {
    String subject =
        JwUtility.format(
            "No CARDIT processed for channel: %s, account: %s",
            channel.getName(), _access.getAccountCode());

    String msg =
        JwUtility.format(
            "Report run at: %s. No CARDITs processed between %s and %s for %s in account %s",
            _now, start, end, channel.getName(), _access.getAccountCode());

    reportMessage(subject, msg);
  }
Пример #6
0
 protected AcAirport getAirport(String airportCode) {
   String accountCode = _access.getAccountCode();
   return AcCacheRegistry.instance
       .getAccount(accountCode)
       .getAirportCache()
       .getAirport(airportCode);
 }
Пример #7
0
  private void fillDatabaseAliases(JwSet<Integer> aliasIds) {
    JwList<AcBatchAlias> v =
        _access.getBatchAliasDb().getBatchAliasesBefore(_batch.getStartUtcTs(), aliasIds);
    for (AcBatchAlias e : v) {
      Integer id = e.getAliasId();
      if (isAliasLoaded(id)) continue;

      _aliases.put(id, e);
      //            if ( id == DEBUG_ALIAS_ID )
      //            {
      //                debug(
      //                    "x",
      //                    "Alias "
      //                        + e.getAliasId()
      //                        + " batch "
      //                        + e.getBatchId()
      //                        + " group "
      //                        + e.getGroupCode());
      //                Thread.dumpStack();
      //            }
      if (e.hasGroupCode()) {
        // debug("1","Alias "+ e.getAliasId()+ " batch "+ e.getBatchId()+ " group "+
        // e.getGroupCode());
        addBatchGroup(_batchGroups, e.getBatchId(), e.getGroupCode());
      }
    }
  }
Пример #8
0
  private void init() {
    String accountCode = _access.getAccountCode();
    AcPropertyRegistry pr = AcPropertyRegistries.getAccount(accountCode);

    _emailConfiguration = getEmailConfiguration(pr);
    _logResults = pr.getReceivedFileMonitorLoggingEnabled();
    _alertExpirationMinutes = pr.getReceivedFileAlertExpirationMinutes();
  }
Пример #9
0
 protected AcConsignment getConsignment(Integer id) {
   AcConsignment c = _consignmentMap.get(id);
   if (c == null) {
     c = _access.getConsignmentDb().getConsignment(id);
     _consignmentMap.put(id, c);
   }
   return c;
 }
Пример #10
0
  private void testAllNestsLoaded() {
    JwSet<Integer> missingIds = new JwSet<Integer>();
    for (Integer flightId : _flights.keySet()) {
      JwList<Integer> dbIds = _access.getNestDb().getAllIdsByRootFlightId(flightId);
      missingIds.addAll(dbIds);
    }
    removeLoaded(missingIds, _nests.keySet());

    if (missingIds.isNotEmpty()) debug(null, "    MISSING NESTS: " + missingIds);
  }
Пример #11
0
  protected byte[] run() {
    _nowUtcTs = AcGlobals.nowUtc();

    makeModels();

    String accountCode = _access.getAccountCode();
    AcPropertyRegistry pr = AcPropertyRegistries.getAccount(accountCode);
    AcCn46Document document = new AcCn46Document(pr);
    byte[] pdf = document.makeDocument(_models.getValues());
    _isValidCn46Document = document.isValidDocument();
    return pdf;
  }
Пример #12
0
  public void loadBatch(AcBatch b) {
    enterMonitor("AcActionSnapshotLoader.loadBatch");
    try {
      _batch = b;
      Integer batchId = b.getId();

      JwList<AcBatchItem> items = _access.getBatchItemDb().getAllByBatchId(batchId);
      JwList<AcBatchNest> nests = _access.getBatchNestDb().getAllByBatchId(batchId);
      JwList<AcBatchAlias> aliases = _access.getBatchAliasDb().getAllByBatchId(batchId);
      JwList<AcBatchFlight> flights = _access.getBatchFlightDb().getAllByBatchId(batchId);

      _items = AcBatchItem.toItemIdMap(items);
      //            AcBatchItem e = _items.get(DEBUG_ITEM_ID);
      //            if ( e != null )
      //            {
      //                debug("x","Item "+ e.getItemId()+ " batch "+ e.getBatchId()+ " group "+
      // e.getGroupCode());
      //                Thread.dumpStack();
      //            }

      _nests = AcBatchNest.toNestIdMap(nests);
      _aliases = AcBatchAlias.toAliasIdMap(aliases);
      //            AcBatchAlias e = _aliases.get(DEBUG_ALIAS_ID);
      //            if ( e != null )
      //            {
      //                debug(
      //                    "x",
      //                    "Alias "
      //                        + e.getAliasId()
      //                        + " batch "
      //                        + e.getBatchId()
      //                        + " group "
      //                        + e.getGroupCode());
      //                Thread.dumpStack();
      //            }
      _flights = AcBatchFlight.toFlightIdMap(flights);
    } finally {
      exitMonitor();
    }
  }
Пример #13
0
 protected void makeModel(
     Integer itemId,
     String offloadingAirport,
     boolean useUld,
     boolean splitOnDispatchDestination) {
   AcItem i = _access.getItemDb().getItem(itemId);
   AcTag tag = AcTagParser.createOverrideTypeSettings(i.getTag());
   if (tag.isUpu()) {
     AcUpuTag upuTag = tag.asUpu();
     AcCn46ActualConveyanceModel model =
         getModel(i, upuTag, offloadingAirport, splitOnDispatchDestination);
     addTagToModel(model, i, upuTag, useUld);
   }
 }
Пример #14
0
  private void fillDatabaseFlights(JwSet<Integer> flightIds) {
    JwList<AcBatchFlight> v =
        _access.getBatchFlightDb().getBatchFlightsBefore(_batch.getStartUtcTs(), flightIds);
    for (AcBatchFlight e : v) {
      Integer id = e.getFlightId();
      if (isFlightLoaded(id)) continue;

      _flights.put(id, e);
      if (e.hasGroupCode()) {
        // debug("1","Flight "+ e.getFlightId()+ " batch "+ e.getBatchId()+ " group "+
        // e.getGroupCode());
        addBatchGroup(_batchGroups, e.getBatchId(), e.getGroupCode());
      }
    }
  }
Пример #15
0
  private void fillDatabaseItems(JwSet<Integer> itemIds) {
    JwList<AcBatchItem> v =
        _access.getBatchItemDb().getBatchItemsBefore(_batch.getStartUtcTs(), itemIds);
    for (AcBatchItem e : v) {
      Integer id = e.getItemId();
      if (isItemLoaded(id)) continue;

      _items.put(id, e);
      if (e.hasGroupCode()) {
        // debug("1","Item "+ e.getItemId()+ " batch "+ e.getBatchId()+ " group "+
        // e.getGroupCode());
        addBatchGroup(_batchGroups, e.getBatchId(), e.getGroupCode());
      }
    }
  }
Пример #16
0
  protected AcCn46ActualConveyanceModel getModel(
      AcItem i, AcUpuTag upuTag, String offloadingAirport, boolean splitOnDispatchDestination) {
    AcFlight f = getDepartingFlight(i.getId());
    AcResult last = getLastHandledAction(i.getId());

    _dummy.clear();
    _dummy.setTypeFromTag(upuTag);
    if (splitOnDispatchDestination)
      _dummy.setDispatchDestination(upuTag.getDestinationDispatchImpcCode());
    if (last != null) {
      AcAirport a = getAirport(last.getAirportCode());
      _dummy.setLastHandledAirport(last.getAirportCode());
      _dummy.setGeneratedTz(a.getTimeZone());
    }
    _dummy.setOriginAdministration(i.getUpuShortPostName());
    _dummy.setAirportOfOffloading(offloadingAirport);
    if (f != null) {
      _dummy.setAirportOfLoading(f.getOriginAirportCode());
      _dummy.setFlightCarrierCode(f.getOperatorCarrierCode());
      _dummy.setFlightNumber(f.getOperatorNumber());
      _dummy.setFlightNumberDisplayLabel(f.getOperatorNumberDisplayLabel());
      _dummy.setDepartureDt(
          f.hasActualDepartureLocalTs()
              ? f.getActualDepartureLocalTs().getDate()
              : f.getScheduledDepartureLocalDt());
    }
    String key = _dummy.getHashKey();
    AcCn46ActualConveyanceModel model = _models.get(key);
    if (model == null) {
      model = _dummy.getCopy();
      model.setCarrierCode(AcUtility.getAccountCarrierName(_access.getAccountCode()));
      model.setGeneratedTs(_nowUtcTs);
      model.setNote("** Note: This document was generated out of VelocityMail **");
      _models.put(key, model);
    }

    return model;
  }
Пример #17
0
 protected AcConsignmentFlight getLastConsignmentFlightLeg(Integer id) {
   return _access.getConsignmentFlightDb().getLastConsignmentFlight(id);
 }
Пример #18
0
 protected AcResult getLastHandledAction(Integer itemId) {
   AcResult action = _access.getResultDb().getLastByItemId(itemId);
   return action;
 }
Пример #19
0
 protected AcNest getNest(Integer id) {
   return _access.getNestDb().getNest(id);
 }
Пример #20
0
 /**
  * Load the models that are explicitly part of the snapshot. It is assumed that these models
  * should all link together; for example, if one of the item's has a parentNestId, then it is
  * assumed that the referenced parent nest is also in the snapshot. This applies to both
  * containment relationships and staging.
  */
 public void loadBatch(Integer batchId) {
   AcBatch e = _access.getBatchDb().getBatch(batchId);
   loadBatch(e);
 }
Пример #21
0
 private boolean noActiveAlertFor(AcInputChannel channel) {
   AcReceivedFileAlertDb db = _access.getReceivedFileAlertDb();
   JwList<AcReceivedFileAlert> v = db.getAllByInputChannelId(channel.getId());
   if (activeAlerts(v)) return false;
   return true;
 }
Пример #22
0
 private String getAccountCode() {
   return _access.getAccountCode();
 }
Пример #23
0
 private void expireOldAlerts() {
   _access.getReceivedFileAlertDb().deleteOldAlerts();
 }
Пример #24
0
 private JwList<AcInputChannel> getInputChannels() {
   return _access.getInputChannelDb().getAllAvailable();
 }
Пример #25
0
 public AcPropertyRegistry getAccountProperties(AcDbAccountAccess a) {
   return a.getAccountProperties();
 }