Search in sources :

Example 1 with UnsupportedDecoderXmlInputException

use of org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException in project arctic-sea by 52North.

the class SweCommonDecoderV20 method parseAbstractDataComponent.

private SweAbstractDataComponent parseAbstractDataComponent(AbstractDataComponentType abstractDataComponent) throws DecodingException {
    SweAbstractDataComponent sosAbstractDataComponent = null;
    if (abstractDataComponent instanceof BooleanType) {
        sosAbstractDataComponent = parseBoolean((BooleanType) abstractDataComponent);
    } else if (abstractDataComponent instanceof CategoryType) {
        sosAbstractDataComponent = parseCategory((CategoryType) abstractDataComponent);
    } else if (abstractDataComponent instanceof CountRangeType) {
        sosAbstractDataComponent = parseCountRange((CountRangeType) abstractDataComponent);
    } else if (abstractDataComponent instanceof CountType) {
        sosAbstractDataComponent = parseCount((CountType) abstractDataComponent);
    } else if (abstractDataComponent instanceof QuantityType) {
        sosAbstractDataComponent = parseQuantity((QuantityType) abstractDataComponent);
    } else if (abstractDataComponent instanceof QuantityRangeType) {
        sosAbstractDataComponent = parseQuantityRange((QuantityRangeType) abstractDataComponent);
    } else if (abstractDataComponent instanceof TextType) {
        sosAbstractDataComponent = parseText((TextType) abstractDataComponent);
    } else if (abstractDataComponent instanceof TimeType) {
        sosAbstractDataComponent = parseTime((TimeType) abstractDataComponent);
    } else if (abstractDataComponent instanceof TimeRangeType) {
        sosAbstractDataComponent = parseTimeRange((TimeRangeType) abstractDataComponent);
    } else if (abstractDataComponent instanceof VectorType) {
        sosAbstractDataComponent = parseVector((VectorType) abstractDataComponent);
    } else if (abstractDataComponent instanceof DataRecordType) {
        SweDataRecord sosDataRecord = parseDataRecord((DataRecordType) abstractDataComponent);
        DataRecordDocument dataRecordDoc = DataRecordDocument.Factory.newInstance(getXmlOptions());
        dataRecordDoc.setDataRecord((DataRecordType) abstractDataComponent);
        sosDataRecord.setXml(dataRecordDoc.xmlText(getXmlOptions()));
        sosAbstractDataComponent = sosDataRecord;
    } else if (abstractDataComponent instanceof DataArrayType) {
        SweDataArray sosDataArray = parseDataArray((DataArrayType) abstractDataComponent);
        DataArrayDocument dataArrayDoc = DataArrayDocument.Factory.newInstance(getXmlOptions());
        dataArrayDoc.setDataArray1((DataArrayType) abstractDataComponent);
        sosDataArray.setXml(dataArrayDoc.xmlText(getXmlOptions()));
        sosAbstractDataComponent = sosDataArray;
    } else {
        throw new UnsupportedDecoderXmlInputException(this, abstractDataComponent);
    }
    if (sosAbstractDataComponent != null) {
        if (abstractDataComponent.isSetDefinition()) {
            sosAbstractDataComponent.setDefinition(abstractDataComponent.getDefinition());
        }
        if (abstractDataComponent.isSetDescription()) {
            sosAbstractDataComponent.setDescription(abstractDataComponent.getDescription());
        }
        if (abstractDataComponent.isSetIdentifier()) {
            sosAbstractDataComponent.setIdentifier(abstractDataComponent.getIdentifier());
        }
        if (abstractDataComponent.isSetLabel()) {
            sosAbstractDataComponent.setLabel(abstractDataComponent.getLabel());
        }
    }
    return sosAbstractDataComponent;
}
Also used : DataRecordType(net.opengis.swe.x20.DataRecordType) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) BooleanType(net.opengis.swe.x20.BooleanType) CategoryType(net.opengis.swe.x20.CategoryType) CountType(net.opengis.swe.x20.CountType) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) DataRecordDocument(net.opengis.swe.x20.DataRecordDocument) TextType(net.opengis.swe.x20.TextType) TimeType(net.opengis.swe.x20.TimeType) TimeRangeType(net.opengis.swe.x20.TimeRangeType) CountRangeType(net.opengis.swe.x20.CountRangeType) QuantityType(net.opengis.swe.x20.QuantityType) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) VectorType(net.opengis.swe.x20.VectorType) UnsupportedDecoderXmlInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException) QuantityRangeType(net.opengis.swe.x20.QuantityRangeType) DataArrayType(net.opengis.swe.x20.DataArrayType) DataArrayDocument(net.opengis.swe.x20.DataArrayDocument)

Example 2 with UnsupportedDecoderXmlInputException

use of org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException in project arctic-sea by 52North.

the class SweCommonDecoderV20 method decode.

@Override
public Object decode(Object element) throws DecodingException {
    if (element instanceof DataArrayPropertyType) {
        final DataArrayPropertyType dataArrayPropertyType = (DataArrayPropertyType) element;
        return parseAbstractDataComponent(dataArrayPropertyType.getDataArray1());
    } else if (element instanceof DataRecordPropertyType) {
        final DataRecordPropertyType dataRecordPropertyType = (DataRecordPropertyType) element;
        return parseAbstractDataComponent(dataRecordPropertyType.getDataRecord());
    } else if (element instanceof AbstractDataComponentDocument) {
        return parseAbstractDataComponentDocument((AbstractDataComponentDocument) element);
    } else if (element instanceof AbstractDataComponentType) {
        return parseAbstractDataComponent((AbstractDataComponentType) element);
    } else if (element instanceof Coordinate[]) {
        return parseCoordinates((Coordinate[]) element);
    } else if (element instanceof AnyScalarPropertyType[]) {
        return parseAnyScalarPropertyTypeArray((AnyScalarPropertyType[]) element);
    } else if (element instanceof TextEncodingDocument) {
        final TextEncodingDocument textEncodingDoc = (TextEncodingDocument) element;
        final SweTextEncoding sosTextEncoding = parseTextEncoding(textEncodingDoc.getTextEncoding());
        sosTextEncoding.setXml(textEncodingDoc.xmlText(getXmlOptions()));
        return sosTextEncoding;
    } else if (element instanceof TextEncodingType) {
        TextEncodingDocument textEncodingDoc = TextEncodingDocument.Factory.newInstance(getXmlOptions());
        TextEncodingType textEncoding = (TextEncodingType) element;
        textEncodingDoc.setTextEncoding(textEncoding);
        SweTextEncoding sosTextEncoding = parseTextEncoding(textEncoding);
        sosTextEncoding.setXml(textEncodingDoc.xmlText(getXmlOptions()));
        return sosTextEncoding;
    } else if (element instanceof TextPropertyType) {
        return parseAbstractDataComponent(((TextPropertyType) element).getText());
    } else if (element instanceof CountPropertyType) {
        return parseAbstractDataComponent(((CountPropertyType) element).getCount());
    } else if (element instanceof BooleanPropertyType) {
        return parseAbstractDataComponent(((BooleanPropertyType) element).getBoolean());
    } else if (element instanceof CategoryPropertyType) {
        return parseAbstractDataComponent(((CategoryPropertyType) element).getCategory());
    } else if (element instanceof QuantityPropertyType) {
        return parseAbstractDataComponent(((QuantityPropertyType) element).getQuantity());
    } else if (element instanceof DataStreamPropertyType) {
        return parseDataStream(((DataStreamPropertyType) element).getDataStream());
    } else if (element instanceof DataStreamType) {
        return parseDataStream((DataStreamType) element);
    } else if (element instanceof DataStreamDocument) {
        return parseDataStream(((DataStreamDocument) element).getDataStream());
    } else if (element instanceof XmlObject) {
        throw new UnsupportedDecoderXmlInputException(this, (XmlObject) element);
    } else {
        throw new UnsupportedDecoderInputException(this, element);
    }
}
Also used : TextEncodingDocument(net.opengis.swe.x20.TextEncodingDocument) DataStreamDocument(net.opengis.swe.x20.DataStreamDocument) AnyScalarPropertyType(net.opengis.swe.x20.AnyScalarPropertyType) DataRecordPropertyType(net.opengis.swe.x20.DataRecordPropertyType) DataArrayPropertyType(net.opengis.swe.x20.DataArrayPropertyType) UnsupportedDecoderInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderInputException) AbstractDataComponentType(net.opengis.swe.x20.AbstractDataComponentType) TextEncodingType(net.opengis.swe.x20.TextEncodingType) SweCoordinate(org.n52.shetland.ogc.swe.SweCoordinate) Coordinate(net.opengis.swe.x20.VectorType.Coordinate) CountPropertyType(net.opengis.swe.x20.CountPropertyType) DataStreamType(net.opengis.swe.x20.DataStreamType) DataStreamPropertyType(net.opengis.swe.x20.DataStreamPropertyType) SweTextEncoding(org.n52.shetland.ogc.swe.encoding.SweTextEncoding) QuantityPropertyType(net.opengis.swe.x20.QuantityPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) UnsupportedDecoderXmlInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException) TextPropertyType(net.opengis.swe.x20.TextPropertyType) AbstractDataComponentDocument(net.opengis.swe.x20.AbstractDataComponentDocument) BooleanPropertyType(net.opengis.swe.x20.BooleanPropertyType) CategoryPropertyType(net.opengis.swe.x20.CategoryPropertyType)

Example 3 with UnsupportedDecoderXmlInputException

use of org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException in project arctic-sea by 52North.

the class SwesDecoderv20 method decode.

@Override
public OwsServiceRequest decode(XmlObject xmlObject) throws DecodingException {
    LOGGER.debug("REQUESTTYPE:" + xmlObject.getClass());
    XmlHelper.validateDocument(xmlObject);
    if (xmlObject instanceof DescribeSensorDocument) {
        return parseDescribeSensor((DescribeSensorDocument) xmlObject);
    } else if (xmlObject instanceof InsertSensorDocument) {
        return parseInsertSensor((InsertSensorDocument) xmlObject);
    } else if (xmlObject instanceof UpdateSensorDescriptionDocument) {
        return parseUpdateSensorDescription((UpdateSensorDescriptionDocument) xmlObject);
    } else if (xmlObject instanceof DeleteSensorDocument) {
        return parseDeleteSensor((DeleteSensorDocument) xmlObject);
    } else {
        throw new UnsupportedDecoderXmlInputException(this, xmlObject);
    }
}
Also used : InsertSensorDocument(net.opengis.swes.x20.InsertSensorDocument) DeleteSensorDocument(net.opengis.swes.x20.DeleteSensorDocument) DescribeSensorDocument(net.opengis.swes.x20.DescribeSensorDocument) UnsupportedDecoderXmlInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException) UpdateSensorDescriptionDocument(net.opengis.swes.x20.UpdateSensorDescriptionDocument)

Example 4 with UnsupportedDecoderXmlInputException

use of org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException in project arctic-sea by 52North.

the class FesDecoderv20 method parseSpatialFilterType.

/**
 * Parses the spatial filter of a request.
 *
 * @param xbSpatialOpsType
 *            XmlBean representing the feature of interest parameter of the
 *            request
 * @return Returns SpatialFilter created from the passed foi request
 *         parameter
 *
 * @throws DecodingException
 *             * if creation of the SpatialFilter failed
 */
private SpatialFilter parseSpatialFilterType(SpatialOpsType xbSpatialOpsType) throws DecodingException {
    SpatialFilter spatialFilter = new SpatialFilter();
    try {
        if (xbSpatialOpsType instanceof BBOXType) {
            spatialFilter.setOperator(FilterConstants.SpatialOperator.BBOX);
            BBOXType xbBBOX = (BBOXType) xbSpatialOpsType;
            if (isValueReferenceExpression(xbBBOX.getExpression())) {
                spatialFilter.setValueReference(parseValueReference(xbBBOX.getExpression()));
            }
            XmlCursor geometryCursor = xbSpatialOpsType.newCursor();
            if (geometryCursor.toChild(GmlConstants.QN_ENVELOPE_32)) {
                Object sosGeometry = decodeXmlObject(Factory.parse(geometryCursor.getDomNode()));
                if (sosGeometry instanceof Geometry) {
                    spatialFilter.setGeometry((Geometry) sosGeometry);
                } else if (sosGeometry instanceof ReferencedEnvelope) {
                    spatialFilter.setGeometry((ReferencedEnvelope) sosGeometry);
                } else {
                    throw new UnsupportedDecoderXmlInputException(this, xbSpatialOpsType);
                }
            } else {
                throw new DecodingException(Sos2Constants.GetObservationParams.spatialFilter, "The requested spatial filter operand is not supported by this SOS!");
            }
            geometryCursor.dispose();
        } else {
            throw new DecodingException(Sos2Constants.GetObservationParams.spatialFilter, "The requested spatial filter is not supported by this SOS!");
        }
    } catch (XmlException xmle) {
        throw new DecodingException("Error while parsing spatial filter!", xmle);
    }
    return spatialFilter;
}
Also used : Geometry(org.locationtech.jts.geom.Geometry) ReferencedEnvelope(org.n52.shetland.util.ReferencedEnvelope) BBOXType(net.opengis.fes.x20.BBOXType) XmlException(org.apache.xmlbeans.XmlException) SpatialFilter(org.n52.shetland.ogc.filter.SpatialFilter) XmlObject(org.apache.xmlbeans.XmlObject) UnsupportedDecoderXmlInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) XmlCursor(org.apache.xmlbeans.XmlCursor)

Example 5 with UnsupportedDecoderXmlInputException

use of org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException in project arctic-sea by 52North.

the class FesDecoderv20 method parseBinaryComparisonFilter.

private ComparisonFilter parseBinaryComparisonFilter(BinaryComparisonOpType comparisonOpsType) throws DecodingException {
    ComparisonFilter comparisonFilter = new ComparisonFilter();
    String localName = XmlHelper.getLocalName(comparisonOpsType);
    if (ComparisonOperator.PropertyIsEqualTo.name().equals(localName)) {
        comparisonFilter.setOperator(ComparisonOperator.PropertyIsEqualTo);
    } else if (ComparisonOperator.PropertyIsNotEqualTo.name().equals(localName)) {
        comparisonFilter.setOperator(ComparisonOperator.PropertyIsNotEqualTo);
    } else if (ComparisonOperator.PropertyIsLessThan.name().equals(localName)) {
        comparisonFilter.setOperator(ComparisonOperator.PropertyIsLessThan);
    } else if (ComparisonOperator.PropertyIsGreaterThan.name().equals(localName)) {
        comparisonFilter.setOperator(ComparisonOperator.PropertyIsGreaterThan);
    } else if (ComparisonOperator.PropertyIsLessThanOrEqualTo.name().equals(localName)) {
        comparisonFilter.setOperator(ComparisonOperator.PropertyIsLessThanOrEqualTo);
    } else if (ComparisonOperator.PropertyIsGreaterThanOrEqualTo.name().equals(localName)) {
        comparisonFilter.setOperator(ComparisonOperator.PropertyIsGreaterThanOrEqualTo);
    } else {
        throw new UnsupportedDecoderXmlInputException(this, comparisonOpsType);
    }
    if (comparisonOpsType.isSetMatchCase()) {
        comparisonFilter.setMatchCase(comparisonOpsType.getMatchCase());
    }
    parseExpressions(comparisonOpsType.getExpressionArray(), comparisonFilter);
    return comparisonFilter;
}
Also used : ComparisonFilter(org.n52.shetland.ogc.filter.ComparisonFilter) UnsupportedDecoderXmlInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException)

Aggregations

UnsupportedDecoderXmlInputException (org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException)8 XmlObject (org.apache.xmlbeans.XmlObject)3 XmlCursor (org.apache.xmlbeans.XmlCursor)2 BBOXType (net.opengis.fes.x20.BBOXType)1 DescribeSensorDocument (net.opengis.sos.x10.DescribeSensorDocument)1 GetCapabilitiesDocument (net.opengis.sos.x10.GetCapabilitiesDocument)1 GetFeatureOfInterestDocument (net.opengis.sos.x10.GetFeatureOfInterestDocument)1 GetObservationByIdDocument (net.opengis.sos.x10.GetObservationByIdDocument)1 GetObservationDocument (net.opengis.sos.x10.GetObservationDocument)1 AbstractDataComponentDocument (net.opengis.swe.x20.AbstractDataComponentDocument)1 AbstractDataComponentType (net.opengis.swe.x20.AbstractDataComponentType)1 AnyScalarPropertyType (net.opengis.swe.x20.AnyScalarPropertyType)1 BooleanPropertyType (net.opengis.swe.x20.BooleanPropertyType)1 BooleanType (net.opengis.swe.x20.BooleanType)1 CategoryPropertyType (net.opengis.swe.x20.CategoryPropertyType)1 CategoryType (net.opengis.swe.x20.CategoryType)1 CountPropertyType (net.opengis.swe.x20.CountPropertyType)1 CountRangeType (net.opengis.swe.x20.CountRangeType)1 CountType (net.opengis.swe.x20.CountType)1 DataArrayDocument (net.opengis.swe.x20.DataArrayDocument)1