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 JwSet<String> _getLockedFilenames(List<String> filenames) { JwSet<String> l = new JwSet<String>(); for (String filename : filenames) if (filename.endsWith(LOCK_EXTENSION_TEMPLAR)) l.add(_getFileNameWithoutExtension(LOCK_EXTENSION_TEMPLAR, filename)); else if (filename.endsWith(LOCK_EXTENSION_THREAD_TEMPLAR)) l.add(_getFileNameWithoutExtension(LOCK_EXTENSION_THREAD_TEMPLAR, filename)); else if (hasLockPrefix() && filename.startsWith(getLockPrefix())) l.add(getFileNameFromTempName(filename)); return l; }
private void logMissing(String modelType, JwSet<Integer> ids) { JwList<Integer> sortedIds = ids.toList(); sortedIds.sort(); JwLog.error( "Account %s, Batch %s, Missing snapshot parent %s %s", getAccountCode(), _batch.getId(), modelType, sortedIds); }
/** * Load the batch nest associated with the specified nest. This is used when processing alias * actions where the alias has not yet been mapped to a nest. The nest being passed in could be * new or it could be an existing nest. Either way we need to load or create the associated batch * nest. */ public AcActionSnapshot loadNest(AcBatch batch, AcNest nest) { _batch = batch; _items = new JwMap<Integer, AcBatchItem>(); _nests = new JwMap<Integer, AcBatchNest>(); _aliases = new JwMap<Integer, AcBatchAlias>(); _flights = new JwMap<Integer, AcBatchFlight>(); JwSet<Integer> flightIds = new JwSet<Integer>(); JwSet<Integer> nestIds = new JwSet<Integer>(); nestIds.add(nest.getId()); fillNests(nestIds); AcBatchNest.collectFlightIdsOn(_nests.values(), flightIds); fillFlights(flightIds); return getSnapshot(true); }
private void fillAliases(JwSet<Integer> aliasIds) { enterMonitor("AcActionSnapshotLoader.fillAlias"); try { if (aliasIds.isEmpty()) return; fillDatabaseAliases(aliasIds); fillMissingAliases(aliasIds); } finally { exitMonitor(); } }
private void fillItems(JwSet<Integer> itemIds) { enterMonitor("AcActionSnapshotLoader.fillItem"); try { if (itemIds.isEmpty()) return; fillDatabaseItems(itemIds); fillMissingItems(itemIds); } finally { exitMonitor(); } }
private void addMissingBatchGroups( JwMap<Integer, JwSet<Integer>> m1, JwMap<Integer, JwSet<Integer>> m2) { Iterator<Entry<Integer, JwSet<Integer>>> i = m2.entrySet().iterator(); while (i.hasNext()) { Entry<Integer, JwSet<Integer>> entry = i.next(); Integer batchId = entry.getKey(); JwSet<Integer> ms = entry.getValue(); JwSet<Integer> bs = m1.get(batchId); if (bs != null) ms.removeAll(bs); else { bs = new JwSet<Integer>(); m1.put(batchId, bs); } if (ms.isEmpty()) i.remove(); else bs.addAll(ms); } }
private void fillFlights(JwSet<Integer> flightIds) { enterMonitor("AcActionSnapshotLoader.fillFlight"); try { if (flightIds.isEmpty()) return; fillDatabaseFlights(flightIds); fillMissingFlights(flightIds); } finally { exitMonitor(); } }
private void fillActions(JwList<AcAction> actions, boolean skipRevokedActions) { enterMonitor("AcActionSnapshotLoader.fillActions"); try { // debug("B", "fillNonRevokedActions"); JwSet<Integer> itemIds = new JwSet<Integer>(); JwSet<Integer> nestIds = new JwSet<Integer>(); JwSet<Integer> aliasIds = new JwSet<Integer>(); JwSet<Integer> flightIds = new JwSet<Integer>(); if (hasEntanglement()) { itemIds.addAll(_entanglement.getItemIds()); nestIds.addAll(_entanglement.getNestIds()); aliasIds.addAll(_entanglement.getAliasIds()); flightIds.addAll(_entanglement.getFlightIds()); } for (AcAction a : actions) { if (skipRevokedActions && a.hasStatusRevoked() && a.hasPendingChangeNone()) continue; a.collectItemIdsOn(itemIds); a.collectNestIdsOn(nestIds); a.collectAliasIdsOn(aliasIds); a.collectFlightIdsOn(flightIds); } fillItems(itemIds); AcBatchItem.collectNestIdsOn(_items.values(), nestIds); AcBatchItem.collectFlightIdsOn(_items.values(), flightIds); // load aliases before nests fillAliases(aliasIds); AcBatchAlias.collectNestIdsOn(_aliases.values(), nestIds); fillNests(nestIds); AcBatchNest.collectFlightIdsOn(_nests.values(), flightIds); fillFlights(flightIds); fillGroups(); testAllItemsAndNestsLoaded(); } finally { exitMonitor(); } }
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); }
private boolean _isLocked(String filename, JwSet<String> locks) { if (locks.contains(filename)) return true; return false; }
private void removeLoaded(JwSet<Integer> dbIds, Set<Integer> loadedIds) { dbIds.removeAll(loadedIds); }
private void removeLoadedIds(JwSet<Integer> ids, Set<Integer> loadedIds) { ids.removeAll(loadedIds); }
private void addBatchGroup(JwMap<Integer, JwSet<Integer>> m, Integer batchId, Integer groupCode) { if (groupCode == null) return; if (!m.containsKey(batchId)) m.put(batchId, new JwSet<Integer>()); JwSet<Integer> groups = m.get(batchId); groups.add(groupCode); }
public static JwSet<Integer> collectActionIds(JwList<AcProblem> v) { JwSet<Integer> ids = new JwSet<Integer>(); for (AcProblem e : v) ids.add(e.getActionId()); return ids; }