4792 clean up and comments

This commit is contained in:
William Schaefer 2019-04-05 17:38:36 -04:00
parent 2728471450
commit ac8f929a09
7 changed files with 187 additions and 42 deletions

View File

@ -24,7 +24,6 @@ DataContentViewerOtherCases.earliestCaseDate.text=Earliest Case Date
DataContentViewerOtherCases.earliestCaseLabel.toolTipText= DataContentViewerOtherCases.earliestCaseLabel.toolTipText=
DataContentViewerOtherCases.earliestCaseLabel.text=Central Repository Starting Date: DataContentViewerOtherCases.earliestCaseLabel.text=Central Repository Starting Date:
DataContentViewerOtherCases.foundInLabel.text= DataContentViewerOtherCases.foundInLabel.text=
DataContentViewerOtherCases.caseDatasourceFileSplitPane.toolTipText=
DataContentViewerOtherCases.title=Other Occurrences DataContentViewerOtherCases.title=Other Occurrences
DataContentViewerOtherCases.toolTip=Displays instances of the selected file/artifact from other occurrences. DataContentViewerOtherCases.toolTip=Displays instances of the selected file/artifact from other occurrences.
DataContentViewerOtherCasesModel.csvHeader.attribute=Matched Attribute DataContentViewerOtherCasesModel.csvHeader.attribute=Matched Attribute

View File

@ -165,14 +165,18 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
updateOnDataSourceSelection(); updateOnDataSourceSelection();
} }
}); });
//alows resizing of the 4th section
filesTable.getSelectionModel().addListSelectionListener((e) -> { filesTable.getSelectionModel().addListSelectionListener((e) -> {
if (Case.isCaseOpen()) { if (Case.isCaseOpen()) {
occurrencePanel = new OccurrencePanel(); occurrencePanel = new OccurrencePanel();
updateOnFileSelection(); updateOnFileSelection();
} }
}); });
//sort tables alphabetically initially
casesTable.getRowSorter().toggleSortOrder(0); casesTable.getRowSorter().toggleSortOrder(0);
dataSourcesTable.getRowSorter().toggleSortOrder(0); dataSourcesTable.getRowSorter().toggleSortOrder(0);
filesTable.getRowSorter().toggleSortOrder(0);
} }
@Messages({"DataContentViewerOtherCases.correlatedArtifacts.isEmpty=There are no files or artifacts to correlate.", @Messages({"DataContentViewerOtherCases.correlatedArtifacts.isEmpty=There are no files or artifacts to correlate.",
@ -233,7 +237,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
if (-1 != selectedRowViewIdx) { if (-1 != selectedRowViewIdx) {
EamDb dbManager = EamDb.getInstance(); EamDb dbManager = EamDb.getInstance();
int selectedRowModelIdx = filesTable.convertRowIndexToModel(selectedRowViewIdx); int selectedRowModelIdx = filesTable.convertRowIndexToModel(selectedRowViewIdx);
List<OtherOccurrenceNodeData> rowList = filesTableModel.getRow(selectedRowModelIdx); List<OtherOccurrenceNodeData> rowList = filesTableModel.getListOfNodesForFile(selectedRowModelIdx);
if (rowList.get(0) instanceof OtherOccurrenceNodeInstanceData) { if (rowList.get(0) instanceof OtherOccurrenceNodeInstanceData) {
if (!rowList.isEmpty()) { if (!rowList.isEmpty()) {
CorrelationCase eamCasePartial = ((OtherOccurrenceNodeInstanceData) rowList.get(0)).getCorrelationAttributeInstance().getCorrelationCase(); CorrelationCase eamCasePartial = ((OtherOccurrenceNodeInstanceData) rowList.get(0)).getCorrelationAttributeInstance().getCorrelationCase();
@ -292,6 +296,9 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
"DataContentViewerOtherCasesModel.csvHeader.path=Path", "DataContentViewerOtherCasesModel.csvHeader.path=Path",
"DataContentViewerOtherCasesModel.csvHeader.comment=Comment" "DataContentViewerOtherCasesModel.csvHeader.comment=Comment"
}) })
/**
* Write data for all cases in the content viewer to a CSV file
*/
private void writeOtherOccurrencesToFileAsCSV(File destFile) { private void writeOtherOccurrencesToFileAsCSV(File destFile) {
try (BufferedWriter writer = Files.newBufferedWriter(destFile.toPath())) { try (BufferedWriter writer = Files.newBufferedWriter(destFile.toPath())) {
//write headers //write headers
@ -558,7 +565,6 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
try { try {
final Case openCase = Case.getCurrentCaseThrows(); final Case openCase = Case.getCurrentCaseThrows();
String caseUUID = openCase.getName(); String caseUUID = openCase.getName();
HashMap<UniquePathKey, OtherOccurrenceNodeInstanceData> nodeDataMap = new HashMap<>(); HashMap<UniquePathKey, OtherOccurrenceNodeInstanceData> nodeDataMap = new HashMap<>();
if (EamDb.isEnabled()) { if (EamDb.isEnabled()) {
@ -583,7 +589,6 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
} }
} }
} }
if (corAttr.getCorrelationType().getDisplayName().equals("Files")) { if (corAttr.getCorrelationType().getDisplayName().equals("Files")) {
List<AbstractFile> caseDbFiles = getCaseDbMatches(corAttr, openCase); List<AbstractFile> caseDbFiles = getCaseDbMatches(corAttr, openCase);
@ -591,7 +596,6 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
addOrUpdateNodeData(openCase, nodeDataMap, caseDbFile); addOrUpdateNodeData(openCase, nodeDataMap, caseDbFile);
} }
} }
return nodeDataMap; return nodeDataMap;
} catch (EamDbException ex) { } catch (EamDbException ex) {
LOGGER.log(Level.SEVERE, "Error getting artifact instances from database.", ex); // NON-NLS LOGGER.log(Level.SEVERE, "Error getting artifact instances from database.", ex); // NON-NLS
@ -867,17 +871,16 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
} }
} }
/**
* Update the data displayed in the details section to be correct for the
* currently selected File
*/
private void updateOnFileSelection() { private void updateOnFileSelection() {
occurrencePanel = new OccurrencePanel();
occurrencePanel.getPreferredSize();
detailsPanelScrollPane.setViewportView(occurrencePanel);
//calling getPreferredSize has a side effect of ensuring it has a preferred size which reflects the contents which are visible
if (filesTable.getSelectedRowCount() == 1) { if (filesTable.getSelectedRowCount() == 1) {
occurrencePanel = new OccurrencePanel(filesTableModel.getRow(filesTable.convertRowIndexToModel(filesTable.getSelectedRow()))); //if there is one file selected update the deatils to show the data for that file
occurrencePanel.getPreferredSize(); occurrencePanel = new OccurrencePanel(filesTableModel.getListOfNodesForFile(filesTable.convertRowIndexToModel(filesTable.getSelectedRow())));
detailsPanelScrollPane.setViewportView(occurrencePanel);
} else if (dataSourcesTable.getSelectedRowCount() == 1) { } else if (dataSourcesTable.getSelectedRowCount() == 1) {
//calling getPreferredSize has a side effect of ensuring it has a preferred size which reflects the contents which are visible //if no files were selected and only one data source is selected update the information to reflect the data source
String caseName = dataSourcesTableModel.getCaseNameForRow(dataSourcesTable.convertRowIndexToModel(dataSourcesTable.getSelectedRow())); String caseName = dataSourcesTableModel.getCaseNameForRow(dataSourcesTable.convertRowIndexToModel(dataSourcesTable.getSelectedRow()));
String dsName = dataSourcesTableModel.getValueAt(dataSourcesTable.convertRowIndexToModel(dataSourcesTable.getSelectedRow()), 0).toString(); String dsName = dataSourcesTableModel.getValueAt(dataSourcesTable.convertRowIndexToModel(dataSourcesTable.getSelectedRow()), 0).toString();
String caseCreatedDate = ""; String caseCreatedDate = "";
@ -888,10 +891,9 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
} }
} }
occurrencePanel = new OccurrencePanel(caseName, caseCreatedDate, dsName); occurrencePanel = new OccurrencePanel(caseName, caseCreatedDate, dsName);
occurrencePanel.getPreferredSize();
detailsPanelScrollPane.setViewportView(occurrencePanel);
} else if (casesTable.getSelectedRowCount() == 1) { } else if (casesTable.getSelectedRowCount() == 1) {
//calling getPreferredSize has a side effect of ensuring it has a preferred size which reflects the contents which are visible //if no files were selected and a number of data source other than 1 are selected
//update the information to reflect the case
String createdDate = ""; String createdDate = "";
String caseName = ""; String caseName = "";
if (casesTable.getRowCount() > 0) { if (casesTable.getRowCount() > 0) {
@ -903,11 +905,23 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
createdDate = getCaseCreatedDate(casesTable.getSelectedRow()); createdDate = getCaseCreatedDate(casesTable.getSelectedRow());
occurrencePanel = new OccurrencePanel(caseName, createdDate); occurrencePanel = new OccurrencePanel(caseName, createdDate);
} }
} else {
//else display an empty details area
occurrencePanel = new OccurrencePanel();
}
//calling getPreferredSize has a side effect of ensuring it has a preferred size which reflects the contents which are visible
occurrencePanel.getPreferredSize(); occurrencePanel.getPreferredSize();
detailsPanelScrollPane.setViewportView(occurrencePanel); detailsPanelScrollPane.setViewportView(occurrencePanel);
} }
}
/**
* Get the date a case was created
*
* @param caseTableRowIdx the row from the casesTable representing the case
*
* @return A string representing the date the case was created or an empty
* string if the date could not be determined
*/
private String getCaseCreatedDate(int caseTableRowIdx) { private String getCaseCreatedDate(int caseTableRowIdx) {
try { try {
if (EamDb.isEnabled()) { if (EamDb.isEnabled()) {
@ -1081,7 +1095,7 @@ public class DataContentViewerOtherCases extends JPanel implements DataContentVi
boolean enableCentralRepoActions = false; boolean enableCentralRepoActions = false;
if (EamDb.isEnabled() && filesTable.getSelectedRowCount() == 1) { if (EamDb.isEnabled() && filesTable.getSelectedRowCount() == 1) {
int rowIndex = filesTable.getSelectedRow(); int rowIndex = filesTable.getSelectedRow();
List<OtherOccurrenceNodeData> selectedFile = filesTableModel.getRow(rowIndex); List<OtherOccurrenceNodeData> selectedFile = filesTableModel.getListOfNodesForFile(rowIndex);
if (selectedFile.get(0) instanceof OtherOccurrenceNodeInstanceData) { if (selectedFile.get(0) instanceof OtherOccurrenceNodeInstanceData) {
OtherOccurrenceNodeInstanceData instanceData = (OtherOccurrenceNodeInstanceData) selectedFile.get(0); OtherOccurrenceNodeInstanceData instanceData = (OtherOccurrenceNodeInstanceData) selectedFile.get(0);
enableCentralRepoActions = instanceData.isCentralRepoNode(); enableCentralRepoActions = instanceData.isCentralRepoNode();

View File

@ -35,6 +35,9 @@ import org.sleuthkit.autopsy.centralrepository.datamodel.EamDbException;
import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.Logger;
import org.sleuthkit.datamodel.TskData; import org.sleuthkit.datamodel.TskData;
/**
* Panel for displaying other occurrence details.
*/
final class OccurrencePanel extends javax.swing.JPanel { final class OccurrencePanel extends javax.swing.JPanel {
private static final Logger LOGGER = Logger.getLogger(OccurrencePanel.class.getName()); private static final Logger LOGGER = Logger.getLogger(OccurrencePanel.class.getName());
@ -52,17 +55,34 @@ final class OccurrencePanel extends javax.swing.JPanel {
private final Set<String> dataSourceNames = new HashSet<>(); private final Set<String> dataSourceNames = new HashSet<>();
private final Set<String> filePaths = new HashSet<>(); private final Set<String> filePaths = new HashSet<>();
/**
* Construct an empty OccurrencePanel
*/
OccurrencePanel() { OccurrencePanel() {
nodeDataList = new ArrayList<>(); nodeDataList = new ArrayList<>();
customizeComponents(); customizeComponents();
} }
/**
* Construct an OccurrencePanel which will display only Case information
*
* @param caseName the name of the case
* @param caseCreatedDate the date the case was created
*/
OccurrencePanel(String caseName, String caseCreatedDate) { OccurrencePanel(String caseName, String caseCreatedDate) {
nodeDataList = new ArrayList<>(); nodeDataList = new ArrayList<>();
caseNamesAndDates.put(caseName, caseCreatedDate); caseNamesAndDates.put(caseName, caseCreatedDate);
customizeComponents(); customizeComponents();
} }
/**
* Construct an OccurrencePanel which will display only case and data source
* information
*
* @param caseName the name of the case
* @param caseCreatedDate the date the case was created
* @param dataSourceName the name of the data source
*/
OccurrencePanel(String caseName, String caseCreatedDate, String dataSourceName) { OccurrencePanel(String caseName, String caseCreatedDate, String dataSourceName) {
nodeDataList = new ArrayList<>(); nodeDataList = new ArrayList<>();
caseNamesAndDates.put(caseName, caseCreatedDate); caseNamesAndDates.put(caseName, caseCreatedDate);
@ -71,16 +91,27 @@ final class OccurrencePanel extends javax.swing.JPanel {
} }
/** /**
* Creates new form OccurrencePanel2 * Construct a OccurrencePanel which will display details for all other
* occurrences associated with a file
*
* @param nodeDataList the list of OtherOccurrenceNodeData representing
* common properties for the file
*/ */
OccurrencePanel(List<OtherOccurrenceNodeData> nodeDataList) { OccurrencePanel(List<OtherOccurrenceNodeData> nodeDataList) {
this.nodeDataList = nodeDataList; this.nodeDataList = nodeDataList;
customizeComponents(); customizeComponents();
} }
/**
* Do all the construction of gui elements and adding of the appropriate
* elements to the gridbaglayout
*/
private void customizeComponents() { private void customizeComponents() {
initComponents(); initComponents();
if (!this.nodeDataList.isEmpty()) { if (!this.nodeDataList.isEmpty()) {
//if addInstanceDetails is going to be called it should be called
// before addFileDetails, addDataSourceDetails, and addCaseDetails
//because it also collects the information they display
addInstanceDetails(); addInstanceDetails();
if (!filePaths.isEmpty()) { if (!filePaths.isEmpty()) {
addFileDetails(); addFileDetails();
@ -103,6 +134,13 @@ final class OccurrencePanel extends javax.swing.JPanel {
"OccurrencePanel.commonPropertyKnownStatusLabel.text=Known Status:", "OccurrencePanel.commonPropertyKnownStatusLabel.text=Known Status:",
"OccurrencePanel.commonPropertyCommentLabel.text=Comment:" "OccurrencePanel.commonPropertyCommentLabel.text=Comment:"
}) })
/**
* Add the Common Property instance details to the gridbaglayout supports
* adding multiple common properties
*
* Also collects the case, data source, and file path information to be
* displayed
*/
private void addInstanceDetails() { private void addInstanceDetails() {
javax.swing.JLabel commonPropertiesLabel = new javax.swing.JLabel(); javax.swing.JLabel commonPropertiesLabel = new javax.swing.JLabel();
org.openide.awt.Mnemonics.setLocalizedText(commonPropertiesLabel, Bundle.OccurrencePanel_commonProperties_text()); org.openide.awt.Mnemonics.setLocalizedText(commonPropertiesLabel, Bundle.OccurrencePanel_commonProperties_text());
@ -143,7 +181,6 @@ final class OccurrencePanel extends javax.swing.JPanel {
} }
addItemToBag(gridY, 1, 0, 0, knownStatusValue); addItemToBag(gridY, 1, 0, 0, knownStatusValue);
gridY++; gridY++;
String comment = ((OtherOccurrenceNodeInstanceData) occurrence).getComment(); String comment = ((OtherOccurrenceNodeInstanceData) occurrence).getComment();
if (!comment.isEmpty()) { if (!comment.isEmpty()) {
javax.swing.JLabel commentLabel = new javax.swing.JLabel(); javax.swing.JLabel commentLabel = new javax.swing.JLabel();
@ -176,6 +213,7 @@ final class OccurrencePanel extends javax.swing.JPanel {
} catch (EamDbException ex) { } catch (EamDbException ex) {
LOGGER.log(Level.WARNING, "Error getting case created date for other occurrence content viewer", ex); LOGGER.log(Level.WARNING, "Error getting case created date for other occurrence content viewer", ex);
} }
//Collect the data that is necessary for the other sections
caseNamesAndDates.put(((OtherOccurrenceNodeInstanceData) occurrence).getCaseName(), caseDate); caseNamesAndDates.put(((OtherOccurrenceNodeInstanceData) occurrence).getCaseName(), caseDate);
dataSourceNames.add(((OtherOccurrenceNodeInstanceData) occurrence).getDataSourceName()); dataSourceNames.add(((OtherOccurrenceNodeInstanceData) occurrence).getDataSourceName());
filePaths.add(((OtherOccurrenceNodeInstanceData) occurrence).getFilePath()); filePaths.add(((OtherOccurrenceNodeInstanceData) occurrence).getFilePath());
@ -188,6 +226,9 @@ final class OccurrencePanel extends javax.swing.JPanel {
"OccurrencePanel.fileDetails.text=File Details", "OccurrencePanel.fileDetails.text=File Details",
"OccurrencePanel.filePathLabel.text=File Path:" "OccurrencePanel.filePathLabel.text=File Path:"
}) })
/**
* Add the File specific details such as file path to the gridbaglayout
*/
private void addFileDetails() { private void addFileDetails() {
String filePath = filePaths.size() > 1 ? "" : filePaths.iterator().next(); String filePath = filePaths.size() > 1 ? "" : filePaths.iterator().next();
if (!filePath.isEmpty()) { if (!filePath.isEmpty()) {
@ -196,7 +237,6 @@ final class OccurrencePanel extends javax.swing.JPanel {
fileDetailsLabel.setFont(fileDetailsLabel.getFont().deriveFont(Font.BOLD, fileDetailsLabel.getFont().getSize())); fileDetailsLabel.setFont(fileDetailsLabel.getFont().deriveFont(Font.BOLD, fileDetailsLabel.getFont().getSize()));
addItemToBag(gridY, 0, TOP_INSET, 0, fileDetailsLabel); addItemToBag(gridY, 0, TOP_INSET, 0, fileDetailsLabel);
gridY++; gridY++;
javax.swing.JLabel filePathLabel = new javax.swing.JLabel(); javax.swing.JLabel filePathLabel = new javax.swing.JLabel();
org.openide.awt.Mnemonics.setLocalizedText(filePathLabel, Bundle.OccurrencePanel_filePathLabel_text()); org.openide.awt.Mnemonics.setLocalizedText(filePathLabel, Bundle.OccurrencePanel_filePathLabel_text());
addItemToBag(gridY, 0, VERTICAL_GAP, VERTICAL_GAP, filePathLabel); addItemToBag(gridY, 0, VERTICAL_GAP, VERTICAL_GAP, filePathLabel);
@ -219,6 +259,10 @@ final class OccurrencePanel extends javax.swing.JPanel {
"OccurrencePanel.dataSourceDetails.text=Data Source Details", "OccurrencePanel.dataSourceDetails.text=Data Source Details",
"OccurrencePanel.dataSourceNameLabel.text=Name:" "OccurrencePanel.dataSourceNameLabel.text=Name:"
}) })
/**
* Add the data source specific details such as data source name to the
* gridbaglayout
*/
private void addDataSourceDetails() { private void addDataSourceDetails() {
String dataSourceName = dataSourceNames.size() > 1 ? "" : dataSourceNames.iterator().next(); String dataSourceName = dataSourceNames.size() > 1 ? "" : dataSourceNames.iterator().next();
if (!dataSourceName.isEmpty()) { if (!dataSourceName.isEmpty()) {
@ -242,6 +286,9 @@ final class OccurrencePanel extends javax.swing.JPanel {
"OccurrencePanel.caseNameLabel.text=Name:", "OccurrencePanel.caseNameLabel.text=Name:",
"OccurrencePanel.caseCreatedDateLabel.text=Created Date:" "OccurrencePanel.caseCreatedDateLabel.text=Created Date:"
}) })
/**
* Add the case specific details such as case name to the gridbaglayout
*/
private void addCaseDetails() { private void addCaseDetails() {
javax.swing.JLabel caseDetailsLabel = new javax.swing.JLabel(); javax.swing.JLabel caseDetailsLabel = new javax.swing.JLabel();
org.openide.awt.Mnemonics.setLocalizedText(caseDetailsLabel, Bundle.OccurrencePanel_caseDetails_text()); org.openide.awt.Mnemonics.setLocalizedText(caseDetailsLabel, Bundle.OccurrencePanel_caseDetails_text());
@ -270,6 +317,16 @@ final class OccurrencePanel extends javax.swing.JPanel {
} }
} }
/**
* Add a JComponent to the gridbaglayout
*
* @param gridYLocation the row number the item should be added at
* @param gridXLocation the column number the item should be added at
* @param topInset the gap from the top of the cell which should exist
* @param bottomInset the gap from the bottom of the cell which should
* exist
* @param item the JComponent to add to the gridbaglayout
*/
private void addItemToBag(int gridYLocation, int gridXLocation, int topInset, int bottomInset, javax.swing.JComponent item) { private void addItemToBag(int gridYLocation, int gridXLocation, int topInset, int bottomInset, javax.swing.JComponent item) {
java.awt.GridBagConstraints gridBagConstraints; java.awt.GridBagConstraints gridBagConstraints;
gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints = new java.awt.GridBagConstraints();

View File

@ -1,7 +1,7 @@
/* /*
* Central Repository * Central Repository
* *
* Copyright 2018 Basis Technology Corp. * Copyright 2018-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");
@ -232,6 +232,12 @@ class OtherOccurrenceNodeInstanceData implements OtherOccurrenceNodeData {
return originalCorrelationInstance; return originalCorrelationInstance;
} }
/**
* Create a string representation of the node's data comma separated with a
* line separator ending
*
* @return a comma separated string representation of the node's data
*/
String toCsvString() { String toCsvString() {
StringBuilder line = new StringBuilder(""); StringBuilder line = new StringBuilder("");
line.append('"').append(getCaseName()).append('"').append(','); line.append('"').append(getCaseName()).append('"').append(',');

View File

@ -33,6 +33,9 @@ public class OtherOccurrencesCasesTableModel extends AbstractTableModel {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private final List<CorrelationCaseWrapper> correlationCaseList = new ArrayList<>(); private final List<CorrelationCaseWrapper> correlationCaseList = new ArrayList<>();
/**
* Create a table model for displaying case names
*/
OtherOccurrencesCasesTableModel() { OtherOccurrencesCasesTableModel() {
} }
@ -66,6 +69,15 @@ public class OtherOccurrencesCasesTableModel extends AbstractTableModel {
return value; return value;
} }
/**
* Get a correlation case for the selected index. Does not query the Central
* Repository so CorrelationCase will be partial missing CR case ID and
* other information that is stored in the CR.
*
* @param rowIdx the row from the table model which corresponds to the case
*
* @return CorrelationCase for the table item specified
*/
CorrelationCase getCorrelationCase(int rowIdx) { CorrelationCase getCorrelationCase(int rowIdx) {
if (rowIdx < correlationCaseList.size()) { if (rowIdx < correlationCaseList.size()) {
return correlationCaseList.get(rowIdx).getCorrelationCase(); return correlationCaseList.get(rowIdx).getCorrelationCase();
@ -80,7 +92,7 @@ public class OtherOccurrencesCasesTableModel extends AbstractTableModel {
} }
/** /**
* Add one correlated instance object to the table * Add one correlation case wrapper object to the table
* *
* @param newCorrelationCaseWrapper data to add to the table * @param newCorrelationCaseWrapper data to add to the table
*/ */

View File

@ -23,15 +23,18 @@ import java.util.Objects;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
/**
* Model for cells in the data sources section of the other occurrences data
* content viewer
*/
final class OtherOccurrencesDataSourcesTableModel extends AbstractTableModel { final class OtherOccurrencesDataSourcesTableModel extends AbstractTableModel {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@NbBundle.Messages({"OtherOccurrencesDataSourcesTableModel.dataSourceName=Data Source Name",
"OtherOccurrencesDataSourcesTableModel.noData=No Data."})
private final LinkedHashSet<DataSourceColumnItem> dataSourceSet = new LinkedHashSet<>(); private final LinkedHashSet<DataSourceColumnItem> dataSourceSet = new LinkedHashSet<>();
/**
* Create a table model for displaying data source names
*/
OtherOccurrencesDataSourcesTableModel() { OtherOccurrencesDataSourcesTableModel() {
} }
@ -46,6 +49,8 @@ final class OtherOccurrencesDataSourcesTableModel extends AbstractTableModel {
return dataSourceSet.size(); return dataSourceSet.size();
} }
@NbBundle.Messages({"OtherOccurrencesDataSourcesTableModel.dataSourceName=Data Source Name",
"OtherOccurrencesDataSourcesTableModel.noData=No Data."})
@Override @Override
public String getColumnName(int colIdx) { public String getColumnName(int colIdx) {
return Bundle.OtherOccurrencesDataSourcesTableModel_dataSourceName(); return Bundle.OtherOccurrencesDataSourcesTableModel_dataSourceName();
@ -59,11 +64,25 @@ final class OtherOccurrencesDataSourcesTableModel extends AbstractTableModel {
return ((DataSourceColumnItem) dataSourceSet.toArray()[rowIdx]).getDataSourceName(); return ((DataSourceColumnItem) dataSourceSet.toArray()[rowIdx]).getDataSourceName();
} }
public String getDeviceIdForRow(int rowIdx) { /**
* Get the device id of the data source shown at the specified row index
*
* @param rowIdx the row index of the data source you want the device id for
*
* @return the device id of the specified data source
*/
String getDeviceIdForRow(int rowIdx) {
return ((DataSourceColumnItem) dataSourceSet.toArray()[rowIdx]).getDeviceId(); return ((DataSourceColumnItem) dataSourceSet.toArray()[rowIdx]).getDeviceId();
} }
public String getCaseNameForRow(int rowIdx){ /**
* Get the case name of the data source shown at the specified row index
*
* @param rowIdx the row index of the data source you want the case name for
*
* @return the case name of the specified data source
*/
String getCaseNameForRow(int rowIdx) {
return ((DataSourceColumnItem) dataSourceSet.toArray()[rowIdx]).getCaseName(); return ((DataSourceColumnItem) dataSourceSet.toArray()[rowIdx]).getCaseName();
} }
@ -73,12 +92,11 @@ final class OtherOccurrencesDataSourcesTableModel extends AbstractTableModel {
} }
/** /**
* Add one correlated instance object to the table * Add data source information to the table of unique data sources
* *
* @param newNodeData data to add to the table * @param newNodeData data to add to the table
*/ */
void addNodeData(OtherOccurrenceNodeData newNodeData) { void addNodeData(OtherOccurrenceNodeData newNodeData) {
// String key = createDataSourceKey((OtherOccurrenceNodeInstanceData)newNodeData);
dataSourceSet.add(new DataSourceColumnItem((OtherOccurrenceNodeInstanceData) newNodeData)); dataSourceSet.add(new DataSourceColumnItem((OtherOccurrenceNodeInstanceData) newNodeData));
fireTableDataChanged(); fireTableDataChanged();
} }
@ -91,30 +109,64 @@ final class OtherOccurrencesDataSourcesTableModel extends AbstractTableModel {
fireTableDataChanged(); fireTableDataChanged();
} }
/**
* Private class for storing data source information in a way that
* facilitates de-duping.
*/
private final class DataSourceColumnItem { private final class DataSourceColumnItem {
private final String caseName; private final String caseName;
private final String deviceId; private final String deviceId;
private final String dataSourceName; private final String dataSourceName;
/**
* Create a DataSourceColumnItem given an
* OtherOccurrenceNodeInstanceData object
*
* @param nodeData the OtherOccurrenceNodeInstanceData which contains
* the data source information
*/
private DataSourceColumnItem(OtherOccurrenceNodeInstanceData nodeData) { private DataSourceColumnItem(OtherOccurrenceNodeInstanceData nodeData) {
this(nodeData.getCaseName(), nodeData.getDeviceID(), nodeData.getDataSourceName()); this(nodeData.getCaseName(), nodeData.getDeviceID(), nodeData.getDataSourceName());
} }
/**
* Create a DataSourceColumnItem given a case name, device id, and data
* source name
*
* @param caseName the name of the case the data source exists in
* @param deviceId the name of the device id for the data source
* @param dataSourceName the name of the data source
*/
private DataSourceColumnItem(String caseName, String deviceId, String dataSourceName) { private DataSourceColumnItem(String caseName, String deviceId, String dataSourceName) {
this.caseName = caseName; this.caseName = caseName;
this.deviceId = deviceId; this.deviceId = deviceId;
this.dataSourceName = dataSourceName; this.dataSourceName = dataSourceName;
} }
/**
* Get the device id
*
* @return the data source's device id
*/
private String getDeviceId() { private String getDeviceId() {
return deviceId; return deviceId;
} }
/**
* Get the data source name
*
* @return the data source's name
*/
private String getDataSourceName() { private String getDataSourceName() {
return dataSourceName; return dataSourceName;
} }
/**
* Get the name of the case the data source exists in
*
* @return the name of the case the data source is in
*/
private String getCaseName() { private String getCaseName() {
return caseName; return caseName;
} }

View File

@ -33,13 +33,12 @@ import org.apache.commons.io.FilenameUtils;
public class OtherOccurrencesFilesTableModel extends AbstractTableModel { public class OtherOccurrencesFilesTableModel extends AbstractTableModel {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Messages({"OtherOccurrencesFilesTableModel.fileName=File Name",
"OtherOccurrencesFilesTableModel.noData=No Data."})
private final List<String> nodeKeys = new ArrayList<>(); private final List<String> nodeKeys = new ArrayList<>();
private final Map<String, List<OtherOccurrenceNodeData>> nodeMap = new HashMap<>(); private final Map<String, List<OtherOccurrenceNodeData>> nodeMap = new HashMap<>();
/**
* Create a table model for displaying file names
*/
OtherOccurrencesFilesTableModel() { OtherOccurrencesFilesTableModel() {
} }
@ -54,6 +53,8 @@ public class OtherOccurrencesFilesTableModel extends AbstractTableModel {
return nodeKeys.size(); return nodeKeys.size();
} }
@Messages({"OtherOccurrencesFilesTableModel.fileName=File Name",
"OtherOccurrencesFilesTableModel.noData=No Data."})
@Override @Override
public String getColumnName(int colIdx) { public String getColumnName(int colIdx) {
return Bundle.OtherOccurrencesFilesTableModel_fileName(); return Bundle.OtherOccurrencesFilesTableModel_fileName();
@ -67,7 +68,15 @@ public class OtherOccurrencesFilesTableModel extends AbstractTableModel {
return FilenameUtils.getName(((OtherOccurrenceNodeInstanceData) nodeMap.get(nodeKeys.get(rowIdx)).get(0)).getFilePath()); return FilenameUtils.getName(((OtherOccurrenceNodeInstanceData) nodeMap.get(nodeKeys.get(rowIdx)).get(0)).getFilePath());
} }
List<OtherOccurrenceNodeData> getRow(int rowIdx) { /**
* Get a list of OtherOccurrenceNodeData that exist for the file which
* corresponds to the Index
*
* @param rowIdx the index of the file to get data for
*
* @return a list of OtherOccurrenceNodeData for the specified index
*/
List<OtherOccurrenceNodeData> getListOfNodesForFile(int rowIdx) {
return nodeMap.get(nodeKeys.get(rowIdx)); return nodeMap.get(nodeKeys.get(rowIdx));
} }
@ -93,10 +102,6 @@ public class OtherOccurrencesFilesTableModel extends AbstractTableModel {
fireTableDataChanged(); fireTableDataChanged();
} }
// List<OtherOccurrenceNodeData> getNodeDataList(String nodeKey) {
// return Collections.unmodifiableList(nodeMap.get(nodeKey));
// }
private String createNodeKey(OtherOccurrenceNodeInstanceData nodeData) { private String createNodeKey(OtherOccurrenceNodeInstanceData nodeData) {
return nodeData.getCaseName() + nodeData.getDataSourceName() + nodeData.getDeviceID() + nodeData.getFilePath(); return nodeData.getCaseName() + nodeData.getDataSourceName() + nodeData.getDeviceID() + nodeData.getFilePath();
} }