Codacy fixes and small interface changes

This commit is contained in:
U-BASIS\dsmyda 2020-04-28 13:39:12 -04:00
parent ffbb65477c
commit 6817c5e3e7
5 changed files with 26 additions and 14 deletions

View File

@ -45,16 +45,16 @@ public interface GeneralReportModule extends ReportModule {
/** /**
* Called to generate the report. Method is responsible for saving the file * Called to generate the report. Method is responsible for saving the file
* at the path specified and updating progress via the progressPanel object. * and updating progress via the progressPanel object. Configuration
* Configuration parameters can be passed in the settings class. Modules should * parameters are passed in the settings class, most notably the directory
* try to respond to all configuration parameters. * to save the report. Modules should try to respond to all configuration
* parameters.
* *
* @param baseReportDir Base directory that reports are being stored in. * @param settings Configuration parameters to customize the report
* Report should go into baseReportDir + getRelativeFilePath(). * generation process
* @param settings Configuration parameters to customize the report generation process
* @param progressPanel panel to update the report's progress with * @param progressPanel panel to update the report's progress with
*/ */
default void generateReport(String baseReportDir, GeneralReportSettings settings, ReportProgressPanel progressPanel) { default void generateReport(GeneralReportSettings settings, ReportProgressPanel progressPanel) {
generateReport(baseReportDir, progressPanel); generateReport(settings.getReportDirectoryPath(), progressPanel);
} }
} }

View File

@ -29,6 +29,7 @@ public class GeneralReportSettings implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private List<Long> dataSourcesToProcess; private List<Long> dataSourcesToProcess;
private String reportDirectoryPath;
public List<Long> getDataSourcesToProcess() { public List<Long> getDataSourcesToProcess() {
return dataSourcesToProcess; return dataSourcesToProcess;
@ -37,4 +38,12 @@ public class GeneralReportSettings implements Serializable {
public void setDataSourcesToProcess(List<Long> dataSourcesToProcess) { public void setDataSourcesToProcess(List<Long> dataSourcesToProcess) {
this.dataSourcesToProcess = new ArrayList<>(dataSourcesToProcess); this.dataSourcesToProcess = new ArrayList<>(dataSourcesToProcess);
} }
public String getReportDirectoryPath() {
return this.reportDirectoryPath;
}
public void setReportDirectoryPath(String reportDirectoryPath) {
this.reportDirectoryPath = reportDirectoryPath;
}
} }

View File

@ -302,7 +302,8 @@ public class ReportGenerator {
if (generalReportModule != null) { if (generalReportModule != null) {
String reportDir = createReportDirectory(generalReportModule); String reportDir = createReportDirectory(generalReportModule);
setupProgressPanel(generalReportModule, reportDir); setupProgressPanel(generalReportModule, reportDir);
generalReportModule.generateReport(reportDir, reportSettings, progressIndicator); reportSettings.setReportDirectoryPath(reportDir);
generalReportModule.generateReport(reportSettings, progressIndicator);
} }
} }

View File

@ -130,7 +130,7 @@ class ReportWizardPanel1 implements WizardDescriptor.FinishablePanel<WizardDescr
} }
// HTML reports in initial PR // HTML reports in initial PR
if(tableModuleSelection != null && tableModuleSelection instanceof HTMLReport) { if(tableModuleSelection instanceof HTMLReport) {
prefs.putBoolean("showDataSourceSelectionPanel", true); prefs.putBoolean("showDataSourceSelectionPanel", true);
} }
} }

View File

@ -165,13 +165,14 @@ public final class KMLReport implements GeneralReportModule {
} }
@Override @Override
public void generateReport(String baseReportDir, GeneralReportSettings settings, ReportProgressPanel progressPanel) { public void generateReport(GeneralReportSettings settings, ReportProgressPanel progressPanel) {
try { try {
currentCase = Case.getCurrentCaseThrows(); currentCase = Case.getCurrentCaseThrows();
} catch (NoCurrentCaseException ex) { } catch (NoCurrentCaseException ex) {
logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS logger.log(Level.SEVERE, "Exception while getting open case.", ex); //NON-NLS
return; return;
} }
String baseReportDir = settings.getReportDirectoryPath();
this.settings = settings; this.settings = settings;
// Start the progress bar and setup the report // Start the progress bar and setup the report
progressPanel.setIndeterminate(true); progressPanel.setIndeterminate(true);
@ -239,15 +240,16 @@ public final class KMLReport implements GeneralReportModule {
@Override @Override
public void generateReport(String baseReportDir, ReportProgressPanel progressPanel) { public void generateReport(String baseReportDir, ReportProgressPanel progressPanel) {
try { try {
GeneralReportSettings settings = new GeneralReportSettings(); GeneralReportSettings reportSettings = new GeneralReportSettings();
currentCase = Case.getCurrentCaseThrows(); currentCase = Case.getCurrentCaseThrows();
// Process all data sources if none are provided. // Process all data sources if none are provided.
List<Long> selections = currentCase.getDataSources() List<Long> selections = currentCase.getDataSources()
.stream() .stream()
.map(Content::getId) .map(Content::getId)
.collect(Collectors.toList()); .collect(Collectors.toList());
settings.setDataSourcesToProcess(selections); reportSettings.setDataSourcesToProcess(selections);
generateReport(baseReportDir, settings, progressPanel); reportSettings.setReportDirectoryPath(baseReportDir);
generateReport(reportSettings, progressPanel);
} catch (NoCurrentCaseException | TskCoreException ex) { } catch (NoCurrentCaseException | TskCoreException ex) {
logger.log(Level.SEVERE, "Exception while accessing case resources.", ex); //NON-NLS logger.log(Level.SEVERE, "Exception while accessing case resources.", ex); //NON-NLS
} }