19 package org.sleuthkit.autopsy.communications.relationships;
21 import java.util.HashMap;
22 import java.util.List;
25 import java.util.logging.Level;
26 import org.openide.nodes.AbstractNode;
27 import org.openide.nodes.ChildFactory;
28 import org.openide.nodes.Children;
29 import org.openide.nodes.Node;
30 import org.openide.nodes.Sheet;
44 final class CorrelationCaseChildNodeFactory
extends ChildFactory<CorrelationCase> {
46 private static final Logger logger = Logger.getLogger(CorrelationCaseChildNodeFactory.class.getName());
48 private Map<Integer, CorrelationAttributeInstance.Type> correlationTypeMap;
49 private final Set<Account> accounts;
56 CorrelationCaseChildNodeFactory(Set<Account> accounts) {
57 this.accounts = accounts;
61 protected boolean createKeys(List<CorrelationCase> list) {
62 if (!EamDb.isEnabled()) {
68 dbInstance = EamDb.getInstance();
69 }
catch (EamDbException ex) {
70 logger.log(Level.SEVERE,
"Unable to connect to the Central Repository database.", ex);
74 Map<String, CorrelationCase> uniqueCaseMap =
new HashMap<>();
76 accounts.forEach((account) -> {
78 CorrelationAttributeInstance.Type correlationType = getCorrelationType(account.getAccountType());
79 if (correlationType != null) {
80 List<CorrelationAttributeInstance> correlationInstances = dbInstance.getArtifactInstancesByTypeValue(correlationType, account.getTypeSpecificID());
81 correlationInstances.forEach((correlationInstance) -> {
82 CorrelationCase correlationCase = correlationInstance.getCorrelationCase();
83 uniqueCaseMap.put(correlationCase.getCaseUUID(), correlationCase);
86 }
catch (EamDbException | CorrelationAttributeNormalizationException ex) {
87 logger.log(Level.WARNING, String.format(
"Unable to getArtifactInstance for accountID: %d", account.getAccountID()), ex);
91 list.addAll(uniqueCaseMap.values());
97 protected Node createNodeForKey(CorrelationCase correlationCase) {
98 return new CaseNode(correlationCase);
111 private CorrelationAttributeInstance.Type getCorrelationType(Account.Type accountType) throws EamDbException {
112 if (correlationTypeMap == null) {
113 correlationTypeMap =
new HashMap<>();
114 List<CorrelationAttributeInstance.Type> correcationTypeList = CorrelationAttributeInstance.getDefaultCorrelationTypes();
115 correcationTypeList.forEach((type) -> {
116 correlationTypeMap.put(type.getId(), type);
120 if (Account.Type.EMAIL.equals(accountType)) {
121 return correlationTypeMap.get(CorrelationAttributeInstance.EMAIL_TYPE_ID);
122 }
else if (Account.Type.PHONE.equals(accountType)) {
123 return correlationTypeMap.get(CorrelationAttributeInstance.PHONE_TYPE_ID);
133 final class CaseNode
extends AbstractNode {
135 private final CorrelationCase correlationCase;
142 CaseNode(CorrelationCase correlationCase) {
143 super(Children.LEAF);
144 this.correlationCase = correlationCase;
146 setDisplayName(correlationCase.getDisplayName());
147 setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/briefcase.png");
151 protected Sheet createSheet() {
153 Sheet sheet =
new Sheet();
154 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
155 if (sheetSet == null) {
156 sheetSet = Sheet.createPropertiesSet();
160 sheetSet.put(
new NodeProperty<>(
"creationDate",
161 correlationCase.getTitleCreationDate(),
162 correlationCase.getTitleCreationDate(),
163 correlationCase.getCreationDate()));