Search in sources :

Example 1 with AqdGetObservationResponseXmlStreamWriter

use of org.n52.svalbard.write.AqdGetObservationResponseXmlStreamWriter in project arctic-sea by 52North.

the class AqdGetObservationResponseEncoder method create.

@Override
protected void create(GetObservationResponse response, OutputStream outputStream, EncodingContext ctx) throws EncodingException {
    FeatureCollection featureCollection = createFeatureCollection(response);
    EReportingHeader eReportingHeader;
    TimePeriod timePeriod;
    try {
        eReportingHeader = getEReportingHeader(getReportObligationType(response));
        featureCollection.addMember(eReportingHeader);
        timePeriod = addToFeatureCollectionAndGetTimePeriod(featureCollection, response, eReportingHeader);
    } catch (OwsExceptionReport ex) {
        throw new EncodingException(ex);
    }
    if (!timePeriod.isEmpty()) {
        eReportingHeader.setReportingPeriod(Referenceable.of((Time) timePeriod));
    }
    try {
        EncodingContext context = ctx.with(EncoderFlags.ENCODER_REPOSITORY, getEncoderRepository()).with(XmlEncoderFlags.XML_OPTIONS, (Supplier<XmlOptions>) this::getXmlOptions).with(XmlEncoderFlags.ENCODE_NAMESPACE, OmConstants.NS_OM_2).with(XmlBeansEncodingFlags.DOCUMENT);
        new AqdGetObservationResponseXmlStreamWriter(context, outputStream, featureCollection).write();
    } catch (XMLStreamException xmlse) {
        throw new EncodingException("Error while writing element to stream!", xmlse);
    }
}
Also used : XMLStreamException(javax.xml.stream.XMLStreamException) FeatureCollection(org.n52.shetland.ogc.om.features.FeatureCollection) EncodingException(org.n52.svalbard.encode.exception.EncodingException) EReportingHeader(org.n52.shetland.aqd.EReportingHeader) TimePeriod(org.n52.shetland.ogc.gml.time.TimePeriod) AqdGetObservationResponseXmlStreamWriter(org.n52.svalbard.write.AqdGetObservationResponseXmlStreamWriter) Time(org.n52.shetland.ogc.gml.time.Time) DateTime(org.joda.time.DateTime) Supplier(java.util.function.Supplier) OwsExceptionReport(org.n52.shetland.ogc.ows.exception.OwsExceptionReport)

Aggregations

Supplier (java.util.function.Supplier)1 XMLStreamException (javax.xml.stream.XMLStreamException)1 DateTime (org.joda.time.DateTime)1 EReportingHeader (org.n52.shetland.aqd.EReportingHeader)1 Time (org.n52.shetland.ogc.gml.time.Time)1 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)1 FeatureCollection (org.n52.shetland.ogc.om.features.FeatureCollection)1 OwsExceptionReport (org.n52.shetland.ogc.ows.exception.OwsExceptionReport)1 EncodingException (org.n52.svalbard.encode.exception.EncodingException)1 AqdGetObservationResponseXmlStreamWriter (org.n52.svalbard.write.AqdGetObservationResponseXmlStreamWriter)1