Commit fb27a687 authored by Matthias Betz's avatar Matthias Betz
Browse files

added global parameters to validation configuration

parent 4178bc72
Pipeline #1120 passed with stage
in 2 minutes and 7 seconds
......@@ -338,6 +338,10 @@ public class Checker {
for (Entry<CheckId, CheckConfiguration> e : config.getChecks().entrySet()) {
if (e.getValue().isEnabled()) {
Check c = checkConfig.getCheckForId(e.getKey());
Map<String, String> parameters = new HashMap<>();
parameters.putAll(e.getValue().getParameters());
parameters.put("numberOfRoundedPlaces", "" + config.getNumberOfRoundingPlaces());
parameters.put("minVertexDistance", "" + config.getMinVertexDistance());
// initialize checks with parameters
c.init(e.getValue().getParameters(), parserConfig);
checks.add(c);
......
......@@ -64,6 +64,8 @@ public class ValidationConfiguration implements Serializable {
private static final Logger logger = LogManager.getLogger(ValidationConfiguration.class);
private int numberOfRoundingPlaces = 8;
private double minVertexDistance = 0.0001;
private String schematronFilePath = null;
private boolean xmlValidation = false;
......@@ -111,31 +113,33 @@ public class ValidationConfiguration implements Serializable {
@Override
protected NodeTuple representJavaBeanProperty(Object javaBean, Property property, Object propertyValue,
Tag customTag) {
if (propertyValue == null) {
return null;
} else {
NodeTuple tuple = super.representJavaBeanProperty(javaBean, property, propertyValue,
customTag);
Node valueNode = tuple.getValueNode();
if (Tag.NULL.equals(valueNode.getTag())) {
return null;// skip 'null' values
}
if (valueNode instanceof CollectionNode) {
if (Tag.SEQ.equals(valueNode.getTag())) {
SequenceNode seq = (SequenceNode) valueNode;
if (seq.getValue().isEmpty()) {
return null;// skip empty lists
}
}
if (Tag.MAP.equals(valueNode.getTag())) {
MappingNode seq = (MappingNode) valueNode;
if (seq.getValue().isEmpty()) {
return null;// skip empty maps
}
}
}
return tuple;
}
if (propertyValue == null) {
return null;
} else {
NodeTuple tuple = super.representJavaBeanProperty(javaBean, property, propertyValue, customTag);
Node valueNode = tuple.getValueNode();
if (Tag.NULL.equals(valueNode.getTag())) {
// skip 'null' values
return null;
}
if (valueNode instanceof CollectionNode) {
if (Tag.SEQ.equals(valueNode.getTag())) {
SequenceNode seq = (SequenceNode) valueNode;
if (seq.getValue().isEmpty()) {
// skip empty lists
return null;
}
}
if (Tag.MAP.equals(valueNode.getTag())) {
MappingNode seq = (MappingNode) valueNode;
if (seq.getValue().isEmpty()) {
// skip empty maps
return null;
}
}
}
return tuple;
}
}
};
rep.addClassTag(ValidationConfiguration.class, Tag.MAP);
......@@ -211,7 +215,7 @@ public class ValidationConfiguration implements Serializable {
}
insertMissingParametersWithDefaultParameters(e, c);
}
if (schematronFilePath != null) {
if (schematronFilePath != null && !schematronFilePath.isEmpty()) {
File f = new File(schematronFilePath);
if (!f.exists() || !f.isFile()) {
schematronFilePath = null;
......@@ -249,4 +253,11 @@ public class ValidationConfiguration implements Serializable {
this.parserConfig = parserConfig;
}
public void setMinVertexDistance(double minVertexDistance) {
this.minVertexDistance = minVertexDistance;
}
public double getMinVertexDistance() {
return minVertexDistance;
}
}
......@@ -29,9 +29,7 @@ import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.check.CheckResult;
import de.hft.stuttgart.citydoctor2.check.CheckType;
import de.hft.stuttgart.citydoctor2.check.Checkable;
import de.hft.stuttgart.citydoctor2.check.DefaultParameter;
import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.check.Unit;
import de.hft.stuttgart.citydoctor2.check.error.ConsecutivePointSameError;
import de.hft.stuttgart.citydoctor2.check.error.DuplicatePointError;
import de.hft.stuttgart.citydoctor2.datastructure.LinearRing;
......@@ -55,7 +53,6 @@ public class DuplicatePointsCheck extends Check {
private static final List<CheckId> dependencies;
private static final List<Class<? extends Checkable>> applicableToClasses;
private static final List<DefaultParameter> defaultParameters;
static {
ArrayList<CheckId> deps = new ArrayList<>();
......@@ -67,9 +64,6 @@ public class DuplicatePointsCheck extends Check {
classes.add(LinearRing.class);
applicableToClasses = Collections.unmodifiableList(classes);
ArrayList<DefaultParameter> defaultParameter = new ArrayList<>();
defaultParameter.add(new DefaultParameter(EPSILON_NAME, "0.0001", Unit.METER));
defaultParameters = Collections.unmodifiableList(defaultParameter);
}
private double epsilon = 0.0001;
......@@ -88,11 +82,6 @@ public class DuplicatePointsCheck extends Check {
super(CheckId.C_GE_R_DUPLICATE_POINT);
}
@Override
public List<DefaultParameter> getDefaultParameter() {
return defaultParameters;
}
@Override
public List<CheckId> getDependencies() {
return dependencies;
......
......@@ -29,9 +29,7 @@ import de.hft.stuttgart.citydoctor2.check.CheckId;
import de.hft.stuttgart.citydoctor2.check.CheckResult;
import de.hft.stuttgart.citydoctor2.check.CheckType;
import de.hft.stuttgart.citydoctor2.check.Checkable;
import de.hft.stuttgart.citydoctor2.check.DefaultParameter;
import de.hft.stuttgart.citydoctor2.check.ResultStatus;
import de.hft.stuttgart.citydoctor2.check.Unit;
import de.hft.stuttgart.citydoctor2.check.error.EdgeIntersectionError;
import de.hft.stuttgart.citydoctor2.check.error.PointTouchesEdgeError;
import de.hft.stuttgart.citydoctor2.datastructure.Edge;
......@@ -49,7 +47,6 @@ public class RingSelfIntCheck extends Check {
private static final List<CheckId> dependencies;
private static final List<Class<? extends Checkable>> applicableToClasses;
private static final List<DefaultParameter> defaultParameters;
static {
......@@ -63,10 +60,6 @@ public class RingSelfIntCheck extends Check {
classes.add(LinearRing.class);
applicableToClasses = Collections.unmodifiableList(classes);
ArrayList<DefaultParameter> defaultParameter = new ArrayList<>();
defaultParameter.add(new DefaultParameter(EPSILON_NAME, "0.0001", Unit.METER));
defaultParameters = Collections.unmodifiableList(defaultParameter);
}
private double epsilon = 0.0001;
......@@ -163,11 +156,6 @@ public class RingSelfIntCheck extends Check {
return applicableToClasses;
}
@Override
public List<DefaultParameter> getDefaultParameter() {
return defaultParameters;
}
@Override
public CheckType getType() {
return CheckType.GEOMETRY;
......
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