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
* at the path specified and updating progress via the progressPanel object.
* Configuration parameters can be passed in the settings class. Modules should
* try to respond to all configuration parameters.
* and updating progress via the progressPanel object. Configuration
* parameters are passed in the settings class, most notably the directory
* to save the report. Modules should try to respond to all configuration
* parameters.
*
* @param baseReportDir Base directory that reports are being stored in.
* Report should go into baseReportDir + getRelativeFilePath().
* @param settings Configuration parameters to customize the report generation process
* @param settings Configuration parameters to customize the report
* generation process
* @param progressPanel panel to update the report's progress with
*/
default void generateReport(String baseReportDir, GeneralReportSettings settings, ReportProgressPanel progressPanel) {
generateReport(baseReportDir, progressPanel);
default void generateReport(GeneralReportSettings settings, ReportProgressPanel progressPanel) {
generateReport(settings.getReportDirectoryPath(), progressPanel);
}
}

View File

@ -29,6 +29,7 @@ public class GeneralReportSettings implements Serializable {
private static final long serialVersionUID = 1L;
private List<Long> dataSourcesToProcess;
private String reportDirectoryPath;
public List<Long> getDataSourcesToProcess() {
return dataSourcesToProcess;
@ -37,4 +38,12 @@ public class GeneralReportSettings implements Serializable {
public void setDataSourcesToProcess(List<Long> 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) {
String reportDir = createReportDirectory(generalReportModule);
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
if(tableModuleSelection != null && tableModuleSelection instanceof HTMLReport) {
if(tableModuleSelection instanceof HTMLReport) {
prefs.putBoolean("showDataSourceSelectionPanel", true);
}
}

View File

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