19 package org.sleuthkit.autopsy.communications;
 
   21 import java.util.ArrayList;
 
   22 import java.util.List;
 
   23 import java.util.logging.Level;
 
   24 import org.openide.nodes.ChildFactory;
 
   25 import org.openide.nodes.Node;
 
   37 final class AccountDeviceInstanceNodeFactory 
extends ChildFactory<AccountDeviceInstanceKey> {
 
   39     private static final Logger logger = Logger.getLogger(AccountDeviceInstanceNodeFactory.class.getName());
 
   41     private final CommunicationsManager commsManager;
 
   42     private final CommunicationsFilter commsFilter;
 
   44     AccountDeviceInstanceNodeFactory(CommunicationsManager commsManager, CommunicationsFilter commsFilter) {
 
   45         this.commsManager = commsManager;
 
   46         this.commsFilter = commsFilter;
 
   50     protected boolean createKeys(List<AccountDeviceInstanceKey> list) {
 
   51         List<AccountDeviceInstanceKey> accountDeviceInstanceKeys = 
new ArrayList<>();
 
   53             final List<AccountDeviceInstance> accountDeviceInstancesWithRelationships =
 
   54                     commsManager.getAccountDeviceInstancesWithRelationships(commsFilter);
 
   55             for (AccountDeviceInstance accountDeviceInstance : accountDeviceInstancesWithRelationships) {
 
   56                 long communicationsCount = commsManager.getRelationshipSourcesCount(accountDeviceInstance, commsFilter);
 
   57                 accountDeviceInstanceKeys.add(
new AccountDeviceInstanceKey(accountDeviceInstance, commsFilter, communicationsCount));
 
   60         } 
catch (TskCoreException tskCoreException) {
 
   61             logger.log(Level.SEVERE, 
"Error getting filtered account device instances", tskCoreException);
 
   63         list.addAll(accountDeviceInstanceKeys);
 
   69     protected Node createNodeForKey(AccountDeviceInstanceKey key) {
 
   70         return new AccountDeviceInstanceNode(key, commsManager);