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);
}
}
Aggregations