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

Merge branch 'citygml3'

parents 6cf1abce bd8f73de
Pipeline #7210 passed with stage
in 7 seconds
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.model.types.SemanticAttributeWrongValueError;
@XMLElement(name = "SE_ATTRIBUTE_WRONG_VALUE", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class SemanticAttributeWrongValueErrorAdapter
extends AbstractSemanticErrorAdapter<SemanticAttributeWrongValueError> {
@Override
public SemanticAttributeWrongValueError createObject(QName name, Object parent) throws ObjectBuildException {
return new SemanticAttributeWrongValueError();
}
@Override
public void buildChildObject(SemanticAttributeWrongValueError object, QName name, Attributes attributes,
XMLReader reader) throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "childId":
reader.getTextContent().ifPresent(object::setChildId);
break;
case "attributeName":
reader.getTextContent().ifPresent(object::setAttributeName);
break;
case "generic":
reader.getTextContent().ifPresent(s -> object.setGeneric(Boolean.parseBoolean(s)));
break;
default:
throw new IllegalStateException(
"Cannot handle name " + name + " when building SemanticAttributeWrongValueError element");
}
}
@Override
public Element createElement(SemanticAttributeWrongValueError object, Namespaces namespaces)
throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "SE_ATTRIBUTE_WRONG_VALUE");
}
@Override
public void writeChildElements(SemanticAttributeWrongValueError object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
super.writeChildElements(object, namespaces, writer);
if (object.getChildId() != null) {
writer.writeElement(
Element.of(QualityADEModule.NAMESPACE_URI, "childId").addTextContent(object.getChildId()));
}
if (object.getAttributeName() != null) {
writer.writeElement(Element.of(QualityADEModule.NAMESPACE_URI, "attributeName")
.addTextContent(object.getAttributeName()));
}
writer.writeElement(Element.of(QualityADEModule.NAMESPACE_URI, "generic")
.addTextContent(Boolean.toString(object.isGeneric())));
}
}
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.adapter.properties.EdgeListPropertyAdapter;
import de.hft.stuttgart.quality.model.types.SolidNotClosedError;
@XMLElement(name = "GE_S_NOT_CLOSED", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class SolidNotClosedErrorAdapter extends AbstractSolidErrorAdapter<SolidNotClosedError> {
@Override
public SolidNotClosedError createObject(QName name, Object parent) throws ObjectBuildException {
return new SolidNotClosedError();
}
@Override
public void buildChildObject(SolidNotClosedError object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "edges":
object.setEdges(reader.getObjectUsingBuilder(EdgeListPropertyAdapter.class));
break;
default:
super.buildChildObject(object, name, attributes, reader);
}
}
@Override
public Element createElement(SolidNotClosedError object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "GE_S_NOT_CLOSED");
}
@Override
public void writeChildElements(SolidNotClosedError object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
super.writeChildElements(object, namespaces, writer);
if (object.getEdges() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "edges"), object.getEdges(),
EdgeListPropertyAdapter.class, namespaces);
}
}
}
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.model.types.SolidSelfIntersectionError;
@XMLElement(name = "GE_S_SELF_INTERSECTION", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class SolidSelfIntersectionErrorAdapter extends AbstractSolidErrorAdapter<SolidSelfIntersectionError> {
@Override
public SolidSelfIntersectionError createObject(QName name, Object parent) throws ObjectBuildException {
return new SolidSelfIntersectionError();
}
@Override
public void buildChildObject(SolidSelfIntersectionError object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "polygonId1":
reader.getTextContent().ifPresent(object::setPolygonId1);
break;
case "polygonId2":
reader.getTextContent().ifPresent(object::setPolygonId2);
break;
default:
super.buildChildObject(object, name, attributes, reader);
}
}
@Override
public Element createElement(SolidSelfIntersectionError object, Namespaces namespaces)
throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "GE_S_SELF_INTERSECTION");
}
@Override
public void writeChildElements(SolidSelfIntersectionError object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
super.writeChildElements(object, namespaces, writer);
if (object.getPolygonId1() != null) {
writer.writeElement(
Element.of(QualityADEModule.NAMESPACE_URI, "polygonId1").addTextContent(object.getPolygonId1()));
}
if (object.getPolygonId2() != null) {
writer.writeElement(
Element.of(QualityADEModule.NAMESPACE_URI, "polygonId2").addTextContent(object.getPolygonId2()));
}
}
}
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.model.types.SolidTooFewPolygonsError;
@XMLElement(name = "GE_S_TOO_FEW_POLYGONS", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class SolidTooFewPolygonsErrorAdapter extends AbstractSolidErrorAdapter<SolidTooFewPolygonsError> {
@Override
public SolidTooFewPolygonsError createObject(QName name, Object parent) throws ObjectBuildException {
return new SolidTooFewPolygonsError();
}
@Override
public Element createElement(SolidTooFewPolygonsError object, Namespaces namespaces)
throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "GE_S_TOO_FEW_POLYGONS");
}
}
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.builder.ObjectBuilder;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.serializer.ObjectSerializer;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.adapter.properties.ErrorPropertyAdapter;
import de.hft.stuttgart.quality.adapter.properties.FeatureStatisticsPropertyAdapter;
import de.hft.stuttgart.quality.model.properties.ErrorProperty;
import de.hft.stuttgart.quality.model.types.Statistics;
@XMLElement(name = "Statistics", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class StatisticsAdapter implements ObjectBuilder<Statistics>, ObjectSerializer<Statistics> {
@Override
public Statistics createObject(QName name, Object parent) throws ObjectBuildException {
return new Statistics();
}
@Override
public void buildChildObject(Statistics object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "numErrorBuildings":
object.setNumErrorBuildings(reader.getObjectUsingBuilder(FeatureStatisticsPropertyAdapter.class));
break;
case "numErrorVegetation":
object.setNumErrorVegetation(reader.getObjectUsingBuilder(FeatureStatisticsPropertyAdapter.class));
break;
case "numErrorLandObjects":
object.setNumErrorLandObjects(reader.getObjectUsingBuilder(FeatureStatisticsPropertyAdapter.class));
break;
case "numErrorBridgeObjects":
object.setNumErrorBridgeObjects(reader.getObjectUsingBuilder(FeatureStatisticsPropertyAdapter.class));
break;
case "numErrorWaterObjects":
object.setNumErrorWaterObjects(reader.getObjectUsingBuilder(FeatureStatisticsPropertyAdapter.class));
break;
case "numErrorTransportation":
object.setNumErrorTransportation(reader.getObjectUsingBuilder(FeatureStatisticsPropertyAdapter.class));
break;
case "error":
object.getErrors().add(reader.getObjectUsingBuilder(ErrorPropertyAdapter.class));
break;
default:
throw new IllegalStateException("Cannot handle name " + name + " when building Statistics element");
}
}
@Override
public Element createElement(Statistics object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "Statistics");
}
@Override
public void writeChildElements(Statistics object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
if (object.getNumErrorBuildings() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "numErrorBuildings"),
object.getNumErrorBuildings(), FeatureStatisticsPropertyAdapter.class, namespaces);
}
if (object.getNumErrorVegetation() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "numErrorVegetation"),
object.getNumErrorVegetation(), FeatureStatisticsPropertyAdapter.class, namespaces);
}
if (object.getNumErrorLandObjects() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "numErrorLandObjects"),
object.getNumErrorLandObjects(), FeatureStatisticsPropertyAdapter.class, namespaces);
}
if (object.getNumErrorBridgeObjects() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "numErrorBridgeObjects"),
object.getNumErrorBridgeObjects(), FeatureStatisticsPropertyAdapter.class, namespaces);
}
if (object.getNumErrorWaterObjects() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "numErrorWaterObjects"),
object.getNumErrorWaterObjects(), FeatureStatisticsPropertyAdapter.class, namespaces);
}
if (object.getNumErrorTransportation() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "numErrorTransportation"),
object.getNumErrorTransportation(), FeatureStatisticsPropertyAdapter.class, namespaces);
}
for (ErrorProperty errorProp : object.getErrors()) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "error"), errorProp,
ErrorPropertyAdapter.class, namespaces);
}
}
}
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.citygml4j.xml.adapter.core.AbstractFeatureAdapter;
import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.adapter.properties.StatisticsPropertyAdapter;
import de.hft.stuttgart.quality.adapter.properties.ValidationPlanPropertyAdapter;
import de.hft.stuttgart.quality.model.types.Validation;
@XMLElement(name = "Validation", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class ValidationAdapter extends AbstractFeatureAdapter<Validation> {
private static final ZonedDateTimeAdapter DATE_TIME_ADAPTER = new ZonedDateTimeAdapter();
@Override
public Validation createObject(QName name, Object parent) throws ObjectBuildException {
return new Validation();
}
@Override
public void buildChildObject(Validation object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "validationDate":
reader.getTextContent().ifPresent(s -> object.setValidationDate(DATE_TIME_ADAPTER.fromString(s)));
break;
case "validationSoftware":
reader.getTextContent().ifPresent(object::setValidationSoftware);
break;
case "statistics":
object.setStatistics(reader.getObjectUsingBuilder(StatisticsPropertyAdapter.class));
break;
case "validationPlan":
object.setValidationPlan(reader.getObjectUsingBuilder(ValidationPlanPropertyAdapter.class));
break;
default:
super.buildChildObject(object, name, attributes, reader);
}
}
@Override
public Element createElement(Validation object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "Validation");
}
@Override
public void writeChildElements(Validation object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
super.writeChildElements(object, namespaces, writer);
if (object.getValidationDate() != null) {
writer.writeElement(Element.of(QualityADEModule.NAMESPACE_URI, "validationDate")
.addTextContent(DATE_TIME_ADAPTER.toString(object.getValidationDate())));
}
if (object.getValidationSoftware() != null) {
writer.writeElement(Element.of(QualityADEModule.NAMESPACE_URI, "validationSoftware")
.addTextContent(object.getValidationSoftware()));
}
if (object.getStatistics() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "statistics"),
object.getStatistics(), StatisticsPropertyAdapter.class, namespaces);
}
if (object.getValidationPlan() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "validationPlan"),
object.getValidationPlan(), ValidationPlanPropertyAdapter.class, namespaces);
}
}
}
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.builder.ObjectBuilder;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.serializer.ObjectSerializer;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.adapter.properties.FilterPropertyAdapter;
import de.hft.stuttgart.quality.adapter.properties.GlobalParametersPropertyAdapter;
import de.hft.stuttgart.quality.adapter.properties.RequirementPropertyAdapter;
import de.hft.stuttgart.quality.model.properties.RequirementProperty;
import de.hft.stuttgart.quality.model.types.ValidationPlan;
@XMLElement(name = "ValidationPlan", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class ValidationPlanAdapter implements ObjectBuilder<ValidationPlan>, ObjectSerializer<ValidationPlan> {
@Override
public ValidationPlan createObject(QName name, Object parent) throws ObjectBuildException {
return new ValidationPlan();
}
@Override
public void buildChildObject(ValidationPlan object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "globalParameters":
object.setGlobalParameters(reader.getObjectUsingBuilder(GlobalParametersPropertyAdapter.class));
break;
case "filter":
object.setFilter(reader.getObjectUsingBuilder(FilterPropertyAdapter.class));
break;
case "requirement":
object.getRequirements().add(reader.getObjectUsingBuilder(RequirementPropertyAdapter.class));
break;
default:
throw new IllegalStateException("Cannot handle name " + name + " when building ValidationPlan element");
}
}
@Override
public Element createElement(ValidationPlan object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "ValidationPlan");
}
@Override
public void writeChildElements(ValidationPlan object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
if (object.getGlobalParameters() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "globalParameters"),
object.getGlobalParameters(), GlobalParametersPropertyAdapter.class, namespaces);
}
if (object.getFilter() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "filter"), object.getFilter(),
FilterPropertyAdapter.class, namespaces);
}
for (RequirementProperty req : object.getRequirements()) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "requirement"), req,
RequirementPropertyAdapter.class, namespaces);
}
}
}
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.builder.ObjectBuilder;
import org.xmlobjects.gml.adapter.base.ReferenceAdapter;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.serializer.ObjectSerializer;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.adapter.properties.AbstractErrorPropertyAdapter;
import de.hft.stuttgart.quality.model.enums.ResultType;
import de.hft.stuttgart.quality.model.properties.AbstractErrorProperty;
import de.hft.stuttgart.quality.model.types.ValidationResult;
@XMLElement(name = "ValidationResult", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class ValidationResultAdapter implements ObjectBuilder<ValidationResult>, ObjectSerializer<ValidationResult> {
@Override
public ValidationResult createObject(QName name, Object parent) throws ObjectBuildException {
return new ValidationResult();
}
@Override
public void buildChildObject(ValidationResult object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "validationPlanID":
object.setValidationPlanID(reader.getObjectUsingBuilder(ReferenceAdapter.class));
break;
case "error":
object.getErrors().add(reader.getObjectUsingBuilder(AbstractErrorPropertyAdapter.class));
break;
case "resultType":
reader.getTextContent().ifPresent(s -> object.setResultType(ResultType.valueOf(s)));
break;
default:
throw new IllegalStateException("Cannot handle name " + name + " when building ValidationResult element");
}
}
@Override
public Element createElement(ValidationResult object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "ValidationResult");
}
@Override
public void writeChildElements(ValidationResult object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
if (object.getValidationPlanID() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "validationPlanID"),
object.getValidationPlanID(), ReferenceAdapter.class, namespaces);
}
for (AbstractErrorProperty err : object.getErrors()) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "error"), err,
AbstractErrorPropertyAdapter.class, namespaces);
}
if (object.getResultType() != null) {
writer.writeElement(Element.of(QualityADEModule.NAMESPACE_URI, "resultType")
.addTextContent(object.getResultType().toString()));
}
}
}
/*- /*-
* Copyright 2020 Hochschule für Technik Stuttgart * Copyright 2022 Hochschule für Technik Stuttgart
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -13,19 +13,16 @@ ...@@ -13,19 +13,16 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package de.hft.stuttgart.quality.marshaller; package de.hft.stuttgart.quality.adapter.types;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import javax.xml.bind.annotation.adapters.XmlAdapter; public class ZonedDateTimeAdapter {
public class ZonedDateTimeAdapter extends XmlAdapter<String, ZonedDateTime> { public ZonedDateTime fromString(String v) {
@Override
public ZonedDateTime unmarshal(String v) throws Exception {
try { try {
return ZonedDateTime.from(DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(v)); return ZonedDateTime.from(DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(v));
} catch (Exception e) { } catch (Exception e) {
...@@ -33,11 +30,8 @@ public class ZonedDateTimeAdapter extends XmlAdapter<String, ZonedDateTime> { ...@@ -33,11 +30,8 @@ public class ZonedDateTimeAdapter extends XmlAdapter<String, ZonedDateTime> {
} }
} }
@Override public String toString(ZonedDateTime v) {
public String marshal(ZonedDateTime v) throws Exception {
return DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(v); return DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(v);
} }
} }
/*-
* Copyright 2020 Hochschule für Technik Stuttgart
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.hft.stuttgart.quality.marshaller;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
import javax.xml.bind.JAXBElement;
import org.citygml4j.builder.jaxb.marshal.citygml.ade.ADEMarshallerHelper;
import org.citygml4j.model.citygml.ade.binding.ADEMarshaller;
import org.citygml4j.model.citygml.ade.binding.ADEModelObject;
import org.citygml4j.util.mapper.TypeMapper;
import de.hft.stuttgart.quality.model.AllPolygonsWrongOrientation;
import de.hft.stuttgart.quality.model.AttributeMissing;
import de.hft.stuttgart.quality.model.AttributeWrongValue;
import de.hft.stuttgart.quality.model.ConsecutivePointsSame;
import de.hft.stuttgart.quality.model.Edge;
import de.hft.stuttgart.quality.model.HoleOutside;
import de.hft.stuttgart.quality.model.InnerRingsNested;
import de.hft.stuttgart.quality.model.InteriorDisconnected;
import de.hft.stuttgart.quality.model.IntersectingRings;
import de.hft.stuttgart.quality.model.MultipleConnectedComponents;
import de.hft.stuttgart.quality.model.NonManifoldEdge;
import de.hft.stuttgart.quality.model.NonManifoldVertex;
import de.hft.stuttgart.quality.model.NonPlanarDistancePlane;
import de.hft.stuttgart.quality.model.NonPlanarNormalsDeviation;
import de.hft.stuttgart.quality.model.OrientationRingsSame;
import de.hft.stuttgart.quality.model.PolygonWrongOrientation;
import de.hft.stuttgart.quality.model.RingNotClosed;
import de.hft.stuttgart.quality.model.RingSelfIntersection;
import de.hft.stuttgart.quality.model.SolidNotClosed;
import de.hft.stuttgart.quality.model.SolidSelfIntersection;
import de.hft.stuttgart.quality.model.TooFewPoints;
import de.hft.stuttgart.quality.model.TooFewPolygons;
import de.hft.stuttgart.quality.model.Validation;
import de.hft.stuttgart.quality.model.ValidationError;
import de.hft.stuttgart.quality.model.ValidationResult;
import de.hft.stuttgart.quality.model.jaxb.AllPolygonsWrongOrientationType;
import de.hft.stuttgart.quality.model.jaxb.AttributeMissingType;
import de.hft.stuttgart.quality.model.jaxb.AttributeWrongValueType;
import de.hft.stuttgart.quality.model.jaxb.ConsecutivePointsSameType;
import de.hft.stuttgart.quality.model.jaxb.EdgeType;
import de.hft.stuttgart.quality.model.jaxb.HoleOutsideType;
import de.hft.stuttgart.quality.model.jaxb.InnerRingsNestedType;
import de.hft.stuttgart.quality.model.jaxb.InteriorDisconnectedType;
import de.hft.stuttgart.quality.model.jaxb.IntersectingRingsType;
import de.hft.stuttgart.quality.model.jaxb.MultipleConnectedComponentsType;
import de.hft.stuttgart.quality.model.jaxb.NonManifoldEdgeType;
import de.hft.stuttgart.quality.model.jaxb.NonManifoldVertexType;
import de.hft.stuttgart.quality.model.jaxb.NonPlanarDistancePlaneType;
import de.hft.stuttgart.quality.model.jaxb.NonPlanarNormalsDeviationType;
import de.hft.stuttgart.quality.model.jaxb.ObjectFactory;
import de.hft.stuttgart.quality.model.jaxb.OrientationRingsSameType;
import de.hft.stuttgart.quality.model.jaxb.PolygonWrongOrientationType;
import de.hft.stuttgart.quality.model.jaxb.RingNotClosedType;
import de.hft.stuttgart.quality.model.jaxb.RingSelfIntersectionType;
import de.hft.stuttgart.quality.model.jaxb.SolidNotClosedType;
import de.hft.stuttgart.quality.model.jaxb.SolidSelfIntersectionType;
import de.hft.stuttgart.quality.model.jaxb.TooFewPointsType;
import de.hft.stuttgart.quality.model.jaxb.TooFewPolygonsType;
import de.hft.stuttgart.quality.model.jaxb.ValidationErrorType;
import de.hft.stuttgart.quality.model.jaxb.ValidationResultType;
import de.hft.stuttgart.quality.model.jaxb.ValidationType;
public class QualityAdeMarshaller implements ADEMarshaller {
private final ReentrantLock lock = new ReentrantLock();
private final ObjectFactory factory = new ObjectFactory();
private TypeMapper<JAXBElement<?>> elementMapper;
private TypeMapper<Object> typeMapper;
private ADEMarshallerHelper helper;
private TypeMapper<JAXBElement<?>> getElementMapper() {
if (elementMapper == null) {
lock.lock();
try {
if (elementMapper == null) {
elementMapper = TypeMapper.<JAXBElement<?>>create().with(Validation.class, this::createValidation)
.with(ValidationResult.class, this::createValidationResult);
}
} finally {
lock.unlock();
}
}
return elementMapper;
}
private TypeMapper<Object> getTypeMapper() {
if (typeMapper == null) {
lock.lock();
try {
if (typeMapper == null) {
typeMapper = TypeMapper.create().with(Validation.class, this::marshalValidation)
.with(ValidationResult.class, this::marshalValidationResult)
.with(ConsecutivePointsSame.class, this::marshalConsecutivePointsSame)
.with(TooFewPoints.class, this::marshalTooFewPoints)
.with(RingSelfIntersection.class, this::marshalRingSelfIntersection)
.with(RingNotClosed.class, this::marshalRingNotClosed)
.with(InteriorDisconnected.class, this::marshalInteriorDisconnected)
.with(IntersectingRings.class, this::marshalIntersectingRings)
.with(NonPlanarDistancePlane.class, this::marshalNonPlanarDistancePlane)
.with(InnerRingsNested.class, this::marshalInnerRingsNested)
.with(HoleOutside.class, this::marshalHoleOutside)
.with(NonPlanarNormalsDeviation.class, this::marshalNonPlanarNormalsDeviation)
.with(OrientationRingsSame.class, this::marshalOrientationRingsSame)
.with(AllPolygonsWrongOrientation.class, this::marshalAllPolygonsWrongOrientation)
.with(PolygonWrongOrientation.class, this::marshalPolygonWrongOrientation)
.with(SolidSelfIntersection.class, this::marshalSolidSelfIntersection)
.with(NonManifoldVertex.class, this::marshalNonManifoldVertex)
.with(NonManifoldEdge.class, this::marshalNonManifoldEdge)
.with(SolidNotClosed.class, this::marshalSolidNotClosed)
.with(TooFewPolygons.class, this::marshalTooFewPolygons)
.with(MultipleConnectedComponents.class, this::marshalMultipleConnectedComponents)
.with(AttributeWrongValue.class, this::marshalAttributeWrongValue)
.with(AttributeMissing.class, this::marshalAttributeMissing);
}
} finally {
lock.unlock();
}
}
return typeMapper;
}
private ValidationType marshalValidation(Validation src) {
ValidationType dest = new ValidationType();
if (src.isSetDateTime()) {
dest.setValidationDate(src.getValidationDate());
}
if (src.isSetValidationSoftware()) {
dest.setValidationSoftware(src.getValidationSoftware());
}
if (src.isSetValidationPlan()) {
dest.setValidationPlan(src.getValidationPlan());
}
if (src.isSetStatistics()) {
dest.setStatistics(src.getStatistics());
}
return dest;
}
private ValidationResultType marshalValidationResult(ValidationResult src) {
ValidationResultType dest = factory.createValidationResultType();
dest.setResult(src.getResult());
if (src.hasErrors()) {
for (ValidationError err : src.getErrors()) {
dest.getErrors().add(marshalValidationError(err));
// sort lexicographic, order does not actually matter but xml is restrictive
// that way
// could be solved with xsd v1.1 but jaxb can only process v1.0
dest.getErrors().sort((e1, e2) -> e1.getName().compareTo(e2.getName()));
}
}
return dest;
}
private JAXBElement<?> createValidation(Validation src) {
return factory.createValidationType(marshalValidation(src));
}
private JAXBElement<?> createValidationResult(ValidationResult src) {
return factory.createValidationResultType(marshalValidationResult(src));
}
private ValidationErrorType marshalValidationError(ValidationError err) {
return (ValidationErrorType) marshal(err);
}
@Override
public void setADEMarshallerHelper(ADEMarshallerHelper helper) {
this.helper = helper;
}
@Override
public JAXBElement<?> marshalJAXBElement(ADEModelObject src) {
return getElementMapper().apply(src);
}
@Override
public Object marshal(ADEModelObject src) {
return getTypeMapper().apply(src);
}
private ConsecutivePointsSameType marshalConsecutivePointsSame(ConsecutivePointsSame src) {
ConsecutivePointsSameType dest = factory.createConsecutivePointsSameType();
dest.setLinearRingId(src.getLinearRingId());
if (src.getVertex1() != null) {
dest.setVertex1(helper.getGMLMarshaller().marshalDirectPosition(src.getVertex1()));
}
if (src.getVertex2() != null) {
dest.setVertex2(helper.getGMLMarshaller().marshalDirectPosition(src.getVertex2()));
}
return dest;
}
private TooFewPointsType marshalTooFewPoints(TooFewPoints src) {
TooFewPointsType dest = factory.createTooFewPointsType();
dest.setLinearRingId(src.getLinearRingId());
return dest;
}
private RingSelfIntersectionType marshalRingSelfIntersection(RingSelfIntersection src) {
RingSelfIntersectionType dest = factory.createRingSelfIntersectionType();
dest.setLinearRingId(src.getLinearRingId());
dest.setType(src.getType());
if (src.getEdge1() != null) {
dest.setEdge1(marshalEdge(src.getEdge1()));
}
if (src.getEdge2() != null) {
dest.setEdge2(marshalEdge(src.getEdge2()));
}
if (src.getVertex1() != null) {
dest.setVertex1(helper.getGMLMarshaller().marshalDirectPosition(src.getVertex1()));
}
if (src.getVertex2() != null) {
dest.setVertex2(helper.getGMLMarshaller().marshalDirectPosition(src.getVertex2()));
}
return dest;
}
private EdgeType marshalEdge(Edge src) {
EdgeType dest = new EdgeType();
if (src.getFrom() != null) {
dest.setFrom(helper.getGMLMarshaller().marshalDirectPosition(src.getFrom()));
}
if (src.getTo() != null) {
dest.setTo(helper.getGMLMarshaller().marshalDirectPosition(src.getTo()));
}
return dest;
}
private RingNotClosedType marshalRingNotClosed(RingNotClosed src) {
RingNotClosedType dest = new RingNotClosedType();
dest.setLinearRingId(src.getLinearRingId());
return dest;
}
private InteriorDisconnectedType marshalInteriorDisconnected(InteriorDisconnected src) {
InteriorDisconnectedType dest = new InteriorDisconnectedType();
dest.setPolygonId(src.getPolygonId());
return dest;
}
private IntersectingRingsType marshalIntersectingRings(IntersectingRings src) {
IntersectingRingsType dest = new IntersectingRingsType();
dest.setPolygonId(src.getPolygonId());
dest.setLinearRingId1(src.getLinearRingId1());
dest.setLinearRingId2(src.getLinearRingId2());
return dest;
}
private NonPlanarDistancePlaneType marshalNonPlanarDistancePlane(NonPlanarDistancePlane src) {
NonPlanarDistancePlaneType dest = new NonPlanarDistancePlaneType();
dest.setPolygonId(src.getPolygonId());
if (src.getVertex() != null) {
dest.setVertex(helper.getGMLMarshaller().marshalDirectPosition(src.getVertex()));
}
if (src.getDistance() != null) {
dest.setDistance(helper.getGMLMarshaller().marshalLength(src.getDistance()));
}
return dest;
}
private InnerRingsNestedType marshalInnerRingsNested(InnerRingsNested src) {
InnerRingsNestedType dest = new InnerRingsNestedType();
dest.setPolygonId(src.getPolygonId());
dest.setLinearRingId1(src.getLinearRingId1());
dest.setLinearRingId2(src.getLinearRingId2());
return dest;
}
private HoleOutsideType marshalHoleOutside(HoleOutside src) {
HoleOutsideType dest = new HoleOutsideType();
dest.setPolygonId(src.getPolygonId());
dest.setLinearRingId(src.getLinearRingId());
return dest;
}
private NonPlanarNormalsDeviationType marshalNonPlanarNormalsDeviation(NonPlanarNormalsDeviation src) {
NonPlanarNormalsDeviationType dest = new NonPlanarNormalsDeviationType();
dest.setPolygonId(src.getPolygonId());
if (src.getDeviation() != null) {
dest.setDeviation(helper.getGMLMarshaller().marshalAngle(src.getDeviation()));
}
return dest;
}
private OrientationRingsSameType marshalOrientationRingsSame(OrientationRingsSame src) {
OrientationRingsSameType dest = new OrientationRingsSameType();
dest.setPolygonId(src.getPolygonId());
dest.setLinearRingId(src.getLinearRingId());
return dest;
}
private AllPolygonsWrongOrientationType marshalAllPolygonsWrongOrientation(AllPolygonsWrongOrientation src) {
AllPolygonsWrongOrientationType dest = new AllPolygonsWrongOrientationType();
dest.setGeometryId(src.getGeometryId());
return dest;
}
private PolygonWrongOrientationType marshalPolygonWrongOrientation(PolygonWrongOrientation src) {
PolygonWrongOrientationType dest = new PolygonWrongOrientationType();
dest.setGeometryId(src.getGeometryId());
if (src.isSetEdges()) {
List<EdgeType> edges = dest.getEdges();
for (Edge e : src.getEdges()) {
edges.add(marshalEdge(e));
}
}
return dest;
}
private SolidSelfIntersectionType marshalSolidSelfIntersection(SolidSelfIntersection src) {
SolidSelfIntersectionType dest = new SolidSelfIntersectionType();
dest.setGeometryId(src.getGeometryId());
dest.setPolygonId1(src.getPolygonId1());
dest.setPolygonId2(src.getPolygonId2());
return dest;
}
private NonManifoldVertexType marshalNonManifoldVertex(NonManifoldVertex src) {
NonManifoldVertexType dest = new NonManifoldVertexType();
dest.setGeometryId(src.getGeometryId());
if (src.getVertex() != null) {
dest.setVertex(helper.getGMLMarshaller().marshalDirectPosition(src.getVertex()));
}
return dest;
}
private NonManifoldEdgeType marshalNonManifoldEdge(NonManifoldEdge src) {
NonManifoldEdgeType dest = new NonManifoldEdgeType();
dest.setGeometryId(src.getGeometryId());
if (src.isSetEdges()) {
List<EdgeType> edges = dest.getEdges();
for (Edge e : src.getEdges()) {
edges.add(marshalEdge(e));
}
}
return dest;
}
private SolidNotClosedType marshalSolidNotClosed(SolidNotClosed src) {
SolidNotClosedType dest = new SolidNotClosedType();
dest.setGeometryId(src.getGeometryId());
if (src.isSetEdges()) {
List<EdgeType> edges = dest.getEdges();
for (Edge e : src.getEdges()) {
edges.add(marshalEdge(e));
}
}
return dest;
}
private TooFewPolygonsType marshalTooFewPolygons(TooFewPolygons src) {
TooFewPolygonsType dest = new TooFewPolygonsType();
dest.setGeometryId(src.getGeometryId());
return dest;
}
private MultipleConnectedComponentsType marshalMultipleConnectedComponents(MultipleConnectedComponents src) {
MultipleConnectedComponentsType dest = new MultipleConnectedComponentsType();
dest.setGeometryId(src.getGeometryId());
if (src.isSetComponents()) {
dest.getComponents().addAll(src.getComponents());
}
return dest;
}
private AttributeWrongValueType marshalAttributeWrongValue(AttributeWrongValue src) {
AttributeWrongValueType dest = new AttributeWrongValueType();
dest.setAttributeName(src.getAttributeName());
dest.setChildId(src.getChildId());
dest.setGeneric(src.isGeneric());
return dest;
}
private AttributeMissingType marshalAttributeMissing(AttributeMissing src) {
AttributeMissingType dest = new AttributeMissingType();
dest.setAttributeName(src.getAttributeName());
dest.setChildId(src.getChildId());
dest.setGeneric(src.isGeneric());
return dest;
}
}
/*-
* Copyright 2020 Hochschule für Technik Stuttgart
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.hft.stuttgart.quality.marshaller;
import java.util.List;
import java.util.concurrent.locks.ReentrantLock;
import java.util.stream.Collectors;
import javax.xml.bind.JAXBElement;
import org.citygml4j.builder.jaxb.unmarshal.citygml.ade.ADEUnmarshallerHelper;
import org.citygml4j.model.citygml.ade.binding.ADEModelObject;
import org.citygml4j.model.citygml.ade.binding.ADEUnmarshaller;
import org.citygml4j.util.mapper.CheckedTypeMapper;
import org.citygml4j.xml.io.reader.MissingADESchemaException;
import de.hft.stuttgart.quality.model.AllPolygonsWrongOrientation;
import de.hft.stuttgart.quality.model.AttributeMissing;
import de.hft.stuttgart.quality.model.AttributeWrongValue;
import de.hft.stuttgart.quality.model.ConsecutivePointsSame;
import de.hft.stuttgart.quality.model.Edge;
import de.hft.stuttgart.quality.model.HoleOutside;
import de.hft.stuttgart.quality.model.InnerRingsNested;
import de.hft.stuttgart.quality.model.InteriorDisconnected;
import de.hft.stuttgart.quality.model.IntersectingRings;
import de.hft.stuttgart.quality.model.MultipleConnectedComponents;
import de.hft.stuttgart.quality.model.NonManifoldEdge;
import de.hft.stuttgart.quality.model.NonManifoldVertex;
import de.hft.stuttgart.quality.model.NonPlanarDistancePlane;
import de.hft.stuttgart.quality.model.NonPlanarNormalsDeviation;
import de.hft.stuttgart.quality.model.OrientationRingsSame;
import de.hft.stuttgart.quality.model.PolygonWrongOrientation;
import de.hft.stuttgart.quality.model.RingNotClosed;
import de.hft.stuttgart.quality.model.RingSelfIntersection;
import de.hft.stuttgart.quality.model.SolidNotClosed;
import de.hft.stuttgart.quality.model.SolidSelfIntersection;
import de.hft.stuttgart.quality.model.TooFewPoints;
import de.hft.stuttgart.quality.model.TooFewPolygons;
import de.hft.stuttgart.quality.model.Validation;
import de.hft.stuttgart.quality.model.ValidationError;
import de.hft.stuttgart.quality.model.ValidationResult;
import de.hft.stuttgart.quality.model.jaxb.AllPolygonsWrongOrientationType;
import de.hft.stuttgart.quality.model.jaxb.AttributeMissingType;
import de.hft.stuttgart.quality.model.jaxb.AttributeWrongValueType;
import de.hft.stuttgart.quality.model.jaxb.ConsecutivePointsSameType;
import de.hft.stuttgart.quality.model.jaxb.EdgeType;
import de.hft.stuttgart.quality.model.jaxb.HoleOutsideType;
import de.hft.stuttgart.quality.model.jaxb.InnerRingsNestedType;
import de.hft.stuttgart.quality.model.jaxb.InteriorDisconnectedType;
import de.hft.stuttgart.quality.model.jaxb.IntersectingRingsType;
import de.hft.stuttgart.quality.model.jaxb.MultipleConnectedComponentsType;
import de.hft.stuttgart.quality.model.jaxb.NonManifoldEdgeType;
import de.hft.stuttgart.quality.model.jaxb.NonManifoldVertexType;
import de.hft.stuttgart.quality.model.jaxb.NonPlanarDistancePlaneType;
import de.hft.stuttgart.quality.model.jaxb.NonPlanarNormalsDeviationType;
import de.hft.stuttgart.quality.model.jaxb.OrientationRingsSameType;
import de.hft.stuttgart.quality.model.jaxb.PolygonWrongOrientationType;
import de.hft.stuttgart.quality.model.jaxb.RingNotClosedType;
import de.hft.stuttgart.quality.model.jaxb.RingSelfIntersectionType;
import de.hft.stuttgart.quality.model.jaxb.SolidNotClosedType;
import de.hft.stuttgart.quality.model.jaxb.SolidSelfIntersectionType;
import de.hft.stuttgart.quality.model.jaxb.TooFewPointsType;
import de.hft.stuttgart.quality.model.jaxb.TooFewPolygonsType;
import de.hft.stuttgart.quality.model.jaxb.ValidationErrorType;
import de.hft.stuttgart.quality.model.jaxb.ValidationResultType;
import de.hft.stuttgart.quality.model.jaxb.ValidationType;
import de.hft.stuttgart.quality.util.UncheckedMissingADESchemaException;
public class QualityAdeUnmarshaller implements ADEUnmarshaller {
private final ReentrantLock lock = new ReentrantLock();
private CheckedTypeMapper<ADEModelObject> typeMapper;
private ADEUnmarshallerHelper helper;
private CheckedTypeMapper<ADEModelObject> getTypeMapper() {
if (typeMapper == null) {
lock.lock();
try {
if (typeMapper == null) {
typeMapper = CheckedTypeMapper.<ADEModelObject>create()
.with(ValidationType.class, this::unmarshalValidationType)
.with(ValidationResultType.class, this::umarshalValidationResultType)
.with(ConsecutivePointsSameType.class, this::unmarshalConsecutivePointsSameType)
.with(TooFewPointsType.class, this::unmarshalTooFewPointsType)
.with(RingSelfIntersectionType.class, this::unmarshalRingSelfIntersectionType)
.with(RingNotClosedType.class, this::unmarshalRingNotClosedType)
.with(InteriorDisconnectedType.class, this::unmarshalInteriorDisconnectedType)
.with(IntersectingRingsType.class, this::unmarshalIntersectingRingsType)
.with(NonPlanarDistancePlaneType.class, this::unmarshalNonPlanarDistancePlaneType)
.with(InnerRingsNestedType.class, this::unmarshalInnerRingsType)
.with(HoleOutsideType.class, this::unmarshalHoleOutsideType)
.with(OrientationRingsSameType.class, this::unmarshalOrientationRingsSameType)
.with(NonPlanarNormalsDeviationType.class, this::unmarshalNonPlanarNormalsDeviationType)
.with(AllPolygonsWrongOrientationType.class, this::unmarshalAllPolygonsWrongOrientationType)
.with(PolygonWrongOrientationType.class, this::unmarshalPolygonWrongOrientationType)
.with(SolidSelfIntersectionType.class, this::unmarshalSolidSelfIntersectionType)
.with(NonManifoldVertexType.class, this::unmarshalNonManifoldVertexType)
.with(NonManifoldEdgeType.class, this::unmarshalNonManifoldEdgeType)
.with(SolidNotClosedType.class, this::unmarshalSolidNotClosedType)
.with(TooFewPolygonsType.class, this::unmarshalTooFewPolygonsType)
.with(MultipleConnectedComponentsType.class, this::unmarshalMultipleConnectedComponentsType)
.with(AttributeWrongValueType.class, this::unmarshalAttributeWrongValueType)
.with(AttributeMissingType.class, this::unmarshalAttributeMissingType);
}
} finally {
lock.unlock();
}
}
return typeMapper;
}
@Override
public void setADEUnmarshallerHelper(ADEUnmarshallerHelper helper) {
this.helper = helper;
}
@Override
public ADEModelObject unmarshal(JAXBElement<?> src) throws MissingADESchemaException {
return unmarshal(src.getValue());
}
@Override
public ADEModelObject unmarshal(Object src) throws MissingADESchemaException {
return getTypeMapper().apply(src);
}
private Validation unmarshalValidationType(ValidationType src) {
Validation dest = new Validation();
dest.setValidationDate(src.getValidationDate());
dest.setValidationSoftware(src.getValidationSoftware());
dest.setValidationPlan(src.getValidationPlan());
dest.setStatistics(src.getStatistics());
return dest;
}
private ValidationResult umarshalValidationResultType(ValidationResultType src) throws MissingADESchemaException {
ValidationResult dest = new ValidationResult();
dest.setResult(src.getResult());
if (src.isSetErrors()) {
try {
dest.getErrors()
.addAll(src.getErrors().stream().map(this::unmarshalError).collect(Collectors.toList()));
} catch (UncheckedMissingADESchemaException e) {
throw e.getCause();
}
}
return dest;
}
private ValidationError unmarshalError(ValidationErrorType err) {
try {
return (ValidationError) getTypeMapper().apply(err);
} catch (MissingADESchemaException e) {
throw new UncheckedMissingADESchemaException(e);
}
}
private ConsecutivePointsSame unmarshalConsecutivePointsSameType(ConsecutivePointsSameType src) {
ConsecutivePointsSame dest = new ConsecutivePointsSame();
dest.setLinearRingId(src.getLinearRingId());
dest.setVertex1(helper.getGMLUnmarshaller().unmarshalDirectPosition(src.getVertex1()));
dest.setVertex2(helper.getGMLUnmarshaller().unmarshalDirectPosition(src.getVertex2()));
return dest;
}
private TooFewPoints unmarshalTooFewPointsType(TooFewPointsType src) {
TooFewPoints dest = new TooFewPoints();
dest.setLinearRingId(src.getLinearRingId());
return dest;
}
private RingSelfIntersection unmarshalRingSelfIntersectionType(RingSelfIntersectionType src) {
RingSelfIntersection dest = new RingSelfIntersection();
if (src.getEdge1() != null) {
dest.setEdge1(unmarshalEdge(src.getEdge1()));
}
if (src.getEdge2() != null) {
dest.setEdge2(unmarshalEdge(src.getEdge2()));
}
dest.setLinearRingId(src.getLinearRingId());
dest.setType(src.getType());
if (src.getVertex1() != null) {
dest.setVertex1(helper.getGMLUnmarshaller().unmarshalDirectPosition(src.getVertex1()));
}
if (src.getVertex2() != null) {
dest.setVertex2(helper.getGMLUnmarshaller().unmarshalDirectPosition(src.getVertex2()));
}
return dest;
}
private RingNotClosed unmarshalRingNotClosedType(RingNotClosedType src) {
RingNotClosed dest = new RingNotClosed();
dest.setLinearRingId(src.getLinearRingId());
return dest;
}
private Edge unmarshalEdge(EdgeType src) {
Edge dest = new Edge();
if (src.getFrom() != null) {
dest.setFrom(helper.getGMLUnmarshaller().unmarshalDirectPosition(src.getFrom()));
}
if (src.getTo() != null) {
dest.setTo(helper.getGMLUnmarshaller().unmarshalDirectPosition(src.getTo()));
}
return dest;
}
private InteriorDisconnected unmarshalInteriorDisconnectedType(InteriorDisconnectedType src) {
InteriorDisconnected dest = new InteriorDisconnected();
dest.setPolygonId(src.getPolygonId());
return dest;
}
private IntersectingRings unmarshalIntersectingRingsType(IntersectingRingsType src) {
IntersectingRings dest = new IntersectingRings();
dest.setPolygonId(src.getPolygonId());
dest.setLinearRingId1(src.getLinearRingId1());
dest.setLinearRingId2(src.getLinearRingId2());
return dest;
}
private InnerRingsNested unmarshalInnerRingsType(InnerRingsNestedType src) {
InnerRingsNested dest = new InnerRingsNested();
dest.setPolygonId(src.getPolygonId());
dest.setLinearRingId1(src.getLinearRingId1());
dest.setLinearRingId2(src.getLinearRingId2());
return dest;
}
private NonPlanarDistancePlane unmarshalNonPlanarDistancePlaneType(NonPlanarDistancePlaneType src) {
NonPlanarDistancePlane dest = new NonPlanarDistancePlane();
dest.setPolygonId(src.getPolygonId());
if (src.getVertex() != null) {
dest.setVertex(helper.getGMLUnmarshaller().unmarshalDirectPosition(src.getVertex()));
}
if (src.getDistance() != null) {
dest.setDistance(helper.getGMLUnmarshaller().unmarshalLength(src.getDistance()));
}
return dest;
}
private HoleOutside unmarshalHoleOutsideType(HoleOutsideType src) {
HoleOutside dest = new HoleOutside();
dest.setPolygonId(src.getPolygonId());
dest.setLinearRingId(src.getLinearRingId());
return dest;
}
private NonPlanarNormalsDeviation unmarshalNonPlanarNormalsDeviationType(NonPlanarNormalsDeviationType src) {
NonPlanarNormalsDeviation dest = new NonPlanarNormalsDeviation();
dest.setPolygonId(src.getPolygonId());
if (src.getDeviation() != null) {
dest.setDeviation(helper.getGMLUnmarshaller().unmarshalAngle(src.getDeviation()));
}
return dest;
}
private OrientationRingsSame unmarshalOrientationRingsSameType(OrientationRingsSameType src) {
OrientationRingsSame dest = new OrientationRingsSame();
dest.setPolygonId(src.getPolygonId());
dest.setLinearRingId(src.getLinearRingId());
return dest;
}
private AllPolygonsWrongOrientation unmarshalAllPolygonsWrongOrientationType(AllPolygonsWrongOrientationType src) {
AllPolygonsWrongOrientation dest = new AllPolygonsWrongOrientation();
dest.setGeometryId(src.getGeometryId());
return dest;
}
private PolygonWrongOrientation unmarshalPolygonWrongOrientationType(PolygonWrongOrientationType src) {
PolygonWrongOrientation dest = new PolygonWrongOrientation();
dest.setGeometryId(src.getGeometryId());
if (src.isSetEdges()) {
List<Edge> edges = dest.getEdges();
for (EdgeType e : src.getEdges()) {
edges.add(unmarshalEdge(e));
}
}
return dest;
}
private SolidSelfIntersection unmarshalSolidSelfIntersectionType(SolidSelfIntersectionType src) {
SolidSelfIntersection dest = new SolidSelfIntersection();
dest.setGeometryId(src.getGeometryId());
dest.setPolygonId1(src.getPolygonId1());
dest.setPolygonId2(src.getPolygonId2());
return dest;
}
private NonManifoldVertex unmarshalNonManifoldVertexType(NonManifoldVertexType src) {
NonManifoldVertex dest = new NonManifoldVertex();
dest.setGeometryId(src.getGeometryId());
if (src.getVertex() != null) {
dest.setVertex(helper.getGMLUnmarshaller().unmarshalDirectPosition(src.getVertex()));
}
return dest;
}
private NonManifoldEdge unmarshalNonManifoldEdgeType(NonManifoldEdgeType src) {
NonManifoldEdge dest = new NonManifoldEdge();
dest.setGeometryId(src.getGeometryId());
if (src.isSetEdges()) {
List<Edge> edges = dest.getEdges();
for (EdgeType e : src.getEdges()) {
edges.add(unmarshalEdge(e));
}
}
return dest;
}
private SolidNotClosed unmarshalSolidNotClosedType(SolidNotClosedType src) {
SolidNotClosed dest = new SolidNotClosed();
dest.setGeometryId(src.getGeometryId());
if (src.isSetEdges()) {
List<Edge> edges = dest.getEdges();
for (EdgeType e : src.getEdges()) {
edges.add(unmarshalEdge(e));
}
}
return dest;
}
private TooFewPolygons unmarshalTooFewPolygonsType(TooFewPolygonsType src) {
TooFewPolygons dest = new TooFewPolygons();
dest.setGeometryId(src.getGeometryId());
return dest;
}
private MultipleConnectedComponents unmarshalMultipleConnectedComponentsType(MultipleConnectedComponentsType src) {
MultipleConnectedComponents dest = new MultipleConnectedComponents();
dest.setGeometryId(src.getGeometryId());
if (src.isSetComponents()) {
dest.getComponents().addAll(src.getComponents());
}
return dest;
}
private AttributeWrongValue unmarshalAttributeWrongValueType(AttributeWrongValueType src) {
AttributeWrongValue dest = new AttributeWrongValue();
dest.setAttributeName(src.getAttributeName());
dest.setChildId(src.getChildId());
dest.setGeneric(src.isGeneric());
return dest;
}
private AttributeMissing unmarshalAttributeMissingType(AttributeMissingType src) {
AttributeMissing dest = new AttributeMissing();
dest.setAttributeName(src.getAttributeName());
dest.setChildId(src.getChildId());
dest.setGeneric(src.isGeneric());
return dest;
}
}
/*-
* Copyright 2020 Hochschule für Technik Stuttgart
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.hft.stuttgart.quality.model;
import org.citygml4j.builder.copy.CopyBuilder;
public class AttributeWrongValue extends SemanticError {
private static final long serialVersionUID = -5650985861847806620L;
private String childId;
private String attributeName;
private boolean generic;
public String getChildId() {
return childId;
}
public void setChildId(String childId) {
this.childId = childId;
}
public String getAttributeName() {
return attributeName;
}
public void setAttributeName(String attributeName) {
this.attributeName = attributeName;
}
public boolean isGeneric() {
return generic;
}
public void setGeneric(boolean generic) {
this.generic = generic;
}
@Override
public String toString() {
return "AttributeWrongValue [childId=" + childId + ", attributeName=" + attributeName + ", generic=" + generic
+ "]";
}
@Override
public Object copy(CopyBuilder copyBuilder) {
return copyTo(new AttributeWrongValue(), copyBuilder);
}
}
/*-
* Copyright 2020 Hochschule für Technik Stuttgart
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.hft.stuttgart.quality.model;
import org.citygml4j.builder.copy.CopyBuilder;
import org.citygml4j.model.citygml.ade.binding.ADEModelObject;
import org.citygml4j.model.common.base.ModelObject;
public abstract class ChildObject implements ADEModelObject {
private static final long serialVersionUID = 6726372382501963276L;
private ModelObject parent;
@Override
public Object copyTo(Object target, CopyBuilder copyBuilder) {
return target;
}
@Override
public ModelObject getParent() {
return parent;
}
@Override
public void setParent(ModelObject parent) {
this.parent = parent;
}
@Override
public boolean isSetParent() {
return parent != null;
}
@Override
public void unsetParent() {
parent = null;
}
}
/*-
* Copyright 2020 Hochschule für Technik Stuttgart
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.hft.stuttgart.quality.model;
import java.util.ArrayList;
import java.util.List;
import org.citygml4j.builder.copy.CopyBuilder;
public class PolygonWrongOrientation extends SolidError {
private static final long serialVersionUID = 1128689472694838648L;
private List<Edge> edges;
public boolean isSetEdges() {
return edges != null && !edges.isEmpty();
}
public List<Edge> getEdges() {
if (edges == null) {
edges = new ArrayList<>();
}
return edges;
}
@Override
public String toString() {
return "PolygonWrongOrientation [geometryId=" + getGeometryId() + ", edges=" + edges + "]";
}
@Override
public Object copy(CopyBuilder copyBuilder) {
return copyTo(new PolygonWrongOrientation(), copyBuilder);
}
}
/*-
* Copyright 2020 Hochschule für Technik Stuttgart
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.hft.stuttgart.quality.model;
import org.citygml4j.builder.copy.CopyBuilder;
public class RingNotClosed extends RingError {
private static final long serialVersionUID = 5502668444088395535L;
@Override
public String toString() {
return "RingNotClosed [linearRingId=" + getLinearRingId() + "]";
}
@Override
public Object copy(CopyBuilder copyBuilder) {
return copyTo(new RingNotClosed(), copyBuilder);
}
}
/*-
* Copyright 2020 Hochschule für Technik Stuttgart
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.hft.stuttgart.quality.model;
public abstract class SemanticError extends ValidationError {
private static final long serialVersionUID = 8986289777859562928L;
}
/*-
* Copyright 2020 Hochschule für Technik Stuttgart
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.hft.stuttgart.quality.model;
import org.citygml4j.builder.copy.CopyBuilder;
public class SolidSelfIntersection extends SolidError {
private static final long serialVersionUID = 4086097021438848040L;
private String polygonId1;
private String polygonId2;
public String getPolygonId1() {
return polygonId1;
}
public void setPolygonId1(String polygonId1) {
this.polygonId1 = polygonId1;
}
public String getPolygonId2() {
return polygonId2;
}
public void setPolygonId2(String polygonId2) {
this.polygonId2 = polygonId2;
}
@Override
public String toString() {
return "SolidSelfIntersection [geometryId=" + getGeometryId() + ", polygonId1=" + polygonId1 + ", polygonId2="
+ polygonId2 + "]";
}
@Override
public Object copy(CopyBuilder copyBuilder) {
return copyTo(new SolidSelfIntersection(), copyBuilder);
}
}
/*-
* Copyright 2020 Hochschule für Technik Stuttgart
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.hft.stuttgart.quality.model;
import java.time.ZonedDateTime;
import org.citygml4j.builder.copy.CopyBuilder;
import de.hft.stuttgart.quality.model.jaxb.Statistics;
import de.hft.stuttgart.quality.model.jaxb.ValidationPlan;
public class Validation extends ChildObject {
private static final long serialVersionUID = 1738293574859506005L;
private ZonedDateTime validationDate;
private String validationSoftware;
private ValidationPlan validationPlan;
private Statistics statistics;
@Override
public Object copy(CopyBuilder copyBuilder) {
return this;
}
public boolean isSetStatistics() {
return statistics != null;
}
public void setStatistics(Statistics statistics) {
this.statistics = statistics;
}
public Statistics getStatistics() {
return statistics;
}
public boolean isSetValidationPlan() {
return validationPlan != null;
}
public void setValidationPlan(ValidationPlan validationPlan) {
this.validationPlan = validationPlan;
}
public ValidationPlan getValidationPlan() {
return validationPlan;
}
public boolean isSetDateTime() {
return validationDate != null;
}
public boolean isSetValidationSoftware() {
return validationSoftware != null;
}
public void setValidationDate(ZonedDateTime validationDate) {
this.validationDate = validationDate;
}
public ZonedDateTime getValidationDate() {
return validationDate;
}
public void setValidationSoftware(String validationSoftware) {
this.validationSoftware = validationSoftware;
}
public String getValidationSoftware() {
return validationSoftware;
}
}
/*-
* Copyright 2020 Hochschule für Technik Stuttgart
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package de.hft.stuttgart.quality.model;
import java.util.ArrayList;
import java.util.List;
import org.citygml4j.builder.copy.CopyBuilder;
import org.citygml4j.model.citygml.ade.binding.ADEModelObject;
import org.citygml4j.model.common.visitor.FeatureFunctor;
import org.citygml4j.model.common.visitor.FeatureVisitor;
import org.citygml4j.model.common.visitor.GMLFunctor;
import org.citygml4j.model.common.visitor.GMLVisitor;
import org.citygml4j.model.gml.feature.AbstractFeature;
import de.hft.stuttgart.quality.model.jaxb.ResultType;
public class ValidationResult extends AbstractFeature implements ADEModelObject {
private static final long serialVersionUID = 1180762313908627342L;
private ResultType result;
private List<ValidationError> errors;
public boolean hasErrors() {
return errors != null && !errors.isEmpty();
}
public List<ValidationError> getErrors() {
if (errors == null) {
errors = new ArrayList<>(2);
}
return errors;
}
public void setResult(ResultType result) {
this.result = result;
}
public ResultType getResult() {
return result;
}
@Override
public Object copy(CopyBuilder copyBuilder) {
return copyTo(new ValidationResult(), copyBuilder);
}
@Override
public void accept(FeatureVisitor visitor) {
visitor.visit(this);
}
@Override
public <T> T accept(FeatureFunctor<T> visitor) {
return visitor.apply(this);
}
@Override
public void accept(GMLVisitor visitor) {
visitor.visit(this);
}
@Override
public <T> T accept(GMLFunctor<T> visitor) {
return visitor.apply(this);
}
}
/*- /*-
* Copyright 2020 Hochschule für Technik Stuttgart * Copyright 2022 Hochschule für Technik Stuttgart
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -13,11 +13,8 @@ ...@@ -13,11 +13,8 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package de.hft.stuttgart.quality.model.jaxb; package de.hft.stuttgart.quality.model.enums;
import javax.xml.bind.annotation.XmlEnum;
@XmlEnum
public enum ErrorId { public enum ErrorId {
GE_R_TOO_FEW_POINTS, GE_R_NOT_CLOSED, GE_R_CONSECUTIVE_POINTS_SAME, GE_R_SELF_INTERSECTION, GE_R_TOO_FEW_POINTS, GE_R_NOT_CLOSED, GE_R_CONSECUTIVE_POINTS_SAME, GE_R_SELF_INTERSECTION,
......
Markdown is supported
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