Updates to TableReportSettings

This commit is contained in:
Eugene Livis 2019-08-15 13:59:18 -04:00
parent a1026861e3
commit b64fcb129b
6 changed files with 74 additions and 34 deletions

View File

@ -124,6 +124,7 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener {
// get configuration for this module // get configuration for this module
ReportModuleConfig config = moduleConfigs.get(module.getClass().getCanonicalName()); ReportModuleConfig config = moduleConfigs.get(module.getClass().getCanonicalName());
if (config != null) { if (config != null) {
// there is an existing configuration for this module
settings = config.getModuleSettings(); settings = config.getModuleSettings();
} else { } else {
// ELTODO get default module configuration (API isn't implemented yet) // ELTODO get default module configuration (API isn't implemented yet)

View File

@ -61,13 +61,15 @@ final class ReportVisualPanel2 extends JPanel {
ArtifactSelectionDialog dialog = new ArtifactSelectionDialog((JFrame) WindowManager.getDefault().getMainWindow(), true); ArtifactSelectionDialog dialog = new ArtifactSelectionDialog((JFrame) WindowManager.getDefault().getMainWindow(), true);
private Map<BlackboardArtifact.Type, Boolean> artifactStates = new HashMap<>(); private Map<BlackboardArtifact.Type, Boolean> artifactStates = new HashMap<>();
private List<BlackboardArtifact.Type> artifacts = new ArrayList<>(); private List<BlackboardArtifact.Type> artifacts = new ArrayList<>();
private TableReportSettings tableReportSettings;
private final boolean useCaseSpecificData;
private TagsListModel tagsModel; private TagsListModel tagsModel;
private TagsListRenderer tagsRenderer; private TagsListRenderer tagsRenderer;
/** /**
* Creates new form ReportVisualPanel2 * Creates new form ReportVisualPanel2
*/ */
public ReportVisualPanel2(ReportWizardPanel2 wizPanel) { public ReportVisualPanel2(ReportWizardPanel2 wizPanel, TableReportSettings tableReportSettings, boolean useCaseSpecificData) {
initComponents(); initComponents();
initTags(); initTags();
initArtifactTypes(); initArtifactTypes();
@ -76,13 +78,15 @@ final class ReportVisualPanel2 extends JPanel {
deselectAllButton.setEnabled(false); deselectAllButton.setEnabled(false);
allResultsRadioButton.setSelected(true); allResultsRadioButton.setSelected(true);
this.wizPanel = wizPanel; this.wizPanel = wizPanel;
this.tableReportSettings = tableReportSettings;
this.useCaseSpecificData = useCaseSpecificData;
this.allResultsRadioButton.addChangeListener(new ChangeListener() { this.allResultsRadioButton.addChangeListener(new ChangeListener() {
@Override @Override
public void stateChanged(ChangeEvent e) { public void stateChanged(ChangeEvent e) {
tagsList.setEnabled(specificTaggedResultsRadioButton.isSelected()); tagsList.setEnabled(specificTaggedResultsRadioButton.isSelected());
selectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); selectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected());
deselectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); deselectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected());
advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected()); advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected() && useCaseSpecificData);
updateFinishButton(); updateFinishButton();
} }
}); });
@ -92,7 +96,7 @@ final class ReportVisualPanel2 extends JPanel {
tagsList.setEnabled(specificTaggedResultsRadioButton.isSelected()); tagsList.setEnabled(specificTaggedResultsRadioButton.isSelected());
selectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); selectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected());
deselectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); deselectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected());
advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected()); advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected() && useCaseSpecificData);
updateFinishButton(); updateFinishButton();
} }
}); });
@ -102,7 +106,7 @@ final class ReportVisualPanel2 extends JPanel {
tagsList.setEnabled(specificTaggedResultsRadioButton.isSelected()); tagsList.setEnabled(specificTaggedResultsRadioButton.isSelected());
selectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); selectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected());
deselectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected()); deselectAllButton.setEnabled(specificTaggedResultsRadioButton.isSelected());
advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected()); advancedButton.setEnabled(!specificTaggedResultsRadioButton.isSelected() && useCaseSpecificData);
updateFinishButton(); updateFinishButton();
} }
}); });
@ -111,6 +115,16 @@ final class ReportVisualPanel2 extends JPanel {
// Initialize the list of Tags // Initialize the list of Tags
private void initTags() { private void initTags() {
List<TagName> tagNamesInUse; List<TagName> tagNamesInUse;
if (tableReportSettings == null) {
// get default table report settings
tableReportSettings = TableReportGenerator.getDefaultTableReportSettings(useCaseSpecificData);
}
// use specified configuration
List<String> tagNames = tableReportSettings.getTagSelections();
// ELTODO convert List<String> tagNames to List<TagName> tagNamesInUse
// use this list instead of of calling Case.getCurrentCaseThrows().getServices().getTagsManager().getTagNamesInUse();
try { try {
tagNamesInUse = Case.getCurrentCaseThrows().getServices().getTagsManager().getTagNamesInUse(); tagNamesInUse = Case.getCurrentCaseThrows().getServices().getTagsManager().getTagNamesInUse();
} catch (TskCoreException | NoCurrentCaseException ex) { } catch (TskCoreException | NoCurrentCaseException ex) {

View File

@ -58,7 +58,7 @@ final class ReportWizardIterator implements WizardDescriptor.Iterator<WizardDesc
private final WizardDescriptor.Panel<WizardDescriptor>[] portableCaseConfigPanels; private final WizardDescriptor.Panel<WizardDescriptor>[] portableCaseConfigPanels;
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
ReportWizardIterator(String reportingConfigurationName, boolean displayCaseSpecificData, boolean runReports) { ReportWizardIterator(String reportingConfigurationName, boolean useCaseSpecificData, boolean runReports) {
ReportingConfig config = null; ReportingConfig config = null;
try { try {
@ -69,12 +69,12 @@ final class ReportWizardIterator implements WizardDescriptor.Iterator<WizardDesc
if (config != null) { if (config != null) {
firstPanel = new ReportWizardPanel1(config.getModuleConfigs()); firstPanel = new ReportWizardPanel1(config.getModuleConfigs());
tableConfigPanel = new ReportWizardPanel2(config.getTableReportSettings()); tableConfigPanel = new ReportWizardPanel2(config.getTableReportSettings(), useCaseSpecificData);
fileConfigPanel = new ReportWizardFileOptionsPanel(config.getFileReportSettings()); fileConfigPanel = new ReportWizardFileOptionsPanel(config.getFileReportSettings());
portableCaseConfigPanel = new ReportWizardPortableCaseOptionsPanel(config.getModuleConfigs()); portableCaseConfigPanel = new ReportWizardPortableCaseOptionsPanel(config.getModuleConfigs());
} else { } else {
firstPanel = new ReportWizardPanel1(null); firstPanel = new ReportWizardPanel1(null);
tableConfigPanel = new ReportWizardPanel2(null); tableConfigPanel = new ReportWizardPanel2(null, useCaseSpecificData);
fileConfigPanel = new ReportWizardFileOptionsPanel(null); fileConfigPanel = new ReportWizardFileOptionsPanel(null);
portableCaseConfigPanel = new ReportWizardPortableCaseOptionsPanel(null); portableCaseConfigPanel = new ReportWizardPortableCaseOptionsPanel(null);
} }

View File

@ -32,8 +32,13 @@ class ReportWizardPanel2 implements WizardDescriptor.Panel<WizardDescriptor> {
private final JButton finishButton; private final JButton finishButton;
private final JButton nextButton; private final JButton nextButton;
private WizardDescriptor wiz; 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")); finishButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel2.finishButton.text"));
nextButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel2.nextButton.text")); nextButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel2.nextButton.text"));
@ -57,7 +62,7 @@ class ReportWizardPanel2 implements WizardDescriptor.Panel<WizardDescriptor> {
@Override @Override
public ReportVisualPanel2 getComponent() { public ReportVisualPanel2 getComponent() {
if (component == null) { if (component == null) {
component = new ReportVisualPanel2(this); component = new ReportVisualPanel2(this, tableReportSettings, useCaseSpecificData);
} }
return component; return component;
} }

View File

@ -61,8 +61,8 @@ import org.sleuthkit.datamodel.TskData;
class TableReportGenerator { class TableReportGenerator {
private final List<BlackboardArtifact.Type> artifactTypes = new ArrayList<>(); private List<BlackboardArtifact.Type> artifactTypes = new ArrayList<>();
private final HashSet<String> tagNamesFilter = new HashSet<>(); private HashSet<String> tagNamesFilter = new HashSet<>();
private final Set<Content> images = new HashSet<>(); private final Set<Content> images = new HashSet<>();
private final ReportProgressPanel progressPanel; private final ReportProgressPanel progressPanel;
@ -79,20 +79,23 @@ class TableReportGenerator {
this.columnHeaderMap = new HashMap<>(); this.columnHeaderMap = new HashMap<>();
errorList = new ArrayList<>(); errorList = new ArrayList<>();
// Get the artifact types selected by the user. // Get the artifact types selected by the user.
for (Map.Entry<BlackboardArtifact.Type, Boolean> entry : settings.getArtifactSelections().entrySet()) { artifactTypes = settings.getArtifactSelections();
if (entry.getValue()) {
artifactTypes.add(entry.getKey());
}
}
// Get the tag names selected by the user and make a tag names filter. // Get the tag names selected by the user and make a tag names filter.
if (null != settings.getTagSelections()) { tagNamesFilter = new HashSet<>(settings.getTagSelections());
for (Map.Entry<String, Boolean> entry : settings.getTagSelections().entrySet()) { }
if (entry.getValue() == true) {
tagNamesFilter.add(entry.getKey()); static TableReportSettings getDefaultTableReportSettings(boolean useCaseSpecificData) {
} Map<BlackboardArtifact.Type, Boolean> artifactTypeSelections = new HashMap<>();
} Map<String, Boolean> 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() { protected void execute() {

View File

@ -19,7 +19,8 @@
package org.sleuthkit.autopsy.report; package org.sleuthkit.autopsy.report;
import java.io.Serializable; import java.io.Serializable;
import java.util.HashMap; import java.util.ArrayList;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardArtifact;
@ -28,30 +29,46 @@ import org.sleuthkit.datamodel.BlackboardArtifact;
* by the TableReportGenerator class to drive report generation by * by the TableReportGenerator class to drive report generation by
* TableReportModules. * TableReportModules.
*/ */
final class TableReportSettings implements Serializable { final class TableReportSettings implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private Map<BlackboardArtifact.Type, Boolean> artifactTypeSelections = new HashMap<>(); private List<BlackboardArtifact.Type> artifactTypes = new ArrayList<>();
private Map<String, Boolean> tagNameSelections = new HashMap<>(); private List<String> tagNames = new ArrayList<>();
/** /**
* Creates TableReportSettings object. * Creates TableReportSettings object.
* *
* @param artifactTypeSelections The enabled/disabled state of the artifact * @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 * @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<BlackboardArtifact.Type, Boolean> artifactTypeSelections, Map<String, Boolean> tagNameSelections) { TableReportSettings(Map<BlackboardArtifact.Type, Boolean> artifactTypeSelections, Map<String, Boolean> tagNameSelections) {
this.artifactTypeSelections = artifactTypeSelections; // Get the artifact types selected by the user
this.tagNameSelections = tagNameSelections; for (Map.Entry<BlackboardArtifact.Type, Boolean> entry : artifactTypeSelections.entrySet()) {
if (entry.getValue()) {
artifactTypes.add(entry.getKey());
}
}
// Get the tag names selected by the user
for (Map.Entry<String, Boolean> entry : tagNameSelections.entrySet()) {
if (entry.getValue() == true) {
tagNames.add(entry.getKey());
}
}
}
TableReportSettings(List<BlackboardArtifact.Type> artifactTypes, List<String> tagNames) {
this.artifactTypes = artifactTypes;
this.tagNames = tagNames;
} }
Map<BlackboardArtifact.Type, Boolean> getArtifactSelections() { List<BlackboardArtifact.Type> getArtifactSelections() {
return artifactTypeSelections; return artifactTypes;
} }
Map<String, Boolean> getTagSelections() { List<String> getTagSelections() {
return tagNameSelections; return tagNames;
} }
} }