From b64fcb129b18dfedd711132f06bd105244ce122d Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Thu, 15 Aug 2019 13:59:18 -0400 Subject: [PATCH] Updates to TableReportSettings --- .../autopsy/report/ReportVisualPanel1.java | 1 + .../autopsy/report/ReportVisualPanel2.java | 22 ++++++++-- .../autopsy/report/ReportWizardIterator.java | 6 +-- .../autopsy/report/ReportWizardPanel2.java | 9 +++- .../autopsy/report/TableReportGenerator.java | 29 +++++++------ .../autopsy/report/TableReportSettings.java | 41 +++++++++++++------ 6 files changed, 74 insertions(+), 34 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel1.java b/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel1.java index 32d5dff80f..b4d490cf95 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel1.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel1.java @@ -124,6 +124,7 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener { // get configuration for this module ReportModuleConfig config = moduleConfigs.get(module.getClass().getCanonicalName()); if (config != null) { + // there is an existing configuration for this module settings = config.getModuleSettings(); } else { // ELTODO get default module configuration (API isn't implemented yet) diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel2.java b/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel2.java index 76771b9b1a..d69e9b9ed3 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel2.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportVisualPanel2.java @@ -61,13 +61,15 @@ final class ReportVisualPanel2 extends JPanel { ArtifactSelectionDialog dialog = new ArtifactSelectionDialog((JFrame) WindowManager.getDefault().getMainWindow(), true); private Map artifactStates = new HashMap<>(); private List artifacts = new ArrayList<>(); + private TableReportSettings tableReportSettings; + private final boolean useCaseSpecificData; private TagsListModel tagsModel; private TagsListRenderer tagsRenderer; /** * Creates new form ReportVisualPanel2 */ - public ReportVisualPanel2(ReportWizardPanel2 wizPanel) { + public ReportVisualPanel2(ReportWizardPanel2 wizPanel, TableReportSettings tableReportSettings, boolean useCaseSpecificData) { initComponents(); initTags(); initArtifactTypes(); @@ -76,13 +78,15 @@ final class ReportVisualPanel2 extends JPanel { deselectAllButton.setEnabled(false); allResultsRadioButton.setSelected(true); this.wizPanel = wizPanel; + this.tableReportSettings = tableReportSettings; + this.useCaseSpecificData = useCaseSpecificData; this.allResultsRadioButton.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { tagsList.setEnabled(specificTaggedResultsRadioButton.isSelected()); selectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); deselectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); - advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected()); + advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected() && useCaseSpecificData); updateFinishButton(); } }); @@ -92,7 +96,7 @@ final class ReportVisualPanel2 extends JPanel { tagsList.setEnabled(specificTaggedResultsRadioButton.isSelected()); selectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); deselectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); - advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected()); + advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected() && useCaseSpecificData); updateFinishButton(); } }); @@ -102,7 +106,7 @@ final class ReportVisualPanel2 extends JPanel { tagsList.setEnabled(specificTaggedResultsRadioButton.isSelected()); selectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); deselectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); - advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected()); + advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected() && useCaseSpecificData); updateFinishButton(); } }); @@ -111,6 +115,16 @@ final class ReportVisualPanel2 extends JPanel { // Initialize the list of Tags private void initTags() { List tagNamesInUse; + if (tableReportSettings == null) { + // get default table report settings + tableReportSettings = TableReportGenerator.getDefaultTableReportSettings(useCaseSpecificData); + } + + // use specified configuration + List tagNames = tableReportSettings.getTagSelections(); + // ELTODO convert List tagNames to List tagNamesInUse + // use this list instead of of calling Case.getCurrentCaseThrows().getServices().getTagsManager().getTagNamesInUse(); + try { tagNamesInUse = Case.getCurrentCaseThrows().getServices().getTagsManager().getTagNamesInUse(); } catch (TskCoreException | NoCurrentCaseException ex) { diff --git a/Core/src/org/sleuthkit/autopsy/report/ReportWizardIterator.java b/Core/src/org/sleuthkit/autopsy/report/ReportWizardIterator.java index 50b20caf3d..71c274474c 100644 --- a/Core/src/org/sleuthkit/autopsy/report/ReportWizardIterator.java +++ b/Core/src/org/sleuthkit/autopsy/report/ReportWizardIterator.java @@ -58,7 +58,7 @@ final class ReportWizardIterator implements WizardDescriptor.Iterator[] portableCaseConfigPanels; @SuppressWarnings({"rawtypes", "unchecked"}) - ReportWizardIterator(String reportingConfigurationName, boolean displayCaseSpecificData, boolean runReports) { + ReportWizardIterator(String reportingConfigurationName, boolean useCaseSpecificData, boolean runReports) { ReportingConfig config = null; try { @@ -69,12 +69,12 @@ final class ReportWizardIterator implements WizardDescriptor.Iterator { private final JButton finishButton; private final JButton nextButton; private WizardDescriptor wiz; + private final TableReportSettings tableReportSettings; + private final boolean useCaseSpecificData; - ReportWizardPanel2(TableReportSettings tableReportSettings) { + ReportWizardPanel2(TableReportSettings tableReportSettings, boolean useCaseSpecificData) { + this.tableReportSettings = tableReportSettings; + this.useCaseSpecificData = useCaseSpecificData; + finishButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel2.finishButton.text")); nextButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel2.nextButton.text")); @@ -57,7 +62,7 @@ class ReportWizardPanel2 implements WizardDescriptor.Panel { @Override public ReportVisualPanel2 getComponent() { if (component == null) { - component = new ReportVisualPanel2(this); + component = new ReportVisualPanel2(this, tableReportSettings, useCaseSpecificData); } return component; } diff --git a/Core/src/org/sleuthkit/autopsy/report/TableReportGenerator.java b/Core/src/org/sleuthkit/autopsy/report/TableReportGenerator.java index 093a4a5eb3..0e06c50ceb 100644 --- a/Core/src/org/sleuthkit/autopsy/report/TableReportGenerator.java +++ b/Core/src/org/sleuthkit/autopsy/report/TableReportGenerator.java @@ -61,8 +61,8 @@ import org.sleuthkit.datamodel.TskData; class TableReportGenerator { - private final List artifactTypes = new ArrayList<>(); - private final HashSet tagNamesFilter = new HashSet<>(); + private List artifactTypes = new ArrayList<>(); + private HashSet tagNamesFilter = new HashSet<>(); private final Set images = new HashSet<>(); private final ReportProgressPanel progressPanel; @@ -79,20 +79,23 @@ class TableReportGenerator { this.columnHeaderMap = new HashMap<>(); errorList = new ArrayList<>(); // Get the artifact types selected by the user. - for (Map.Entry entry : settings.getArtifactSelections().entrySet()) { - if (entry.getValue()) { - artifactTypes.add(entry.getKey()); - } - } + artifactTypes = settings.getArtifactSelections(); // Get the tag names selected by the user and make a tag names filter. - if (null != settings.getTagSelections()) { - for (Map.Entry entry : settings.getTagSelections().entrySet()) { - if (entry.getValue() == true) { - tagNamesFilter.add(entry.getKey()); - } - } + tagNamesFilter = new HashSet<>(settings.getTagSelections()); + } + + static TableReportSettings getDefaultTableReportSettings(boolean useCaseSpecificData) { + Map artifactTypeSelections = new HashMap<>(); + Map tagNameSelections = new HashMap<>(); + + if (useCaseSpecificData) { + // get tags and artifact types from current case + } else { + // get all possible tag names and artifact types } + + return new TableReportSettings(artifactTypeSelections, tagNameSelections); } protected void execute() { diff --git a/Core/src/org/sleuthkit/autopsy/report/TableReportSettings.java b/Core/src/org/sleuthkit/autopsy/report/TableReportSettings.java index 7817d70b83..5c9c5f7985 100755 --- a/Core/src/org/sleuthkit/autopsy/report/TableReportSettings.java +++ b/Core/src/org/sleuthkit/autopsy/report/TableReportSettings.java @@ -19,7 +19,8 @@ package org.sleuthkit.autopsy.report; import java.io.Serializable; -import java.util.HashMap; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import org.sleuthkit.datamodel.BlackboardArtifact; @@ -28,30 +29,46 @@ import org.sleuthkit.datamodel.BlackboardArtifact; * by the TableReportGenerator class to drive report generation by * TableReportModules. */ -final class TableReportSettings implements Serializable { +final class TableReportSettings implements Serializable { private static final long serialVersionUID = 1L; - private Map artifactTypeSelections = new HashMap<>(); - private Map tagNameSelections = new HashMap<>(); + private List artifactTypes = new ArrayList<>(); + private List tagNames = new ArrayList<>(); /** * Creates TableReportSettings object. * * @param artifactTypeSelections The enabled/disabled state of the artifact - * types to be included in the report + * types to be included in the report. Only enabled entries will be kept. * @param tagNameSelections The enabled/disabled state of the tag names to - * be included in the report + * be included in the report. Only enabled entries will be kept. */ TableReportSettings(Map artifactTypeSelections, Map tagNameSelections) { - this.artifactTypeSelections = artifactTypeSelections; - this.tagNameSelections = tagNameSelections; + // Get the artifact types selected by the user + for (Map.Entry entry : artifactTypeSelections.entrySet()) { + if (entry.getValue()) { + artifactTypes.add(entry.getKey()); + } + } + + // Get the tag names selected by the user + for (Map.Entry entry : tagNameSelections.entrySet()) { + if (entry.getValue() == true) { + tagNames.add(entry.getKey()); + } + } + } + + TableReportSettings(List artifactTypes, List tagNames) { + this.artifactTypes = artifactTypes; + this.tagNames = tagNames; } - Map getArtifactSelections() { - return artifactTypeSelections; + List getArtifactSelections() { + return artifactTypes; } - Map getTagSelections() { - return tagNameSelections; + List getTagSelections() { + return tagNames; } }