4792 fix counts and display of intra case results

This commit is contained in:
William Schaefer 2019-03-12 14:12:49 -04:00
parent 2a04c86faa
commit 19797646a0
2 changed files with 45 additions and 52 deletions

View File

@ -44,6 +44,8 @@ import org.sleuthkit.autopsy.coreutils.Logger;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.JMenuItem; import javax.swing.JMenuItem;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.RowSorter;
import javax.swing.SortOrder;
import static javax.swing.JOptionPane.DEFAULT_OPTION; import static javax.swing.JOptionPane.DEFAULT_OPTION;
import static javax.swing.JOptionPane.PLAIN_MESSAGE; import static javax.swing.JOptionPane.PLAIN_MESSAGE;
import static javax.swing.JOptionPane.ERROR_MESSAGE; import static javax.swing.JOptionPane.ERROR_MESSAGE;
@ -161,15 +163,8 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
updateDataSourceSelection(); updateDataSourceSelection();
} }
}); });
// List<RowSorter.SortKey> sortKeys = new ArrayList<>(); caseTable.getRowSorter().toggleSortOrder(0);
dataSourceTable.getRowSorter().toggleSortOrder(0);
// int caseNameColumnIndex = DataContentViewerOtherCasesTableModel.TableColumns.CASE_NAME.ordinal();
// sortKeys.add(new RowSorter.SortKey(caseNameColumnIndex, SortOrder.ASCENDING));
//
// int dataSourceColumnIndex = DataContentViewerOtherCasesTableModel.TableColumns.DATA_SOURCE.ordinal();
// sortKeys.add(new RowSorter.SortKey(dataSourceColumnIndex, SortOrder.ASCENDING));
// sorter.setSortKeys(sortKeys);
sorter.sort();
} }
@Messages({"DataContentViewerOtherCases.correlatedArtifacts.isEmpty=There are no files or artifacts to correlate.", @Messages({"DataContentViewerOtherCases.correlatedArtifacts.isEmpty=There are no files or artifacts to correlate.",
@ -403,7 +398,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
// devices.put(deviceId, caseName); // devices.put(deviceId, caseName);
} }
foundInLabel.setText(String.format(Bundle.DataContentViewerOtherCases_foundIn_text(), model.getRowCount(), cases.size(), devices.size())); foundInLabel.setText(String.format(Bundle.DataContentViewerOtherCases_foundIn_text(), model.getRowCount(), casesTableModel.getRowCount(), devices.size()));
} }
/** /**
@ -768,6 +763,8 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
// get the attributes we can correlate on // get the attributes we can correlate on
correlationAttributes.addAll(getCorrelationAttributesFromNode(node)); correlationAttributes.addAll(getCorrelationAttributesFromNode(node));
Map<String, CorrelationCase> caseNames = new HashMap<>(); Map<String, CorrelationCase> caseNames = new HashMap<>();
int totalCount = 0;
Set<String> dataSources = new HashSet<>();
for (CorrelationAttributeInstance corAttr : correlationAttributes) { for (CorrelationAttributeInstance corAttr : correlationAttributes) {
Map<UniquePathKey, OtherOccurrenceNodeInstanceData> correlatedNodeDataMap = new HashMap<>(0); Map<UniquePathKey, OtherOccurrenceNodeInstanceData> correlatedNodeDataMap = new HashMap<>(0);
@ -776,47 +773,48 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
for (OtherOccurrenceNodeInstanceData nodeData : correlatedNodeDataMap.values()) { for (OtherOccurrenceNodeInstanceData nodeData : correlatedNodeDataMap.values()) {
if (nodeData.isCentralRepoNode()) { if (nodeData.isCentralRepoNode()) {
try { try {
dataSources.add(makeDataSourceString(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(), nodeData.getDeviceID(), nodeData.getDataSourceName()));
caseNames.put(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(), nodeData.getCorrelationAttributeInstance().getCorrelationCase()); caseNames.put(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID(), nodeData.getCorrelationAttributeInstance().getCorrelationCase());
} catch (EamDbException ex) { } catch (EamDbException ex) {
System.out.println("can't get correlation case"); System.out.println("can't get correlation case");
} }
} else { } else {
try { try {
caseNames.put(Case.getCurrentCaseThrows().getName(), new CorrelationCase(Case.getCurrentCaseThrows().getName(), Case.getCurrentCaseThrows().getDisplayName())); dataSources.add(makeDataSourceString(Case.getCurrentCaseThrows().getName(), nodeData.getDeviceID(), nodeData.getDataSourceName()));
} catch (NoCurrentCaseException ex){ caseNames.put(Case.getCurrentCaseThrows().getName(), new CorrelationCase(Case.getCurrentCaseThrows().getName(), Case.getCurrentCaseThrows().getDisplayName()));
} catch (NoCurrentCaseException ex) {
System.out.println("NO cURRENT CASE"); System.out.println("NO cURRENT CASE");
} }
} }
totalCount++;
} }
} }
// if (caseNames.isEmpty()) {
// setColumnWidthToText(0, Bundle.DataContentViewerOtherCases_table_noArtifacts());
// } else if (0 == casesTableModel.getRowCount()) {
// setColumnWidthToText(0, Bundle.DataContentViewerOtherCases_table_noResultsFound());
// } else {
for (CorrelationCase corCase : caseNames.values()) { for (CorrelationCase corCase : caseNames.values()) {
casesTableModel.addNodeData(corCase); casesTableModel.addNodeData(corCase);
} }
// }
// if (correlationAttributes.isEmpty()) { if (correlationAttributes.isEmpty()) {
// tableModel.addNodeData(new OtherOccurrenceNodeMessageData(Bundle.DataContentViewerOtherCases_table_noArtifacts())); tableModel.addNodeData(new OtherOccurrenceNodeMessageData(Bundle.DataContentViewerOtherCases_table_noArtifacts()));
// setColumnWidthToText(0, Bundle.DataContentViewerOtherCases_table_noArtifacts()); setColumnWidthToText(0, Bundle.DataContentViewerOtherCases_table_noArtifacts());
// } else if (0 == tableModel.getRowCount()) { } else if (0 == tableModel.getRowCount()) {
// tableModel.addNodeData(new OtherOccurrenceNodeMessageData(Bundle.DataContentViewerOtherCases_table_noResultsFound())); tableModel.addNodeData(new OtherOccurrenceNodeMessageData(Bundle.DataContentViewerOtherCases_table_noResultsFound()));
// setColumnWidthToText(0, Bundle.DataContentViewerOtherCases_table_noResultsFound()); setColumnWidthToText(0, Bundle.DataContentViewerOtherCases_table_noResultsFound());
// } else { } else {
// setColumnWidths(); setColumnWidths();
// } }
setEarliestCaseDate(); setEarliestCaseDate();
setOccurrenceCounts(); foundInLabel.setText(String.format(Bundle.DataContentViewerOtherCases_foundIn_text(), totalCount, casesTableModel.getRowCount(), dataSources.size()));
if (caseTable.getRowCount() > 0) { if (caseTable.getRowCount() > 0) {
caseTable.setRowSelectionInterval(0, 0); caseTable.setRowSelectionInterval(0, 0);
} }
} }
private String makeDataSourceString(String caseUUID, String deviceId, String dataSourceName){
return caseUUID + deviceId + dataSourceName;
}
private void updateCaseSelection() { private void updateCaseSelection() {
int[] selectedCaseIndexes = caseTable.getSelectedRows(); int[] selectedCaseIndexes = caseTable.getSelectedRows();
@ -831,7 +829,11 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
for (OtherOccurrenceNodeInstanceData nodeData : correlatedNodeDataMap.values()) { for (OtherOccurrenceNodeInstanceData nodeData : correlatedNodeDataMap.values()) {
for (int selectedRow : selectedCaseIndexes) { for (int selectedRow : selectedCaseIndexes) {
try { try {
if (((CorrelationCase) casesTableModel.getRow(caseTable.convertRowIndexToModel(selectedRow))).getCaseUUID().equals(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID())) { if (nodeData.isCentralRepoNode()) {
if (((CorrelationCase) casesTableModel.getRow(caseTable.convertRowIndexToModel(selectedRow))).getCaseUUID().equals(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID())) {
dataSourceModel.addRow(new Object[]{nodeData.getDataSourceName(), nodeData.getDeviceID()});
}
} else {
dataSourceModel.addRow(new Object[]{nodeData.getDataSourceName(), nodeData.getDeviceID()}); dataSourceModel.addRow(new Object[]{nodeData.getDataSourceName(), nodeData.getDeviceID()});
} }
} catch (EamDbException ex) { } catch (EamDbException ex) {
@ -859,9 +861,15 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
for (int selectedCaseRow : selectedCaseIndexes) { for (int selectedCaseRow : selectedCaseIndexes) {
for (int selectedDataSourceRow : selectedDataSources) { for (int selectedDataSourceRow : selectedDataSources) {
try { try {
if (((CorrelationCase) casesTableModel.getRow(caseTable.convertRowIndexToModel(selectedCaseRow))).getCaseUUID().equals(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID()) if (nodeData.isCentralRepoNode()) {
&& dataSourceModel.getValueAt(dataSourceTable.convertRowIndexToModel(selectedDataSourceRow), 1).toString().equals(nodeData.getDeviceID())) { if (((CorrelationCase) casesTableModel.getRow(caseTable.convertRowIndexToModel(selectedCaseRow))).getCaseUUID().equals(nodeData.getCorrelationAttributeInstance().getCorrelationCase().getCaseUUID())
tableModel.addNodeData(nodeData); && dataSourceModel.getValueAt(dataSourceTable.convertRowIndexToModel(selectedDataSourceRow), 1).toString().equals(nodeData.getDeviceID())) {
tableModel.addNodeData(nodeData);
}
} else {
if (dataSourceModel.getValueAt(dataSourceTable.convertRowIndexToModel(selectedDataSourceRow), 1).toString().equals(nodeData.getDeviceID())) {
tableModel.addNodeData(nodeData);
}
} }
} catch (EamDbException ex) { } catch (EamDbException ex) {
System.out.println("failure 2 to compare"); System.out.println("failure 2 to compare");

View File

@ -1,7 +1,7 @@
/* /*
* Central Repository * Central Repository
* *
* Copyright 2015-2018 Basis Technology Corp. * Copyright 2015-2019 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -126,9 +126,9 @@ public class DataContentViewerOtherCasesTableModel extends AbstractTableModel {
* @return The value in the cell. * @return The value in the cell.
*/ */
private Object mapNodeMessageData(OtherOccurrenceNodeMessageData nodeData, TableColumns columnId) { private Object mapNodeMessageData(OtherOccurrenceNodeMessageData nodeData, TableColumns columnId) {
// if (columnId == TableColumns.CASE_NAME) { if (columnId == TableColumns.ATTRIBUTE) {
// return nodeData.getDisplayMessage(); return nodeData.getDisplayMessage();
// } }
return ""; return "";
} }
@ -144,21 +144,6 @@ public class DataContentViewerOtherCasesTableModel extends AbstractTableModel {
String value = Bundle.DataContentViewerOtherCasesTableModel_noData(); String value = Bundle.DataContentViewerOtherCasesTableModel_noData();
switch (columnId) { switch (columnId) {
// case CASE_NAME:
// if (null != nodeData.getCaseName()) {
// value = nodeData.getCaseName();
// }
// break;
// case DEVICE:
// if (null != nodeData.getDeviceID()) {
// value = nodeData.getDeviceID();
// }
// break;
// case DATA_SOURCE:
// if (null != nodeData.getDataSourceName()) {
// value = nodeData.getDataSourceName();
// }
// break;
case FILE_PATH: case FILE_PATH:
value = nodeData.getFilePath(); value = nodeData.getFilePath();
break; break;