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

removing one list depth of multiple component error

parent 21048170
/*-
* Copyright 2022 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.adapter.properties;
import de.hft.stuttgart.quality.model.properties.ComponentListProperty;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.gml.adapter.base.AbstractInlinePropertyAdapter;
import javax.xml.namespace.QName;
public class ComponentListPropertyAdapter extends AbstractInlinePropertyAdapter<ComponentListProperty> {
@Override
public ComponentListProperty createObject(QName name, Object parent) throws ObjectBuildException {
return new ComponentListProperty();
}
}
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.builder.ObjectBuilder;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.serializer.ObjectSerializer;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.adapter.properties.PolygonIdListPropertyAdapter;
import de.hft.stuttgart.quality.model.properties.PolygonIdListProperty;
import de.hft.stuttgart.quality.model.types.ComponentList;
@XMLElement(name = "ComponentList", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class ComponentListAdapter implements ObjectBuilder<ComponentList>, ObjectSerializer<ComponentList> {
@Override
public ComponentList createObject(QName name, Object parent) throws ObjectBuildException {
return new ComponentList();
}
@Override
public void buildChildObject(ComponentList object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "component" -> object.getComponents()
.add(reader.getObjectUsingBuilder(PolygonIdListPropertyAdapter.class));
default -> throw new IllegalStateException(
"Cannot handle name " + name + " when building ComponentList element");
}
}
@Override
public Element createElement(ComponentList object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "ComponentList");
}
@Override
public void writeChildElements(ComponentList object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
for (PolygonIdListProperty listProperty : object.getComponents()) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "component"), listProperty,
PolygonIdListPropertyAdapter.class, namespaces);
}
}
}
......@@ -14,8 +14,8 @@ import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.adapter.properties.ComponentListPropertyAdapter;
import de.hft.stuttgart.quality.model.properties.ComponentListProperty;
import de.hft.stuttgart.quality.adapter.properties.PolygonIdListPropertyAdapter;
import de.hft.stuttgart.quality.model.properties.PolygonIdListProperty;
import de.hft.stuttgart.quality.model.types.MultipleComponentsError;
@XMLElement(name = "GE_S_MULTIPLE_CONNECTED_COMPONENTS", namespaceURI = QualityADEModule.NAMESPACE_URI)
......@@ -33,11 +33,11 @@ public class MultipleComponentsErrorAdapter extends AbstractSolidErrorAdapter<Mu
return;
}
switch (name.getLocalPart()) {
case "components" -> object.getComponents().add(reader.getObjectUsingBuilder(ComponentListPropertyAdapter.class));
case "component" -> object.getComponents().add(reader.getObjectUsingBuilder(PolygonIdListPropertyAdapter.class));
default -> super.buildChildObject(object, name, attributes, reader);
}
}
@Override
public Element createElement(MultipleComponentsError object, Namespaces namespaces)
throws ObjectSerializeException {
......@@ -48,9 +48,9 @@ public class MultipleComponentsErrorAdapter extends AbstractSolidErrorAdapter<Mu
public void writeChildElements(MultipleComponentsError object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
super.writeChildElements(object, namespaces, writer);
for (ComponentListProperty clp : object.getComponents()) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "components"), clp,
ComponentListPropertyAdapter.class, namespaces);
for (PolygonIdListProperty clp : object.getComponents()) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "component"), clp,
PolygonIdListPropertyAdapter.class, namespaces);
}
}
}
/*-
* Copyright 2022 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.properties;
import java.io.Serial;
import org.citygml4j.core.model.ade.ADEObject;
import org.xmlobjects.gml.model.base.AbstractInlineProperty;
import de.hft.stuttgart.quality.model.types.ComponentList;
public class ComponentListProperty extends AbstractInlineProperty<ComponentList> implements ADEObject {
@Serial
private static final long serialVersionUID = 3081945215746143126L;
public ComponentListProperty() {
super();
}
public ComponentListProperty(ComponentList cl) {
super(cl);
}
@Override
public Class<ComponentList> getTargetType() {
return ComponentList.class;
}
}
/*-
* Copyright 2022 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.types;
import java.io.Serial;
import java.util.List;
import org.citygml4j.core.model.ade.ADEObject;
import org.xmlobjects.gml.model.GMLObject;
import org.xmlobjects.model.ChildList;
import de.hft.stuttgart.quality.model.properties.PolygonIdListProperty;
public class ComponentList extends GMLObject implements ADEObject {
@Serial
private static final long serialVersionUID = 7846916128728837265L;
private List<PolygonIdListProperty> components;
public List<PolygonIdListProperty> getComponents() {
if (components == null) {
components = new ChildList<>(this);
}
return components;
}
public void setComponents(List<PolygonIdListProperty> components) {
this.components = asChild(components);
}
}
......@@ -20,23 +20,23 @@ import java.util.List;
import org.xmlobjects.model.ChildList;
import de.hft.stuttgart.quality.model.properties.ComponentListProperty;
import de.hft.stuttgart.quality.model.properties.PolygonIdListProperty;
public class MultipleComponentsError extends AbstractSolidError {
@Serial
private static final long serialVersionUID = 4322219502819024437L;
private List<ComponentListProperty> components;
private List<PolygonIdListProperty> components;
public List<ComponentListProperty> getComponents() {
public List<PolygonIdListProperty> getComponents() {
if (components == null) {
components = new ChildList<>(this);
}
return components;
}
public void setComponents(List<ComponentListProperty> edges) {
public void setComponents(List<PolygonIdListProperty> edges) {
this.components = asChild(edges);
}
......
......@@ -94,17 +94,6 @@
<element ref="qual:Checking"/>
</sequence>
</complexType>
<element name="ComponentList" substitutionGroup="gml:_Object" type="qual:ComponentListType"/>
<complexType name="ComponentListType">
<sequence>
<element maxOccurs="unbounded" name="component" type="qual:PolygonIdListPropertyType"/>
</sequence>
</complexType>
<complexType name="ComponentListPropertyType">
<sequence>
<element ref="qual:ComponentList"/>
</sequence>
</complexType>
<element name="Edge" substitutionGroup="gml:_Object" type="qual:EdgeType"/>
<complexType name="EdgeType">
<sequence>
......@@ -383,7 +372,7 @@
<complexContent>
<extension base="qual:AbstractSolidErrorType">
<sequence>
<element maxOccurs="unbounded" name="components" type="qual:ComponentListPropertyType"/>
<element maxOccurs="unbounded" name="component" type="qual:PolygonIdListPropertyType"/>
</sequence>
</extension>
</complexContent>
......
......@@ -63,7 +63,6 @@ import de.hft.stuttgart.quality.model.enums.RingSelfIntType;
import de.hft.stuttgart.quality.model.enums.TopLevelFeatureType;
import de.hft.stuttgart.quality.model.properties.AbstractErrorProperty;
import de.hft.stuttgart.quality.model.properties.CheckingProperty;
import de.hft.stuttgart.quality.model.properties.ComponentListProperty;
import de.hft.stuttgart.quality.model.properties.EdgeListProperty;
import de.hft.stuttgart.quality.model.properties.EdgeProperty;
import de.hft.stuttgart.quality.model.properties.FeatureStatisticsProperty;
......@@ -78,7 +77,6 @@ import de.hft.stuttgart.quality.model.properties.ValidationResultProperty;
import de.hft.stuttgart.quality.model.types.AllPolygonsOrientedWrongError;
import de.hft.stuttgart.quality.model.types.Checking;
import de.hft.stuttgart.quality.model.types.CityObjectProperties;
import de.hft.stuttgart.quality.model.types.ComponentList;
import de.hft.stuttgart.quality.model.types.ConsecutivePointsSameError;
import de.hft.stuttgart.quality.model.types.Edge;
import de.hft.stuttgart.quality.model.types.EdgeList;
......@@ -213,14 +211,10 @@ class QualityAdeTests {
MultipleComponentsError err = new MultipleComponentsError();
err.setGeometryId("geomId");
ComponentList comp = new ComponentList();
PolygonIdList polygons = new PolygonIdList();
polygons.getPolygonIds().add("test1");
polygons.getPolygonIds().add("test2");
comp.getComponents().add(new PolygonIdListProperty(polygons));
err.getComponents().add(new ComponentListProperty(comp));
err.getComponents().add(new PolygonIdListProperty(polygons));
res.getErrors().add(new AbstractErrorProperty(err));
byte[] buf = writeModel(model);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment