19 package org.sleuthkit.autopsy.centralrepository.contentviewer;
22 import java.util.LinkedHashSet;
23 import java.util.Objects;
25 import java.util.logging.Level;
26 import javax.swing.table.AbstractTableModel;
27 import org.openide.util.NbBundle;
38 final class OtherOccurrencesDataSourcesTableModel
extends AbstractTableModel {
40 private static final long serialVersionUID = 1L;
41 private static final Logger logger = Logger.
getLogger(OtherOccurrencesDataSourcesTableModel.class.getName());
42 private final Set<DataSourceColumnItem> dataSourceSet =
new LinkedHashSet<>();
47 OtherOccurrencesDataSourcesTableModel() {
52 public int getColumnCount() {
57 public int getRowCount() {
58 return dataSourceSet.size();
61 @NbBundle.Messages({
"OtherOccurrencesDataSourcesTableModel.dataSourceName=Data Source Name",
62 "OtherOccurrencesDataSourcesTableModel.noData=No Data."})
64 public String getColumnName(
int colIdx) {
65 return Bundle.OtherOccurrencesDataSourcesTableModel_dataSourceName();
69 public Object getValueAt(
int rowIdx,
int colIdx) {
71 if (dataSourceSet.isEmpty() || rowIdx < 0
72 || rowIdx >= dataSourceSet.size()
73 || !(dataSourceSet.toArray()[rowIdx] instanceof DataSourceColumnItem)) {
74 return Bundle.OtherOccurrencesDataSourcesTableModel_noData();
76 return ((DataSourceColumnItem) dataSourceSet.toArray()[rowIdx]).getDataSourceName();
87 String getDeviceIdForRow(
int rowIdx) {
89 if (dataSourceSet.isEmpty() || rowIdx < 0
90 || rowIdx >= dataSourceSet.size()
91 || !(dataSourceSet.toArray()[rowIdx] instanceof DataSourceColumnItem)) {
94 return ((DataSourceColumnItem) dataSourceSet.toArray()[rowIdx]).getDeviceId();
106 String getCaseUUIDForRow(
int rowIdx) {
108 if (dataSourceSet.isEmpty() || rowIdx < 0
109 || rowIdx >= dataSourceSet.size()
110 || !(dataSourceSet.toArray()[rowIdx] instanceof DataSourceColumnItem)) {
113 return ((DataSourceColumnItem) dataSourceSet.toArray()[rowIdx]).getCaseUUID();
124 String getCaseNameForRow(
int rowIdx) {
126 if (dataSourceSet.isEmpty() || rowIdx < 0
127 || rowIdx >= dataSourceSet.size()
128 || !(dataSourceSet.toArray()[rowIdx] instanceof DataSourceColumnItem)) {
131 return ((DataSourceColumnItem) dataSourceSet.toArray()[rowIdx]).getCaseName();
135 public Class<String> getColumnClass(
int colIdx) {
144 void addNodeData(NodeData newNodeData) {
147 caseUUID = newNodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID();
148 }
catch (CentralRepoException ignored) {
151 caseUUID = Case.getCurrentCaseThrows().getName();
153 }
catch (NoCurrentCaseException ex) {
154 logger.log(Level.WARNING,
"Unable to get current case", ex);
155 caseUUID = OtherOccurrences.getPlaceholderUUID();
158 dataSourceSet.add(
new DataSourceColumnItem(newNodeData.getCaseName(), newNodeData.getDeviceID(), newNodeData.getDataSourceName(), caseUUID));
159 fireTableDataChanged();
166 dataSourceSet.clear();
167 fireTableDataChanged();
245 return Objects.hash(caseName, deviceId, dataSourceName, caseUUID);
String getDataSourceName()
boolean equals(Object other)
final String dataSourceName
synchronized static Logger getLogger(String name)
DataSourceColumnItem(String caseName, String deviceId, String dataSourceName, String caseUUID)