diff --git a/CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization.properties b/CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization.properties index 613ac5449296753153627df781cbaaab6dbe5326..78349133d6520a64c71648949f2205e4c513add6 100644 --- a/CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization.properties +++ b/CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization.properties @@ -20,6 +20,7 @@ CityDoctorController.noDatamodel=Datamodel is null, no checks could be done CityDoctorController.noSourceFile=Source file is null, no checks could be done CityDoctorController.noZipFile=ZIP archive is null, no checks could be done CityDoctorController.exportSuccess=Successfully exported feature +CityDoctorController.saveZipArchiveReports=Successfully exported validation reports! ExceptionDialog.stacktrace=The exception stacktrace was: FilterPane.buildings=Buildings FilterPane.bridges=Bridges diff --git a/CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization_de.properties b/CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization_de.properties index 2ca4bbb17ad75f016681ac2802647ee3fcca64d3..864c13b7b84e9974f1bd6c2b2ab9c6d5e3b45129 100644 --- a/CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization_de.properties +++ b/CityDoctorParent/CityDoctorModel/src/main/resources/CityDoctorLocalization_de.properties @@ -18,6 +18,7 @@ CityDoctorController.noDatamodel=Datenmodell ist null, keine Pr\u00fcfungen konn CityDoctorController.noSourceFile=Quelldatei ist null, keine Pr\u00fcfungen konnten ausgef\u00fchrt werden CityDoctorController.noZipFile=ZIP-Archiv ist null, keine Pr\u00fcfungen konnten ausgef\u00fchrt werden CityDoctorController.exportSuccess=Feature export erfolgreich abgeschlossen +CityDoctorController.saveZipArchiveReports=Validierungsberichte erfolgreich exportiert! ExceptionDialog.stacktrace=Der Stacktrace des Fehlers war: FilterPane.buildings=Geb\u00e4ude FilterPane.bridges=Br\u00fccken diff --git a/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/CityDoctorController.java b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/CityDoctorController.java index 6c71bdc9404f058d79f835f92140ff43c077930e..f8c1be3f7f2a204b2fb605abb7e185cba420ba7c 100644 --- a/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/CityDoctorController.java +++ b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/CityDoctorController.java @@ -11,6 +11,7 @@ import de.hft.stuttgart.citydoctor2.gui.table.ErrorStat; import de.hft.stuttgart.citydoctor2.gui.tree.*; import de.hft.stuttgart.citydoctor2.mapper.citygml3.GMLValidationHandler; import de.hft.stuttgart.citydoctor2.parser.*; +import de.hft.stuttgart.citydoctor2.utils.ArchivePacker; import de.hft.stuttgart.citydoctor2.utils.Localization; import de.hft.stuttgart.citydoctor2.zip.CityGmlZipArchive; import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntry; @@ -25,6 +26,7 @@ import javafx.scene.control.TreeItem; import javafx.scene.control.TreeView; import javafx.stage.FileChooser; import javafx.stage.FileChooser.ExtensionFilter; +import org.apache.commons.io.FileUtils; import org.apache.commons.io.FilenameUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -1011,6 +1013,46 @@ public class CityDoctorController { } + public void saveZipArchiveReports(File outputZipDirectory) { + if (zipArchive == null) { + return; + } + String directoryName = FilenameUtils.removeExtension(outputZipDirectory.getAbsolutePath()); + Path tempOutput = Path.of(directoryName + File.separator); + File temp = null; + try { + temp = tempOutput.toFile(); + for (CityGmlZipEntry entry : zipArchive.getEntries()) { + if (entry.getErrorType() != null || entry.getModel() == null) { + continue; + } + model = entry.getModel(); + if (model.isValidated()) { + Checker checker = previousCheckers.get(model); + Files.createDirectories(tempOutput.resolve(entry.getFullFileName()).getParent()); + checker.writeXmlReport(tempOutput.resolve(entry.getDisplayName() + "_report.xml").toString()); + checker.writePdfReport(tempOutput.resolve(entry.getDisplayName() + "_report.pdf").toString()); + } + } + ArchivePacker.packAndDeleteDirectory(tempOutput.toString()); + temp = null; + Alert alert = new Alert(Alert.AlertType.INFORMATION); + alert.setTitle("Export Report"); + alert.setContentText(Localization.getText("CityDoctorController.saveZipArchiveReports")); + alert.showAndWait(); + } catch (IOException e) { + logger.error(e); + } finally { + try { + if (temp != null) { + FileUtils.deleteDirectory(temp); + } + } catch (IOException e) { + logger.error(e); + } + } + } + void updateFeatureTrees() { updateTree(mainWindow.getBuildingsView().getRoot()); updateTree(mainWindow.getVegetationView().getRoot()); diff --git a/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/ZipEntryManager.java b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/ZipEntryManager.java index 8d868c85dd8c0477ff74c4dfd8cc782a887c4183..0678a0835d02ba477b389d878c44ff33c8356d11 100644 --- a/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/ZipEntryManager.java +++ b/CityDoctorParent/Extensions/CityDoctorGUI/src/main/java/de/hft/stuttgart/citydoctor2/gui/ZipEntryManager.java @@ -287,15 +287,21 @@ public class ZipEntryManager { showReportBtn.setDisable(true); saveBtn.setOnAction(e -> { - FileChooser fileChooser = new FileChooser(); - fileChooser.setTitle("Export Zip file"); - FileChooser.ExtensionFilter zipFilter = new FileChooser.ExtensionFilter("Zip File", "*.zip"); - fileChooser.getExtensionFilters().add(zipFilter); - File f = fileChooser.showSaveDialog(stage.getOwner()); - if (f != null) { - ArchivePacker.packArchive(f.getAbsolutePath(), archive); + disableTaskButtons(); + setEntryListLocked(true); + try { + FileChooser fileChooser = new FileChooser(); + fileChooser.setTitle("Export Zip file"); + FileChooser.ExtensionFilter zipFilter = new FileChooser.ExtensionFilter("Zip File", "*.zip"); + fileChooser.getExtensionFilters().add(zipFilter); + File f = fileChooser.showSaveDialog(stage.getOwner()); + if (f != null) { + controller.saveZipArchiveReports(f); + } + } finally { + setEntryListLocked(false); + refresh(); } - }); saveBtn.setDisable(true);