Search in sources :

Example 1 with DataArrayDocument

use of net.opengis.swe.x20.DataArrayDocument 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 DataArrayDocument

use of net.opengis.swe.x20.DataArrayDocument in project arctic-sea by 52North.

the class SweCommonEncoderv20 method asDocument.

private XmlObject asDocument(AbstractDataComponentType type) throws NotYetSupportedEncodingException {
    if (type instanceof BooleanType) {
        BooleanDocument document = BooleanDocument.Factory.newInstance();
        document.setBoolean((BooleanType) type);
        return document;
    } else if (type instanceof CountType) {
        CountDocument document = CountDocument.Factory.newInstance();
        document.setCount((CountType) type);
        return document;
    } else if (type instanceof CountRangeType) {
        CountRangeDocument document = CountRangeDocument.Factory.newInstance();
        document.setCountRange((CountRangeType) type);
        return document;
    } else if (type instanceof QuantityType) {
        QuantityDocument document = QuantityDocument.Factory.newInstance();
        document.setQuantity((QuantityType) type);
        return document;
    } else if (type instanceof QuantityRangeType) {
        QuantityRangeDocument document = QuantityRangeDocument.Factory.newInstance();
        document.setQuantityRange((QuantityRangeType) type);
        return document;
    } else if (type instanceof TimeType) {
        TimeDocument document = TimeDocument.Factory.newInstance();
        document.setTime((TimeType) type);
        return document;
    } else if (type instanceof TimeRangeType) {
        TimeRangeDocument document = TimeRangeDocument.Factory.newInstance();
        document.setTimeRange((TimeRangeType) type);
        return document;
    } else if (type instanceof CategoryType) {
        CategoryDocument document = CategoryDocument.Factory.newInstance();
        document.setCategory((CategoryType) type);
        return document;
    } else if (type instanceof CategoryRangeType) {
        CategoryRangeDocument document = CategoryRangeDocument.Factory.newInstance();
        document.setCategoryRange((CategoryRangeType) type);
        return document;
    } else if (type instanceof MatrixType) {
        MatrixDocument document = MatrixDocument.Factory.newInstance();
        document.setMatrix((MatrixType) type);
        return document;
    } else if (type instanceof DataArrayType) {
        DataArrayDocument document = DataArrayDocument.Factory.newInstance();
        document.setDataArray1((DataArrayType) type);
        return document;
    } else if (type instanceof DataChoiceType) {
        DataChoiceDocument document = DataChoiceDocument.Factory.newInstance();
        document.setDataChoice((DataChoiceType) type);
        return document;
    } else if (type instanceof DataRecordType) {
        DataRecordDocument document = DataRecordDocument.Factory.newInstance();
        document.setDataRecord((DataRecordType) type);
        return document;
    } else if (type instanceof TextType) {
        TextDocument document = TextDocument.Factory.newInstance();
        document.setText((TextType) type);
        return document;
    } else if (type instanceof VectorType) {
        VectorDocument document = VectorDocument.Factory.newInstance();
        document.setVector((VectorType) type);
        return document;
    } else {
        throw new NotYetSupportedEncodingException(type.getClass().getName(), type);
    }
}
Also used : MatrixDocument(net.opengis.swe.x20.MatrixDocument) DataRecordType(net.opengis.swe.x20.DataRecordType) CategoryRangeType(net.opengis.swe.x20.CategoryRangeType) NotYetSupportedEncodingException(org.n52.svalbard.encode.exception.NotYetSupportedEncodingException) TimeRangeDocument(net.opengis.swe.x20.TimeRangeDocument) CategoryType(net.opengis.swe.x20.CategoryType) CountType(net.opengis.swe.x20.CountType) QuantityDocument(net.opengis.swe.x20.QuantityDocument) TimeType(net.opengis.swe.x20.TimeType) VectorDocument(net.opengis.swe.x20.VectorDocument) CountRangeType(net.opengis.swe.x20.CountRangeType) DataChoiceType(net.opengis.swe.x20.DataChoiceType) VectorType(net.opengis.swe.x20.VectorType) DataChoiceDocument(net.opengis.swe.x20.DataChoiceDocument) CountRangeDocument(net.opengis.swe.x20.CountRangeDocument) DataArrayType(net.opengis.swe.x20.DataArrayType) DataArrayDocument(net.opengis.swe.x20.DataArrayDocument) TextDocument(net.opengis.swe.x20.TextDocument) BooleanType(net.opengis.swe.x20.BooleanType) BooleanDocument(net.opengis.swe.x20.BooleanDocument) DataRecordDocument(net.opengis.swe.x20.DataRecordDocument) TextType(net.opengis.swe.x20.TextType) TimeRangeType(net.opengis.swe.x20.TimeRangeType) CategoryDocument(net.opengis.swe.x20.CategoryDocument) CategoryRangeDocument(net.opengis.swe.x20.CategoryRangeDocument) CountDocument(net.opengis.swe.x20.CountDocument) QuantityType(net.opengis.swe.x20.QuantityType) MatrixType(net.opengis.swe.x20.MatrixType) QuantityRangeDocument(net.opengis.swe.x20.QuantityRangeDocument) TimeDocument(net.opengis.swe.x20.TimeDocument) QuantityRangeType(net.opengis.swe.x20.QuantityRangeType)

Example 3 with DataArrayDocument

use of net.opengis.swe.x20.DataArrayDocument in project arctic-sea by 52North.

the class SweCommonDecoderV101 method parseSweDataArrayType.

private SweDataArray parseSweDataArrayType(DataArrayType xbDataArray) throws DecodingException {
    if (!xbDataArray.getElementType().isSetAbstractDataRecord()) {
        throw new DecodingException("The swe:DataArray contains a not yet supported elementType element. " + "Currently only 'swe:DataRecord' is supported as elementType element.");
    }
    final SweDataArray dataArray = new SweDataArray();
    if (xbDataArray.getElementCount() != null) {
        dataArray.setElementCount(parseElementCount(xbDataArray.getElementCount()));
    }
    // parse data record to elementType
    DataComponentPropertyType elementType = xbDataArray.getElementType();
    if (elementType != null) {
        dataArray.setElementType(parseDataComponentProperty(elementType));
    }
    if (xbDataArray.isSetEncoding()) {
        dataArray.setEncoding(parseEncoding(xbDataArray.getEncoding()));
    }
    // parse values
    // if (xbDataArray.isSetValues()) {
    // // TODO implement full support
    // // dataArray.setValues(parseValues(dataArray.getElementCount(),
    // // dataArray.getElementType(),
    // // dataArray.getEncoding(), xbDataArray.getValues()));
    // }
    DataArrayDocument xbDataArrayDoc = DataArrayDocument.Factory.newInstance(getXmlOptions());
    xbDataArrayDoc.setDataArray1(xbDataArray);
    dataArray.setXml(xbDataArrayDoc.xmlText());
    return dataArray;
}
Also used : NotYetSupportedDecodingException(org.n52.svalbard.decode.exception.NotYetSupportedDecodingException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) DataArrayDocument(net.opengis.swe.x101.DataArrayDocument)

Example 4 with DataArrayDocument

use of net.opengis.swe.x20.DataArrayDocument in project arctic-sea by 52North.

the class SweCommonDecoderV20 method parseDataArray.

private SweDataArray parseDataArray(DataArrayType xbDataArray) throws DecodingException {
    SweDataArray sosSweDataArray = new SweDataArray();
    CountPropertyType elementCount = xbDataArray.getElementCount();
    if (elementCount != null) {
        sosSweDataArray.setElementCount(parseElementCount(elementCount));
    }
    // parse data record to elementType
    DataArrayType.ElementType xbElementType = xbDataArray.getElementType();
    if (xbElementType != null && xbElementType.getAbstractDataComponent() != null) {
        sosSweDataArray.setElementType(parseAbstractDataComponent(xbElementType.getAbstractDataComponent()));
    }
    if (xbDataArray.isSetEncoding()) {
        sosSweDataArray.setEncoding(parseEncoding(xbDataArray.getEncoding().getAbstractEncoding()));
    }
    // parse values
    if (xbDataArray.isSetValues()) {
        sosSweDataArray.setValues(parseValues(sosSweDataArray.getElementCount(), sosSweDataArray.getElementType(), sosSweDataArray.getEncoding(), xbDataArray.getValues()));
    }
    // set XML
    DataArrayDocument dataArrayDoc = DataArrayDocument.Factory.newInstance(getXmlOptions());
    dataArrayDoc.setDataArray1(xbDataArray);
    sosSweDataArray.setXml(dataArrayDoc.xmlText(getXmlOptions()));
    return sosSweDataArray;
}
Also used : CountPropertyType(net.opengis.swe.x20.CountPropertyType) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) DataArrayType(net.opengis.swe.x20.DataArrayType) DataArrayDocument(net.opengis.swe.x20.DataArrayDocument)

Example 5 with DataArrayDocument

use of net.opengis.swe.x20.DataArrayDocument in project arctic-sea by 52North.

the class SweCommonEncoderv101 method createDataArray.

private DataArrayDocument createDataArray(SweDataArray sosDataArray) throws EncodingException {
    if (sosDataArray != null) {
        if (sosDataArray.isSetElementTyp()) {
            DataArrayDocument xbDataArrayDoc = DataArrayDocument.Factory.newInstance(getXmlOptions());
            DataArrayType xbDataArray = xbDataArrayDoc.addNewDataArray1();
            // set element count
            if (sosDataArray.isSetElementCount()) {
                xbDataArray.addNewElementCount().addNewCount().set(createCount(sosDataArray.getElementCount()));
            }
            if (sosDataArray.isSetElementTyp()) {
                DataComponentPropertyType xbElementType = xbDataArray.addNewElementType();
                xbElementType.setName("Components");
                // FIXME use visitor pattern
                if (sosDataArray.getElementType() instanceof SweBoolean) {
                    xbElementType.addNewBoolean().set(createSimpleType((SweBoolean) sosDataArray.getElementType()));
                } else if (sosDataArray.getElementType() instanceof SweCategory) {
                    xbElementType.addNewCategory().set(createSimpleType((SweCategory) sosDataArray.getElementType()));
                } else if (sosDataArray.getElementType() instanceof SweCount) {
                    xbElementType.addNewCount().set(createSimpleType((SweCount) sosDataArray.getElementType()));
                } else if (sosDataArray.getElementType() instanceof SweQuantity) {
                    xbElementType.addNewQuantity().set(createSimpleType((SweQuantity) sosDataArray.getElementType()));
                } else if (sosDataArray.getElementType() instanceof SweText) {
                    xbElementType.addNewText().set(createSimpleType((SweText) sosDataArray.getElementType()));
                } else if (sosDataArray.getElementType() instanceof SweTimeRange) {
                    xbElementType.addNewTimeRange().set(createSimpleType((SweTimeRange) sosDataArray.getElementType()));
                } else if (sosDataArray.getElementType() instanceof SweTime) {
                    xbElementType.addNewTime().set(createSimpleType((SweTime) sosDataArray.getElementType()));
                } else if (sosDataArray.getElementType() instanceof SweEnvelope) {
                    xbElementType.addNewAbstractDataRecord().set(createEnvelope((SweEnvelope) sosDataArray.getElementType()));
                    xbElementType.getAbstractDataRecord().substitute(SweConstants.QN_ENVELOPE_SWE_101, EnvelopeType.type);
                } else if (sosDataArray.getElementType() instanceof SweDataRecord) {
                    xbElementType.addNewAbstractDataRecord().set(createDataRecord((SweDataRecord) sosDataArray.getElementType()));
                    xbElementType.getAbstractDataRecord().substitute(SweConstants.QN_DATA_RECORD_SWE_101, DataRecordType.type);
                } else if (sosDataArray.getElementType() instanceof SweDataArray) {
                    xbElementType.addNewAbstractDataArray1().set(createDataArray((SweDataArray) sosDataArray.getElementType()).getDataArray1());
                    xbElementType.getAbstractDataArray1().substitute(SweConstants.QN_DATA_RECORD_SWE_101, DataArrayType.type);
                } else {
                    throw new UnsupportedEncoderInputException(this, sosDataArray.getElementType());
                }
            }
            if (sosDataArray.isSetEncoding()) {
                BlockEncodingPropertyType xbEncoding = xbDataArray.addNewEncoding();
                xbEncoding.set(createBlockEncoding(sosDataArray.getEncoding()));
            // xbDataArray.getEncoding().substitute(
            // new QName(SWEConstants.NS_SWE_101,
            // SWEConstants.EN_TEXT_ENCODING,
            // SWEConstants.NS_SWE_PREFIX), TextBlock.type);
            }
            // }
            if (sosDataArray.isSetValues()) {
                xbDataArray.addNewValues().set(createValues(sosDataArray.getValues(), sosDataArray.getEncoding()));
            }
            return xbDataArrayDoc;
        } else if (sosDataArray.isSetXml()) {
            try {
                XmlObject xmlObject = XmlObject.Factory.parse(sosDataArray.getXml().trim());
                if (xmlObject instanceof DataArrayDocument) {
                    return (DataArrayDocument) xmlObject;
                } else {
                    DataArrayDocument xbDataArrayDoc = DataArrayDocument.Factory.newInstance(getXmlOptions());
                    xbDataArrayDoc.setDataArray1(DataArrayType.Factory.parse(sosDataArray.getXml().trim()));
                    return xbDataArrayDoc;
                }
            } catch (XmlException e) {
                throw new EncodingException("Error while encoding SweDataArray!", e);
            }
        }
    }
    return null;
}
Also used : SweQuantity(org.n52.shetland.ogc.swe.simpleType.SweQuantity) SweText(org.n52.shetland.ogc.swe.simpleType.SweText) SweTime(org.n52.shetland.ogc.swe.simpleType.SweTime) BlockEncodingPropertyType(net.opengis.swe.x101.BlockEncodingPropertyType) EncodingException(org.n52.svalbard.encode.exception.EncodingException) NotYetSupportedEncodingException(org.n52.svalbard.encode.exception.NotYetSupportedEncodingException) SweCount(org.n52.shetland.ogc.swe.simpleType.SweCount) SweTimeRange(org.n52.shetland.ogc.swe.simpleType.SweTimeRange) SweDataArray(org.n52.shetland.ogc.swe.SweDataArray) SweBoolean(org.n52.shetland.ogc.swe.simpleType.SweBoolean) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException) SweEnvelope(org.n52.shetland.ogc.swe.SweEnvelope) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) XmlException(org.apache.xmlbeans.XmlException) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) XmlObject(org.apache.xmlbeans.XmlObject) DataArrayDocument(net.opengis.swe.x101.DataArrayDocument) DataArrayType(net.opengis.swe.x101.DataArrayType)

Aggregations

SweDataArray (org.n52.shetland.ogc.swe.SweDataArray)5 DataArrayDocument (net.opengis.swe.x101.DataArrayDocument)3 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)3 DataArrayType (net.opengis.swe.x101.DataArrayType)2 DataComponentPropertyType (net.opengis.swe.x101.DataComponentPropertyType)2 BooleanType (net.opengis.swe.x20.BooleanType)2 CategoryType (net.opengis.swe.x20.CategoryType)2 CountRangeType (net.opengis.swe.x20.CountRangeType)2 CountType (net.opengis.swe.x20.CountType)2 DataArrayDocument (net.opengis.swe.x20.DataArrayDocument)2 DataArrayType (net.opengis.swe.x20.DataArrayType)2 DataRecordDocument (net.opengis.swe.x20.DataRecordDocument)2 DataRecordType (net.opengis.swe.x20.DataRecordType)2 QuantityRangeType (net.opengis.swe.x20.QuantityRangeType)2 QuantityType (net.opengis.swe.x20.QuantityType)2 TextType (net.opengis.swe.x20.TextType)2 TimeRangeType (net.opengis.swe.x20.TimeRangeType)2 TimeType (net.opengis.swe.x20.TimeType)2 VectorType (net.opengis.swe.x20.VectorType)2 XmlException (org.apache.xmlbeans.XmlException)2