Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
InstanceCountNode.java
Go to the documentation of this file.
1/*
2 *
3 * Autopsy Forensic Browser
4 *
5 * Copyright 2018-2021 Basis Technology Corp.
6 * Contact: carrier <at> sleuthkit <dot> org
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 */
20package org.sleuthkit.autopsy.commonpropertiessearch;
21
22import java.util.HashMap;
23import java.util.Iterator;
24import java.util.List;
25import java.util.Map;
26import org.openide.nodes.ChildFactory;
27import org.openide.nodes.Children;
28import org.openide.nodes.Node;
29import org.openide.nodes.Sheet;
30import org.openide.util.NbBundle;
31import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance;
32import org.sleuthkit.autopsy.core.UserPreferences;
33import org.sleuthkit.autopsy.coreutils.Logger;
34import org.sleuthkit.autopsy.datamodel.AbstractAbstractFileNode;
35import org.sleuthkit.autopsy.datamodel.DisplayableItemNode;
36import org.sleuthkit.autopsy.datamodel.DisplayableItemNodeVisitor;
37import org.sleuthkit.autopsy.datamodel.NodeProperty;
38
43public final class InstanceCountNode extends DisplayableItemNode {
44
45 private static final Logger logger = Logger.getLogger(InstanceCountNode.class.getName());
46
47 final private int instanceCount;
50
59 @NbBundle.Messages({
60 "InstanceCountNode.displayName=Exists in %s data sources (%s)"
61 })
63 super(Children.create(new CommonAttributeValueNodeFactory(attributeValues.getMetadataList(), type), true));
64 this.type = type;
65 this.instanceCount = instanceCount;
66 this.attributeValues = attributeValues;
67
68 this.setDisplayName(String.format(Bundle.InstanceCountNode_displayName(), Integer.toString(instanceCount), attributeValues.getCommonAttributeListSize()));
69 this.setIconBaseWithExtension("org/sleuthkit/autopsy/images/fileset-icon-16.png"); //NON-NLS
70 }
71
77 int getInstanceCount() {
78 return this.instanceCount;
79 }
80
85 void createChildren() {
87 setChildren(Children.create(new CommonAttributeValueNodeFactory(attributeValues.getMetadataList(), type), false));
88 }
89
95 CommonAttributeValueList getAttributeValues() {
96 return this.attributeValues;
97 }
98
99 @Override
100 public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
101 return visitor.visit(this);
102 }
103
104 @Override
105 public boolean isLeafTypeNode() {
106 return false;
107 }
108
109 @Override
110 public String getItemType() {
111 return getClass().getName();
112 }
113
114 @NbBundle.Messages({"InstanceCountNode.createSheet.noDescription= "})
115 @Override
116 protected Sheet createSheet() {
117 Sheet sheet = new Sheet();
118 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
119 if (sheetSet == null) {
120 sheetSet = Sheet.createPropertiesSet();
121 sheet.put(sheetSet);
122 }
123
124 final String NO_DESCR = Bundle.InstanceCountNode_createSheet_noDescription();
125 sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.nameColLbl"), NO_DESCR, ""));
126 if (UserPreferences.getHideSCOColumns() == false) {
127 sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.score.name"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.score.name"), NO_DESCR, ""));
128 sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.comment.name"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.comment.name"), NO_DESCR, ""));
129 sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.count.name"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.createSheet.count.name"), NO_DESCR, ""));
130 }
131 sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_instancesColLbl(), Bundle.CommonFilesSearchResultsViewerTable_instancesColLbl(), NO_DESCR, this.getInstanceCount()));
132 sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_pathColLbl(), Bundle.CommonFilesSearchResultsViewerTable_pathColLbl(), NO_DESCR, ""));
133 sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_caseColLbl(), Bundle.CommonFilesSearchResultsViewerTable_caseColLbl(), NO_DESCR, ""));
134 sheetSet.put(new NodeProperty<>(Bundle.CommonFilesSearchResultsViewerTable_dataSourceColLbl(), Bundle.CommonFilesSearchResultsViewerTable_dataSourceColLbl(), NO_DESCR, ""));
135 sheetSet.put(new NodeProperty<>(NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.mimeType"), NbBundle.getMessage(AbstractAbstractFileNode.class, "AbstractAbstractFileNode.mimeType"), NO_DESCR, ""));
136
137 return sheet;
138 }
139
144 static class CommonAttributeValueNodeFactory extends ChildFactory<String> {
145
150 // maps sting version of value to value Object (??)
151 private final Map<String, CommonAttributeValue> metadata;
153
154 CommonAttributeValueNodeFactory(List<CommonAttributeValue> attributeValues, CorrelationAttributeInstance.Type type) {
155 this.metadata = new HashMap<>();
156 this.type = type;
157 Iterator<CommonAttributeValue> iterator = attributeValues.iterator();
158 while (iterator.hasNext()) {
159 CommonAttributeValue attributeValue = iterator.next();
160 this.metadata.put(attributeValue.getValue(), attributeValue);
161 }
162 }
163
164 @Override
165 protected boolean createKeys(List<String> list) {
166 // @@@ We should just use CommonAttributeValue as the key...
167 list.addAll(this.metadata.keySet());
168 return true;
169 }
170
171 @Override
172 protected Node createNodeForKey(String attributeValue) {
173 CommonAttributeValue md5Metadata = this.metadata.get(attributeValue);
174 return new CommonAttributeValueNode(md5Metadata, type);
175 }
176 }
177}
InstanceCountNode(int instanceCount, CommonAttributeValueList attributeValues, CorrelationAttributeInstance.Type type)
synchronized static Logger getLogger(String name)
Definition Logger.java:124

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.