Search in sources :

Example 1 with SmlParameter

use of org.n52.shetland.ogc.sensorML.elements.SmlParameter in project arctic-sea by 52North.

the class SensorMLEncoderv20 method createParameters.

private Parameters createParameters(List<SmlParameter> smlParameters) throws EncodingException {
    final Parameters parameters = Parameters.Factory.newInstance(getXmlOptions());
    final ParameterListType parameterList = parameters.addNewParameterList();
    for (SmlParameter smlParameter : smlParameters) {
        Parameter param = parameterList.addNewParameter();
        param.setName(smlParameter.getName());
        if (smlParameter.isSetHref()) {
            param.setHref(smlParameter.getHref());
            if (smlParameter.isSetTitle()) {
                param.setTitle(smlParameter.getTitle());
            }
        } else {
            XmlObject xmlObject = encodeObjectToXmlSwe20(smlParameter.getParameter());
            if (xmlObject != null) {
                SweAbstractDataComponent parameter = smlParameter.getParameter();
                if (parameter instanceof SmlDataInterface) {
                    substitute(param.addNewDataInterface(), xmlObject);
                } else if (parameter instanceof SweObservableProperty) {
                    substitute(param.addNewObservableProperty(), xmlObject);
                } else {
                    substitute(param.addNewAbstractDataComponent(), xmlObject);
                }
            }
        }
    }
    return parameters;
}
Also used : SmlParameter(org.n52.shetland.ogc.sensorML.elements.SmlParameter) Parameters(net.opengis.sensorml.x20.AbstractProcessType.Parameters) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) SmlParameter(org.n52.shetland.ogc.sensorML.elements.SmlParameter) Parameter(net.opengis.sensorml.x20.ParameterListType.Parameter) XmlObject(org.apache.xmlbeans.XmlObject) ParameterListType(net.opengis.sensorml.x20.ParameterListType) SmlDataInterface(org.n52.shetland.ogc.sensorML.v20.SmlDataInterface) SweObservableProperty(org.n52.shetland.ogc.swe.simpleType.SweObservableProperty)

Example 2 with SmlParameter

use of org.n52.shetland.ogc.sensorML.elements.SmlParameter in project arctic-sea by 52North.

the class SensorMLDecoderV101 method parseDataComponentPropertyType.

private SmlParameter parseDataComponentPropertyType(final DataComponentPropertyType xbDataComponentPropertyType) throws DecodingException {
    final SmlParameter smlParameter = new SmlParameter();
    smlParameter.setName(xbDataComponentPropertyType.getName());
    XmlObject toDecode = null;
    if (xbDataComponentPropertyType.isSetHref()) {
        smlParameter.setHref(xbDataComponentPropertyType.getHref());
        if (xbDataComponentPropertyType.isSetTitle()) {
            smlParameter.setTitle(xbDataComponentPropertyType.getTitle());
        }
        return smlParameter;
    }
    if (xbDataComponentPropertyType.isSetBoolean()) {
        toDecode = xbDataComponentPropertyType.getBoolean();
    } else if (xbDataComponentPropertyType.isSetCategory()) {
        toDecode = xbDataComponentPropertyType.getCategory();
    } else if (xbDataComponentPropertyType.isSetCount()) {
        toDecode = xbDataComponentPropertyType.getCount();
    } else if (xbDataComponentPropertyType.isSetCountRange()) {
        toDecode = xbDataComponentPropertyType.getCountRange();
    } else if (xbDataComponentPropertyType.isSetQuantity()) {
        toDecode = xbDataComponentPropertyType.getQuantity();
    } else if (xbDataComponentPropertyType.isSetQuantityRange()) {
        toDecode = xbDataComponentPropertyType.getQuantityRange();
    } else if (xbDataComponentPropertyType.isSetText()) {
        toDecode = xbDataComponentPropertyType.getText();
    } else if (xbDataComponentPropertyType.isSetTime()) {
        toDecode = xbDataComponentPropertyType.getTime();
    } else if (xbDataComponentPropertyType.isSetTimeRange()) {
        toDecode = xbDataComponentPropertyType.getTimeRange();
    } else if (xbDataComponentPropertyType.isSetAbstractDataArray1()) {
        toDecode = xbDataComponentPropertyType.getAbstractDataArray1();
    } else if (xbDataComponentPropertyType.isSetAbstractDataRecord()) {
        toDecode = xbDataComponentPropertyType.getAbstractDataRecord();
    } else {
        throw new DecodingException(XmlHelper.getLocalName(xbDataComponentPropertyType), "An 'DataComponentProperty' is not supported");
    }
    final Object decodedObject = decodeXmlElement(toDecode);
    if (decodedObject instanceof SweAbstractDataComponent) {
        smlParameter.setParameter((SweAbstractDataComponent) decodedObject);
    } else {
        throw new DecodingException(XmlHelper.getLocalName(xbDataComponentPropertyType), "The 'DataComponentProperty' with type '%s' as value for '%s' is not supported.", XmlHelper.getLocalName(toDecode), XmlHelper.getLocalName(xbDataComponentPropertyType));
    }
    return smlParameter;
}
Also used : SmlParameter(org.n52.shetland.ogc.sensorML.elements.SmlParameter) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) XmlObject(org.apache.xmlbeans.XmlObject)

Example 3 with SmlParameter

use of org.n52.shetland.ogc.sensorML.elements.SmlParameter in project arctic-sea by 52North.

the class SensorMLEncoderv101 method createParameters.

private Parameters createParameters(List<SmlParameter> smlParameters) throws EncodingException {
    final Parameters parameters = Parameters.Factory.newInstance(getXmlOptions());
    ParameterList parameterList = parameters.addNewParameterList();
    for (SmlParameter smlParameter : smlParameters) {
        DataComponentPropertyType param = parameterList.addNewParameter();
        param.setName(smlParameter.getName());
        if (smlParameter.isSetHref()) {
            param.setHref(smlParameter.getHref());
            if (smlParameter.isSetTitle()) {
                param.setTitle(smlParameter.getTitle());
            }
        } else {
            SweAbstractDataComponent parameter = smlParameter.getParameter();
            XmlObject xmlObject = encodeObjectToXml(SweConstants.NS_SWE_101, parameter);
            if (xmlObject != null) {
                if (parameter instanceof SweBoolean) {
                    param.addNewBoolean().set(xmlObject);
                } else if (parameter instanceof SweCategory) {
                    param.addNewCategory().set(xmlObject);
                } else if (parameter instanceof SweCount) {
                    param.addNewCount().set(xmlObject);
                } else if (parameter instanceof SweQuantity) {
                    param.addNewQuantity().set(xmlObject);
                } else if (parameter instanceof SweText) {
                    param.addNewText().set(xmlObject);
                } else if (parameter instanceof SweTimeRange) {
                    param.addNewTimeRange().set(xmlObject);
                } else if (parameter instanceof SweTime) {
                    param.addNewTime().set(xmlObject);
                } else if (parameter instanceof SweEnvelope) {
                    param.addNewAbstractDataRecord().set(xmlObject);
                    param.getAbstractDataRecord().substitute(SweConstants.QN_ENVELOPE_SWE_101, EnvelopeType.type);
                } else if (parameter instanceof SweDataRecord) {
                    param.addNewAbstractDataRecord().set(xmlObject);
                    param.getAbstractDataRecord().substitute(SweConstants.QN_DATA_RECORD_SWE_101, DataRecordType.type);
                } else if (parameter instanceof SweSimpleDataRecord) {
                    param.addNewAbstractDataRecord().set(xmlObject);
                    param.getAbstractDataRecord().substitute(SweConstants.QN_SIMPLEDATARECORD_SWE_101, SimpleDataRecordType.type);
                } else if (parameter instanceof SweDataArray) {
                    param.addNewAbstractDataArray1().set(xmlObject);
                    param.getAbstractDataArray1().substitute(SweConstants.QN_DATA_RECORD_SWE_101, DataArrayType.type);
                } else {
                    throw new UnsupportedEncoderInputException(this, parameter);
                }
            }
        }
    }
    return parameters;
}
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) Parameters(net.opengis.sensorML.x101.ParametersDocument.Parameters) SweSimpleDataRecord(org.n52.shetland.ogc.swe.SweSimpleDataRecord) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) 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) SmlParameter(org.n52.shetland.ogc.sensorML.elements.SmlParameter) SweEnvelope(org.n52.shetland.ogc.swe.SweEnvelope) SweDataRecord(org.n52.shetland.ogc.swe.SweDataRecord) ParameterList(net.opengis.sensorML.x101.ParametersDocument.Parameters.ParameterList) SweCategory(org.n52.shetland.ogc.swe.simpleType.SweCategory) DataComponentPropertyType(net.opengis.swe.x101.DataComponentPropertyType) XmlObject(org.apache.xmlbeans.XmlObject)

Example 4 with SmlParameter

use of org.n52.shetland.ogc.sensorML.elements.SmlParameter in project arctic-sea by 52North.

the class SensorMLDecoderV20 method parseSweParameter.

private SmlParameter parseSweParameter(Parameter xbParameter) throws DecodingException {
    SmlParameter param = new SmlParameter();
    String name = xbParameter.getName();
    if (xbParameter.isSetHref()) {
        param.setHref(xbParameter.getHref());
        if (xbParameter.isSetTitle()) {
            param.setTitle(xbParameter.getTitle());
        }
        return param;
    }
    Object parameter = decodeXmlElement(xbParameter.getAbstractDataComponent());
    if (parameter instanceof SweAbstractDataComponent) {
        if (xbParameter.getName() != null && !xbParameter.getName().isEmpty()) {
            ((SweAbstractDataComponent) parameter).setName(name);
        }
        param.setName(name);
        param.setParameter((SweAbstractDataComponent) parameter);
        return param;
    } else {
        throw new DecodingException(XmlHelper.getLocalName(xbParameter), "An 'SweAbstractDataComponent' is not supported");
    }
}
Also used : SmlParameter(org.n52.shetland.ogc.sensorML.elements.SmlParameter) SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) DescribedObject(org.n52.shetland.ogc.sensorML.v20.DescribedObject) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)4 SmlParameter (org.n52.shetland.ogc.sensorML.elements.SmlParameter)4 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)4 DecodingException (org.n52.svalbard.decode.exception.DecodingException)2 Parameters (net.opengis.sensorML.x101.ParametersDocument.Parameters)1 ParameterList (net.opengis.sensorML.x101.ParametersDocument.Parameters.ParameterList)1 Parameters (net.opengis.sensorml.x20.AbstractProcessType.Parameters)1 ParameterListType (net.opengis.sensorml.x20.ParameterListType)1 Parameter (net.opengis.sensorml.x20.ParameterListType.Parameter)1 DataComponentPropertyType (net.opengis.swe.x101.DataComponentPropertyType)1 DescribedObject (org.n52.shetland.ogc.sensorML.v20.DescribedObject)1 SmlDataInterface (org.n52.shetland.ogc.sensorML.v20.SmlDataInterface)1 SweDataArray (org.n52.shetland.ogc.swe.SweDataArray)1 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)1 SweEnvelope (org.n52.shetland.ogc.swe.SweEnvelope)1 SweSimpleDataRecord (org.n52.shetland.ogc.swe.SweSimpleDataRecord)1 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)1 SweCategory (org.n52.shetland.ogc.swe.simpleType.SweCategory)1 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)1 SweObservableProperty (org.n52.shetland.ogc.swe.simpleType.SweObservableProperty)1