From db25e16dcb20af2cb246f92eb961a04ba8592698 Mon Sep 17 00:00:00 2001 From: Riegel Date: Wed, 27 Nov 2024 08:48:31 +0100 Subject: [PATCH] Feat: Add basis for ZipLoader implementation --- .../Extensions/CityDoctorZipLoader/pom.xml | 190 ++++++++++++++++++ .../citydoctor2/ziploader/CityGmlArchive.java | 23 +++ .../ziploader/CityGmlZipEntry.java | 62 ++++++ .../citydoctor2/ziploader/ZipParser.java | 37 ++++ .../ziploader/gui/ZipLoaderView.java | 4 + .../src/main/resources/citydoctor_logo.ico | Bin 0 -> 4286 bytes .../ziploader/gui/ZipLoaderGUI.fxml | 31 +++ CityDoctorParent/pom.xml | 1 + 8 files changed, 348 insertions(+) create mode 100644 CityDoctorParent/Extensions/CityDoctorZipLoader/pom.xml create mode 100644 CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/CityGmlArchive.java create mode 100644 CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/CityGmlZipEntry.java create mode 100644 CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/ZipParser.java create mode 100644 CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/gui/ZipLoaderView.java create mode 100644 CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/resources/citydoctor_logo.ico create mode 100644 CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/resources/de/hft/stuttgart/citydoctor2/ziploader/gui/ZipLoaderGUI.fxml diff --git a/CityDoctorParent/Extensions/CityDoctorZipLoader/pom.xml b/CityDoctorParent/Extensions/CityDoctorZipLoader/pom.xml new file mode 100644 index 00000000..3346570c --- /dev/null +++ b/CityDoctorParent/Extensions/CityDoctorZipLoader/pom.xml @@ -0,0 +1,190 @@ + + + 4.0.0 + + de.hft.stuttgart + CityDoctorParent + 3.16.0 + ../../pom.xml + + CityDoctorZipLoader + CityDoctorZipLoader + ZipLoader enables the loading and parsing of zip archives + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + + + + de.hft.stuttgart + CityDoctorModel + + + de.hft.stuttgart + CityDoctorValidation + + + org.apache.logging.log4j + log4j-api + + + org.apache.logging.log4j + log4j-core + + + junit + junit + test + + + org.apache.logging.log4j + log4j-slf4j18-impl + + + + + create-binaries + + jre-${jre-version-short} + ${win-jre} + ${win-jre}.jre + + + + + com.googlecode.maven-download-plugin + download-maven-plugin + 1.7.0 + + + downloadWindowsJre + install + + wget + + + https://download.bell-sw.com/java/${jre-version}/bellsoft-jre${jre-version}-windows-amd64.zip + false + ${project.build.directory}/jre/jre-win + win-runtime.zip + + + + downloadLinuxJre + install + + wget + + + https://download.bell-sw.com/java/${jre-version}/bellsoft-jre${jre-version}-linux-amd64.tar.gz + false + ${project.build.directory}/jre/jre-lin + lin-runtime.tar.gz + + + + downloadMacJre + install + + wget + + + https://download.bell-sw.com/java/${jre-version}/bellsoft-jre${jre-version}-macos-amd64.zip + false + ${project.build.directory}/jre/jre-mac + mac-runtime.zip + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 3.1.0 + + + unpack + install + + + + + + + + + run + + + + + + maven-assembly-plugin + + false + + + + create-archive-no-runtime + install + + single + + + ${project.artifactId}-${project.version}-no-runtime + + ${project.basedir}/src/assembly/no_runtime/assembly.xml + + + + + create-archive-win + install + + single + + + ${project.artifactId}-${project.version}-win + + ${project.basedir}/src/assembly/win/assembly.xml + + + + + create-archive-lin + install + + single + + + ${project.artifactId}-${project.version}-lin + + ${project.basedir}/src/assembly/lin/assembly.xml + + + + + create-archive-mac + install + + single + + + ${project.artifactId}-${project.version}-mac + + ${project.basedir}/src/assembly/mac/assembly.xml + + + + + + + + + + \ No newline at end of file diff --git a/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/CityGmlArchive.java b/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/CityGmlArchive.java new file mode 100644 index 00000000..79c88237 --- /dev/null +++ b/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/CityGmlArchive.java @@ -0,0 +1,23 @@ +package de.hft.stuttgart.citydoctor2.ziploader; + +import de.hft.stuttgart.citydoctor2.check.Checker; + +import java.util.ArrayList; +import java.util.List; + +public class CityGmlArchive { + + private List entries; + + public CityGmlArchive(List entries) { + this.entries = entries; + } + + public void checkEntries(){ + for(CityGmlZipEntry entry : entries){ + Checker checker = new Checker(entry.getModel()); + checker.runChecks(); + + } + } +} diff --git a/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/CityGmlZipEntry.java b/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/CityGmlZipEntry.java new file mode 100644 index 00000000..c4fff6d1 --- /dev/null +++ b/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/CityGmlZipEntry.java @@ -0,0 +1,62 @@ +package de.hft.stuttgart.citydoctor2.ziploader; + +import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel; +import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException; +import de.hft.stuttgart.citydoctor2.parser.CityGmlParser; +import de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException; +import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.zip.ZipEntry; + +public class CityGmlZipEntry { + + private static final Logger logger = LogManager.getLogger(CityGmlZipEntry.class); + + + private String fileName; + private String archivePath; + private CityDoctorModel model; + + private boolean erroneous = false; + private boolean isLibraryObject = false; + + public static CityGmlZipEntry of(ZipEntry entry, ParserConfiguration config, String archivePath){ + CityGmlZipEntry cgzEntry = new CityGmlZipEntry(); + cgzEntry.fileName = entry.getName(); + cgzEntry.archivePath = archivePath; + try { + cgzEntry.model = CityGmlParser.parseCityGmlFile(entry.getName(), config); + } + catch (CityGmlParseException | InvalidGmlFileException e) { + logger.error(e); + cgzEntry.erroneous = true; + } + return cgzEntry; + } + + public void setIsLibraryObject(boolean isLibraryObject) { + this.isLibraryObject = isLibraryObject; + } + + public String getFileName() { + return fileName; + } + + public String getArchivePath() { + return archivePath; + } + + public CityDoctorModel getModel() { + return model; + } + + public boolean isLibraryObject() { + return isLibraryObject; + } + + public boolean isErroneous() { + return erroneous; + } +} diff --git a/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/ZipParser.java b/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/ZipParser.java new file mode 100644 index 00000000..bc32a45c --- /dev/null +++ b/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/ZipParser.java @@ -0,0 +1,37 @@ +package de.hft.stuttgart.citydoctor2.ziploader; + +import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Enumeration; +import java.util.List; +import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; + +public class ZipParser { + + private static final Logger logger = LogManager.getLogger(ZipParser.class); + + public static List parseZipFile(String zipFile, ParserConfiguration config) { + ArrayList archiveEntries = new ArrayList<>(); + try (ZipFile zipFileObj = new ZipFile(zipFile)) { + for (Enumeration entries = zipFileObj.entries(); entries.hasMoreElements();) { + ZipEntry entry = entries.nextElement(); + if (entry.isDirectory()) { + continue; + } + if (entry.getName().endsWith(".gml")) { + archiveEntries.add(CityGmlZipEntry.of(entry, config, zipFile)); + } + } + } catch (IOException e) { + throw new RuntimeException(e); + } + return archiveEntries; + } + +} diff --git a/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/gui/ZipLoaderView.java b/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/gui/ZipLoaderView.java new file mode 100644 index 00000000..09633f22 --- /dev/null +++ b/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/java/de/hft/stuttgart/citydoctor2/ziploader/gui/ZipLoaderView.java @@ -0,0 +1,4 @@ +package de.hft.stuttgart.citydoctor2.ziploader.gui; + +public class ZipLoaderView { +} diff --git a/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/resources/citydoctor_logo.ico b/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/resources/citydoctor_logo.ico new file mode 100644 index 0000000000000000000000000000000000000000..3321b741356a9f40506da39dd8377c83e227d67a GIT binary patch literal 4286 zcmeH~SxA&o6vwamdd%RqvI?#%jujub3bJ4n{j3=2>OOI-<^BUJ-`3m?=Y5x zpR6oK-|TieW0{PxxoDWh^3f=tKUnr=LePR4|L(Uzk_&Z`@e3KH|5i)1FLLDaQuZmJF2%y~K2YR>$oRdE?H7&D8 zqG2j)Pt{AtW@7K%-U$>Z-iLG-Z|xKsK2hvw8jxE-?8S52puaDUhKGqAaQI=#f;KT9 z$|Lb7GqWDqPFiD)@7!UL;{W-+!Ohn##vX{YE^)4wQQLQK?u;L%Qgc^Pa2)iKd{V6s zko|%9ub!)~ah32+D7)D|N9;g z{gZGH+lH^IZ{6P(H=F3 zpFeoGQTp-20l0R-&V33Ob-)yjauuj)gi3O;gWNUIQuyccrpZDbR z?v)!{&f$A#y!@eB5=oDgPxsl;ekf*izT8VbGTj@ba>n+YUHW{vEci zvcjx1g-L9RS*1@g&r{=zd>u1op>H|f8$SshalQkgyJR`V6!BwuXEIrE_>;bTp8N6u>}de?$p95efEy$P b7(0a%CC|gy3_D|KWM;-RqhS=281(!CmHv7& literal 0 HcmV?d00001 diff --git a/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/resources/de/hft/stuttgart/citydoctor2/ziploader/gui/ZipLoaderGUI.fxml b/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/resources/de/hft/stuttgart/citydoctor2/ziploader/gui/ZipLoaderGUI.fxml new file mode 100644 index 00000000..c00817e5 --- /dev/null +++ b/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/resources/de/hft/stuttgart/citydoctor2/ziploader/gui/ZipLoaderGUI.fxml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CityDoctorParent/pom.xml b/CityDoctorParent/pom.xml index d0370894..916e1aac 100644 --- a/CityDoctorParent/pom.xml +++ b/CityDoctorParent/pom.xml @@ -267,6 +267,7 @@ Extensions/CityDoctorGUI + Extensions/CityDoctorZipLoader