19package org.sleuthkit.autopsy.communications;
21import java.util.ArrayList;
23import java.util.logging.Level;
24import org.openide.nodes.ChildFactory;
25import org.openide.nodes.Node;
26import org.sleuthkit.autopsy.coreutils.Logger;
27import org.sleuthkit.datamodel.AccountDeviceInstance;
28import org.sleuthkit.datamodel.CommunicationsFilter;
29import org.sleuthkit.datamodel.CommunicationsManager;
30import org.sleuthkit.datamodel.TskCoreException;
37final 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);