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;
45 final class CorrelationCaseChildNodeFactory
extends ChildFactory<CorrelationCase> {
47 private static final Logger logger = Logger.getLogger(CorrelationCaseChildNodeFactory.class.getName());
49 private final Set<Account> accounts;
56 CorrelationCaseChildNodeFactory(Set<Account> accounts) {
57 this.accounts = accounts;
61 protected boolean createKeys(List<CorrelationCase> list) {
62 if (!CentralRepository.isEnabled()) {
66 CentralRepository dbInstance;
69 }
catch (CentralRepoException 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 (CentralRepoException | 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 CentralRepoException {
112 String accountTypeStr = accountType.getTypeName();
113 if (Account.Type.DEVICE.getTypeName().equalsIgnoreCase(accountTypeStr) ==
false) {
114 CentralRepoAccount.CentralRepoAccountType crAccountType = CentralRepository.getInstance().getAccountTypeByName(accountTypeStr);
115 int corrTypeId = crAccountType.getCorrelationTypeId();
116 return CentralRepository.getInstance().getCorrelationTypeById(corrTypeId);
126 final class CaseNode
extends AbstractNode {
128 private final CorrelationCase correlationCase;
135 CaseNode(CorrelationCase correlationCase) {
136 super(Children.LEAF);
137 this.correlationCase = correlationCase;
139 setDisplayName(correlationCase.getDisplayName());
140 setIconBaseWithExtension(
"org/sleuthkit/autopsy/images/briefcase.png");
144 protected Sheet createSheet() {
146 Sheet sheet =
new Sheet();
147 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
148 if (sheetSet == null) {
149 sheetSet = Sheet.createPropertiesSet();
153 sheetSet.put(
new NodeProperty<>(
"creationDate",
154 correlationCase.getTitleCreationDate(),
155 correlationCase.getTitleCreationDate(),
156 correlationCase.getCreationDate()));
static CentralRepository getInstance()