19 package org.sleuthkit.autopsy.communications;
21 import com.google.common.collect.Iterables;
22 import com.google.common.collect.Sets;
23 import java.util.Collections;
24 import java.util.List;
26 import java.util.logging.Level;
27 import java.util.stream.Collectors;
28 import org.openide.nodes.AbstractNode;
29 import org.openide.nodes.ChildFactory;
30 import org.openide.nodes.Children;
31 import org.openide.nodes.Node;
32 import org.openide.util.Lookup;
33 import org.openide.util.lookup.Lookups;
48 final class SelectionNode
extends AbstractNode {
50 private SelectionNode(Children children, Lookup lookup) {
51 super(children, lookup);
54 static SelectionNode createFromAccountsAndRelationships(
55 Set<Content> edgeRelationshipArtifacts,
56 Set<AccountDeviceInstanceKey> accountDeviceInstanceKeys,
57 CommunicationsFilter filter,
58 CommunicationsManager commsManager) {
60 Set<AccountDeviceInstance> accountDeviceInstances = accountDeviceInstanceKeys.stream()
61 .map(AccountDeviceInstanceKey::getAccountDeviceInstance)
62 .collect(Collectors.toSet());
64 SelectionNode node =
new SelectionNode(Children.create(
65 new RelationshipChildren(
66 edgeRelationshipArtifacts,
67 accountDeviceInstances,
70 true), Lookups.fixed(accountDeviceInstanceKeys.toArray()));
74 final int accounts = accountDeviceInstances.size();
76 name = accounts +
" accounts";
77 }
else if (accounts == 1) {
78 name = Iterables.getOnlyElement(accountDeviceInstances).getAccount().getTypeSpecificID();
81 final int edges = edgeRelationshipArtifacts.size();
84 name = name + (name.isEmpty() ?
"" :
" and ") + edges +
" relationship" + (edges > 1 ?
"s" :
"");
87 node.setDisplayName(name);
91 static SelectionNode createFromAccounts(
92 Set<AccountDeviceInstanceKey> accountDeviceInstances,
93 CommunicationsFilter filter,
94 CommunicationsManager commsManager) {
96 return createFromAccountsAndRelationships(Collections.emptySet(), accountDeviceInstances, filter, commsManager);
111 private final CommunicationsFilter
filter;
113 private RelationshipChildren(Set<Content> selectedEdgeRelationshipSources, Set<AccountDeviceInstance> selecedAccountDeviceInstances, CommunicationsManager commsManager, CommunicationsFilter filter) {
114 this.edgeRelationshipArtifacts = selectedEdgeRelationshipSources;
115 this.accountDeviceInstances = selecedAccountDeviceInstances;
123 final Set<Content> relationshipSources = commsManager.getRelationshipSources(accountDeviceInstances, filter);
124 list.addAll(Sets.union(relationshipSources, edgeRelationshipArtifacts));
125 }
catch (TskCoreException ex) {
126 logger.log(Level.SEVERE,
"Error getting communications", ex);
133 if (content instanceof BlackboardArtifact) {
134 return new RelationshipNode((BlackboardArtifact) content);
136 throw new UnsupportedOperationException(
"Cannot create a RelationshipNode for non BlackboardArtifact content.");
static final Logger logger
boolean createKeys(List< Content > list)
final Set< AccountDeviceInstance > accountDeviceInstances
final CommunicationsFilter filter
Node createNodeForKey(Content content)
RelationshipChildren(Set< Content > selectedEdgeRelationshipSources, Set< AccountDeviceInstance > selecedAccountDeviceInstances, CommunicationsManager commsManager, CommunicationsFilter filter)
final CommunicationsManager commsManager
synchronized static Logger getLogger(String name)
final Set< Content > edgeRelationshipArtifacts