Commit 8b2f8ba8 authored by Luna Riegel's avatar Luna Riegel
Browse files

Fix: Connect Healer with models CityObjectCache

parent 19f5db34
package de.hft.stuttgart.citydoctor2.exceptions;
import java.io.Serial;
public class CityObjectCacheException extends RuntimeException{
@Serial
private static final long serialVersionUID = -460467145629964615L;
public CityObjectCacheException(String message) {
super(message);
}
public CityObjectCacheException(String message, Throwable cause) {
super(message, cause);
}
}
...@@ -12,6 +12,8 @@ import java.util.List; ...@@ -12,6 +12,8 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import de.hft.stuttgart.citydoctor2.database.CityObjectCache;
import de.hft.stuttgart.citydoctor2.exceptions.CityObjectCacheException;
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 org.citygml4j.core.ade.ADEException; import org.citygml4j.core.ade.ADEException;
...@@ -64,7 +66,7 @@ public class Healer { ...@@ -64,7 +66,7 @@ public class Healer {
private Checker checker; private Checker checker;
private ModificationListener l; private ModificationListener l;
private HealingPlan plan; private HealingPlan plan;
private CityObjectCache cache;
static { static {
// CppInitializer.initCpp(); // CppInitializer.initCpp();
} }
...@@ -187,6 +189,7 @@ public class Healer { ...@@ -187,6 +189,7 @@ public class Healer {
} }
}; };
} }
cache = checker.getModel().getCache();
this.l = l; this.l = l;
} }
...@@ -208,7 +211,12 @@ public class Healer { ...@@ -208,7 +211,12 @@ public class Healer {
} }
public void healModel(CityDoctorModel model) { public void healModel(CityDoctorModel model) {
model.createFeatureStream().forEach(this::healCityObject); try (AutoCloseable checkingContext = model.getCache().startCheckingMode()){
model.createFeatureStream().forEach(this::healCityObject);
} catch (Exception e) {
throw new CityObjectCacheException("Healer critically failed during attempt to heal the model",e);
}
} }
public void healCityObject(CityObject co) { public void healCityObject(CityObject co) {
...@@ -348,6 +356,8 @@ public class Healer { ...@@ -348,6 +356,8 @@ public class Healer {
if (checker.getConfig().getParserConfiguration().useLowMemoryConsumption()) { if (checker.getConfig().getParserConfiguration().useLowMemoryConsumption()) {
co.clearMetaInformation(); co.clearMetaInformation();
} }
//Reinsert object into cache and release locks
cache.put(co);
} }
} }
......
...@@ -31,7 +31,7 @@ public class TestUtil { ...@@ -31,7 +31,7 @@ public class TestUtil {
} }
public static CityDoctorModel loadCityModel(String path, ValidationConfiguration config) throws CityGmlParseException, IOException, InvalidGmlFileException { public static CityDoctorModel loadCityModel(String path, ValidationConfiguration config) throws CityGmlParseException, IOException, InvalidGmlFileException {
return CityGmlParser.parseCityGmlFile(path, config.getParserConfiguration()); return CityGmlParser.nestedCityGmlFileParse(path, config.getParserConfiguration());
} }
public static Polygon getPolygonById(String gmlId, CityDoctorModel model) { public static Polygon getPolygonById(String gmlId, CityDoctorModel model) {
......
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