Search in sources :

Example 1 with GetObservationByIdResponse

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;
}
Also used : EncodingException(org.n52.svalbard.encode.exception.EncodingException) OmObservation(org.n52.shetland.ogc.om.OmObservation) GetObservationResponse(org.n52.shetland.ogc.sos.response.GetObservationResponse) XmlObject(org.apache.xmlbeans.XmlObject) GetObservationByIdResponse(org.n52.shetland.ogc.sos.response.GetObservationByIdResponse) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Example 2 with GetObservationByIdResponse

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;
}
Also used : ObservationStream(org.n52.shetland.ogc.om.ObservationStream) HashMap(java.util.HashMap) EncodingException(org.n52.svalbard.encode.exception.EncodingException) OmObservation(org.n52.shetland.ogc.om.OmObservation) GetObservationByIdResponseDocument(net.opengis.sos.x20.GetObservationByIdResponseDocument) CodeWithAuthority(org.n52.shetland.ogc.gml.CodeWithAuthority) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport) GetObservationByIdResponseType(net.opengis.sos.x20.GetObservationByIdResponseType)

Example 3 with GetObservationByIdResponse

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);
}
Also used : GetObservationByIdResponse(org.n52.shetland.ogc.sos.response.GetObservationByIdResponse) UnsupportedDecoderInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderInputException) GetObservationByIdResponseType(net.opengis.sos.x20.GetObservationByIdResponseType) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

GetObservationByIdResponseType (net.opengis.sos.x20.GetObservationByIdResponseType)2 OmObservation (org.n52.shetland.ogc.om.OmObservation)2 GetObservationByIdResponse (org.n52.shetland.ogc.sos.response.GetObservationByIdResponse)2 EncodingException (org.n52.svalbard.encode.exception.EncodingException)2 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)1 HashMap (java.util.HashMap)1 GetObservationByIdResponseDocument (net.opengis.sos.x20.GetObservationByIdResponseDocument)1 XmlObject (org.apache.xmlbeans.XmlObject)1 CodeWithAuthority (org.n52.shetland.ogc.gml.CodeWithAuthority)1 ObservationStream (org.n52.shetland.ogc.om.ObservationStream)1 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)1 GetObservationResponse (org.n52.shetland.ogc.sos.response.GetObservationResponse)1 UnsupportedDecoderInputException (org.n52.svalbard.decode.exception.UnsupportedDecoderInputException)1 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)1