Commit 11c31eb0 authored by Luna Riegel's avatar Luna Riegel
Browse files

Refactor: Cleanup Code

parent 9e555084
...@@ -25,7 +25,6 @@ public record EmbeddedDatabaseConfiguration(String databaseName, String database ...@@ -25,7 +25,6 @@ public record EmbeddedDatabaseConfiguration(String databaseName, String database
private static final String JDBC_DRIVER_PREFIX = "jdbc:h2:"; private static final String JDBC_DRIVER_PREFIX = "jdbc:h2:";
private static final String AUTO_SERVER_PARAMETER = "AUTO_SERVER=TRUE"; private static final String AUTO_SERVER_PARAMETER = "AUTO_SERVER=TRUE";
private static final String KEEP_ALIVE_PARAMETER = "DB_CLOSE_DELAY=-1"; private static final String KEEP_ALIVE_PARAMETER = "DB_CLOSE_DELAY=-1";
private static final String FILE_PREFIX = "file://";
/** /**
* Instantiates the default configuration for the embedded database. * Instantiates the default configuration for the embedded database.
*/ */
......
...@@ -23,15 +23,13 @@ import java.util.List; ...@@ -23,15 +23,13 @@ import java.util.List;
import static de.hft.stuttgart.citydoctor2.database.SerializationTest.assertCityObjectEquality; import static de.hft.stuttgart.citydoctor2.database.SerializationTest.assertCityObjectEquality;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
public class EmbeddedDataBaseHandlerTest { public class EmbeddedDataBaseHandlerTest {
private EmbeddedDatabaseHandler handler = new EmbeddedDatabaseHandler(new EmbeddedDatabaseConfiguration()); private final EmbeddedDatabaseHandler handler = new EmbeddedDatabaseHandler(new EmbeddedDatabaseConfiguration());
@Test @Test
public void testTempFileConfiguration(){ public void testTempFileConfiguration(){
......
...@@ -150,8 +150,8 @@ public class Checker { ...@@ -150,8 +150,8 @@ public class Checker {
return; return;
} }
File xmlFile = new File(xmlOutput); File xmlFile = new File(xmlOutput);
if (xmlFile.getParentFile() != null) { if (xmlFile.getParentFile() != null && xmlFile.getParentFile().mkdirs()) {
xmlFile.getParentFile().mkdirs(); logger.trace("Xml dir created");
} }
Reporter reporter = new XmlValidationReporter(); Reporter reporter = new XmlValidationReporter();
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(xmlFile.getAbsolutePath()))) { try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(xmlFile.getAbsolutePath()))) {
...@@ -166,9 +166,10 @@ public class Checker { ...@@ -166,9 +166,10 @@ public class Checker {
return; return;
} }
File pdfFile = new File(pdfOutput); File pdfFile = new File(pdfOutput);
if (pdfFile.getParentFile() != null) { if (pdfFile.getParentFile() != null && pdfFile.getParentFile().mkdirs()){
pdfFile.getParentFile().mkdirs(); logger.trace("Pdf dir created");
} }
Reporter reporter = new PdfReporter(); Reporter reporter = new PdfReporter();
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(pdfFile.getAbsolutePath()))) { try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(pdfFile.getAbsolutePath()))) {
reporter.writeReport(checkConfig, bos, model, config); reporter.writeReport(checkConfig, bos, model, config);
...@@ -243,7 +244,6 @@ public class Checker { ...@@ -243,7 +244,6 @@ public class Checker {
private void handleSchematronResults(SvrlContentHandler handler) { private void handleSchematronResults(SvrlContentHandler handler) {
CityObjectCache cache = model.getCache(); CityObjectCache cache = model.getCache();
handleSchematronErrorsGlobal(handler.getGeneralErrors()); handleSchematronErrorsGlobal(handler.getGeneralErrors());
Map<String, CityObject> featureMap = new HashMap<>();
boolean onlySchematron = execLayers.isEmpty(); boolean onlySchematron = execLayers.isEmpty();
if (onlySchematron) { if (onlySchematron) {
CheckableUtilsVisitor visitor = new CheckableUtilsVisitor() { CheckableUtilsVisitor visitor = new CheckableUtilsVisitor() {
...@@ -252,12 +252,7 @@ public class Checker { ...@@ -252,12 +252,7 @@ public class Checker {
checkable.setValidated(true); checkable.setValidated(true);
} }
}; };
model.createFeatureStream().forEach(f -> { model.createFeatureStream().forEach(co -> co.accept(visitor));
featureMap.put(f.getGmlId().getGmlString(), f);
f.accept(visitor);
});
} else {
model.createFeatureStream().forEach(f -> featureMap.put(f.getGmlId().getGmlString(), f));
} }
handler.getFeatureErrors().forEach((k, v) -> { handler.getFeatureErrors().forEach((k, v) -> {
String trimmedId = k.trim(); String trimmedId = k.trim();
......
...@@ -296,9 +296,7 @@ public class Healer { ...@@ -296,9 +296,7 @@ public class Healer {
* *
* @param aco the feature to write * @param aco the feature to write
* @return the byte array containing the feature * @return the byte array containing the feature
* @throws ADEException * @throws CityGMLWriteException if writing of the CityGML file fails
* @throws CityGMLBuilderException
* @throws CityGMLWriteException
*/ */
private byte[] writeCityGml(AbstractCityObject aco) throws CityGMLWriteException { private byte[] writeCityGml(AbstractCityObject aco) throws CityGMLWriteException {
CityModel model = new CityModel(); CityModel model = new CityModel();
......
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