private void fillNests(JwSet<Integer> nestIds) {
    enterMonitor("AcActionSnapshotLoader.fillNest");
    try {
      if (nestIds.isEmpty()) return;

      // we need to continue loading nests until all parent and
      // top nests have been loaded into the snapshot.
      // also load all any aliases for nests newly loaded nests.
      JwSet<Integer> aliasIds = new JwSet<Integer>();
      while (nestIds.isNotEmpty()) {
        fillDatabaseNests(nestIds);
        fillMissingNests(nestIds);

        // determine missing nest ids
        JwSet<Integer> allNestIds = AcBatchNest.collectNestIds(_nests.values());
        JwSet<Integer> loadedNestIds = AcBatchNest.collectIds(_nests.values());
        nestIds = allNestIds;
        nestIds.removeAll(loadedNestIds);

        // determine missing alias ids
        JwSet<Integer> allAliasIds = AcBatchNest.collectAliasIds(_nests.values());
        JwSet<Integer> loadedAliasIds = AcBatchAlias.collectIds(_aliases.values());
        aliasIds = allAliasIds;
        aliasIds.removeAll(loadedAliasIds);
        fillAliases(aliasIds);
      }
    } finally {
      exitMonitor();
    }
  }
  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);
  }
  private void loadMissing(boolean logMissing) {
    JwSet<Integer> nestIds = new JwSet<Integer>();
    AcBatchItem.collectNestIdsOn(_items.values(), nestIds);
    removeLoadedIds(nestIds, _nests.keySet());
    if (logMissing && nestIds.isNotEmpty()) logMissing("nests", nestIds);
    fillNests(nestIds);

    JwSet<Integer> aliasIds = new JwSet<Integer>();
    AcBatchNest.collectAliasIdsOn(_nests.values(), aliasIds);
    removeLoadedIds(aliasIds, _aliases.keySet());
    if (logMissing && aliasIds.isNotEmpty()) logMissing("aliases", aliasIds);
    fillAliases(aliasIds);

    JwSet<Integer> flightIds = new JwSet<Integer>();
    AcBatchItem.collectFlightIdsOn(_items.values(), flightIds);
    AcBatchNest.collectFlightIdsOn(_nests.values(), flightIds);
    removeLoadedIds(flightIds, _flights.keySet());
    if (logMissing && flightIds.isNotEmpty()) logMissing("flights", flightIds);
    fillFlights(flightIds);
  }