Commit 813914eb authored by Riegel's avatar Riegel
Browse files

Feat: Add short-term memory of previous Checkers

Adds a HashMap to allow CityDoctorController to remember the Checker of
a CityDoctorModel, to allow switching of models with ZipEntryManager
without having to rerun the Checks when an already validated model is
loaded again.

Short-term meaning, that the memory is only kept for this session and
only till the next CityGML source is loaded (even if the same zip file
gets loaded again).
parent 1ad79192
Showing with 12 additions and 1 deletion
+12 -1
...@@ -47,6 +47,7 @@ public class CityDoctorController { ...@@ -47,6 +47,7 @@ public class CityDoctorController {
private String sourceFile; private String sourceFile;
private CityGmlZipArchive zipArchive; private CityGmlZipArchive zipArchive;
private ZipEntryManager currentZipEntryManager; private ZipEntryManager currentZipEntryManager;
private HashMap<CityDoctorModel, Checker> previousCheckers = null;
private Checker currentChecker; private Checker currentChecker;
private HighlightController highlightController; private HighlightController highlightController;
...@@ -92,6 +93,7 @@ public class CityDoctorController { ...@@ -92,6 +93,7 @@ public class CityDoctorController {
return; return;
} }
currentZipEntryManager = null; currentZipEntryManager = null;
previousCheckers = null;
currentChecker = null; currentChecker = null;
currentConfig = new ParserConfiguration(numberOfRoundingPlaces, useValidation, lowMemory); currentConfig = new ParserConfiguration(numberOfRoundingPlaces, useValidation, lowMemory);
GMLValidationHandler handler = null; GMLValidationHandler handler = null;
...@@ -155,6 +157,7 @@ public class CityDoctorController { ...@@ -155,6 +157,7 @@ public class CityDoctorController {
currentConfig = new ParserConfiguration(numberOfRoundingPlaces, useValidation, lowMemory); currentConfig = new ParserConfiguration(numberOfRoundingPlaces, useValidation, lowMemory);
zipArchive = CityGmlZipArchive.register(path); zipArchive = CityGmlZipArchive.register(path);
if (zipArchive != null) { if (zipArchive != null) {
previousCheckers = new HashMap<>();
Platform.runLater(() -> { Platform.runLater(() -> {
try { try {
currentZipEntryManager = new ZipEntryManager(mainWindow.getMainStage(), this); currentZipEntryManager = new ZipEntryManager(mainWindow.getMainStage(), this);
...@@ -191,11 +194,14 @@ public class CityDoctorController { ...@@ -191,11 +194,14 @@ public class CityDoctorController {
mainWindow.resetSearchBar(); mainWindow.resetSearchBar();
mainWindow.resetFilterComboBox(); mainWindow.resetFilterComboBox();
}); });
currentChecker = null;
model = entry.getModel(); model = entry.getModel();
currentChecker = previousCheckers.getOrDefault(model, null);
mainWindow.getClickHandler().setConfig(currentConfig); mainWindow.getClickHandler().setConfig(currentConfig);
sourceFile = entry.getArchive().getArchivePath().toString(); sourceFile = entry.getArchive().getArchivePath().toString();
renderer.reset(); renderer.reset();
Platform.runLater(() -> { Platform.runLater(() -> {
mainWindow.addFileNameToTitle(entry.getArchive().getArchivePath().toString()); mainWindow.addFileNameToTitle(entry.getArchive().getArchivePath().toString());
mainWindow.getCheckButton().setDisable(false); mainWindow.getCheckButton().setDisable(false);
...@@ -212,6 +218,8 @@ public class CityDoctorController { ...@@ -212,6 +218,8 @@ public class CityDoctorController {
mainWindow.alignNorthArrow(); mainWindow.alignNorthArrow();
setupFeatureTabs(); setupFeatureTabs();
buildTrees(); buildTrees();
updateFeatureTrees();
mainWindow.getWriteReportButton().setDisable(currentChecker == null);
}); });
} finally { } finally {
Platform.runLater(() -> mainWindow.getOpenBtn().setDisable(false)); Platform.runLater(() -> mainWindow.getOpenBtn().setDisable(false));
...@@ -871,6 +879,9 @@ public class CityDoctorController { ...@@ -871,6 +879,9 @@ public class CityDoctorController {
config.setNumberOfRoundingPlacesInGlobalParameters(currentConfig.getNumberOfRoundingPlaces()); config.setNumberOfRoundingPlacesInGlobalParameters(currentConfig.getNumberOfRoundingPlaces());
config.setParserConfig(currentConfig); config.setParserConfig(currentConfig);
currentChecker = new Checker(config, model); currentChecker = new Checker(config, model);
if (previousCheckers != null) {
previousCheckers.put(model, currentChecker);
}
currentChecker.runChecks(l); currentChecker.runChecks(l);
Platform.runLater(() -> { Platform.runLater(() -> {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment