use of org.n52.shetland.ogc.om.values.TextValue in project arctic-sea by 52North.
the class JSONBinding method parseRequest.
private OwsServiceRequest parseRequest(HttpServletRequest request) throws OwsExceptionReport {
try {
JsonNode json = Json.loadReader(request.getReader());
if (LOG.isDebugEnabled()) {
LOG.debug("JSON-REQUEST: {}", Json.print(json));
}
OperationDecoderKey key = new OperationDecoderKey(json.path(SERVICE).textValue(), json.path(VERSION).textValue(), json.path(REQUEST).textValue(), MediaTypes.APPLICATION_JSON);
Decoder<OwsServiceRequest, JsonNode> decoder = getDecoder(key);
if (decoder == null) {
NoDecoderForKeyException cause = new NoDecoderForKeyException(key);
throw new NoApplicableCodeException().withMessage(cause.getMessage()).causedBy(cause);
}
OwsServiceRequest sosRequest;
try {
sosRequest = decoder.decode(json);
} catch (OwsDecodingException ex) {
throw ex.getCause();
} catch (DecodingException ex) {
throw new NoApplicableCodeException().withMessage(ex.getMessage()).causedBy(ex);
}
sosRequest.setRequestContext(getRequestContext(request));
return sosRequest;
} catch (IOException ioe) {
throw new NoApplicableCodeException().causedBy(ioe).withMessage("Error while reading request! Message: %s", ioe.getMessage());
}
}
use of org.n52.shetland.ogc.om.values.TextValue in project arctic-sea by 52North.
the class DeleteSensorRequestDecoder method decodeRequest.
@Override
protected DeleteSensorRequest decodeRequest(JsonNode node) {
DeleteSensorRequest req = new DeleteSensorRequest();
req.setProcedureIdentifier(node.path(JSONConstants.PROCEDURE).textValue());
return req;
}
use of org.n52.shetland.ogc.om.values.TextValue in project arctic-sea by 52North.
the class DescribeSensorRequestDecoder method decodeRequest.
@Override
protected DescribeSensorRequest decodeRequest(JsonNode node) {
DescribeSensorRequest req = new DescribeSensorRequest();
req.setProcedure(node.path(JSONConstants.PROCEDURE).textValue());
req.setProcedureDescriptionFormat(node.path(JSONConstants.PROCEDURE_DESCRIPTION_FORMAT).textValue());
if (node.has(JSONConstants.VALID_TIME)) {
req.setValidTime(parseTime(node.path(JSONConstants.VALID_TIME)));
}
return req;
}
use of org.n52.shetland.ogc.om.values.TextValue in project arctic-sea by 52North.
the class FieldDecoder method decodeJSON.
public SweField decodeJSON(JsonNode node) throws DecodingException {
final String type = node.path(JSONConstants.TYPE).textValue();
final SweAbstractDataComponent element;
if (type.equals(JSONConstants.BOOLEAN_TYPE)) {
element = decodeBoolean(node);
} else if (type.equals(JSONConstants.COUNT_TYPE)) {
element = decodeCount(node);
} else if (type.equals(JSONConstants.COUNT_RANGE_TYPE)) {
element = decodeCountRange(node);
} else if (type.equals(JSONConstants.OBSERVABLE_PROPERTY_TYPE)) {
element = decodeObservableProperty(node);
} else if (type.equals(JSONConstants.QUALITY_TYPE)) {
element = decodeQuality(node);
} else if (type.equals(JSONConstants.TEXT_TYPE)) {
element = decodeText(node);
} else if (type.equals(JSONConstants.QUANTITY_TYPE)) {
element = decodeQuantity(node);
} else if (type.equals(JSONConstants.QUANTITY_RANGE_TYPE)) {
element = decodeQuantityRange(node);
} else if (type.equals(JSONConstants.TIME_TYPE)) {
element = decodeTime(node);
} else if (type.equals(JSONConstants.TIME_RANGE_TYPE)) {
element = decodeTimeRange(node);
} else if (type.equals(JSONConstants.CATEGORY_TYPE)) {
element = decodeCategory(node);
} else {
throw new UnsupportedDecoderInputException(this, node);
}
final String name = node.path(JSONConstants.NAME).textValue();
element.setDescription(node.path(JSONConstants.DESCRIPTION).textValue());
element.setIdentifier(node.path(JSONConstants.IDENTIFIER).textValue());
element.setDefinition(node.path(JSONConstants.DEFINITION).textValue());
element.setLabel(node.path(JSONConstants.LABEL).textValue());
return new SweField(name, element);
}
use of org.n52.shetland.ogc.om.values.TextValue in project arctic-sea by 52North.
the class FieldDecoder method decodeQuantityRange.
protected SweAbstractDataComponent decodeQuantityRange(JsonNode node) {
SweQuantityRange swe = new SweQuantityRange();
if (node.hasNonNull(JSONConstants.VALUE)) {
BigDecimal start = BigDecimal.valueOf(node.path(JSONConstants.VALUE).path(0).doubleValue());
BigDecimal end = BigDecimal.valueOf(node.path(JSONConstants.VALUE).path(1).doubleValue());
swe.setValue(new RangeValue<BigDecimal>(start, end));
}
return swe.setUom(node.path(JSONConstants.UOM).textValue());
}
Aggregations