diff --git a/CityDoctorParent/Extensions/CityDoctorZipLoader/pom.xml b/CityDoctorParent/Extensions/CityDoctorZipLoader/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..3346570ce3c94b8f832392b1cf6386d2a6ca8586 --- /dev/null +++ b/CityDoctorParent/Extensions/CityDoctorZipLoader/pom.xml @@ -0,0 +1,190 @@ +<?xml version="1.0" encoding="utf-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>de.hft.stuttgart</groupId> + <artifactId>CityDoctorParent</artifactId> + <version>3.16.0</version> + <relativePath>../../pom.xml</relativePath> + </parent> + <artifactId>CityDoctorZipLoader</artifactId> + <name>CityDoctorZipLoader</name> + <description>ZipLoader enables the loading and parsing of zip archives</description> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <version>3.2.0</version> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>de.hft.stuttgart</groupId> + <artifactId>CityDoctorModel</artifactId> + </dependency> + <dependency> + <groupId>de.hft.stuttgart</groupId> + <artifactId>CityDoctorValidation</artifactId> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-api</artifactId> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-core</artifactId> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.logging.log4j</groupId> + <artifactId>log4j-slf4j18-impl</artifactId> + </dependency> + </dependencies> + <profiles> + <profile> + <id>create-binaries</id> + <properties> + <win-jre>jre-${jre-version-short}</win-jre> + <lin-jre>${win-jre}</lin-jre> + <mac-jre>${win-jre}.jre</mac-jre> + </properties> + <build> + <plugins> + <plugin> + <groupId>com.googlecode.maven-download-plugin</groupId> + <artifactId>download-maven-plugin</artifactId> + <version>1.7.0</version> + <executions> + <execution> + <id>downloadWindowsJre</id> + <phase>install</phase> + <goals> + <goal>wget</goal> + </goals> + <configuration> + <uri>https://download.bell-sw.com/java/${jre-version}/bellsoft-jre${jre-version}-windows-amd64.zip</uri> + <unpack>false</unpack> + <outputDirectory>${project.build.directory}/jre/jre-win</outputDirectory> + <outputFileName>win-runtime.zip</outputFileName> + </configuration> + </execution> + <execution> + <id>downloadLinuxJre</id> + <phase>install</phase> + <goals> + <goal>wget</goal> + </goals> + <configuration> + <uri>https://download.bell-sw.com/java/${jre-version}/bellsoft-jre${jre-version}-linux-amd64.tar.gz</uri> + <unpack>false</unpack> + <outputDirectory>${project.build.directory}/jre/jre-lin</outputDirectory> + <outputFileName>lin-runtime.tar.gz</outputFileName> + </configuration> + </execution> + <execution> + <id>downloadMacJre</id> + <phase>install</phase> + <goals> + <goal>wget</goal> + </goals> + <configuration> + <uri>https://download.bell-sw.com/java/${jre-version}/bellsoft-jre${jre-version}-macos-amd64.zip</uri> + <unpack>false</unpack> + <outputDirectory>${project.build.directory}/jre/jre-mac</outputDirectory> + <outputFileName>mac-runtime.zip</outputFileName> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-antrun-plugin</artifactId> + <version>3.1.0</version> + <executions> + <execution> + <id>unpack</id> + <phase>install</phase> + <configuration> + <target name="unpack"> + <untar src="${project.build.directory}/jre/jre-lin/lin-runtime.tar.gz" dest="${project.build.directory}/jre/jre-lin/runtime" compression="gzip"></untar> + <unzip src="${project.build.directory}/jre/jre-win/win-runtime.zip" dest="${project.build.directory}/jre/jre-win/runtime"></unzip> + <unzip src="${project.build.directory}/jre/jre-mac/mac-runtime.zip" dest="${project.build.directory}/jre/jre-mac/runtime"></unzip> + </target> + </configuration> + <goals> + <goal>run</goal> + </goals> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-assembly-plugin</artifactId> + <configuration> + <appendAssemblyId>false</appendAssemblyId> + </configuration> + <executions> + <execution> + <id>create-archive-no-runtime</id> + <phase>install</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <finalName>${project.artifactId}-${project.version}-no-runtime</finalName> + <descriptors> + <descriptor>${project.basedir}/src/assembly/no_runtime/assembly.xml</descriptor> + </descriptors> + </configuration> + </execution> + <execution> + <id>create-archive-win</id> + <phase>install</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <finalName>${project.artifactId}-${project.version}-win</finalName> + <descriptors> + <descriptor>${project.basedir}/src/assembly/win/assembly.xml</descriptor> + </descriptors> + </configuration> + </execution> + <execution> + <id>create-archive-lin</id> + <phase>install</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <finalName>${project.artifactId}-${project.version}-lin</finalName> + <descriptors> + <descriptor>${project.basedir}/src/assembly/lin/assembly.xml</descriptor> + </descriptors> + </configuration> + </execution> + <execution> + <id>create-archive-mac</id> + <phase>install</phase> + <goals> + <goal>single</goal> + </goals> + <configuration> + <finalName>${project.artifactId}-${project.version}-mac</finalName> + <descriptors> + <descriptor>${project.basedir}/src/assembly/mac/assembly.xml</descriptor> + </descriptors> + </configuration> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> +</project> \ 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 0000000000000000000000000000000000000000..79c882378f23d34c7213966c6d96b8ede070ebe2 --- /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<CityGmlZipEntry> entries; + + public CityGmlArchive(List<CityGmlZipEntry> 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 0000000000000000000000000000000000000000..c4fff6d179fc9b064043e2d8509fc0a054fad007 --- /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 0000000000000000000000000000000000000000..bc32a45c0e8ee4e1e7621b8a018afc6d07e3f0ee --- /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<CityGmlZipEntry> parseZipFile(String zipFile, ParserConfiguration config) { + ArrayList<CityGmlZipEntry> archiveEntries = new ArrayList<>(); + try (ZipFile zipFileObj = new ZipFile(zipFile)) { + for (Enumeration<? extends ZipEntry> 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 0000000000000000000000000000000000000000..09633f22c1e59bc78e518d4a273098718238e82a --- /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 Binary files /dev/null and b/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/resources/citydoctor_logo.ico differ 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 0000000000000000000000000000000000000000..c00817e52a2a0fbaf9a2b6b508218a20646cfc3f --- /dev/null +++ b/CityDoctorParent/Extensions/CityDoctorZipLoader/src/main/resources/de/hft/stuttgart/citydoctor2/ziploader/gui/ZipLoaderGUI.fxml @@ -0,0 +1,31 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.control.ScrollPane?> +<?import javafx.scene.control.SplitPane?> +<?import javafx.scene.control.TreeView?> +<?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.layout.VBox?> + + +<VBox maxHeight="534.0" maxWidth="833.0" prefHeight="534.0" prefWidth="833.0" xmlns="http://javafx.com/javafx/22" xmlns:fx="http://javafx.com/fxml/1"> + <children> + <SplitPane dividerPositions="0.48736462093862815" prefHeight="487.0" prefWidth="833.0"> + <items> + <AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="160.0" prefWidth="100.0"> + <children> + <ScrollPane prefHeight="534.0" prefWidth="402.0"> + <content> + <TreeView prefHeight="482.0" prefWidth="400.0" /> + </content> + </ScrollPane> + </children> + </AnchorPane> + <AnchorPane minHeight="0.0" minWidth="0.0" SplitPane.resizableWithParent="false"> + <children> + <TreeView prefHeight="482.0" prefWidth="423.0" /> + </children> + </AnchorPane> + </items> + </SplitPane> + </children> +</VBox> diff --git a/CityDoctorParent/pom.xml b/CityDoctorParent/pom.xml index d037089435eacd67f7b66f1abf16f7908216b132..916e1aacdcd7318766aabf3f44960b4aa73f52ff 100644 --- a/CityDoctorParent/pom.xml +++ b/CityDoctorParent/pom.xml @@ -267,6 +267,7 @@ <!--CityDoctor2 Extension Modules--> <module>Extensions/CityDoctorGUI</module> + <module>Extensions/CityDoctorZipLoader</module> <!-- <module>Extensions/CityDoctorAutoPro</module> <module>Extensions/CityDoctorHealer</module>