Commit 98b386d2 authored by Claus Nagel's avatar Claus Nagel
Browse files

updated citygml4j module to support QualityADE version 0.1.4

parent 6cf1abce
//
// Generated with ade-xjc - XML Schema binding compiler for CityGML ADEs, version 2.10.0
// ade-xjc is part of the citygml4j project, see https://github.com/citygml4j
// Any modifications to this file will be lost upon recompilation of the source
// Generated: Fri Nov 19 14:36:13 CET 2021
//
package de.hft.stuttgart.quality.model.jaxb;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java-Klasse für ValidationResultType complex type.
*
* <p>Das folgende Schemafragment gibt den erwarteten Content an, der in dieser Klasse enthalten ist.
*
* <pre>
* &lt;complexType name="ValidationResultType"&gt;
* &lt;complexContent&gt;
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType"&gt;
* &lt;sequence&gt;
* &lt;element name="validationPlanID" type="{https://transfer.hft-stuttgart.de/pages/citydoctor/qualityade/0.1.4}ValidationPropertyType"/&gt;
* &lt;element name="error" type="{https://transfer.hft-stuttgart.de/pages/citydoctor/qualityade/0.1.4}AbstractErrorPropertyType" maxOccurs="unbounded" minOccurs="0"/&gt;
* &lt;element name="resultType" type="{https://transfer.hft-stuttgart.de/pages/citydoctor/qualityade/0.1.4}ResultTypeType"/&gt;
* &lt;/sequence&gt;
* &lt;/restriction&gt;
* &lt;/complexContent&gt;
* &lt;/complexType&gt;
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ValidationResultType", propOrder = {
"validationPlanID",
"error",
"resultType"
})
public class ValidationResultType {
@XmlElement(required = true)
protected ValidationPropertyType validationPlanID;
protected List<AbstractErrorPropertyType> error;
@XmlElement(required = true)
@XmlSchemaType(name = "string")
protected ResultTypeType resultType;
/**
* Ruft den Wert der validationPlanID-Eigenschaft ab.
*
* @return
* possible object is
* {@link ValidationPropertyType }
*
*/
public ValidationPropertyType getValidationPlanID() {
return validationPlanID;
}
/**
* Legt den Wert der validationPlanID-Eigenschaft fest.
*
* @param value
* allowed object is
* {@link ValidationPropertyType }
*
*/
public void setValidationPlanID(ValidationPropertyType value) {
this.validationPlanID = value;
}
public boolean isSetValidationPlanID() {
return (this.validationPlanID!= null);
}
/**
* Gets the value of the error property.
*
* <p>
* This accessor method returns a reference to the live list,
* not a snapshot. Therefore any modification you make to the
* returned list will be present inside the JAXB object.
* This is why there is not a <CODE>set</CODE> method for the error property.
*
* <p>
* For example, to add a new item, do as follows:
* <pre>
* getError().add(newItem);
* </pre>
*
*
* <p>
* Objects of the following type(s) are allowed in the list
* {@link AbstractErrorPropertyType }
*
*
*/
public List<AbstractErrorPropertyType> getError() {
if (error == null) {
error = new ArrayList<AbstractErrorPropertyType>();
}
return this.error;
}
public boolean isSetError() {
return ((this.error!= null)&&(!this.error.isEmpty()));
}
public void unsetError() {
this.error = null;
}
/**
* Ruft den Wert der resultType-Eigenschaft ab.
*
* @return
* possible object is
* {@link ResultTypeType }
*
*/
public ResultTypeType getResultType() {
return resultType;
}
/**
* Legt den Wert der resultType-Eigenschaft fest.
*
* @param value
* allowed object is
* {@link ResultTypeType }
*
*/
public void setResultType(ResultTypeType value) {
this.resultType = value;
}
public boolean isSetResultType() {
return (this.resultType!= null);
}
}
//
// Generated with ade-xjc - XML Schema binding compiler for CityGML ADEs, version 2.10.0
// ade-xjc is part of the citygml4j project, see https://github.com/citygml4j
// Any modifications to this file will be lost upon recompilation of the source
// Generated: Fri Nov 19 14:36:13 CET 2021
//
package de.hft.stuttgart.quality.model.jaxb;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;
import net.opengis.gml.AbstractFeatureType;
/**
* <p>Java-Klasse für ValidationType complex type.
*
* <p>Das folgende Schemafragment gibt den erwarteten Content an, der in dieser Klasse enthalten ist.
*
* <pre>
* &lt;complexType name="ValidationType"&gt;
* &lt;complexContent&gt;
* &lt;extension base="{http://www.opengis.net/gml}AbstractFeatureType"&gt;
* &lt;sequence&gt;
* &lt;element name="validationDate" type="{http://www.w3.org/2001/XMLSchema}dateTime"/&gt;
* &lt;element name="validationSoftware" type="{http://www.w3.org/2001/XMLSchema}string"/&gt;
* &lt;element name="statistics" type="{https://transfer.hft-stuttgart.de/pages/citydoctor/qualityade/0.1.4}StatisticsPropertyType" minOccurs="0"/&gt;
* &lt;element name="validationPlan" type="{https://transfer.hft-stuttgart.de/pages/citydoctor/qualityade/0.1.4}ValidationPlanPropertyType"/&gt;
* &lt;/sequence&gt;
* &lt;/extension&gt;
* &lt;/complexContent&gt;
* &lt;/complexType&gt;
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ValidationType", propOrder = {
"validationDate",
"validationSoftware",
"statistics",
"validationPlan"
})
public class ValidationType
extends AbstractFeatureType
{
@XmlElement(required = true)
@XmlSchemaType(name = "dateTime")
protected XMLGregorianCalendar validationDate;
@XmlElement(required = true)
protected String validationSoftware;
protected StatisticsPropertyType statistics;
@XmlElement(required = true)
protected ValidationPlanPropertyType validationPlan;
/**
* Ruft den Wert der validationDate-Eigenschaft ab.
*
* @return
* possible object is
* {@link XMLGregorianCalendar }
*
*/
public XMLGregorianCalendar getValidationDate() {
return validationDate;
}
/**
* Legt den Wert der validationDate-Eigenschaft fest.
*
* @param value
* allowed object is
* {@link XMLGregorianCalendar }
*
*/
public void setValidationDate(XMLGregorianCalendar value) {
this.validationDate = value;
}
public boolean isSetValidationDate() {
return (this.validationDate!= null);
}
/**
* Ruft den Wert der validationSoftware-Eigenschaft ab.
*
* @return
* possible object is
* {@link String }
*
*/
public String getValidationSoftware() {
return validationSoftware;
}
/**
* Legt den Wert der validationSoftware-Eigenschaft fest.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setValidationSoftware(String value) {
this.validationSoftware = value;
}
public boolean isSetValidationSoftware() {
return (this.validationSoftware!= null);
}
/**
* Ruft den Wert der statistics-Eigenschaft ab.
*
* @return
* possible object is
* {@link StatisticsPropertyType }
*
*/
public StatisticsPropertyType getStatistics() {
return statistics;
}
/**
* Legt den Wert der statistics-Eigenschaft fest.
*
* @param value
* allowed object is
* {@link StatisticsPropertyType }
*
*/
public void setStatistics(StatisticsPropertyType value) {
this.statistics = value;
}
public boolean isSetStatistics() {
return (this.statistics!= null);
}
/**
* Ruft den Wert der validationPlan-Eigenschaft ab.
*
* @return
* possible object is
* {@link ValidationPlanPropertyType }
*
*/
public ValidationPlanPropertyType getValidationPlan() {
return validationPlan;
}
/**
* Legt den Wert der validationPlan-Eigenschaft fest.
*
* @param value
* allowed object is
* {@link ValidationPlanPropertyType }
*
*/
public void setValidationPlan(ValidationPlanPropertyType value) {
this.validationPlan = value;
}
public boolean isSetValidationPlan() {
return (this.validationPlan!= null);
}
}
//
// Generated with ade-xjc - XML Schema binding compiler for CityGML ADEs, version 2.10.0
// ade-xjc is part of the citygml4j project, see https://github.com/citygml4j
// Any modifications to this file will be lost upon recompilation of the source
// Generated: Fri Nov 19 14:36:13 CET 2021
//
@javax.xml.bind.annotation.XmlSchema(namespace = "https://transfer.hft-stuttgart.de/pages/citydoctor/qualityade/0.1.4", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED, xmlns = {
@javax.xml.bind.annotation.XmlNs(namespaceURI = "https://transfer.hft-stuttgart.de/pages/citydoctor/qualityade/0.1.4", prefix = "qual")
})
package de.hft.stuttgart.quality.model.jaxb;
/*- /*
* Copyright 2020 Hochschule für Technik Stuttgart * Copyright 2021 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,41 +13,63 @@ ...@@ -13,41 +13,63 @@
* 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;
import java.util.Collections; package de.hft.stuttgart.quality;
import java.util.List;
import de.hft.stuttgart.quality.bind.QualityADEMarshaller;
import de.hft.stuttgart.quality.bind.QualityADEUnmarshaller;
import org.citygml4j.model.citygml.ade.binding.ADEContext; import org.citygml4j.model.citygml.ade.binding.ADEContext;
import org.citygml4j.model.citygml.ade.binding.ADEMarshaller; import org.citygml4j.model.citygml.ade.binding.ADEMarshaller;
import org.citygml4j.model.citygml.ade.binding.ADEUnmarshaller; import org.citygml4j.model.citygml.ade.binding.ADEUnmarshaller;
import org.citygml4j.model.citygml.ade.binding.ADEWalker;
import org.citygml4j.model.module.ade.ADEModule; import org.citygml4j.model.module.ade.ADEModule;
import org.citygml4j.util.walker.FeatureFunctionWalker;
import org.citygml4j.util.walker.FeatureWalker;
import org.citygml4j.util.walker.GMLFunctionWalker;
import org.citygml4j.util.walker.GMLWalker;
import de.hft.stuttgart.quality.marshaller.QualityAdeMarshaller; import java.util.Collections;
import de.hft.stuttgart.quality.marshaller.QualityAdeUnmarshaller; import java.util.List;
public class QualityADEContext implements ADEContext { public class QualityADEContext implements ADEContext {
private final List<ADEModule> modules = Collections.singletonList(QualityADEModule.V0_1_3);
@Override @Override
public List<ADEModule> getADEModules() { public List<ADEModule> getADEModules() {
return modules; return Collections.singletonList(QualityADEModule.v0_1_4);
} }
@Override
public List<String> getModelPackageNames() {
return Collections.singletonList("de.hft.stuttgart.quality.model");
}
@Override
public ADEMarshaller createADEMarshaller() {
return new QualityADEMarshaller();
}
@Override
public ADEUnmarshaller createADEUnmarshaller() {
return new QualityADEUnmarshaller();
}
@Override @Override
public List<String> getModelPackageNames() { public ADEWalker<FeatureWalker> createDefaultFeatureWalker() {
return Collections.singletonList("de.hft.stuttgart.quality.model"); return new de.hft.stuttgart.quality.walker.FeatureWalker();
} }
@Override @Override
public ADEMarshaller createADEMarshaller() { public ADEWalker<GMLWalker> createDefaultGMLWalker() {
return new QualityAdeMarshaller(); return new de.hft.stuttgart.quality.walker.GMLWalker();
} }
@Override @Override
public ADEUnmarshaller createADEUnmarshaller() { public <T> ADEWalker<FeatureFunctionWalker<T>> createDefaultFeatureFunctionWalker() {
return new QualityAdeUnmarshaller(); return new de.hft.stuttgart.quality.walker.FeatureFunctionWalker<>();
} }
@Override
public <T> ADEWalker<GMLFunctionWalker<T>> createDefaultGMLFunctionWalker() {
return new de.hft.stuttgart.quality.walker.GMLFunctionWalker<>();
}
} }
/*- /*
* Copyright 2020 Hochschule für Technik Stuttgart * Copyright 2021 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,69 +13,77 @@ ...@@ -13,69 +13,77 @@
* 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; package de.hft.stuttgart.quality;
import de.hft.stuttgart.quality.model.Validation;
import org.citygml4j.model.gml.feature.AbstractFeature;
import org.citygml4j.model.module.ade.ADEModule;
import org.citygml4j.model.module.citygml.CityGMLVersion;
import javax.xml.namespace.QName;
import java.net.URL; import java.net.URL;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import javax.xml.namespace.QName;
import org.citygml4j.model.gml.feature.AbstractFeature;
import org.citygml4j.model.module.ade.ADEModule;
import org.citygml4j.model.module.citygml.CityGMLVersion;
public class QualityADEModule extends ADEModule { public class QualityADEModule extends ADEModule {
public static final QualityADEModule v0_1_4 = new QualityADEModule();
private final Map<String, Class<? extends AbstractFeature>> features;
public static final String NAMESPACE_URI = "https://transfer.hft-stuttgart.de/pages/citydoctor/qualityade/0.1.3"; private QualityADEModule() {
super("https://transfer.hft-stuttgart.de/pages/citydoctor/qualityade/0.1.4",
"qual",
CityGMLVersion.v2_0_0);
public static final QualityADEModule V0_1_3 = new QualityADEModule(); features = new HashMap<>();
features.put("Validation", Validation.class);
private static final long serialVersionUID = -8208579547274734280L; }
public QualityADEModule() { @Override
super(NAMESPACE_URI, "qual", CityGMLVersion.v2_0_0); public URL getSchemaResource() {
} return getClass().getResource("/de/hft/stuttgart/quality/schema/qualityAde.xsd");
}
@Override
public URL getSchemaResource() {
return QualityADEContext.class.getResource("/qualityAde.xsd");
}
@Override @Override
public List<String> getJAXBPackageNames() { public List<String> getJAXBPackageNames() {
return Collections.singletonList("de.hft.stuttgart.quality.model.jaxb"); return Collections.singletonList("de.hft.stuttgart.quality.model.jaxb");
} }
@Override @Override
public boolean hasFeatureProperty(String name) { public boolean hasFeatureProperty(String name) {
return false; return false;
} }
@Override @Override
public boolean hasFeature(String name) { public boolean hasFeature(String name) {
return false; return features.containsKey(name);
} }
@Override @Override
public Class<? extends AbstractFeature> getFeatureClass(String name) { public Class<? extends AbstractFeature> getFeatureClass(String name) {
throw new IllegalStateException("No feature classes available"); return features.get(name);
} }
@Override @Override
public QName getFeatureName(Class<? extends AbstractFeature> featureClass) { public QName getFeatureName(Class<? extends AbstractFeature> featureClass) {
return null; for (Map.Entry<String, Class<? extends AbstractFeature>> entry : features.entrySet()) {
} if (entry.getValue() == featureClass) {
return new QName(getNamespaceURI(), entry.getKey());
}
}
@Override return null;
public Map<String, Class<? extends AbstractFeature>> getFeatures() { }
return Collections.emptyMap();
}
@Override @Override
public boolean isTopLevelFeature(String name) { public Map<String, Class<? extends AbstractFeature>> getFeatures() {
return false; return new HashMap<>(features);
} }
@Override
public boolean isTopLevelFeature(String name) {
return true;
}
} }
/*
* Copyright 2021 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.bind;
import de.hft.stuttgart.quality.model.ErrorType;
import de.hft.stuttgart.quality.model.*;
import de.hft.stuttgart.quality.model.jaxb.RequirementType;
import de.hft.stuttgart.quality.model.jaxb.*;
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 org.w3._1999.xlink.ActuateType;
import org.w3._1999.xlink.ShowType;
import org.w3._1999.xlink.TypeType;
import javax.xml.bind.JAXBElement;
import javax.xml.datatype.DatatypeConstants;
import javax.xml.datatype.XMLGregorianCalendar;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
public class QualityADEMarshaller implements ADEMarshaller {
private final ObjectFactory factory = new ObjectFactory();
private TypeMapper<JAXBElement<?>> elementMapper;
private TypeMapper<Object> typeMapper;
private ADEMarshallerHelper helper;
private synchronized TypeMapper<JAXBElement<?>> getElementMapper() {
if (elementMapper == null) {
elementMapper = TypeMapper.<JAXBElement<?>>create()
.with(PolygonHoleOutside.class, this::createPolygonHoleOutside)
.with(PolygonInnerRingsNested.class, this::createPolygonInnerRingsNested)
.with(PolygonInteriorDisconnected.class, this::createPolygonInteriorDisconnected)
.with(PolygonIntersectingRings.class, this::createPolygonIntersectingRings)
.with(PolygonNonPlanarDistancePlane.class, this::createPolygonNonPlanarDistancePlane)
.with(PolygonNonPlanarNormalsDeviation.class, this::createPolygonNonPlanarNormalsDeviation)
.with(PolygonOrientationRingsSame.class, this::createPolygonOrientationRingsSame)
.with(RingConsecutivePointsSame.class, this::createRingConsecutivePointsSame)
.with(RingNotClosed.class, this::createRingNotClosed)
.with(RingSelfIntersection.class, this::createRingSelfIntersection)
.with(RingTooFewPoints.class, this::createRingTooFewPoints)
.with(SemanticAttributeMissing.class, this::createSemanticAttributeMissing)
.with(SemanticAttributeWrongValue.class, this::createSemanticAttributeWrongValue)
.with(SolidAllPolygonsWrongOrientation.class, this::createSolidAllPolygonsWrongOrientation)
.with(SolidMultipleConnectedComponents.class, this::createSolidMultipleConnectedComponents)
.with(SolidNonManifoldEdge.class, this::createSolidNonManifoldEdge)
.with(SolidNonManifoldVertex.class, this::createSolidNonManifoldVertex)
.with(SolidNotClosed.class, this::createSolidNotClosed)
.with(SolidPolygonWrongOrientation.class, this::createSolidPolygonWrongOrientation)
.with(SolidSelfIntersection.class, this::createSolidSelfIntersection)
.with(SolidTooFewPolygons.class, this::createSolidTooFewPolygons)
.with(Validation.class, this::createValidation)
.with(ValidationResultPropertyElement.class, this::createValidationResultPropertyElement);
}
return elementMapper;
}
private synchronized TypeMapper<Object> getTypeMapper() {
if (typeMapper == null) {
typeMapper = TypeMapper.create()
.with(Edge.class, this::marshalEdge)
.with(ErrorStatistics.class, this::marshalErrorStatistics)
.with(FeatureStatistics.class, this::marshalFeatureStatistics)
.with(Filter.class, this::marshalFilter)
.with(Parameter.class, this::marshalParameter)
.with(PolygonHoleOutside.class, this::marshalPolygonHoleOutside)
.with(PolygonInnerRingsNested.class, this::marshalPolygonInnerRingsNested)
.with(PolygonInteriorDisconnected.class, this::marshalPolygonInteriorDisconnected)
.with(PolygonIntersectingRings.class, this::marshalPolygonIntersectingRings)
.with(PolygonNonPlanarDistancePlane.class, this::marshalPolygonNonPlanarDistancePlane)
.with(PolygonNonPlanarNormalsDeviation.class, this::marshalPolygonNonPlanarNormalsDeviation)
.with(PolygonOrientationRingsSame.class, this::marshalPolygonOrientationRingsSame)
.with(Parameter.class, this::marshalParameter)
.with(RingConsecutivePointsSame.class, this::marshalRingConsecutivePointsSame)
.with(RingNotClosed.class, this::marshalRingNotClosed)
.with(RingSelfIntersection.class, this::marshalRingSelfIntersection)
.with(RingTooFewPoints.class, this::marshalRingTooFewPoints)
.with(SemanticAttributeMissing.class, this::marshalSemanticAttributeMissing)
.with(SemanticAttributeWrongValue.class, this::marshalSemanticAttributeWrongValue)
.with(SolidAllPolygonsWrongOrientation.class, this::marshalSolidAllPolygonsWrongOrientation)
.with(SolidMultipleConnectedComponents.class, this::marshalSolidMultipleConnectedComponents)
.with(SolidNonManifoldEdge.class, this::marshalSolidNonManifoldEdge)
.with(SolidNonManifoldVertex.class, this::marshalSolidNonManifoldVertex)
.with(SolidNotClosed.class, this::marshalSolidNotClosed)
.with(SolidPolygonWrongOrientation.class, this::marshalSolidPolygonWrongOrientation)
.with(SolidSelfIntersection.class, this::marshalSolidSelfIntersection)
.with(SolidTooFewPolygons.class, this::marshalSolidTooFewPolygons)
.with(Statistics.class, this::marshalStatistics)
.with(Validation.class, this::marshalValidation)
.with(ValidationPlan.class, this::marshalValidationPlan)
.with(ValidationProperty.class, this::marshalValidationProperty)
.with(ValidationResult.class, this::marshalValidationResult)
.with(ValidationResultProperty.class, this::marshalValidationResultProperty);
}
return typeMapper;
}
@Override
public void setADEMarshallerHelper(ADEMarshallerHelper helper) {
this.helper = helper;
}
@Override
public JAXBElement<?> marshalJAXBElement(ADEModelObject src) {
TypeMapper<JAXBElement<?>> elementMapper = getElementMapper();
return elementMapper != null ? elementMapper.apply(src) : null;
}
@Override
public Object marshal(ADEModelObject src) {
TypeMapper<Object> typeMapper = getTypeMapper();
return typeMapper != null ? typeMapper.apply(src) : null;
}
private void marshalAbstractPolygonError(AbstractPolygonError src, AbstractPolygonErrorType dest) {
if (src.getPolygonId() != null) {
dest.setPolygonId(src.getPolygonId());
}
}
private void marshalAbstractRingError(AbstractRingError src, AbstractRingErrorType dest) {
if (src.getLinearRingId() != null) {
dest.setLinearRingId(src.getLinearRingId());
}
}
private void marshalAbstractSolidError(AbstractSolidError src, AbstractSolidErrorType dest) {
if (src.getGeometryId() != null) {
dest.setGeometryId(src.getGeometryId());
}
}
private EdgeType marshalEdge(Edge src) {
EdgeType dest = factory.createEdgeType();
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 ErrorStatisticsType marshalErrorStatistics(ErrorStatistics src) {
ErrorStatisticsType dest = factory.createErrorStatisticsType();
dest.setOccurrences(BigInteger.valueOf(src.getOccurrences()));
if (src.isSetErrors()) {
for (ErrorType errorType : src.getErrors()) {
de.hft.stuttgart.quality.model.jaxb.ErrorType error = factory.createErrorType();
error.setName(ErrorTypeType.fromValue(errorType.name()));
ErrorPropertyType property = factory.createErrorPropertyType();
property.setError(error);
dest.getError().add(property);
}
}
return dest;
}
private FeatureStatisticsType marshalFeatureStatistics(FeatureStatistics src) {
FeatureStatisticsType dest = factory.createFeatureStatisticsType();
dest.setNumChecked(BigInteger.valueOf(src.getNumChecked()));
dest.setNumErrors(BigInteger.valueOf(src.getNumErrors()));
return dest;
}
private FilterType marshalFilter(Filter src) {
FilterType dest = factory.createFilterType();
if (src.isSetFeatureTypes()) {
for (FeatureType featureType : src.getFeatureTypes()) {
CheckingType checking = factory.createCheckingType();
checking.setFeatureType(FeatureTypeType.fromValue(featureType.name()));
CheckingPropertyType property = factory.createCheckingPropertyType();
property.setChecking(checking);
dest.getChecking().add(property);
}
}
return dest;
}
private ParameterType marshalParameter(Parameter src) {
ParameterType dest = factory.createParameterType();
if (src.getName() != null) {
dest.setName(src.getName());
}
if (src.getUom() != null) {
dest.setUom(src.getUom());
}
if (src.getValue() != null) {
dest.setValue(src.getValue());
}
return dest;
}
private PolygonHoleOutsideType marshalPolygonHoleOutside(PolygonHoleOutside src) {
PolygonHoleOutsideType dest = factory.createPolygonHoleOutsideType();
marshalAbstractPolygonError(src, dest);
if (src.getLinearRingId() != null) {
dest.setLinearRingId(src.getLinearRingId());
}
return dest;
}
private PolygonInnerRingsNestedType marshalPolygonInnerRingsNested(PolygonInnerRingsNested src) {
PolygonInnerRingsNestedType dest = factory.createPolygonInnerRingsNestedType();
marshalAbstractPolygonError(src, dest);
if (src.getLinearRingId1() != null) {
dest.setLinearRingId1(src.getLinearRingId1());
}
if (src.getLinearRingId2() != null) {
dest.setLinearRingId2(src.getLinearRingId2());
}
return dest;
}
private PolygonInteriorDisconnectedType marshalPolygonInteriorDisconnected(PolygonInteriorDisconnected src) {
PolygonInteriorDisconnectedType dest = factory.createPolygonInteriorDisconnectedType();
marshalAbstractPolygonError(src, dest);
return dest;
}
private PolygonIntersectingRingsType marshalPolygonIntersectingRings(PolygonIntersectingRings src) {
PolygonIntersectingRingsType dest = factory.createPolygonIntersectingRingsType();
marshalAbstractPolygonError(src, dest);
if (src.getLinearRingId1() != null) {
dest.setLinearRingId1(src.getLinearRingId1());
}
if (src.getLinearRingId2() != null) {
dest.setLinearRingId2(src.getLinearRingId2());
}
return dest;
}
private PolygonNonPlanarDistancePlaneType marshalPolygonNonPlanarDistancePlane(PolygonNonPlanarDistancePlane src) {
PolygonNonPlanarDistancePlaneType dest = factory.createPolygonNonPlanarDistancePlaneType();
marshalAbstractPolygonError(src, dest);
if (src.getDistance() != null) {
dest.setDistance(helper.getGMLMarshaller().marshalLength(src.getDistance()));
}
if (src.getVertex() != null) {
dest.setVertex(helper.getGMLMarshaller().marshalDirectPosition(src.getVertex()));
}
return dest;
}
private PolygonNonPlanarNormalsDeviationType marshalPolygonNonPlanarNormalsDeviation(PolygonNonPlanarNormalsDeviation src) {
PolygonNonPlanarNormalsDeviationType dest = factory.createPolygonNonPlanarNormalsDeviationType();
marshalAbstractPolygonError(src, dest);
if (src.getDeviation() != null) {
dest.setDeviation(helper.getGMLMarshaller().marshalAngle(src.getDeviation()));
}
return dest;
}
private PolygonOrientationRingsSameType marshalPolygonOrientationRingsSame(PolygonOrientationRingsSame src) {
PolygonOrientationRingsSameType dest = factory.createPolygonOrientationRingsSameType();
marshalAbstractPolygonError(src, dest);
if (src.getLinearRingId() != null) {
dest.setLinearRingId(src.getLinearRingId());
}
return dest;
}
private RequirementType marshalRequirement(Requirement src) {
RequirementType dest = factory.createRequirementType();
dest.setEnabled(src.isEnabled());
if (src.getRequirementType() != null) {
dest.setRequirementType(RequirementTypeType.fromValue(src.getRequirementType().name()));
}
if (src.isSetParameters()) {
for (Parameter parameter : src.getParameters()) {
ParameterPropertyType property = factory.createParameterPropertyType();
property.setParameter(marshalParameter(parameter));
dest.getParameter().add(property);
}
}
return dest;
}
private RingConsecutivePointsSameType marshalRingConsecutivePointsSame(RingConsecutivePointsSame src) {
RingConsecutivePointsSameType dest = factory.createRingConsecutivePointsSameType();
marshalAbstractRingError(src, dest);
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 RingNotClosedType marshalRingNotClosed(RingNotClosed src) {
RingNotClosedType dest = factory.createRingNotClosedType();
marshalAbstractRingError(src, dest);
return dest;
}
private RingSelfIntersectionType marshalRingSelfIntersection(RingSelfIntersection src) {
RingSelfIntersectionType dest = factory.createRingSelfIntersectionType();
marshalAbstractRingError(src, dest);
if (src.getEdge1() != null) {
EdgePropertyType property = factory.createEdgePropertyType();
property.setEdge(marshalEdge(src.getEdge1()));
dest.setEdge1(property);
}
if (src.getEdge2() != null) {
EdgePropertyType property = factory.createEdgePropertyType();
property.setEdge(marshalEdge(src.getEdge2()));
dest.setEdge2(property);
}
if (src.getType() != null) {
dest.setType(src.getType());
}
if (src.getVertex() != null) {
dest.setVertex(helper.getGMLMarshaller().marshalDirectPosition(src.getVertex()));
}
return dest;
}
private RingTooFewPointsType marshalRingTooFewPoints(RingTooFewPoints src) {
RingTooFewPointsType dest = factory.createRingTooFewPointsType();
marshalAbstractRingError(src, dest);
return dest;
}
private SemanticAttributeMissingType marshalSemanticAttributeMissing(SemanticAttributeMissing src) {
SemanticAttributeMissingType dest = factory.createSemanticAttributeMissingType();
if (src.getAttributeName() != null) {
dest.setAttributeName(src.getAttributeName());
}
if (src.getChildId() != null) {
dest.setChildId(src.getChildId());
}
dest.setGeneric(src.isGeneric());
return dest;
}
private SemanticAttributeWrongValueType marshalSemanticAttributeWrongValue(SemanticAttributeWrongValue src) {
SemanticAttributeWrongValueType dest = factory.createSemanticAttributeWrongValueType();
if (src.getAttributeName() != null) {
dest.setAttributeName(src.getAttributeName());
}
if (src.getChildId() != null) {
dest.setChildId(src.getChildId());
}
dest.setGeneric(src.isGeneric());
return dest;
}
private SolidAllPolygonsWrongOrientationType marshalSolidAllPolygonsWrongOrientation(SolidAllPolygonsWrongOrientation src) {
SolidAllPolygonsWrongOrientationType dest = factory.createSolidAllPolygonsWrongOrientationType();
marshalAbstractSolidError(src, dest);
return dest;
}
private SolidMultipleConnectedComponentsType marshalSolidMultipleConnectedComponents(SolidMultipleConnectedComponents src) {
SolidMultipleConnectedComponentsType dest = factory.createSolidMultipleConnectedComponentsType();
marshalAbstractSolidError(src, dest);
if (src.isSetComponents()) {
for (Component component : src.getComponents()) {
ComponentListType componentList = factory.createComponentListType();
if (component.isSetPolygonIds()) {
for (String polygonId : component.getPolygonIds()) {
PolygonIdListType polygonIdList = factory.createPolygonIdListType();
polygonIdList.setPolygonId(polygonId);
PolygonIdListPropertyType property = factory.createPolygonIdListPropertyType();
property.setPolygonIdList(polygonIdList);
componentList.getComponent().add(property);
}
}
ComponentListPropertyType property = factory.createComponentListPropertyType();
property.setComponentList(componentList);
dest.getComponents().add(property);
}
}
return dest;
}
private SolidNonManifoldEdgeType marshalSolidNonManifoldEdge(SolidNonManifoldEdge src) {
SolidNonManifoldEdgeType dest = factory.createSolidNonManifoldEdgeType();
marshalAbstractSolidError(src, dest);
if (src.isSetEdges()) {
EdgeListType edgeList = factory.createEdgeListType();
for (Edge edge : src.getEdges()) {
EdgePropertyType property = factory.createEdgePropertyType();
property.setEdge(marshalEdge(edge));
edgeList.getEdge().add(property);
}
EdgeListPropertyType property = factory.createEdgeListPropertyType();
dest.setEdges(property);
}
return dest;
}
private SolidNonManifoldVertexType marshalSolidNonManifoldVertex(SolidNonManifoldVertex src) {
SolidNonManifoldVertexType dest = factory.createSolidNonManifoldVertexType();
marshalAbstractSolidError(src, dest);
if (src.getVertex() != null) {
dest.setVertex(helper.getGMLMarshaller().marshalDirectPosition(src.getVertex()));
}
return dest;
}
private SolidNotClosedType marshalSolidNotClosed(SolidNotClosed src) {
SolidNotClosedType dest = factory.createSolidNotClosedType();
marshalAbstractSolidError(src, dest);
if (src.isSetEdges()) {
EdgeListType edgeList = factory.createEdgeListType();
for (Edge edge : src.getEdges()) {
EdgePropertyType property = factory.createEdgePropertyType();
property.setEdge(marshalEdge(edge));
edgeList.getEdge().add(property);
}
EdgeListPropertyType property = factory.createEdgeListPropertyType();
dest.setEdges(property);
}
return dest;
}
private SolidPolygonWrongOrientationType marshalSolidPolygonWrongOrientation(SolidPolygonWrongOrientation src) {
SolidPolygonWrongOrientationType dest = factory.createSolidPolygonWrongOrientationType();
marshalAbstractSolidError(src, dest);
if (src.isSetEdges()) {
EdgeListType edgeList = factory.createEdgeListType();
for (Edge edge : src.getEdges()) {
EdgePropertyType property = factory.createEdgePropertyType();
property.setEdge(marshalEdge(edge));
edgeList.getEdge().add(property);
}
EdgeListPropertyType property = factory.createEdgeListPropertyType();
dest.setEdges(property);
}
return dest;
}
private SolidSelfIntersectionType marshalSolidSelfIntersection(SolidSelfIntersection src) {
SolidSelfIntersectionType dest = factory.createSolidSelfIntersectionType();
marshalAbstractSolidError(src, dest);
if (src.getPolygonId1() != null) {
dest.setPolygonId1(src.getPolygonId1());
}
if (src.getPolygonId2() != null) {
dest.setPolygonId2(src.getPolygonId2());
}
return dest;
}
private SolidTooFewPolygonsType marshalSolidTooFewPolygons(SolidTooFewPolygons src) {
SolidTooFewPolygonsType dest = factory.createSolidTooFewPolygonsType();
marshalAbstractSolidError(src, dest);
return dest;
}
private StatisticsType marshalStatistics(Statistics src) {
StatisticsType dest = factory.createStatisticsType();
if (src.getNumErrorBridgeObjects() != null) {
FeatureStatisticsPropertyType property = factory.createFeatureStatisticsPropertyType();
property.setFeatureStatistics(marshalFeatureStatistics(src.getNumErrorBridgeObjects()));
dest.setNumErrorBridgeObjects(property);
}
if (src.getNumErrorBuildings() != null) {
FeatureStatisticsPropertyType property = factory.createFeatureStatisticsPropertyType();
property.setFeatureStatistics(marshalFeatureStatistics(src.getNumErrorBuildings()));
dest.setNumErrorBuildings(property);
}
if (src.getNumErrorLandObjects() != null) {
FeatureStatisticsPropertyType property = factory.createFeatureStatisticsPropertyType();
property.setFeatureStatistics(marshalFeatureStatistics(src.getNumErrorLandObjects()));
dest.setNumErrorLandObjects(property);
}
if (src.getNumErrorTransportation() != null) {
FeatureStatisticsPropertyType property = factory.createFeatureStatisticsPropertyType();
property.setFeatureStatistics(marshalFeatureStatistics(src.getNumErrorTransportation()));
dest.setNumErrorTransportation(property);
}
if (src.getNumErrorVegetation() != null) {
FeatureStatisticsPropertyType property = factory.createFeatureStatisticsPropertyType();
property.setFeatureStatistics(marshalFeatureStatistics(src.getNumErrorVegetation()));
dest.setNumErrorVegetation(property);
}
if (src.getNumErrorWaterObjects() != null) {
FeatureStatisticsPropertyType property = factory.createFeatureStatisticsPropertyType();
property.setFeatureStatistics(marshalFeatureStatistics(src.getNumErrorWaterObjects()));
dest.setNumErrorWaterObjects(property);
}
if (src.getErrorStatistics() != null) {
ErrorStatisticsPropertyType property = factory.createErrorStatisticsPropertyType();
property.setErrorStatistics(marshalErrorStatistics(src.getErrorStatistics()));
dest.setErrorStatistics(property);
}
return dest;
}
public ValidationType marshalValidation(Validation src) {
ValidationType dest = factory.createValidationType();
helper.getGMLMarshaller().marshalAbstractFeature(src, dest);
if (src.getValidationDate() != null) {
ZonedDateTime validationDate = src.getValidationDate();
XMLGregorianCalendar value = helper.getJAXBMarshaller().getDataTypeFactory().newXMLGregorianCalendar(
validationDate.getYear(),
validationDate.getMonthValue(),
validationDate.getDayOfMonth(),
validationDate.getHour(),
validationDate.getMinute(),
validationDate.getSecond(),
DatatypeConstants.FIELD_UNDEFINED,
validationDate.getOffset() != ZoneOffset.UTC ?
validationDate.getOffset().getTotalSeconds() / 60 :
DatatypeConstants.FIELD_UNDEFINED);
if (validationDate.getNano() != 0) {
value.setFractionalSecond(BigDecimal.valueOf(validationDate.getNano(), 9).stripTrailingZeros());
}
dest.setValidationDate(value);
}
if (src.getValidationSoftware() != null) {
dest.setValidationSoftware(src.getValidationSoftware());
}
if (src.getValidationPlan() != null) {
ValidationPlanPropertyType property = factory.createValidationPlanPropertyType();
property.setValidationPlan(marshalValidationPlan(src.getValidationPlan()));
dest.setValidationPlan(property);
}
if (src.getStatistics() != null) {
StatisticsPropertyType property = factory.createStatisticsPropertyType();
property.setStatistics(marshalStatistics(src.getStatistics()));
dest.setStatistics(property);
}
return dest;
}
public ValidationPlanType marshalValidationPlan(ValidationPlan src) {
ValidationPlanType dest = factory.createValidationPlanType();
if (src.isSetGlobalParameters()) {
GlobalParametersType globalParameters = factory.createGlobalParametersType();
for (Parameter parameter : src.getGlobalParameters()) {
ParameterPropertyType property = factory.createParameterPropertyType();
property.setParameter(marshalParameter(parameter));
globalParameters.getParameter().add(property);
}
GlobalParametersPropertyType property = factory.createGlobalParametersPropertyType();
property.setGlobalParameters(globalParameters);
dest.setGlobalParameters(property);
}
if (src.getFilter() != null) {
FilterPropertyType property = factory.createFilterPropertyType();
property.setFilter(marshalFilter(src.getFilter()));
dest.setFilter(property);
}
if (src.getRequirement() != null) {
RequirementPropertyType property = factory.createRequirementPropertyType();
property.setRequirement(marshalRequirement(src.getRequirement()));
dest.setRequirement(property);
}
return dest;
}
public ValidationPropertyType marshalValidationProperty(ValidationProperty src) {
ValidationPropertyType dest = factory.createValidationPropertyType();
if (src.isSetFeature()) {
dest.setValidation(marshalValidation(src.getFeature()));
}
if (src.isSetRemoteSchema())
dest.setRemoteSchema(src.getRemoteSchema());
if (src.isSetType())
dest.setType(TypeType.fromValue(src.getType().getValue()));
if (src.isSetHref())
dest.setHref(src.getHref());
if (src.isSetRole())
dest.setRole(src.getRole());
if (src.isSetArcrole())
dest.setArcrole(src.getArcrole());
if (src.isSetTitle())
dest.setTitle(src.getTitle());
if (src.isSetShow())
dest.setShow(ShowType.fromValue(src.getShow().getValue()));
if (src.isSetActuate())
dest.setActuate(ActuateType.fromValue(src.getActuate().getValue()));
return dest;
}
@SuppressWarnings("unchecked")
private ValidationResultType marshalValidationResult(ValidationResult src) {
ValidationResultType dest = factory.createValidationResultType();
if (src.getValidation() != null) {
dest.setValidationPlanID(marshalValidationProperty(src.getValidation()));
}
if (src.isSetErrors()) {
for (AbstractError error : src.getErrors()) {
JAXBElement<?> element = helper.getJAXBMarshaller().marshalJAXBElement(error);
if (element != null && element.getValue() instanceof AbstractErrorType) {
AbstractErrorPropertyType property = factory.createAbstractErrorPropertyType();
property.setAbstractError((JAXBElement<? extends AbstractErrorType> ) element);
dest.getError().add(property);
}
}
}
if (src.getResultType() != null) {
dest.setResultType(ResultTypeType.fromValue(src.getResultType().name()));
}
return dest;
}
public ValidationResultPropertyType marshalValidationResultProperty(ValidationResultProperty src) {
ValidationResultPropertyType dest = factory.createValidationResultPropertyType();
if (src.isSetObject()) {
dest.setValidationResult(marshalValidationResult(src.getObject()));
}
return dest;
}
private JAXBElement<?> createPolygonHoleOutside(PolygonHoleOutside src) {
return factory.createPolygonHoleOutside(marshalPolygonHoleOutside(src));
}
private JAXBElement<?> createPolygonInnerRingsNested(PolygonInnerRingsNested src) {
return factory.createPolygonInnerRingsNested(marshalPolygonInnerRingsNested(src));
}
private JAXBElement<?> createPolygonInteriorDisconnected(PolygonInteriorDisconnected src) {
return factory.createPolygonInteriorDisconnected(marshalPolygonInteriorDisconnected(src));
}
private JAXBElement<?> createPolygonIntersectingRings(PolygonIntersectingRings src) {
return factory.createPolygonIntersectingRings(marshalPolygonIntersectingRings(src));
}
private JAXBElement<?> createPolygonNonPlanarDistancePlane(PolygonNonPlanarDistancePlane src) {
return factory.createPolygonNonPlanarDistancePlane(marshalPolygonNonPlanarDistancePlane(src));
}
private JAXBElement<?> createPolygonNonPlanarNormalsDeviation(PolygonNonPlanarNormalsDeviation src) {
return factory.createPolygonNonPlanarNormalsDeviation(marshalPolygonNonPlanarNormalsDeviation(src));
}
private JAXBElement<?> createPolygonOrientationRingsSame(PolygonOrientationRingsSame src) {
return factory.createPolygonOrientationRingsSame(marshalPolygonOrientationRingsSame(src));
}
private JAXBElement<?> createRingConsecutivePointsSame(RingConsecutivePointsSame src) {
return factory.createRingConsecutivePointsSame(marshalRingConsecutivePointsSame(src));
}
private JAXBElement<?> createRingNotClosed(RingNotClosed src) {
return factory.createRingNotClosed(marshalRingNotClosed(src));
}
private JAXBElement<?> createRingSelfIntersection(RingSelfIntersection src) {
return factory.createRingSelfIntersection(marshalRingSelfIntersection(src));
}
private JAXBElement<?> createRingTooFewPoints(RingTooFewPoints src) {
return factory.createRingTooFewPoints(marshalRingTooFewPoints(src));
}
private JAXBElement<?> createSemanticAttributeMissing(SemanticAttributeMissing src) {
return factory.createSemanticAttributeMissing(marshalSemanticAttributeMissing(src));
}
private JAXBElement<?> createSemanticAttributeWrongValue(SemanticAttributeWrongValue src) {
return factory.createSemanticAttributeWrongValue(marshalSemanticAttributeWrongValue(src));
}
private JAXBElement<?> createSolidAllPolygonsWrongOrientation(SolidAllPolygonsWrongOrientation src) {
return factory.createSolidAllPolygonsWrongOrientation(marshalSolidAllPolygonsWrongOrientation(src));
}
private JAXBElement<?> createSolidMultipleConnectedComponents(SolidMultipleConnectedComponents src) {
return factory.createSolidMultipleConnectedComponents(marshalSolidMultipleConnectedComponents(src));
}
private JAXBElement<?> createSolidNonManifoldEdge(SolidNonManifoldEdge src) {
return factory.createSolidNonManifoldEdge(marshalSolidNonManifoldEdge(src));
}
private JAXBElement<?> createSolidNonManifoldVertex(SolidNonManifoldVertex src) {
return factory.createSolidNonManifoldVertex(marshalSolidNonManifoldVertex(src));
}
private JAXBElement<?> createSolidNotClosed(SolidNotClosed src) {
return factory.createSolidNotClosed(marshalSolidNotClosed(src));
}
private JAXBElement<?> createSolidPolygonWrongOrientation(SolidPolygonWrongOrientation src) {
return factory.createSolidPolygonWrongOrientation(marshalSolidPolygonWrongOrientation(src));
}
private JAXBElement<?> createSolidSelfIntersection(SolidSelfIntersection src) {
return factory.createSolidSelfIntersection(marshalSolidSelfIntersection(src));
}
private JAXBElement<?> createSolidTooFewPolygons(SolidTooFewPolygons src) {
return factory.createSolidTooFewPolygons(marshalSolidTooFewPolygons(src));
}
public JAXBElement<?> createValidation(Validation src) {
return factory.createValidation(marshalValidation(src));
}
public JAXBElement<?> createValidationResultPropertyElement(ValidationResultPropertyElement src) {
return factory.createValidationResultProperty(marshalValidationResultProperty(src.getValue()));
}
}
/*
* Copyright 2021 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.bind;
import de.hft.stuttgart.quality.model.ErrorType;
import de.hft.stuttgart.quality.model.RequirementType;
import de.hft.stuttgart.quality.model.*;
import de.hft.stuttgart.quality.model.jaxb.*;
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.model.common.base.ModelObject;
import org.citygml4j.model.gml.xlink.XLinkActuate;
import org.citygml4j.model.gml.xlink.XLinkShow;
import org.citygml4j.model.gml.xlink.XLinkType;
import org.citygml4j.util.mapper.CheckedTypeMapper;
import org.citygml4j.xml.io.reader.MissingADESchemaException;
import javax.xml.bind.JAXBElement;
import javax.xml.datatype.DatatypeConstants;
import javax.xml.datatype.XMLGregorianCalendar;
public class QualityADEUnmarshaller implements ADEUnmarshaller {
private CheckedTypeMapper<ADEModelObject> typeMapper;
private ADEUnmarshallerHelper helper;
private synchronized CheckedTypeMapper<ADEModelObject> getTypeMapper() {
if (typeMapper == null) {
typeMapper = CheckedTypeMapper.<ADEModelObject>create()
.with(EdgeType.class, this::unmarshalEdge)
.with(ErrorStatisticsType.class, this::unmarshalErrorStatistics)
.with(FeatureStatisticsType.class, this::unmarshalFeatureStatistics)
.with(FilterType.class, this::unmarshalFilter)
.with(ParameterType.class, this::unmarshalParameter)
.with(PolygonHoleOutsideType.class, this::unmarshalPolygonHoleOutside)
.with(PolygonInnerRingsNestedType.class, this::unmarshalPolygonInnerRingsNested)
.with(PolygonInteriorDisconnectedType.class, this::unmarshalPolygonInteriorDisconnected)
.with(PolygonIntersectingRingsType.class, this::unmarshalPolygonIntersectingRings)
.with(PolygonNonPlanarDistancePlaneType.class, this::unmarshalPolygonNonPlanarDistancePlane)
.with(PolygonNonPlanarNormalsDeviationType.class, this::unmarshalPolygonNonPlanarNormalsDeviation)
.with(PolygonOrientationRingsSameType.class, this::unmarshalPolygonOrientationRingsSame)
.with(de.hft.stuttgart.quality.model.jaxb.RequirementType.class, this::unmarshalRequirement)
.with(RingConsecutivePointsSameType.class, this::unmarshalRingConsecutivePointsSame)
.with(RingNotClosedType.class, this::unmarshalRingNotClosed)
.with(RingSelfIntersectionType.class, this::unmarshalRingSelfIntersection)
.with(RingTooFewPointsType.class, this::unmarshalRingTooFewPoints)
.with(SemanticAttributeMissingType.class, this::unmarshalSemanticAttributeMissing)
.with(SemanticAttributeWrongValueType.class, this::unmarshalSemanticAttributeWrongValue)
.with(SolidAllPolygonsWrongOrientationType.class, this::unmarshalSolidAllPolygonsWrongOrientation)
.with(SolidMultipleConnectedComponentsType.class, this::unmarshalSolidMultipleConnectedComponents)
.with(SolidNonManifoldEdgeType.class, this::unmarshalSolidNonManifoldEdge)
.with(SolidNonManifoldVertexType.class, this::unmarshalSolidNonManifoldVertex)
.with(SolidNotClosedType.class, this::unmarshalSolidNotClosed)
.with(SolidPolygonWrongOrientationType.class, this::unmarshalSolidPolygonWrongOrientation)
.with(SolidSelfIntersectionType.class, this::unmarshalSolidSelfIntersection)
.with(SolidTooFewPolygonsType.class, this::unmarshalSolidTooFewPolygons)
.with(StatisticsType.class, this::unmarshalStatistics)
.with(ValidationType.class, this::unmarshalValidation)
.with(ValidationPlanType.class, this::unmarshalValidationPlan)
.with(ValidationPropertyType.class, this::unmarshalValidationProperty)
.with(ValidationResultType.class, this::unmarshalValidationResult)
.with(ValidationResultPropertyType.class, this::unmarshalValidationResultProperty);
}
return typeMapper;
}
@Override
public void setADEUnmarshallerHelper(ADEUnmarshallerHelper helper) {
this.helper = helper;
}
@Override
public ADEModelObject unmarshal(JAXBElement<?> src) throws MissingADESchemaException {
final Object value = src.getValue();
// generic application properties
if ("validationResult".equals(src.getName().getLocalPart())) {
return new ValidationResultPropertyElement(unmarshalValidationResultProperty((ValidationResultPropertyType) src.getValue()));
} else {
return unmarshal(value);
}
}
@Override
public ADEModelObject unmarshal(Object src) throws MissingADESchemaException {
CheckedTypeMapper<ADEModelObject> typeMapper = getTypeMapper();
return typeMapper != null ? typeMapper.apply(src) : null;
}
private void unmarshalAbstractPolygonError(AbstractPolygonErrorType src, AbstractPolygonError dest) {
if (src.isSetPolygonId()) {
dest.setPolygonId(src.getPolygonId());
}
}
private void unmarshalAbstractRingError(AbstractRingErrorType src, AbstractRingError dest) {
if (src.isSetLinearRingId()) {
dest.setLinearRingId(src.getLinearRingId());
}
}
private void unmarshalAbstractSolidError(AbstractSolidErrorType src, AbstractSolidError dest) {
if (src.isSetGeometryId()) {
dest.setGeometryId(src.getGeometryId());
}
}
private Edge unmarshalEdge(EdgeType src) {
Edge dest = new Edge();
if (src.isSetFrom()) {
dest.setFrom(helper.getGMLUnmarshaller().unmarshalDirectPosition(src.getFrom()));
}
if (src.isSetTo()) {
dest.setTo(helper.getGMLUnmarshaller().unmarshalDirectPosition(src.getTo()));
}
return dest;
}
private ErrorStatistics unmarshalErrorStatistics(ErrorStatisticsType src) {
ErrorStatistics dest = new ErrorStatistics();
if (src.isSetOccurrences()) {
dest.setOccurrences(src.getOccurrences().intValue());
}
if (src.isSetError()) {
for (ErrorPropertyType property : src.getError()) {
if (property.isSetError() && property.getError().isSetName()) {
dest.getErrors().add(ErrorType.fromValue(property.getError().getName().value()));
}
}
}
return dest;
}
private FeatureStatistics unmarshalFeatureStatistics(FeatureStatisticsType src) {
FeatureStatistics dest = new FeatureStatistics();
if (src.isSetNumChecked()) {
dest.setNumChecked(src.getNumChecked().intValue());
}
if (src.isSetNumErrors()) {
dest.setNumErrors(src.getNumErrors().intValue());
}
return dest;
}
private Filter unmarshalFilter(FilterType src) {
Filter dest = new Filter();
if (src.isSetChecking()) {
for (CheckingPropertyType property : src.getChecking()) {
if (property.isSetChecking()
&& property.getChecking().isSetFeatureType()) {
dest.getFeatureTypes().add(FeatureType.fromValue(property.getChecking().getFeatureType().value()));
}
}
}
return dest;
}
private Parameter unmarshalParameter(ParameterType src) {
Parameter dest = new Parameter();
if (src.isSetName()) {
dest.setName(src.getName());
}
if (src.isSetUom()) {
dest.setUom(src.getUom());
}
if (src.isSetValue()) {
dest.setValue(src.getValue());
}
return dest;
}
private PolygonHoleOutside unmarshalPolygonHoleOutside(PolygonHoleOutsideType src) {
PolygonHoleOutside dest = new PolygonHoleOutside();
unmarshalAbstractPolygonError(src, dest);
if (src.isSetLinearRingId()) {
dest.setLinearRingId(src.getLinearRingId());
}
return dest;
}
private PolygonInnerRingsNested unmarshalPolygonInnerRingsNested(PolygonInnerRingsNestedType src) {
PolygonInnerRingsNested dest = new PolygonInnerRingsNested();
unmarshalAbstractPolygonError(src, dest);
if (src.isSetLinearRingId1()) {
dest.setLinearRingId1(src.getLinearRingId1());
}
if (src.isSetLinearRingId2()) {
dest.setLinearRingId2(src.getLinearRingId2());
}
return dest;
}
private PolygonInteriorDisconnected unmarshalPolygonInteriorDisconnected(PolygonInteriorDisconnectedType src) {
PolygonInteriorDisconnected dest = new PolygonInteriorDisconnected();
unmarshalAbstractPolygonError(src, dest);
return dest;
}
private PolygonIntersectingRings unmarshalPolygonIntersectingRings(PolygonIntersectingRingsType src) {
PolygonIntersectingRings dest = new PolygonIntersectingRings();
unmarshalAbstractPolygonError(src, dest);
if (src.isSetLinearRingId1()) {
dest.setLinearRingId1(src.getLinearRingId1());
}
if (src.isSetLinearRingId2()) {
dest.setLinearRingId2(src.getLinearRingId2());
}
return dest;
}
private PolygonNonPlanarDistancePlane unmarshalPolygonNonPlanarDistancePlane(PolygonNonPlanarDistancePlaneType src) {
PolygonNonPlanarDistancePlane dest = new PolygonNonPlanarDistancePlane();
unmarshalAbstractPolygonError(src, dest);
if (src.isSetDistance()) {
dest.setDistance(helper.getGMLUnmarshaller().unmarshalLength(src.getDistance()));
}
if (src.isSetVertex()) {
dest.setVertex(helper.getGMLUnmarshaller().unmarshalDirectPosition(src.getVertex()));
}
return dest;
}
private PolygonNonPlanarNormalsDeviation unmarshalPolygonNonPlanarNormalsDeviation(PolygonNonPlanarNormalsDeviationType src) {
PolygonNonPlanarNormalsDeviation dest = new PolygonNonPlanarNormalsDeviation();
unmarshalAbstractPolygonError(src, dest);
if (src.isSetDeviation()) {
dest.setDeviation(helper.getGMLUnmarshaller().unmarshalAngle(src.getDeviation()));
}
return dest;
}
private PolygonOrientationRingsSame unmarshalPolygonOrientationRingsSame(PolygonOrientationRingsSameType src) {
PolygonOrientationRingsSame dest = new PolygonOrientationRingsSame();
unmarshalAbstractPolygonError(src, dest);
if (src.isSetLinearRingId()) {
dest.setLinearRingId(src.getLinearRingId());
}
return dest;
}
private Requirement unmarshalRequirement(de.hft.stuttgart.quality.model.jaxb.RequirementType src) {
Requirement dest = new Requirement();
dest.setEnabled(src.isEnabled());
if (src.isSetRequirementType()) {
dest.setRequirementType(RequirementType.fromValue(src.getRequirementType().value()));
}
if (src.isSetParameter()) {
for (ParameterPropertyType property : src.getParameter()) {
if (property.isSetParameter()) {
dest.getParameters().add(unmarshalParameter(property.getParameter()));
}
}
}
return dest;
}
private RingConsecutivePointsSame unmarshalRingConsecutivePointsSame(RingConsecutivePointsSameType src) {
RingConsecutivePointsSame dest = new RingConsecutivePointsSame();
unmarshalAbstractRingError(src, dest);
if (src.isSetVertex1()) {
dest.setVertex1(helper.getGMLUnmarshaller().unmarshalDirectPosition(src.getVertex1()));
}
if (src.isSetVertex2()) {
dest.setVertex2(helper.getGMLUnmarshaller().unmarshalDirectPosition(src.getVertex2()));
}
return dest;
}
private RingNotClosed unmarshalRingNotClosed(RingNotClosedType src) {
RingNotClosed dest = new RingNotClosed();
unmarshalAbstractRingError(src, dest);
return dest;
}
private RingSelfIntersection unmarshalRingSelfIntersection(RingSelfIntersectionType src) {
RingSelfIntersection dest = new RingSelfIntersection();
unmarshalAbstractRingError(src, dest);
if (src.isSetEdge1() && src.getEdge1() != null) {
dest.setEdge1(unmarshalEdge(src.getEdge1().getEdge()));
}
if (src.isSetEdge2() && src.getEdge2() != null) {
dest.setEdge2(unmarshalEdge(src.getEdge2().getEdge()));
}
if (src.isSetType()) {
dest.setType(src.getType());
}
if (src.isSetVertex()) {
dest.setVertex(helper.getGMLUnmarshaller().unmarshalDirectPosition(src.getVertex()));
}
return dest;
}
private RingTooFewPoints unmarshalRingTooFewPoints(RingTooFewPointsType src) {
RingTooFewPoints dest = new RingTooFewPoints();
unmarshalAbstractRingError(src, dest);
return dest;
}
private SemanticAttributeMissing unmarshalSemanticAttributeMissing(SemanticAttributeMissingType src) {
SemanticAttributeMissing dest = new SemanticAttributeMissing();
if (src.isSetAttributeName()) {
dest.setAttributeName(src.getAttributeName());
}
if (src.isSetChildId()) {
dest.setChildId(src.getChildId());
}
dest.setGeneric(src.isGeneric());
return dest;
}
private SemanticAttributeWrongValue unmarshalSemanticAttributeWrongValue(SemanticAttributeWrongValueType src) {
SemanticAttributeWrongValue dest = new SemanticAttributeWrongValue();
if (src.isSetAttributeName()) {
dest.setAttributeName(src.getAttributeName());
}
if (src.isSetChildId()) {
dest.setChildId(src.getChildId());
}
dest.setGeneric(src.isGeneric());
return dest;
}
private SolidAllPolygonsWrongOrientation unmarshalSolidAllPolygonsWrongOrientation(SolidAllPolygonsWrongOrientationType src) {
SolidAllPolygonsWrongOrientation dest = new SolidAllPolygonsWrongOrientation();
unmarshalAbstractSolidError(src, dest);
return dest;
}
private SolidMultipleConnectedComponents unmarshalSolidMultipleConnectedComponents(SolidMultipleConnectedComponentsType src) {
SolidMultipleConnectedComponents dest = new SolidMultipleConnectedComponents();
unmarshalAbstractSolidError(src, dest);
if (src.isSetComponents()) {
for (ComponentListPropertyType componentProperty : src.getComponents()) {
Component component = new Component();
dest.getComponents().add(component);
if (componentProperty.isSetComponentList()
&& componentProperty.getComponentList().isSetComponent()) {
for (PolygonIdListPropertyType property : componentProperty.getComponentList().getComponent()) {
if (property.isSetPolygonIdList()
&& property.getPolygonIdList().isSetPolygonId()) {
component.getPolygonIds().add(property.getPolygonIdList().getPolygonId());
}
}
}
}
}
return dest;
}
private SolidNonManifoldEdge unmarshalSolidNonManifoldEdge(SolidNonManifoldEdgeType src) {
SolidNonManifoldEdge dest = new SolidNonManifoldEdge();
unmarshalAbstractSolidError(src, dest);
if (src.isSetEdges()
&& src.getEdges().isSetEdgeList()
&& src.getEdges().getEdgeList().isSetEdge()) {
for (EdgePropertyType property : src.getEdges().getEdgeList().getEdge()) {
if (property.isSetEdge()) {
dest.getEdges().add(unmarshalEdge(property.getEdge()));
}
}
}
return dest;
}
private SolidNonManifoldVertex unmarshalSolidNonManifoldVertex(SolidNonManifoldVertexType src) {
SolidNonManifoldVertex dest = new SolidNonManifoldVertex();
unmarshalAbstractSolidError(src, dest);
if (src.isSetVertex()) {
dest.setVertex(helper.getGMLUnmarshaller().unmarshalDirectPosition(src.getVertex()));
}
return dest;
}
private SolidNotClosed unmarshalSolidNotClosed(SolidNotClosedType src) {
SolidNotClosed dest = new SolidNotClosed();
unmarshalAbstractSolidError(src, dest);
if (src.isSetEdges()
&& src.getEdges().isSetEdgeList()
&& src.getEdges().getEdgeList().isSetEdge()) {
for (EdgePropertyType property : src.getEdges().getEdgeList().getEdge()) {
if (property.isSetEdge()) {
dest.getEdges().add(unmarshalEdge(property.getEdge()));
}
}
}
return dest;
}
private SolidPolygonWrongOrientation unmarshalSolidPolygonWrongOrientation(SolidPolygonWrongOrientationType src) {
SolidPolygonWrongOrientation dest = new SolidPolygonWrongOrientation();
unmarshalAbstractSolidError(src, dest);
if (src.isSetEdges()
&& src.getEdges().isSetEdgeList()
&& src.getEdges().getEdgeList().isSetEdge()) {
for (EdgePropertyType property : src.getEdges().getEdgeList().getEdge()) {
if (property.isSetEdge()) {
dest.getEdges().add(unmarshalEdge(property.getEdge()));
}
}
}
return dest;
}
private SolidSelfIntersection unmarshalSolidSelfIntersection(SolidSelfIntersectionType src) {
SolidSelfIntersection dest = new SolidSelfIntersection();
unmarshalAbstractSolidError(src, dest);
if (src.isSetPolygonId1()) {
dest.setPolygonId1(src.getPolygonId1());
}
if (src.isSetPolygonId2()) {
dest.setPolygonId2(src.getPolygonId2());
}
return dest;
}
private SolidTooFewPolygons unmarshalSolidTooFewPolygons(SolidTooFewPolygonsType src) {
SolidTooFewPolygons dest = new SolidTooFewPolygons();
unmarshalAbstractSolidError(src, dest);
return dest;
}
private Statistics unmarshalStatistics(StatisticsType src) {
Statistics dest = new Statistics();
if (src.isSetNumErrorBridgeObjects()
&& src.getNumErrorBridgeObjects().isSetFeatureStatistics()) {
dest.setNumErrorBridgeObjects(unmarshalFeatureStatistics(src.getNumErrorBridgeObjects().getFeatureStatistics()));
}
if (src.isSetNumErrorBuildings()
&& src.getNumErrorBuildings().isSetFeatureStatistics()) {
dest.setNumErrorBuildings(unmarshalFeatureStatistics(src.getNumErrorBuildings().getFeatureStatistics()));
}
if (src.isSetNumErrorLandObjects()
&& src.getNumErrorLandObjects().isSetFeatureStatistics()) {
dest.setNumErrorLandObjects(unmarshalFeatureStatistics(src.getNumErrorLandObjects().getFeatureStatistics()));
}
if (src.isSetNumErrorTransportation()
&& src.getNumErrorTransportation().isSetFeatureStatistics()) {
dest.setNumErrorTransportation(unmarshalFeatureStatistics(src.getNumErrorTransportation().getFeatureStatistics()));
}
if (src.isSetNumErrorVegetation()
&& src.getNumErrorVegetation().isSetFeatureStatistics()) {
dest.setNumErrorVegetation(unmarshalFeatureStatistics(src.getNumErrorVegetation().getFeatureStatistics()));
}
if (src.isSetNumErrorWaterObjects()
&& src.getNumErrorWaterObjects().isSetFeatureStatistics()) {
dest.setNumErrorWaterObjects(unmarshalFeatureStatistics(src.getNumErrorWaterObjects().getFeatureStatistics()));
}
if (src.isSetErrorStatistics()
&& src.getErrorStatistics().isSetErrorStatistics()) {
dest.setErrorStatistics(unmarshalErrorStatistics(src.getErrorStatistics().getErrorStatistics()));
}
return dest;
}
public Validation unmarshalValidation(ValidationType src) throws MissingADESchemaException {
Validation dest = new Validation();
helper.getGMLUnmarshaller().unmarshalAbstractFeature(src, dest);
if (src.isSetValidationDate()) {
XMLGregorianCalendar validationDate = src.getValidationDate();
if (validationDate.getTimezone() == DatatypeConstants.FIELD_UNDEFINED) {
validationDate.setTimezone(0);
}
dest.setValidationDate(validationDate.toGregorianCalendar().toZonedDateTime());
}
if (src.isSetValidationSoftware()) {
dest.setValidationSoftware(src.getValidationSoftware());
}
if (src.isSetValidationPlan()
&& src.getValidationPlan().isSetValidationPlan()) {
dest.setValidationPlan(unmarshalValidationPlan(src.getValidationPlan().getValidationPlan()));
}
if (src.isSetStatistics()
&& src.getStatistics().isSetStatistics()) {
dest.setStatistics(unmarshalStatistics(src.getStatistics().getStatistics()));
}
return dest;
}
public ValidationPlan unmarshalValidationPlan(ValidationPlanType src) {
ValidationPlan dest = new ValidationPlan();
if (src.isSetGlobalParameters()
&& src.getGlobalParameters().isSetGlobalParameters()
&& src.getGlobalParameters().getGlobalParameters().isSetParameter()) {
for (ParameterPropertyType property : src.getGlobalParameters().getGlobalParameters().getParameter()) {
if (property.isSetParameter()) {
dest.getGlobalParameters().add(unmarshalParameter(property.getParameter()));
}
}
}
if (src.isSetFilter()
&& src.getFilter().isSetFilter()) {
dest.setFilter(unmarshalFilter(src.getFilter().getFilter()));
}
if (src.isSetRequirement()
&& src.getRequirement().isSetRequirement()) {
dest.setRequirement(unmarshalRequirement(src.getRequirement().getRequirement()));
}
return dest;
}
public ValidationProperty unmarshalValidationProperty(ValidationPropertyType src) throws MissingADESchemaException {
ValidationProperty dest = new ValidationProperty();
if (src.isSetValidation()) {
dest.setFeature(unmarshalValidation(src.getValidation()));
}
if (src.isSetRemoteSchema()) {
dest.setRemoteSchema(src.getRemoteSchema());
}
if (src.isSetType()) {
dest.setType(XLinkType.fromValue(src.getType().value()));
}
if (src.isSetHref()) {
dest.setHref(src.getHref());
}
if (src.isSetRole()) {
dest.setRole(src.getRole());
}
if (src.isSetArcrole()) {
dest.setArcrole(src.getArcrole());
}
if (src.isSetTitle()) {
dest.setTitle(src.getTitle());
}
if (src.isSetShow()) {
dest.setShow(XLinkShow.fromValue(src.getShow().value()));
}
if (src.isSetActuate()) {
dest.setActuate(XLinkActuate.fromValue(src.getActuate().value()));
}
return dest;
}
private ValidationResult unmarshalValidationResult(ValidationResultType src) throws MissingADESchemaException {
ValidationResult dest = new ValidationResult();
if (src.isSetValidationPlanID()) {
dest.setValidation(unmarshalValidationProperty(src.getValidationPlanID()));
}
if (src.isSetError()) {
for (AbstractErrorPropertyType property : src.getError()) {
if (property.isSetAbstractError()) {
ModelObject object = helper.getJAXBUnmarshaller().unmarshal(property.getAbstractError());
if (object instanceof AbstractError) {
dest.getErrors().add((AbstractError) object);
}
}
}
}
if (src.isSetResultType()) {
dest.setResultType(ResultType.fromValue(src.getResultType().value()));
}
return dest;
}
public ValidationResultProperty unmarshalValidationResultProperty(ValidationResultPropertyType src) throws MissingADESchemaException {
ValidationResultProperty dest = new ValidationResultProperty();
if (src.isSetValidationResult()) {
dest.setObject(unmarshalValidationResult(src.getValidationResult()));
}
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 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.marshaller;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import javax.xml.bind.annotation.adapters.XmlAdapter;
public class ZonedDateTimeAdapter extends XmlAdapter<String, ZonedDateTime> {
@Override
public ZonedDateTime unmarshal(String v) throws Exception {
try {
return ZonedDateTime.from(DateTimeFormatter.ISO_OFFSET_DATE_TIME.parse(v));
} catch (Exception e) {
return LocalDateTime.parse(v).atZone(ZoneId.systemDefault());
}
}
@Override
public String marshal(ZonedDateTime v) throws Exception {
return DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(v);
}
}
/*- /*
* Copyright 2020 Hochschule für Technik Stuttgart * Copyright 2021 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,41 +13,33 @@ ...@@ -13,41 +13,33 @@
* 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; package de.hft.stuttgart.quality.model;
import org.citygml4j.builder.copy.CopyBuilder;
import org.citygml4j.model.citygml.ade.binding.ADEModelObject; import org.citygml4j.model.citygml.ade.binding.ADEModelObject;
import org.citygml4j.model.common.association.Associable;
import org.citygml4j.model.common.base.ModelObject; import org.citygml4j.model.common.base.ModelObject;
public abstract class ChildObject implements ADEModelObject { public abstract class AbstractDataType implements Associable, ADEModelObject {
private ModelObject parent;
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 @Override
public void setParent(ModelObject parent) { public ModelObject getParent() {
this.parent = parent; return parent;
} }
@Override @Override
public boolean isSetParent() { public void setParent(ModelObject parent) {
return parent != null; this.parent = parent;
} }
@Override @Override
public void unsetParent() { public boolean isSetParent() {
parent = null; return parent != null;
} }
@Override
public void unsetParent() {
parent = null;
}
} }
/*- /*
* Copyright 2020 Hochschule für Technik Stuttgart * Copyright 2021 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,41 +13,44 @@ ...@@ -13,41 +13,44 @@
* 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;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List; import java.util.List;
import javax.xml.bind.annotation.XmlAttribute; public abstract class AbstractError extends AbstractDataType {
import javax.xml.bind.annotation.XmlElementRef;
public abstract ErrorType getErrorType();
import net.opengis.gml.AbstractFeatureType;
@Override
public class ValidationResultType extends AbstractFeatureType { public String toString() {
Class<?> target = getClass();
@XmlAttribute(name = "result") LinkedList<Class<?>> types = new LinkedList<>();
private ResultType result; do {
types.addFirst(target);
@XmlElementRef } while ((target = target.getSuperclass()) != AbstractDataType.class && target != null);
private List<ValidationErrorType> errors;
List<String> fields = new ArrayList<>();
public List<ValidationErrorType> getErrors() { for (Class<?> type : types) {
if (errors == null) { for (Field field : type.getDeclaredFields()) {
errors = new ArrayList<>(2); int modifiers = field.getModifiers();
} if (Modifier.isStatic(modifiers)) {
return errors; continue;
} }
public void setResult(ResultType result) { try {
this.result = result; field.setAccessible(true);
} fields.add(field.getName() + "=" + field.get(this));
} catch (Exception e) {
public ResultType getResult() { //
return result; }
} }
}
public boolean isSetErrors() {
return errors != null && !errors.isEmpty(); return getClass().getSimpleName() + " [" + String.join(", ", fields) + "]";
} }
} }
/*- /*
* Copyright 2020 Hochschule für Technik Stuttgart * Copyright 2021 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,10 +13,8 @@ ...@@ -13,10 +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;
public abstract class SemanticError extends ValidationError {
private static final long serialVersionUID = 8986289777859562928L; package de.hft.stuttgart.quality.model;
public abstract class AbstractGeometryError extends AbstractError {
} }
/*
* Copyright 2021 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.builder.copy.ObjectCopier;
public abstract class AbstractPolygonError extends AbstractGeometryError {
private String polygonId;
public String getPolygonId() {
return polygonId;
}
public void setPolygonId(String polygonId) {
this.polygonId = polygonId;
}
@Override
public Object copyTo(Object target, CopyBuilder copyBuilder) {
return target instanceof AbstractPolygonError ?
ObjectCopier.copyTo(this, (AbstractPolygonError) target, AbstractPolygonError.class, copyBuilder) :
target;
}
}
/*
* Copyright 2021 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.builder.copy.ObjectCopier;
public abstract class AbstractRingError extends AbstractGeometryError {
private String linearRingId;
public String getLinearRingId() {
return linearRingId;
}
public void setLinearRingId(String linearRingId) {
this.linearRingId = linearRingId;
}
@Override
public Object copyTo(Object target, CopyBuilder copyBuilder) {
return target instanceof AbstractRingError ?
ObjectCopier.copyTo(this, (AbstractRingError) target, AbstractRingError.class, copyBuilder) :
target;
}
}
/*- /*
* Copyright 2020 Hochschule für Technik Stuttgart * Copyright 2021 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,9 +13,8 @@ ...@@ -13,9 +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; package de.hft.stuttgart.quality.model;
public abstract class ValidationError extends ChildObject { public abstract class AbstractSemanticError extends AbstractError {
private static final long serialVersionUID = -2995694676938108325L;
} }
/*- /*
* Copyright 2020 Hochschule für Technik Stuttgart * Copyright 2021 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,31 +13,27 @@ ...@@ -13,31 +13,27 @@
* 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; package de.hft.stuttgart.quality.model;
import org.citygml4j.builder.copy.CopyBuilder; import org.citygml4j.builder.copy.CopyBuilder;
import org.citygml4j.builder.copy.ObjectCopier;
public class HoleOutside extends PolygonError { public abstract class AbstractSolidError extends AbstractGeometryError {
private String geometryId;
private static final long serialVersionUID = -3029497342950689843L;
private String linearRingId;
public void setLinearRingId(String linearRingId) {
this.linearRingId = linearRingId;
}
public String getLinearRingId() { public String getGeometryId() {
return linearRingId; return geometryId;
} }
@Override public void setGeometryId(String geometryId) {
public String toString() { this.geometryId = geometryId;
return "HoleOutside [polygonId=" + getPolygonId() + ", linearRingId=" + linearRingId + "]"; }
}
@Override @Override
public Object copy(CopyBuilder copyBuilder) { public Object copyTo(Object target, CopyBuilder copyBuilder) {
return copyTo(new HoleOutside(), copyBuilder); return target instanceof AbstractSolidError ?
} ObjectCopier.copyTo(this, (AbstractSolidError) target, AbstractSolidError.class, copyBuilder) :
target;
}
} }
/*- /*
* Copyright 2020 Hochschule für Technik Stuttgart * Copyright 2021 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,37 +13,45 @@ ...@@ -13,37 +13,45 @@
* 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; package de.hft.stuttgart.quality.model;
import org.citygml4j.builder.copy.CopyBuilder;
import org.citygml4j.builder.copy.ObjectCopier;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.citygml4j.builder.copy.CopyBuilder; public class Component extends AbstractDataType {
private List<String> polygonIds;
public boolean isSetPolygonIds() {
return polygonIds != null && !polygonIds.isEmpty();
}
public List<String> getPolygonIds() {
if (polygonIds == null) {
polygonIds = new ArrayList<>();
}
return polygonIds;
}
public void setPolygonIds(List<String> polygonIds) {
this.polygonIds = polygonIds;
}
@Override
public Object copyTo(Object target, CopyBuilder copyBuilder) {
Component copy = target == null ?
new Component() :
(Component) target;
return ObjectCopier.copyTo(this, copy, copyBuilder);
}
public class PolygonWrongOrientation extends SolidError { @Override
public Object copy(CopyBuilder copyBuilder) {
private static final long serialVersionUID = 1128689472694838648L; return copyTo(new Component(), copyBuilder);
}
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 * Copyright 2021 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,33 +13,45 @@ ...@@ -13,33 +13,45 @@
* 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;
import java.io.Serializable; package de.hft.stuttgart.quality.model;
import org.citygml4j.builder.copy.CopyBuilder;
import org.citygml4j.builder.copy.ObjectCopier;
import org.citygml4j.model.common.base.ModelObjects;
import org.citygml4j.model.gml.geometry.primitives.DirectPosition; import org.citygml4j.model.gml.geometry.primitives.DirectPosition;
public class Edge implements Serializable { public class Edge extends AbstractDataType {
private DirectPosition from;
private static final long serialVersionUID = -5076265818764666094L; private DirectPosition to;
private DirectPosition from; public DirectPosition getFrom() {
private DirectPosition to; return from;
}
public void setFrom(DirectPosition from) {
this.from = from; public void setFrom(DirectPosition from) {
} this.from = ModelObjects.setParent(from, this);
}
public void setTo(DirectPosition to) {
this.to = to; public DirectPosition getTo() {
} return to;
}
public DirectPosition getFrom() {
return from; public void setTo(DirectPosition to) {
} this.to = ModelObjects.setParent(to, this);
}
public DirectPosition getTo() {
return to; @Override
} public Object copyTo(Object target, CopyBuilder copyBuilder) {
Edge copy = target == null ?
new Edge() :
(Edge) target;
return ObjectCopier.copyTo(this, copy, copyBuilder);
}
@Override
public Object copy(CopyBuilder copyBuilder) {
return copyTo(new Edge(), copyBuilder);
}
} }
/*
* Copyright 2021 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.builder.copy.ObjectCopier;
import java.util.ArrayList;
import java.util.List;
public class ErrorStatistics extends AbstractDataType {
private int occurrences;
private List<ErrorType> errors;
public int getOccurrences() {
return occurrences;
}
public void setOccurrences(int occurrences) {
this.occurrences = occurrences;
}
public boolean isSetErrors() {
return errors != null && !errors.isEmpty();
}
public List<ErrorType> getErrors() {
if (errors == null) {
errors = new ArrayList<>();
}
return errors;
}
public void setErrors(List<ErrorType> errors) {
this.errors = errors;
}
@Override
public Object copyTo(Object target, CopyBuilder copyBuilder) {
ErrorStatistics copy = target == null ?
new ErrorStatistics() :
(ErrorStatistics) target;
return ObjectCopier.copyTo(this, copy, copyBuilder);
}
@Override
public Object copy(CopyBuilder copyBuilder) {
return copyTo(new ErrorStatistics(), copyBuilder);
}
}
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