Search in sources :

Example 41 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class Soap12Decoder method getBodyContent.

private OwsServiceRequest getBodyContent(EnvelopeDocument doc) throws DecodingException {
    Body body = doc.getEnvelope().getBody();
    try {
        Node domNode = body.getDomNode();
        if (domNode.hasChildNodes()) {
            NodeList childNodes = domNode.getChildNodes();
            for (int i = 0; i < childNodes.getLength(); i++) {
                Node node = childNodes.item(i);
                if (node.getNodeType() == Node.ELEMENT_NODE) {
                    XmlObject content = XmlObject.Factory.parse(node);
                    // fix problem with invalid prefix in xsi:type value for
                    // om:result, e.g. OM_SWEArrayObservation or
                    // gml:ReferenceType
                    Map<?, ?> namespaces = XmlHelper.getNamespaces(doc.getEnvelope());
                    fixNamespaceForXsiType(content, namespaces);
                    XmlHelper.fixNamespaceForXsiType(content, SweConstants.QN_DATA_ARRAY_PROPERTY_TYPE_SWE_200);
                    return decodeXmlElement(content);
                }
            }
        }
        return decodeXmlElement(body);
    } catch (XmlException xmle) {
        throw new DecodingException("Error while parsing SOAP body element!", xmle);
    }
}
Also used : XmlException(org.apache.xmlbeans.XmlException) Node(org.w3c.dom.Node) NodeList(org.w3c.dom.NodeList) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) Body(org.w3.x2003.x05.soapEnvelope.Body)

Example 42 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class SweCommonDecoderV101 method parseQuantityRange.

private SweQuantityRange parseQuantityRange(QuantityRange xbQuantityRange) throws DecodingException {
    SweQuantityRange sosQuantityRange = new SweQuantityRange();
    if (xbQuantityRange.isSetAxisID()) {
        sosQuantityRange.setAxisID(xbQuantityRange.getAxisID());
    }
    if (xbQuantityRange.isSetDefinition()) {
        sosQuantityRange.setDefinition(xbQuantityRange.getDefinition());
    }
    if (xbQuantityRange.isSetDescription()) {
        sosQuantityRange.setDescription(xbQuantityRange.getDescription().getStringValue());
    }
    if (xbQuantityRange.isSetUom() && xbQuantityRange.getUom().isSetCode()) {
        sosQuantityRange.setUom(xbQuantityRange.getUom().getCode());
    }
    if (xbQuantityRange.isSetValue()) {
        try {
            List<?> value = xbQuantityRange.getValue();
            BigDecimal rangeStart = new BigDecimal(value.get(0).toString());
            BigDecimal rangeEnd = new BigDecimal(value.get(1).toString());
            sosQuantityRange.setValue(new RangeValue<>(rangeStart, rangeEnd));
        } catch (final NumberFormatException | NullPointerException | IndexOutOfBoundsException nfe) {
            throw createParsingException(nfe);
        }
    }
    if (xbQuantityRange.isSetConstraint()) {
        LOGGER.error("Decoding of swe:QuantityRange/swe:constraint is not implemented");
    }
    if (xbQuantityRange.getQualityArray() != null && xbQuantityRange.getQualityArray().length > 0) {
        LOGGER.error("Decoding of swe:QuantityRange/swe:quality is not implemented");
    }
    return sosQuantityRange;
}
Also used : SweQuantityRange(org.n52.shetland.ogc.swe.simpleType.SweQuantityRange) BigDecimal(java.math.BigDecimal)

Example 43 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class SweCommonDecoderV101 method parseAllowedTimes.

@SuppressWarnings({ "unchecked", "rawtypes" })
private SweAllowedTimes parseAllowedTimes(AllowedTimes att) throws DateTimeParseException {
    SweAllowedTimes allowedTimes = new SweAllowedTimes();
    if (att.isSetId()) {
        allowedTimes.setGmlId(att.getId());
    }
    if (CollectionHelper.isNotNullOrEmpty(att.getValueListArray())) {
        for (List list : att.getValueListArray()) {
            if (CollectionHelper.isNotEmpty(list)) {
                for (Object value : list) {
                    allowedTimes.addValue(DateTimeHelper.parseIsoString2DateTime(value.toString()));
                }
            }
        }
    }
    if (CollectionHelper.isNotNullOrEmpty(att.getIntervalArray())) {
        for (List interval : att.getIntervalArray()) {
            RangeValue<DateTime> rangeValue = new RangeValue<DateTime>();
            Iterator iterator = interval.iterator();
            if (iterator.hasNext()) {
                rangeValue.setRangeStart(DateTimeHelper.parseIsoString2DateTime(iterator.next().toString()));
            }
            if (iterator.hasNext()) {
                rangeValue.setRangeEnd(DateTimeHelper.parseIsoString2DateTime(iterator.next().toString()));
            }
            allowedTimes.addInterval(rangeValue);
        }
    }
    return allowedTimes;
}
Also used : Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) XmlObject(org.apache.xmlbeans.XmlObject) SweAllowedTimes(org.n52.shetland.ogc.swe.simpleType.SweAllowedTimes) DateTime(org.joda.time.DateTime) RangeValue(org.n52.shetland.ogc.swe.RangeValue)

Example 44 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class SweCommonDecoderV20 method parseAllowedTimes.

@SuppressWarnings("rawtypes")
private SweAllowedTimes parseAllowedTimes(AllowedTimesType att) throws DateTimeParseException {
    SweAllowedTimes allowedTimes = new SweAllowedTimes();
    if (att.isSetId()) {
        allowedTimes.setGmlId(att.getId());
    }
    if (CollectionHelper.isNotNullOrEmpty(att.getValueArray())) {
        for (Object value : att.getValueArray()) {
            allowedTimes.addValue(DateTimeHelper.parseIsoString2DateTime(value.toString()));
        }
    }
    if (CollectionHelper.isNotNullOrEmpty(att.getIntervalArray())) {
        for (List interval : att.getIntervalArray()) {
            RangeValue<DateTime> rangeValue = new RangeValue<DateTime>();
            Iterator iterator = interval.iterator();
            if (iterator.hasNext()) {
                rangeValue.setRangeStart(DateTimeHelper.parseIsoString2DateTime(iterator.next().toString()));
            }
            if (iterator.hasNext()) {
                rangeValue.setRangeEnd(DateTimeHelper.parseIsoString2DateTime(iterator.next().toString()));
            }
            allowedTimes.addInterval(rangeValue);
        }
    }
    if (att.isSetSignificantFigures()) {
        allowedTimes.setSignificantFigures(att.getSignificantFigures());
    }
    return allowedTimes;
}
Also used : Iterator(java.util.Iterator) XmlObject(org.apache.xmlbeans.XmlObject) List(java.util.List) ArrayList(java.util.ArrayList) SweAllowedTimes(org.n52.shetland.ogc.swe.simpleType.SweAllowedTimes) DateTime(org.joda.time.DateTime) RangeValue(org.n52.shetland.ogc.swe.RangeValue)

Example 45 with Value

use of org.n52.shetland.ogc.om.values.Value in project arctic-sea by 52North.

the class SensorMLDecoderV101 method parseIoComponentPropertyType.

/**
 * Parses the components
 *
 * @param xbIoCompPropType XML components
 *
 * @return SOS components
 *
 * @throws DecodingException if an error occurs
 */
@SuppressWarnings({ "rawtypes" })
private SmlIo parseIoComponentPropertyType(final IoComponentPropertyType xbIoCompPropType) throws DecodingException {
    final SmlIo sosIo = new SmlIo();
    sosIo.setIoName(xbIoCompPropType.getName());
    XmlObject toDecode = null;
    if (xbIoCompPropType.isSetHref()) {
        sosIo.setHref(xbIoCompPropType.getHref());
        if (xbIoCompPropType.isSetTitle()) {
            sosIo.setTitle(xbIoCompPropType.getTitle());
        }
        return sosIo;
    }
    if (xbIoCompPropType.isSetBoolean()) {
        toDecode = xbIoCompPropType.getBoolean();
    } else if (xbIoCompPropType.isSetCategory()) {
        toDecode = xbIoCompPropType.getCategory();
    } else if (xbIoCompPropType.isSetCount()) {
        toDecode = xbIoCompPropType.getCount();
    } else if (xbIoCompPropType.isSetCountRange()) {
        toDecode = xbIoCompPropType.getCountRange();
    } else if (xbIoCompPropType.isSetObservableProperty()) {
        toDecode = xbIoCompPropType.getObservableProperty();
    } else if (xbIoCompPropType.isSetQuantity()) {
        toDecode = xbIoCompPropType.getQuantity();
    } else if (xbIoCompPropType.isSetQuantityRange()) {
        toDecode = xbIoCompPropType.getQuantityRange();
    } else if (xbIoCompPropType.isSetText()) {
        toDecode = xbIoCompPropType.getText();
    } else if (xbIoCompPropType.isSetTime()) {
        toDecode = xbIoCompPropType.getTime();
    } else if (xbIoCompPropType.isSetTimeRange()) {
        toDecode = xbIoCompPropType.getTimeRange();
    } else if (xbIoCompPropType.isSetAbstractDataArray1()) {
        toDecode = xbIoCompPropType.getAbstractDataArray1();
    } else if (xbIoCompPropType.isSetAbstractDataRecord()) {
        toDecode = xbIoCompPropType.getAbstractDataRecord();
    } else {
        throw new DecodingException(XmlHelper.getLocalName(xbIoCompPropType), "An 'IoComponentProperty' is not supported");
    }
    final Object decodedObject = decodeXmlElement(toDecode);
    if (decodedObject instanceof SweAbstractDataComponent) {
        sosIo.setIoValue((SweAbstractDataComponent) decodedObject);
    } else {
        throw new DecodingException(XmlHelper.getLocalName(xbIoCompPropType), "The 'IoComponentProperty' with type '%s' as value for '%s' is not supported.", XmlHelper.getLocalName(toDecode), XmlHelper.getLocalName(xbIoCompPropType));
    }
    return sosIo;
}
Also used : SweAbstractDataComponent(org.n52.shetland.ogc.swe.SweAbstractDataComponent) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) XmlObject(org.apache.xmlbeans.XmlObject) SmlIo(org.n52.shetland.ogc.sensorML.elements.SmlIo)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)28 Test (org.junit.Test)27 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)20 IoParameters (org.n52.io.request.IoParameters)19 SweField (org.n52.shetland.ogc.swe.SweField)16 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)13 QuantityValue (org.n52.shetland.ogc.om.values.QuantityValue)13 RequestSimpleParameterSet (org.n52.io.request.RequestSimpleParameterSet)12 List (java.util.List)9 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)9 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)7 CategoryValue (org.n52.shetland.ogc.om.values.CategoryValue)7 CountValue (org.n52.shetland.ogc.om.values.CountValue)7 SweBoolean (org.n52.shetland.ogc.swe.simpleType.SweBoolean)7 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)7 DecodingException (org.n52.svalbard.decode.exception.DecodingException)7 DateTime (org.joda.time.DateTime)6 ModelAndView (org.springframework.web.servlet.ModelAndView)6 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)5 ArrayList (java.util.ArrayList)5