Commit 671c277b authored by Riegel's avatar Riegel
Browse files

Style: Reformat code

parent 491b8247
...@@ -18,28 +18,16 @@ ...@@ -18,28 +18,16 @@
*/ */
package de.hft.stuttgart.citydoctor2.parser; package de.hft.stuttgart.citydoctor2.parser;
import java.io.*; import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
import java.nio.charset.StandardCharsets; import de.hft.stuttgart.citydoctor2.datastructure.CityObject;
import java.nio.file.Path; import de.hft.stuttgart.citydoctor2.mapper.citygml3.Citygml3FeatureMapper;
import java.nio.file.Paths; import de.hft.stuttgart.citydoctor2.mapper.citygml3.GMLValidationHandler;
import java.util.ArrayList; import de.hft.stuttgart.citydoctor2.math.Vector3d;
import java.util.List; import de.hft.stuttgart.citydoctor2.utils.Localization;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.xml.XMLConstants;
import javax.xml.namespace.QName;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntry; import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntry;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntryFile; import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntryFile;
import de.hft.stuttgart.quality.QualityADEContext;
import de.hft.stuttgart.quality.QualityADEModule;
import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Level;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
...@@ -69,26 +57,44 @@ import org.locationtech.proj4j.CoordinateReferenceSystem; ...@@ -69,26 +57,44 @@ import org.locationtech.proj4j.CoordinateReferenceSystem;
import org.locationtech.proj4j.ProjCoordinate; import org.locationtech.proj4j.ProjCoordinate;
import org.locationtech.proj4j.proj.Projection; import org.locationtech.proj4j.proj.Projection;
import org.locationtech.proj4j.units.Units; import org.locationtech.proj4j.units.Units;
import org.xml.sax.*; import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.SAXNotRecognizedException;
import org.xml.sax.SAXNotSupportedException;
import org.xml.sax.SAXParseException;
import org.xmlobjects.schema.SchemaHandler; import org.xmlobjects.schema.SchemaHandler;
import org.xmlobjects.schema.SchemaHandlerException; import org.xmlobjects.schema.SchemaHandlerException;
import org.xmlobjects.stream.XMLReader; import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLReaderFactory; import org.xmlobjects.stream.XMLReaderFactory;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel; import javax.xml.XMLConstants;
import de.hft.stuttgart.citydoctor2.datastructure.CityObject; import javax.xml.namespace.QName;
import de.hft.stuttgart.citydoctor2.mapper.citygml3.Citygml3FeatureMapper; import javax.xml.parsers.ParserConfigurationException;
import de.hft.stuttgart.citydoctor2.mapper.citygml3.GMLValidationHandler; import javax.xml.parsers.SAXParser;
import de.hft.stuttgart.citydoctor2.math.Vector3d; import javax.xml.parsers.SAXParserFactory;
import de.hft.stuttgart.citydoctor2.utils.Localization; import javax.xml.transform.Source;
import de.hft.stuttgart.quality.QualityADEContext; import javax.xml.transform.stream.StreamSource;
import de.hft.stuttgart.quality.QualityADEModule; import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/** /**
* Utility class to parse CityGML files. * Utility class to parse CityGML files.
* *
* @author Matthias Betz * @author Matthias Betz
*
*/ */
public class CityGmlParser { public class CityGmlParser {
...@@ -199,8 +205,8 @@ public class CityGmlParser { ...@@ -199,8 +205,8 @@ public class CityGmlParser {
CityGMLContext context = getContext(); CityGMLContext context = getContext();
if (config.getValidate()) { if (config.getValidate()) {
try (CityGmlZipEntryFile entryFile = new CityGmlZipEntryFile(entry)){ try (CityGmlZipEntryFile entryFile = new CityGmlZipEntryFile(entry)) {
List<String> messages = validateStream(entryFile.getInputStream(),context); List<String> messages = validateStream(entryFile.getInputStream(), context);
if (!messages.isEmpty()) { if (!messages.isEmpty()) {
throw new InvalidGmlFileException("Invalid GML File. First error: \n" + messages.get(0)); throw new InvalidGmlFileException("Invalid GML File. First error: \n" + messages.get(0));
} }
...@@ -220,13 +226,13 @@ public class CityGmlParser { ...@@ -220,13 +226,13 @@ public class CityGmlParser {
public static CityDoctorModel decompressAndParseCityGmlEntry(CityGmlZipEntry entry, ParserConfiguration config, ProgressListener l, CityGMLContext context) public static CityDoctorModel decompressAndParseCityGmlEntry(CityGmlZipEntry entry, ParserConfiguration config, ProgressListener l, CityGMLContext context)
throws CityGmlParseException { throws CityGmlParseException {
try (CityGmlZipEntryFile entryFile = new CityGmlZipEntryFile(entry)){ try (CityGmlZipEntryFile entryFile = new CityGmlZipEntryFile(entry)) {
BufferedInputStream bis = new BufferedInputStream(entryFile.getInputStream()); BufferedInputStream bis = new BufferedInputStream(entryFile.getInputStream());
readEpsgCodeFromInputStream(bis,config); readEpsgCodeFromInputStream(bis, config);
CityGMLInputFactory in = context.createCityGMLInputFactory() CityGMLInputFactory in = context.createCityGMLInputFactory()
.withChunking(ChunkOptions.chunkByProperties(chunkProperties).skipCityModel(false)); .withChunking(ChunkOptions.chunkByProperties(chunkProperties).skipCityModel(false));
try(ObservedInputStream ois = new ObservedInputStream(bis, bis.available())){ try (ObservedInputStream ois = new ObservedInputStream(bis, bis.available())) {
if (l != null){ if (l != null) {
ois.addListener(l::updateProgress); ois.addListener(l::updateProgress);
} }
return readAndKeepFeatures(config, entry, in, ois, false); return readAndKeepFeatures(config, entry, in, ois, false);
...@@ -277,7 +283,7 @@ public class CityGmlParser { ...@@ -277,7 +283,7 @@ public class CityGmlParser {
} }
private static void readEpsgCodeFromInputStream(BufferedInputStream bis, ParserConfiguration config) throws CityGmlParseException { private static void readEpsgCodeFromInputStream(BufferedInputStream bis, ParserConfiguration config) throws CityGmlParseException {
try{ try {
// Mark start position of GML-"file" // Mark start position of GML-"file"
bis.mark(Integer.MAX_VALUE); bis.mark(Integer.MAX_VALUE);
// Buffer the first 10000 chars of the Stream, EPSG/envelope info should be found within that range // Buffer the first 10000 chars of the Stream, EPSG/envelope info should be found within that range
...@@ -296,7 +302,7 @@ public class CityGmlParser { ...@@ -296,7 +302,7 @@ public class CityGmlParser {
String outputFile) throws CityGmlParseException, IOException { String outputFile) throws CityGmlParseException, IOException {
try (CityGmlZipEntryFile entryFile = new CityGmlZipEntryFile(entry)) { try (CityGmlZipEntryFile entryFile = new CityGmlZipEntryFile(entry)) {
parseEpsgCodeFromStream(entryFile.getInputStream(), config); parseEpsgCodeFromStream(entryFile.getInputStream(), config);
startReadingCityGmlZipEntry(entry, config, null,cityObjectConsumer, outputFile); startReadingCityGmlZipEntry(entry, config, null, cityObjectConsumer, outputFile);
} catch (ParserConfigurationException | SAXException | IOException e) { } catch (ParserConfigurationException | SAXException | IOException e) {
throw new CityGmlParseException("Failed to read CityGML stream", e); throw new CityGmlParseException("Failed to read CityGML stream", e);
} }
...@@ -361,7 +367,7 @@ public class CityGmlParser { ...@@ -361,7 +367,7 @@ public class CityGmlParser {
private static void startReadingCityGmlZipEntry(CityGmlZipEntry entry, ParserConfiguration config, ProgressListener l, private static void startReadingCityGmlZipEntry(CityGmlZipEntry entry, ParserConfiguration config, ProgressListener l,
CityGmlConsumer cityObjectConsumer, String outputFile) { CityGmlConsumer cityObjectConsumer, String outputFile) {
try (CityGmlZipEntryFile entryFile = new CityGmlZipEntryFile(entry); try (CityGmlZipEntryFile entryFile = new CityGmlZipEntryFile(entry);
ObservedInputStream ois = new ObservedInputStream(entryFile.getInputStream(), entry.getFileSize())){ ObservedInputStream ois = new ObservedInputStream(entryFile.getInputStream(), entry.getFileSize())) {
if (l != null) { if (l != null) {
ois.addListener(l::updateProgress); ois.addListener(l::updateProgress);
} }
...@@ -468,7 +474,7 @@ public class CityGmlParser { ...@@ -468,7 +474,7 @@ public class CityGmlParser {
} }
private static CityDoctorModel readAndKeepModel(Citygml3FeatureMapper mapper, CityGMLInputFactory inputFactory, private static CityDoctorModel readAndKeepModel(Citygml3FeatureMapper mapper, CityGMLInputFactory inputFactory,
ObservedInputStream ois, boolean verbose) throws CityGMLReadException{ ObservedInputStream ois, boolean verbose) throws CityGMLReadException {
try (CityGMLReader reader = inputFactory.createCityGMLReader(ois)) { try (CityGMLReader reader = inputFactory.createCityGMLReader(ois)) {
CityGMLVersion version = null; CityGMLVersion version = null;
// model is read in chunked mode // model is read in chunked mode
...@@ -551,17 +557,17 @@ public class CityGmlParser { ...@@ -551,17 +557,17 @@ public class CityGmlParser {
} catch (Exception e2) { } catch (Exception e2) {
logEpsgParseError(e2); logEpsgParseError(e2);
} }
}catch (SAXParseException spe){ } catch (SAXParseException spe) {
// suppress XML document structure warning // suppress XML document structure warning
if (!spe.getMessage().matches("XML document structures must start and end within the same entity.")){ if (!spe.getMessage().matches("XML document structures must start and end within the same entity.")) {
logEpsgParseError(spe); logEpsgParseError(spe);
} }
}catch (Exception e) { } catch (Exception e) {
logEpsgParseError(e); logEpsgParseError(e);
} }
} }
private static void logEpsgParseError(Exception e){ private static void logEpsgParseError(Exception e) {
logger.debug("Exception while parsing for EPSG code", e); logger.debug("Exception while parsing for EPSG code", e);
if (logger.isWarnEnabled()) { if (logger.isWarnEnabled()) {
logger.warn(Localization.getText("CityGmlParser.noEPSG")); logger.warn(Localization.getText("CityGmlParser.noEPSG"));
...@@ -632,12 +638,12 @@ public class CityGmlParser { ...@@ -632,12 +638,12 @@ public class CityGmlParser {
* string and detect the corresponding reference system. If it is found, it * string and detect the corresponding reference system. If it is found, it
* returns a proj4j.CoordinateReferenceSystem. It throws an * returns a proj4j.CoordinateReferenceSystem. It throws an
* IllegalArgumentException otherwise. * IllegalArgumentException otherwise.
* * <p>
* This method should be able to parse any EPSG id : e.g. "EPSG:1234". German * This method should be able to parse any EPSG id : e.g. "EPSG:1234". German
* Citygmls might also have "DE_DHDN_3GK3" or "ETRS89_UTM32" as srsName, so * Citygmls might also have "DE_DHDN_3GK3" or "ETRS89_UTM32" as srsName, so
* those are also included. It isn't guaranteed that those formats are correctly * those are also included. It isn't guaranteed that those formats are correctly
* parsed, though. * parsed, though.
* * <p>
* The EPSG ids and parameters are defined in resources ('nad/epsg') inside * The EPSG ids and parameters are defined in resources ('nad/epsg') inside
* proj4j-0.1.0.jar. Some EPSG ids are missing though, e.g. 7415 * proj4j-0.1.0.jar. Some EPSG ids are missing though, e.g. 7415
* *
......
...@@ -5,12 +5,14 @@ import de.hft.stuttgart.citydoctor2.utils.ArchivePacker; ...@@ -5,12 +5,14 @@ import de.hft.stuttgart.citydoctor2.utils.ArchivePacker;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import java.io.*; import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.Serial;
import java.io.Serializable;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipFile; import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
...@@ -32,8 +34,7 @@ public class CityGmlZipArchive implements Serializable { ...@@ -32,8 +34,7 @@ public class CityGmlZipArchive implements Serializable {
CityGmlZipArchive cgmlArchive = new CityGmlZipArchive(Path.of(zipFile)); CityGmlZipArchive cgmlArchive = new CityGmlZipArchive(Path.of(zipFile));
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile))) { try (ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFile))) {
ZipEntry ze; ZipEntry ze;
while ((ze = zis.getNextEntry()) != null ) while ((ze = zis.getNextEntry()) != null) {
{
if (ze.isDirectory()) { if (ze.isDirectory()) {
continue; continue;
} }
...@@ -49,9 +50,9 @@ public class CityGmlZipArchive implements Serializable { ...@@ -49,9 +50,9 @@ public class CityGmlZipArchive implements Serializable {
} }
} }
public void mountArchive(ParserConfiguration config){ public void mountArchive(ParserConfiguration config) {
try (ZipFile zip = new ZipFile(archivePath.toFile())) { try (ZipFile zip = new ZipFile(archivePath.toFile())) {
for (CityGmlZipEntry entry : entries){ for (CityGmlZipEntry entry : entries) {
entry.loadEntry(config); entry.loadEntry(config);
} }
} catch (IOException e) { } catch (IOException e) {
...@@ -59,9 +60,9 @@ public class CityGmlZipArchive implements Serializable { ...@@ -59,9 +60,9 @@ public class CityGmlZipArchive implements Serializable {
} }
} }
private CityGmlZipArchive(Path archivePath){ private CityGmlZipArchive(Path archivePath) {
this.archivePath = archivePath; this.archivePath = archivePath;
this.archiveNameRE = archivePath.getFileName().toString().replace(".zip","") + File.separator; this.archiveNameRE = archivePath.getFileName().toString().replace(".zip", "") + File.separator;
} }
private void setEntries(List<CityGmlZipEntry> entries) { private void setEntries(List<CityGmlZipEntry> entries) {
...@@ -76,9 +77,9 @@ public class CityGmlZipArchive implements Serializable { ...@@ -76,9 +77,9 @@ public class CityGmlZipArchive implements Serializable {
public CityGmlZipEntry getEntry(String fileName) { public CityGmlZipEntry getEntry(String fileName) {
fileName = stripArchivePath(fileName); fileName = stripArchivePath(fileName);
for(CityGmlZipEntry entry : entries){ for (CityGmlZipEntry entry : entries) {
String entryName = stripArchivePath(entry.getFileName()); String entryName = stripArchivePath(entry.getFileName());
if(entryName.equals(fileName)){ if (entryName.equals(fileName)) {
return entry; return entry;
} }
} }
......
...@@ -27,39 +27,39 @@ public class CityGmlZipEntry implements Serializable { ...@@ -27,39 +27,39 @@ public class CityGmlZipEntry implements Serializable {
private static final long MB = 1024 * 1024L; private static final long MB = 1024 * 1024L;
private ZipEntryErrorType errorType = null; private ZipEntryErrorType errorType = null;
public static CityGmlZipEntry of(ZipEntry entry,CityGmlZipArchive parentArchive, ParserConfiguration config){ public static CityGmlZipEntry of(ZipEntry entry, CityGmlZipArchive parentArchive, ParserConfiguration config) {
CityGmlZipEntry ze = CityGmlZipEntry.register(entry, parentArchive); CityGmlZipEntry ze = CityGmlZipEntry.register(entry, parentArchive);
ze.loadEntry(config); ze.loadEntry(config);
return ze; return ze;
} }
public void loadEntry(ParserConfiguration config){ public void loadEntry(ParserConfiguration config) {
if (decompressed){ if (decompressed) {
return; return;
} }
if (errorType != null){ if (errorType != null) {
logger.warn("Tried loading erroneous CityGmlZipEntry"); logger.warn("Tried loading erroneous CityGmlZipEntry");
return; return;
} }
try{ try {
this.model = CityGmlParser.parseCityGmlZipEntry(this, config); this.model = CityGmlParser.parseCityGmlZipEntry(this, config);
this.decompressed = true; this.decompressed = true;
} catch (CityGmlParseException | InvalidGmlFileException e) { } catch (CityGmlParseException | InvalidGmlFileException e) {
logger.error(e); logger.error(e);
this.errorType = ZipEntryErrorType.INVALID_CITY_GML_FILE; this.errorType = ZipEntryErrorType.INVALID_CITY_GML_FILE;
} catch (IOException e){ } catch (IOException e) {
logger.error(e); logger.error(e);
this.errorType = ZipEntryErrorType.IO_ERROR; this.errorType = ZipEntryErrorType.IO_ERROR;
} }
} }
public static CityGmlZipEntry register(ZipEntry entry, CityGmlZipArchive parentArchive){ public static CityGmlZipEntry register(ZipEntry entry, CityGmlZipArchive parentArchive) {
CityGmlZipEntry cgzEntry = new CityGmlZipEntry(entry, parentArchive,false); CityGmlZipEntry cgzEntry = new CityGmlZipEntry(entry, parentArchive, false);
try{ try {
if (!cgzEntry.entrySizeWithinMemoryLimits()) { if (!cgzEntry.entrySizeWithinMemoryLimits()) {
cgzEntry.errorType = ZipEntryErrorType.EXCESSIVE_FILESIZE; cgzEntry.errorType = ZipEntryErrorType.EXCESSIVE_FILESIZE;
} }
} catch (IOException e){ } catch (IOException e) {
logger.error(e); logger.error(e);
cgzEntry.errorType = ZipEntryErrorType.IO_ERROR; cgzEntry.errorType = ZipEntryErrorType.IO_ERROR;
} }
...@@ -67,11 +67,11 @@ public class CityGmlZipEntry implements Serializable { ...@@ -67,11 +67,11 @@ public class CityGmlZipEntry implements Serializable {
} }
private boolean entrySizeWithinMemoryLimits() throws IOException { private boolean entrySizeWithinMemoryLimits() throws IOException {
long memoryLimit = (long) Math.ceil(((double) Runtime.getRuntime().maxMemory() / MB)*0.9); long memoryLimit = (long) Math.ceil(((double) Runtime.getRuntime().maxMemory() / MB) * 0.9);
if (fileSize == -1L) { if (fileSize == -1L) {
try (CityGmlZipEntryFile entryFile = new CityGmlZipEntryFile(this)){ try (CityGmlZipEntryFile entryFile = new CityGmlZipEntryFile(this)) {
long filesize = entryFile.getFileSize(); long filesize = entryFile.getFileSize();
if (filesize != -1){ if (filesize != -1) {
this.fileSize = filesize; this.fileSize = filesize;
} else { } else {
return false; return false;
...@@ -83,9 +83,9 @@ public class CityGmlZipEntry implements Serializable { ...@@ -83,9 +83,9 @@ public class CityGmlZipEntry implements Serializable {
return memoryLimit > fileSize; return memoryLimit > fileSize;
} }
protected CityGmlZipEntry(ZipEntry entry,CityGmlZipArchive parentArchive, boolean decompressed) { protected CityGmlZipEntry(ZipEntry entry, CityGmlZipArchive parentArchive, boolean decompressed) {
this.fileName = entry.getName(); this.fileName = entry.getName();
if (entry.getSize() != -1){ if (entry.getSize() != -1) {
this.fileSize = entry.getSize(); this.fileSize = entry.getSize();
} }
this.model = null; this.model = null;
...@@ -93,15 +93,14 @@ public class CityGmlZipEntry implements Serializable { ...@@ -93,15 +93,14 @@ public class CityGmlZipEntry implements Serializable {
this.parentArchive = parentArchive; this.parentArchive = parentArchive;
} }
public void setArchive(CityGmlZipArchive archive){ public void setArchive(CityGmlZipArchive archive) {
parentArchive = archive; parentArchive = archive;
} }
public CityGmlZipArchive getArchive(){ public CityGmlZipArchive getArchive() {
return parentArchive; return parentArchive;
} }
public String getFileName() { public String getFileName() {
return fileName; return fileName;
} }
...@@ -118,7 +117,7 @@ public class CityGmlZipEntry implements Serializable { ...@@ -118,7 +117,7 @@ public class CityGmlZipEntry implements Serializable {
fileSize = size; fileSize = size;
} }
public long getFileSize(){ public long getFileSize() {
return fileSize; return fileSize;
} }
} }
...@@ -9,11 +9,14 @@ import java.io.IOException; ...@@ -9,11 +9,14 @@ import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import static org.junit.Assert.*; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
public class ZipTest { public class ZipTest {
ParserConfiguration config = new ParserConfiguration(8,false); ParserConfiguration config = new ParserConfiguration(8, false);
@Test @Test
...@@ -25,8 +28,8 @@ public class ZipTest { ...@@ -25,8 +28,8 @@ public class ZipTest {
checkMockArchive(cgmlArch); checkMockArchive(cgmlArch);
} }
private void checkMockArchive(CityGmlZipArchive cgmlArch){ private void checkMockArchive(CityGmlZipArchive cgmlArch) {
assertEquals(5,cgmlArch.getEntries().size()); assertEquals(5, cgmlArch.getEntries().size());
for (CityGmlZipEntry entry : cgmlArch.getEntries()) { for (CityGmlZipEntry entry : cgmlArch.getEntries()) {
assertNotNull(entry); assertNotNull(entry);
assertTrue(entry.getFileName().matches("^mock[1-5].gml$")); assertTrue(entry.getFileName().matches("^mock[1-5].gml$"));
...@@ -79,8 +82,8 @@ public class ZipTest { ...@@ -79,8 +82,8 @@ public class ZipTest {
} }
@Test @Test
public void testXMLValidation(){ public void testXMLValidation() {
ParserConfiguration valConfig = new ParserConfiguration(8,true); ParserConfiguration valConfig = new ParserConfiguration(8, true);
CityGmlZipArchive cgmlArch = CityGmlZipArchive.register("src/test/resources/zip/validate.zip"); CityGmlZipArchive cgmlArch = CityGmlZipArchive.register("src/test/resources/zip/validate.zip");
assertNotNull(cgmlArch); assertNotNull(cgmlArch);
cgmlArch.mountArchive(valConfig); cgmlArch.mountArchive(valConfig);
...@@ -91,7 +94,7 @@ public class ZipTest { ...@@ -91,7 +94,7 @@ public class ZipTest {
@Test @Test
public void testImplicitParsing(){ public void testImplicitParsing() {
CityGmlZipArchive cgmlArch = CityGmlZipArchive.register("src/test/resources/zip/implicit.zip"); CityGmlZipArchive cgmlArch = CityGmlZipArchive.register("src/test/resources/zip/implicit.zip");
assertNotNull(cgmlArch); assertNotNull(cgmlArch);
cgmlArch.mountArchive(config); cgmlArch.mountArchive(config);
......
...@@ -18,41 +18,6 @@ ...@@ -18,41 +18,6 @@
*/ */
package de.hft.stuttgart.citydoctor2.check; package de.hft.stuttgart.citydoctor2.check;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Stream;
import javax.xml.XMLConstants;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntry;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntryFile;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import de.hft.stuttgart.citydoctor2.check.error.AttributeInvalidError; import de.hft.stuttgart.citydoctor2.check.error.AttributeInvalidError;
import de.hft.stuttgart.citydoctor2.check.error.AttributeMissingError; import de.hft.stuttgart.citydoctor2.check.error.AttributeMissingError;
import de.hft.stuttgart.citydoctor2.check.error.AttributeValueWrongError; import de.hft.stuttgart.citydoctor2.check.error.AttributeValueWrongError;
...@@ -78,6 +43,8 @@ import de.hft.stuttgart.citydoctor2.reporting.XmlValidationReporter; ...@@ -78,6 +43,8 @@ import de.hft.stuttgart.citydoctor2.reporting.XmlValidationReporter;
import de.hft.stuttgart.citydoctor2.reporting.pdf.PdfReporter; import de.hft.stuttgart.citydoctor2.reporting.pdf.PdfReporter;
import de.hft.stuttgart.citydoctor2.reporting.pdf.PdfStreamReporter; import de.hft.stuttgart.citydoctor2.reporting.pdf.PdfStreamReporter;
import de.hft.stuttgart.citydoctor2.utils.Localization; import de.hft.stuttgart.citydoctor2.utils.Localization;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntry;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntryFile;
import de.hft.stuttgart.quality.model.enums.RequirementId; import de.hft.stuttgart.quality.model.enums.RequirementId;
import de.hft.stuttgart.quality.model.enums.TopLevelFeatureType; import de.hft.stuttgart.quality.model.enums.TopLevelFeatureType;
import de.hft.stuttgart.quality.model.properties.CheckingProperty; import de.hft.stuttgart.quality.model.properties.CheckingProperty;
...@@ -88,13 +55,43 @@ import de.hft.stuttgart.quality.model.properties.RequirementProperty; ...@@ -88,13 +55,43 @@ import de.hft.stuttgart.quality.model.properties.RequirementProperty;
import de.hft.stuttgart.quality.model.types.Checking; import de.hft.stuttgart.quality.model.types.Checking;
import de.hft.stuttgart.quality.model.types.Parameter; import de.hft.stuttgart.quality.model.types.Parameter;
import de.hft.stuttgart.quality.model.types.ValidationPlan; import de.hft.stuttgart.quality.model.types.ValidationPlan;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.xml.XMLConstants;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXResult;
import javax.xml.transform.stream.StreamSource;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.stream.Stream;
/** /**
* The main container class for checking. It contains the logic for validation, * The main container class for checking. It contains the logic for validation,
* as well as contains the state of the checks performed. * as well as contains the state of the checks performed.
* *
* @author Matthias Betz * @author Matthias Betz
*
*/ */
public class Checker { public class Checker {
...@@ -742,8 +739,8 @@ public class Checker { ...@@ -742,8 +739,8 @@ public class Checker {
return hasUnusedDependency; return hasUnusedDependency;
} }
public static void streamCheck (CityGmlZipEntry entry, String xmlOutput, String pdfOutput, ValidationConfiguration config, public static void streamCheck(CityGmlZipEntry entry, String xmlOutput, String pdfOutput, ValidationConfiguration config,
String outputFile) throws IOException, CityGmlParseException{ String outputFile) throws IOException, CityGmlParseException {
try (BufferedOutputStream xmlBos = getXmlOutputMaybe(xmlOutput); try (BufferedOutputStream xmlBos = getXmlOutputMaybe(xmlOutput);
BufferedOutputStream pdfBos = getPdfOutputMaybe(pdfOutput)) { BufferedOutputStream pdfBos = getPdfOutputMaybe(pdfOutput)) {
Checker c = new Checker(config, null); Checker c = new Checker(config, null);
......
...@@ -18,16 +18,6 @@ ...@@ -18,16 +18,6 @@
*/ */
package de.hft.stuttgart.citydoctor2.check; package de.hft.stuttgart.citydoctor2.check;
import java.io.File;
import java.io.IOException;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipArchive;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntry;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import de.hft.stuttgart.citydoctor2.CityDoctorValidation; import de.hft.stuttgart.citydoctor2.CityDoctorValidation;
import de.hft.stuttgart.citydoctor2.datastructure.Building; import de.hft.stuttgart.citydoctor2.datastructure.Building;
import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel; import de.hft.stuttgart.citydoctor2.datastructure.CityDoctorModel;
...@@ -35,15 +25,22 @@ import de.hft.stuttgart.citydoctor2.exceptions.CityDoctorWriteException; ...@@ -35,15 +25,22 @@ import de.hft.stuttgart.citydoctor2.exceptions.CityDoctorWriteException;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException; import de.hft.stuttgart.citydoctor2.parser.CityGmlParseException;
import de.hft.stuttgart.citydoctor2.parser.CityGmlParser; import de.hft.stuttgart.citydoctor2.parser.CityGmlParser;
import de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException; import de.hft.stuttgart.citydoctor2.parser.InvalidGmlFileException;
import de.hft.stuttgart.citydoctor2.parser.ParserConfiguration;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipArchive;
import de.hft.stuttgart.citydoctor2.zip.CityGmlZipEntry;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.IOException;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
/** /**
*
* @author Matthias Betz * @author Matthias Betz
*
*/ */
public class CheckerTest { public class CheckerTest {
...@@ -123,10 +120,10 @@ public class CheckerTest { ...@@ -123,10 +120,10 @@ public class CheckerTest {
public void testZipEntryChecking() throws CityGmlParseException, IOException, InvalidGmlFileException, CityDoctorWriteException { public void testZipEntryChecking() throws CityGmlParseException, IOException, InvalidGmlFileException, CityDoctorWriteException {
CityGmlZipArchive cgmlArch = CityGmlZipArchive.register("src/test/resources/zipArchive.zip"); CityGmlZipArchive cgmlArch = CityGmlZipArchive.register("src/test/resources/zipArchive.zip");
assertNotNull(cgmlArch); assertNotNull(cgmlArch);
cgmlArch.mountArchive(new ParserConfiguration(8,false)); cgmlArch.mountArchive(new ParserConfiguration(8, false));
ValidationConfiguration config = ValidationConfiguration.loadStandardValidationConfig(); ValidationConfiguration config = ValidationConfiguration.loadStandardValidationConfig();
for (CityGmlZipEntry entry : cgmlArch.getEntries()){ for (CityGmlZipEntry entry : cgmlArch.getEntries()) {
Checker.streamCheck(entry, null, null, config, null ); Checker.streamCheck(entry, null, null, config, null);
} }
} }
......
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