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

quality ade 0.1.4

parent c0df41b0
......@@ -8,8 +8,8 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
......
......@@ -15,23 +15,31 @@ import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.model.types.AbstractPolygonError;
public abstract class AbstractPolygonErrorAdapter<T extends AbstractPolygonError> extends AbstractGeometryErrorAdapter<T> {
public abstract class AbstractPolygonErrorAdapter<T extends AbstractPolygonError>
extends AbstractGeometryErrorAdapter<T> {
@Override
public void buildChildObject(AbstractPolygonError object, QName name, Attributes attributes, XMLReader reader) throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "polygonId" -> reader.getTextContent().ifPresent(object::setPolygonId);
default -> throw new IllegalStateException("Cannot handle name " + name + " when building AbstractPolygonError element");
}
}
@Override
public void buildChildObject(AbstractPolygonError object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "polygonId":
reader.getTextContent().ifPresent(object::setPolygonId);
break;
default:
throw new IllegalStateException(
"Cannot handle name " + name + " when building AbstractPolygonError element");
}
}
@Override
public void writeChildElements(AbstractPolygonError object, Namespaces namespaces, XMLWriter writer) throws ObjectSerializeException, XMLWriteException {
if (object.getPolygonId() != null) {
writer.writeElement(Element.of(QualityADEModule.NAMESPACE_URI, "polygonId").addTextContent(object.getPolygonId()));
}
}
@Override
public void writeChildElements(AbstractPolygonError object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
if (object.getPolygonId() != null) {
writer.writeElement(
Element.of(QualityADEModule.NAMESPACE_URI, "polygonId").addTextContent(object.getPolygonId()));
}
}
}
......@@ -15,22 +15,27 @@ import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.model.types.AbstractRingError;
public abstract class AbstractRingErrorAdapter<T extends AbstractRingError> extends AbstractGeometryErrorAdapter<T> {
public abstract class AbstractRingErrorAdapter<T extends AbstractRingError> extends AbstractGeometryErrorAdapter<T> {
@Override
public void buildChildObject(AbstractRingError object, QName name, Attributes attributes, XMLReader reader) throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "linearRingId" -> reader.getTextContent().ifPresent(object::setLinearRingId);
}
}
@Override
public void buildChildObject(AbstractRingError object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "linearRingId":
reader.getTextContent().ifPresent(object::setLinearRingId);
break;
}
}
@Override
public void writeChildElements(AbstractRingError object, Namespaces namespaces, XMLWriter writer) throws ObjectSerializeException, XMLWriteException {
if (object.getLinearRingId() != null) {
writer.writeElement(Element.of(QualityADEModule.NAMESPACE_URI, "linearRingId").addTextContent(object.getLinearRingId()));
}
}
@Override
public void writeChildElements(AbstractRingError object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
if (object.getLinearRingId() != null) {
writer.writeElement(Element.of(QualityADEModule.NAMESPACE_URI, "linearRingId")
.addTextContent(object.getLinearRingId()));
}
}
}
......@@ -17,21 +17,27 @@ import de.hft.stuttgart.quality.model.types.AbstractSolidError;
public abstract class AbstractSolidErrorAdapter<T extends AbstractSolidError> extends AbstractGeometryErrorAdapter<T> {
@Override
public void buildChildObject(AbstractSolidError object, QName name, Attributes attributes, XMLReader reader) throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "geometryId" -> reader.getTextContent().ifPresent(object::setGeometryId);
default -> throw new IllegalStateException("Cannot handle name " + name + " when building AbstractSolidError element");
}
}
@Override
public void buildChildObject(AbstractSolidError object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "geometryId":
reader.getTextContent().ifPresent(object::setGeometryId);
break;
default:
throw new IllegalStateException("Cannot handle name " + name + " when building AbstractSolidError element");
}
}
@Override
public void writeChildElements(AbstractSolidError object, Namespaces namespaces, XMLWriter writer) throws ObjectSerializeException, XMLWriteException {
if (object.getGeometryId() != null) {
writer.writeElement(Element.of(QualityADEModule.NAMESPACE_URI, "geometryId").addTextContent(object.getGeometryId()));
}
}
@Override
public void writeChildElements(AbstractSolidError object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
if (object.getGeometryId() != null) {
writer.writeElement(
Element.of(QualityADEModule.NAMESPACE_URI, "geometryId").addTextContent(object.getGeometryId()));
}
}
}
......@@ -35,9 +35,11 @@ public class CheckingAdapter implements ObjectBuilder<Checking>, ObjectSerialize
return;
}
switch (name.getLocalPart()) {
case "featureType" -> reader.getTextContent()
.ifPresent(s -> object.setFeatureType(TopLevelFeatureType.valueOf(s)));
default -> throw new IllegalStateException("Cannot handle name " + name + " when building Checking element");
case "featureType":
reader.getTextContent().ifPresent(s -> object.setFeatureType(TopLevelFeatureType.valueOf(s)));
break;
default:
throw new IllegalStateException("Cannot handle name " + name + " when building Checking element");
}
}
......
......@@ -20,28 +20,36 @@ import de.hft.stuttgart.quality.adapter.properties.ValidationResultPropertyAdapt
import de.hft.stuttgart.quality.model.types.CityObjectProperties;
@XMLElement(name = "validationResult", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class CityObjectPropertiesAdapter implements ObjectBuilder<CityObjectProperties>, ObjectSerializer<CityObjectProperties> {
public class CityObjectPropertiesAdapter
implements ObjectBuilder<CityObjectProperties>, ObjectSerializer<CityObjectProperties> {
@Override
public CityObjectProperties createObject(QName name, Object parent) throws ObjectBuildException {
return new CityObjectProperties();
}
@Override
public CityObjectProperties createObject(QName name, Object parent) throws ObjectBuildException {
return new CityObjectProperties();
}
@Override
public void buildChildObject(CityObjectProperties object, QName name, Attributes attributes, XMLReader reader) throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "ValidationResult" -> object.setValidationResult(reader.getObjectUsingBuilder(ValidationResultPropertyAdapter.class));
default -> throw new IllegalStateException("Cannot handle name " + name + " when building CityObjectProperties element");
}
}
@Override
public void buildChildObject(CityObjectProperties object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "ValidationResult":
object.setValidationResult(reader.getObjectUsingBuilder(ValidationResultPropertyAdapter.class));
break;
default:
throw new IllegalStateException(
"Cannot handle name " + name + " when building CityObjectProperties element");
}
}
@Override
public void writeChildElements(CityObjectProperties object, Namespaces namespaces, XMLWriter writer) throws ObjectSerializeException, XMLWriteException {
if (object.getValidationResult() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "validationResult"), object.getValidationResult(), ValidationResultPropertyAdapter.class, namespaces);
}
}
@Override
public void writeChildElements(CityObjectProperties object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
if (object.getValidationResult() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "validationResult"),
object.getValidationResult(), ValidationResultPropertyAdapter.class, namespaces);
}
}
}
......@@ -32,12 +32,17 @@ public class ConsecutivePointsSameErrorAdapter extends AbstractRingErrorAdapter<
return;
}
switch (name.getLocalPart()) {
case "vertex1" -> object.setVertex1(reader.getObjectUsingBuilder(DirectPositionAdapter.class));
case "vertex2" -> object.setVertex2(reader.getObjectUsingBuilder(DirectPositionAdapter.class));
default -> super.buildChildObject(object, name, attributes, reader);
case "vertex1":
object.setVertex1(reader.getObjectUsingBuilder(DirectPositionAdapter.class));
break;
case "vertex2":
object.setVertex2(reader.getObjectUsingBuilder(DirectPositionAdapter.class));
break;
default:
super.buildChildObject(object, name, attributes, reader);
}
}
@Override
public Element createElement(ConsecutivePointsSameError object, Namespaces namespaces)
throws ObjectSerializeException {
......
......@@ -22,35 +22,44 @@ import de.hft.stuttgart.quality.model.types.Edge;
@XMLElement(name = "Edge", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class EdgeAdapter implements ObjectBuilder<Edge>, ObjectSerializer<Edge> {
@Override
public Edge createObject(QName name, Object parent) throws ObjectBuildException {
return new Edge();
}
@Override
public void buildChildObject(Edge object, QName name, Attributes attributes, XMLReader reader) throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "from" -> object.setFrom(reader.getObjectUsingBuilder(DirectPositionAdapter.class));
case "to" -> object.setTo(reader.getObjectUsingBuilder(DirectPositionAdapter.class));
default -> throw new IllegalStateException("Cannot handle name " + name + " when building Edge element");
}
}
@Override
public Element createElement(Edge object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "Edge");
}
@Override
public void writeChildElements(Edge object, Namespaces namespaces, XMLWriter writer) throws ObjectSerializeException, XMLWriteException {
if (object.getFrom() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "from"), object.getFrom(), DirectPositionAdapter.class, namespaces);
}
if (object.getTo() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "to"), object.getTo(), DirectPositionAdapter.class, namespaces);
}
}
@Override
public Edge createObject(QName name, Object parent) throws ObjectBuildException {
return new Edge();
}
@Override
public void buildChildObject(Edge object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "from":
object.setFrom(reader.getObjectUsingBuilder(DirectPositionAdapter.class));
break;
case "to":
object.setTo(reader.getObjectUsingBuilder(DirectPositionAdapter.class));
break;
default:
throw new IllegalStateException("Cannot handle name " + name + " when building Edge element");
}
}
@Override
public Element createElement(Edge object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "Edge");
}
@Override
public void writeChildElements(Edge object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
if (object.getFrom() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "from"), object.getFrom(),
DirectPositionAdapter.class, namespaces);
}
if (object.getTo() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "to"), object.getTo(),
DirectPositionAdapter.class, namespaces);
}
}
}
......@@ -35,11 +35,14 @@ public class EdgeListAdapter implements ObjectBuilder<EdgeList>, ObjectSerialize
return;
}
switch (name.getLocalPart()) {
case "edge" -> object.getEdges().add(reader.getObjectUsingBuilder(EdgePropertyAdapter.class));
default -> throw new IllegalStateException("Cannot handle name " + name + " when building EdgeList element");
case "edge":
object.getEdges().add(reader.getObjectUsingBuilder(EdgePropertyAdapter.class));
break;
default:
throw new IllegalStateException("Cannot handle name " + name + " when building EdgeList element");
}
}
@Override
public Element createElement(EdgeList object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "EdgeList");
......@@ -49,7 +52,8 @@ public class EdgeListAdapter implements ObjectBuilder<EdgeList>, ObjectSerialize
public void writeChildElements(EdgeList object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
for (EdgeProperty edgeProp : object.getEdges()) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "edge"), edgeProp, EdgePropertyAdapter.class, namespaces);
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "edge"), edgeProp,
EdgePropertyAdapter.class, namespaces);
}
}
}
......@@ -34,12 +34,17 @@ public class ErrorAdapter implements ObjectBuilder<Error>, ObjectSerializer<Erro
return;
}
switch (name.getLocalPart()) {
case "occurrences" -> reader.getTextContent().ifPresent(s -> object.setOccurrences(Integer.parseInt(s)));
case "name" -> reader.getTextContent().ifPresent(s -> object.setName(ErrorId.valueOf(s)));
default -> throw new IllegalStateException("Cannot handle name " + name + " when building Error element");
case "occurrences":
reader.getTextContent().ifPresent(s -> object.setOccurrences(Integer.parseInt(s)));
break;
case "name":
reader.getTextContent().ifPresent(s -> object.setName(ErrorId.valueOf(s)));
break;
default:
throw new IllegalStateException("Cannot handle name " + name + " when building Error element");
}
}
@Override
public Element createElement(Error object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "Error");
......
......@@ -34,13 +34,17 @@ public class FeatureStatisticsAdapter implements ObjectBuilder<FeatureStatistics
return;
}
switch (name.getLocalPart()) {
case "numChecked" -> reader.getTextContent().ifPresent(s -> object.setNumChecked(Integer.parseInt(s)));
case "numErrors" -> reader.getTextContent().ifPresent(s -> object.setNumErrors(Integer.parseInt(s)));
default -> throw new IllegalStateException(
"Cannot handle name " + name + " when building FeatureStatistics element");
case "numChecked":
reader.getTextContent().ifPresent(s -> object.setNumChecked(Integer.parseInt(s)));
break;
case "numErrors":
reader.getTextContent().ifPresent(s -> object.setNumErrors(Integer.parseInt(s)));
break;
default:
throw new IllegalStateException("Cannot handle name " + name + " when building FeatureStatistics element");
}
}
@Override
public Element createElement(FeatureStatistics object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "FeatureStatistics");
......
......@@ -35,8 +35,11 @@ public class FilterAdapter implements ObjectBuilder<Filter>, ObjectSerializer<Fi
return;
}
switch (name.getLocalPart()) {
case "checking" -> object.getChecking().add(reader.getObjectUsingBuilder(CheckingPropertyAdapter.class));
default -> throw new IllegalStateException("Cannot handle name " + name + " when building Filter element");
case "checking":
object.getChecking().add(reader.getObjectUsingBuilder(CheckingPropertyAdapter.class));
break;
default:
throw new IllegalStateException("Cannot handle name " + name + " when building Filter element");
}
}
......
......@@ -35,9 +35,11 @@ public class GlobalParametersAdapter implements ObjectBuilder<GlobalParameters>,
return;
}
switch (name.getLocalPart()) {
case "parameter" -> object.getParameters().add(reader.getObjectUsingBuilder(ParameterPropertyAdapter.class));
default -> throw new IllegalStateException(
"Cannot handle name " + name + " when building GlobalParameters element");
case "parameter":
object.getParameters().add(reader.getObjectUsingBuilder(ParameterPropertyAdapter.class));
break;
default:
throw new IllegalStateException("Cannot handle name " + name + " when building GlobalParameters element");
}
}
......
......@@ -31,11 +31,14 @@ public class HoleOutsideErrorAdapter extends AbstractPolygonErrorAdapter<HoleOut
return;
}
switch (name.getLocalPart()) {
case "linearRingId" -> reader.getTextContent().ifPresent(object::setLinearRingId);
default -> super.buildChildObject(object, name, attributes, reader);
case "linearRingId":
reader.getTextContent().ifPresent(object::setLinearRingId);
break;
default:
super.buildChildObject(object, name, attributes, reader);
}
}
@Override
public Element createElement(HoleOutsideError object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "GE_P_HOLE_OUTSIDE");
......@@ -45,7 +48,7 @@ public class HoleOutsideErrorAdapter extends AbstractPolygonErrorAdapter<HoleOut
public void writeChildElements(HoleOutsideError object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
super.writeChildElements(object, namespaces, writer);
if (object.getLinearRingId() != null) {
writer.writeElement(Element.of(QualityADEModule.NAMESPACE_URI, "linearRingId")
.addTextContent(object.getLinearRingId()));
......
......@@ -31,9 +31,14 @@ public class InnerRingsNestedErrorAdapter extends AbstractPolygonErrorAdapter<In
return;
}
switch (name.getLocalPart()) {
case "linearRingId1" -> reader.getTextContent().ifPresent(object::setLinearRingId1);
case "linearRingId2" -> reader.getTextContent().ifPresent(object::setLinearRingId2);
default -> super.buildChildObject(object, name, attributes, reader);
case "linearRingId1":
reader.getTextContent().ifPresent(object::setLinearRingId1);
break;
case "linearRingId2":
reader.getTextContent().ifPresent(object::setLinearRingId2);
break;
default:
super.buildChildObject(object, name, attributes, reader);
}
}
......
......@@ -31,12 +31,17 @@ public class IntersectingRingsErrorAdapter extends AbstractPolygonErrorAdapter<I
return;
}
switch (name.getLocalPart()) {
case "linearRingId1" -> reader.getTextContent().ifPresent(object::setLinearRingId1);
case "linearRingId2" -> reader.getTextContent().ifPresent(object::setLinearRingId2);
default -> super.buildChildObject(object, name, attributes, reader);
case "linearRingId1":
reader.getTextContent().ifPresent(object::setLinearRingId1);
break;
case "linearRingId2":
reader.getTextContent().ifPresent(object::setLinearRingId2);
break;
default:
super.buildChildObject(object, name, attributes, reader);
}
}
@Override
public Element createElement(IntersectingRingsError object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "GE_P_INTERSECTING_RINGS");
......@@ -46,7 +51,7 @@ public class IntersectingRingsErrorAdapter extends AbstractPolygonErrorAdapter<I
public void writeChildElements(IntersectingRingsError object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
super.writeChildElements(object, namespaces, writer);
if (object.getLinearRingId1() != null) {
writer.writeElement(Element.of(QualityADEModule.NAMESPACE_URI, "linearRingId1")
.addTextContent(object.getLinearRingId1()));
......
......@@ -33,8 +33,11 @@ public class MultipleComponentsErrorAdapter extends AbstractSolidErrorAdapter<Mu
return;
}
switch (name.getLocalPart()) {
case "component" -> object.getComponents().add(reader.getObjectUsingBuilder(PolygonIdListPropertyAdapter.class));
default -> super.buildChildObject(object, name, attributes, reader);
case "component":
object.getComponents().add(reader.getObjectUsingBuilder(PolygonIdListPropertyAdapter.class));
break;
default:
super.buildChildObject(object, name, attributes, reader);
}
}
......
......@@ -32,8 +32,11 @@ public class NonManifoldEdgeErrorAdapter extends AbstractSolidErrorAdapter<NonMa
return;
}
switch (name.getLocalPart()) {
case "edges" -> object.setEdges(reader.getObjectUsingBuilder(EdgeListPropertyAdapter.class));
default -> super.buildChildObject(object, name, attributes, reader);
case "edges":
object.setEdges(reader.getObjectUsingBuilder(EdgeListPropertyAdapter.class));
break;
default:
super.buildChildObject(object, name, attributes, reader);