use of org.n52.shetland.ogc.sos.ro.RelatedOfferings in project arctic-sea by 52North.
the class RelatedOfferingTypeDecoder method decode.
@Override
public RelatedOfferings decode(RelatedOfferingsPropertyType rot) throws DecodingException {
RelatedOfferings relatedOfferings = new RelatedOfferings();
relatedOfferings.setNamespace(RelatedOfferingConstants.NS_RO).setDefinition(RelatedOfferingConstants.RELATED_OFFERINGS).setIdentifier(RelatedOfferingConstants.RELATED_OFFERINGS);
for (RelatedOffering relatedOffering : rot.getRelatedOfferings().getRelatedOfferingArray()) {
relatedOfferings.getValue().add(parseRelatedOffering(relatedOffering));
}
return relatedOfferings;
}
use of org.n52.shetland.ogc.sos.ro.RelatedOfferings in project arctic-sea by 52North.
the class RelatedOfferingXmlStreamWriterTest method should_encode_relatedOfferings.
@Test
public void should_encode_relatedOfferings() throws XMLStreamException, EncodingException, XmlException, IOException {
RelatedOfferings ro = new RelatedOfferings();
ro.addValue("role_1", "offering_1");
ro.addValue("role_2", "offering_2");
try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
new RelatedOfferingXmlStreamWriter(EncodingContext.of(EncoderFlags.ENCODER_REPOSITORY, new EncoderRepository()), out, ro).write();
XmlObject.Factory.parse(new String(out.toByteArray()));
}
}
use of org.n52.shetland.ogc.sos.ro.RelatedOfferings in project arctic-sea by 52North.
the class RelatedOfferingsEncoder method encode.
@Override
public XmlObject encode(RelatedOfferings objectToEncode, EncodingContext ctx) throws EncodingException {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
EncodingContext context = ctx.with(EncoderFlags.ENCODER_REPOSITORY, getEncoderRepository()).with(XmlEncoderFlags.XML_OPTIONS, (Supplier<XmlOptions>) this::getXmlOptions);
new RelatedOfferingXmlStreamWriter(context, baos, objectToEncode).write();
return XmlObject.Factory.parse(baos.toString("UTF8"));
} catch (XMLStreamException | XmlException | UnsupportedEncodingException ex) {
String message = String.format("Error encoding %s", objectToEncode.getClass().getSimpleName());
throw new EncodingException(message, ex);
}
}
Aggregations