19 package org.sleuthkit.autopsy.centralrepository.contentviewer;
21 import java.util.LinkedHashSet;
22 import java.util.Objects;
24 import java.util.logging.Level;
25 import javax.swing.table.AbstractTableModel;
26 import org.openide.util.NbBundle;
36 final class OtherOccurrencesDataSourcesTableModel
extends AbstractTableModel {
38 private static final long serialVersionUID = 1L;
39 private static final Logger logger = Logger.
getLogger(OtherOccurrencesDataSourcesTableModel.class.getName());
40 private final Set<DataSourceColumnItem> dataSourceSet =
new LinkedHashSet<>();
45 OtherOccurrencesDataSourcesTableModel() {
50 public int getColumnCount() {
55 public int getRowCount() {
56 return dataSourceSet.size();
59 @NbBundle.Messages({
"OtherOccurrencesDataSourcesTableModel.dataSourceName=Data Source Name",
60 "OtherOccurrencesDataSourcesTableModel.noData=No Data."})
62 public String getColumnName(
int colIdx) {
63 return Bundle.OtherOccurrencesDataSourcesTableModel_dataSourceName();
67 public Object getValueAt(
int rowIdx,
int colIdx) {
69 if (dataSourceSet.isEmpty() || rowIdx < 0
70 || rowIdx >= dataSourceSet.size()
71 || !(dataSourceSet.toArray()[rowIdx] instanceof DataSourceColumnItem)) {
72 return Bundle.OtherOccurrencesDataSourcesTableModel_noData();
74 return ((DataSourceColumnItem) dataSourceSet.toArray()[rowIdx]).getDataSourceName();
85 String getDeviceIdForRow(
int rowIdx) {
87 if (dataSourceSet.isEmpty() || rowIdx < 0
88 || rowIdx >= dataSourceSet.size()
89 || !(dataSourceSet.toArray()[rowIdx] instanceof DataSourceColumnItem)) {
92 return ((DataSourceColumnItem) dataSourceSet.toArray()[rowIdx]).getDeviceId();
104 String getCaseUUIDForRow(
int rowIdx) {
106 if (dataSourceSet.isEmpty() || rowIdx < 0
107 || rowIdx >= dataSourceSet.size()
108 || !(dataSourceSet.toArray()[rowIdx] instanceof DataSourceColumnItem)) {
111 return ((DataSourceColumnItem) dataSourceSet.toArray()[rowIdx]).getCaseUUID();
122 String getCaseNameForRow(
int rowIdx) {
124 if (dataSourceSet.isEmpty() || rowIdx < 0
125 || rowIdx >= dataSourceSet.size()
126 || !(dataSourceSet.toArray()[rowIdx] instanceof DataSourceColumnItem)) {
129 return ((DataSourceColumnItem) dataSourceSet.toArray()[rowIdx]).getCaseName();
133 public Class<String> getColumnClass(
int colIdx) {
142 void addNodeData(OtherOccurrenceNodeData newNodeData) {
143 OtherOccurrenceNodeInstanceData nodeData = (OtherOccurrenceNodeInstanceData) newNodeData;
146 caseUUID = nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID();
147 }
catch (CentralRepoException ignored) {
150 caseUUID = Case.getCurrentCaseThrows().getName();
152 }
catch (NoCurrentCaseException ex) {
153 logger.log(Level.WARNING,
"Unable to get current case", ex);
154 caseUUID = DataContentViewerOtherCases.getPlaceholderUUID();
157 dataSourceSet.add(
new DataSourceColumnItem(nodeData.getCaseName(), nodeData.getDeviceID(), nodeData.getDataSourceName(), caseUUID));
158 fireTableDataChanged();
165 dataSourceSet.clear();
166 fireTableDataChanged();
244 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)