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);
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations