use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class InsertSensorRequestDecoder method parseProcedureDescription.
private SosProcedureDescription<?> parseProcedureDescription(JsonNode path, String pdf) throws DecodingException {
try {
final XmlObject xb = XmlObject.Factory.parse(path.textValue());
Decoder<?, XmlObject> decoder = getProcedureDescriptionDecoder(pdf, xb);
if (decoder == null) {
throw new DecodingException(JSONConstants.PROCEDURE_DESCRIPTION_FORMAT, "The requested %s is not supported!", JSONConstants.PROCEDURE_DESCRIPTION_FORMAT);
}
Object decode = decoder.decode(xb);
if (decode instanceof SosProcedureDescription<?>) {
return (SosProcedureDescription<?>) decode;
} else if (decode instanceof AbstractFeature) {
return new SosProcedureDescription<AbstractFeature>((AbstractFeature) decode);
} else {
throw new DecodingException("The decoded element {} is not of type {}!", decode.getClass().getName(), AbstractFeature.class.getName());
}
} catch (final XmlException xmle) {
throw new DecodingException("Error while parsing procedure description of InsertSensor request!", xmle);
}
}
use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class ObservationDecoder method parseParameter.
protected Collection<NamedValue<?>> parseParameter(JsonNode node) throws DecodingException {
Set<NamedValue<?>> parameters = Sets.newTreeSet();
JsonNode parameter = node.path(JSONConstants.PARAMETER);
if (parameter.isArray()) {
for (JsonNode jsonNode : parameter) {
parameters.add(parseNamedValue(jsonNode));
}
} else if (parameter.isObject()) {
parameters.add(parseNamedValue(parameter));
}
return parameters;
}
use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class ObservationDecoder method decodeJSON.
protected OmObservation decodeJSON(JsonNode node) throws DecodingException {
if (node.isObject()) {
OmObservation o = new OmObservation();
o.setIdentifier(parseIdentifier(node));
o.setValidTime(parseValidTime(node));
o.setResultTime(parseResultTime(node));
o.setValue(parseValue(node));
o.setParameter(parseParameter(node));
o.setObservationConstellation(parseObservationConstellation(node));
return o;
} else {
return null;
}
}
use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class ObservationDecoder method parseObservationConstellation.
public OmObservationConstellation parseObservationConstellation(JsonNode node) throws DecodingException {
OmObservationConstellation oc = new OmObservationConstellation();
oc.setProcedure(parseProcedure(node));
oc.setObservableProperty(parseObservableProperty(node));
oc.setObservationType(parseObservationType(node));
oc.setFeatureOfInterest(parseFeatureOfInterest(node));
return oc;
}
use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.
the class RelatedPartyJSONDecoder method decodeJSON.
@Override
public RelatedParty decodeJSON(JsonNode node, boolean validate) throws DecodingException {
RelatedParty relatedParty = new RelatedParty();
relatedParty.setContact(decodeJsonToNillable(node.path(AQDJSONConstants.CONTACT), Contact.class));
relatedParty.setIndividualName(parseNillable(node.path(AQDJSONConstants.INDIVIDUAL_NAME)).map(this::parseFreeText));
relatedParty.setOrganisationName(parseNillable(node.path(AQDJSONConstants.ORGANISATION_NAME)).map(this::parseFreeText));
relatedParty.setPositionName(parseNillable(node.path(AQDJSONConstants.POSITION_NAME)).map(this::parseFreeText));
for (JsonNode n : node.path(AQDJSONConstants.ROLES)) {
relatedParty.addRole(parseNillableReference(n));
}
return relatedParty;
}
Aggregations