use of org.n52.shetland.ogc.sos.response.GetObservationByIdResponse in project arctic-sea by 52North.
the class OmEncoderv100 method encode.
@Override
public XmlObject encode(Object element, EncodingContext additionalValues) throws EncodingException {
XmlObject encodedObject = null;
if (element instanceof OmObservation) {
encodedObject = createObservation((OmObservation) element, additionalValues);
} else if (element instanceof GetObservationResponse) {
GetObservationResponse response = (GetObservationResponse) element;
encodedObject = createObservationCollection(response.getObservationCollection(), response.getResultModel());
} else if (element instanceof GetObservationByIdResponse) {
GetObservationByIdResponse response = (GetObservationByIdResponse) element;
encodedObject = createObservationCollection(response.getObservationCollection(), response.getResultModel());
} else {
throw new UnsupportedEncoderInputException(this, element);
}
XmlHelper.validateDocument(encodedObject, EncodingException::new);
return encodedObject;
}
use of org.n52.shetland.ogc.sos.response.GetObservationByIdResponse in project arctic-sea by 52North.
the class GetObservationByIdResponseEncoder method createResponse.
@Override
protected XmlObject createResponse(ObservationEncoder<XmlObject, OmObservation> encoder, GetObservationByIdResponse response) throws EncodingException {
GetObservationByIdResponseDocument doc = GetObservationByIdResponseDocument.Factory.newInstance(getXmlOptions());
GetObservationByIdResponseType xbResponse = doc.addNewGetObservationByIdResponse();
ObservationStream observations = getObservationsAndCheckForStreaming(response, encoder);
HashMap<CodeWithAuthority, String> gmlID4sfIdentifier = new HashMap<>();
try {
while (observations.hasNext()) {
OmObservation observation = observations.next();
EncodingContext codingContext = EncodingContext.empty();
CodeWithAuthority foiId = observation.getObservationConstellation().getFeatureOfInterest().getIdentifierCodeWithAuthority();
if (gmlID4sfIdentifier.containsKey(foiId)) {
codingContext = codingContext.with(XmlBeansEncodingFlags.EXIST_FOI_IN_DOC, true);
} else {
gmlID4sfIdentifier.put(foiId, GML_ID);
codingContext = codingContext.with(XmlBeansEncodingFlags.EXIST_FOI_IN_DOC, false);
}
codingContext = codingContext.with(XmlBeansEncodingFlags.GMLID, gmlID4sfIdentifier.get(foiId));
xbResponse.addNewObservation().addNewOMObservation().set(encoder.encode(observation, codingContext));
}
} catch (OwsExceptionReport ex) {
throw new EncodingException(ex);
}
XmlHelper.makeGmlIdsUnique(xbResponse.getDomNode());
return doc;
}
use of org.n52.shetland.ogc.sos.response.GetObservationByIdResponse in project arctic-sea by 52North.
the class GetObservationByIdResponseDocumentDecoder method decode.
@Override
@SuppressFBWarnings("NP_LOAD_OF_KNOWN_NULL_VALUE")
public GetObservationByIdResponse decode(GetObservationByIdResponseDocument doc) throws DecodingException {
if (doc != null) {
GetObservationByIdResponse response = new GetObservationByIdResponse();
setService(response);
setVersions(response);
GetObservationByIdResponseType type = doc.getGetObservationByIdResponse();
response.setExtensions(parseExtensibleResponse(type));
response.setObservationCollection(ObservationStream.of(parseObservations(type)));
return response;
}
throw new UnsupportedDecoderInputException(this, doc);
}
Aggregations