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;
38 final class AccountDeviceInstanceNodeFactory
extends ChildFactory<AccountDeviceInstanceKey> {
40 private static final Logger logger = Logger.getLogger(AccountDeviceInstanceNodeFactory.class.getName());
42 private final CommunicationsManager commsManager;
43 private final CommunicationsFilter commsFilter;
45 AccountDeviceInstanceNodeFactory(CommunicationsManager commsManager, CommunicationsFilter commsFilter) {
46 this.commsManager = commsManager;
47 this.commsFilter = commsFilter;
51 protected boolean createKeys(List<AccountDeviceInstanceKey> list) {
52 List<AccountDeviceInstanceKey> accountDeviceInstanceKeys =
new ArrayList<>();
54 final List<AccountDeviceInstance> accountDeviceInstancesWithRelationships =
55 commsManager.getAccountDeviceInstancesWithRelationships(commsFilter);
56 for (AccountDeviceInstance accountDeviceInstance : accountDeviceInstancesWithRelationships) {
58 if (Account.Type.DEVICE.equals(accountDeviceInstance.getAccount().getAccountType()) ==
false) {
59 long communicationsCount = commsManager.getRelationshipSourcesCount(accountDeviceInstance, commsFilter);
60 accountDeviceInstanceKeys.add(
new AccountDeviceInstanceKey(accountDeviceInstance, commsFilter, communicationsCount));
63 }
catch (TskCoreException tskCoreException) {
64 logger.log(Level.SEVERE,
"Error getting filtered account device instances", tskCoreException);
66 list.addAll(accountDeviceInstanceKeys);
72 protected Node createNodeForKey(AccountDeviceInstanceKey key) {
73 return new AccountDeviceInstanceNode(key, commsManager);