use of org.n52.svalbard.encode.exception.EncodingException 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);
}
}
use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class EnvironmentalMonitoringFaciltityDocumentEncoder method encode.
@Override
public XmlObject encode(AbstractFeature abstractFeature, EncodingContext context) throws EncodingException {
if (abstractFeature instanceof EnvironmentalMonitoringFacility) {
EnvironmentalMonitoringFacilityDocument emfpd = EnvironmentalMonitoringFacilityDocument.Factory.newInstance();
emfpd.setEnvironmentalMonitoringFacility(createEnvironmentalMonitoringFaciltityType((EnvironmentalMonitoringFacility) abstractFeature));
return emfpd;
}
throw new UnsupportedEncoderInputException(this, abstractFeature);
}
use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class FesEncoderv20 method setTemporalFilterCapabilities.
/**
* Sets the TemporalFilterCapabilities.
*
* @param temporalCapabilitiesType FES TemporalCapabilities.
* @param sosFilterCaps SOS temporal filter information
*
* @throws org.n52.svalbard.encode.exception.EncodingException if one of the temporal operators is not supported
*/
private void setTemporalFilterCapabilities(TemporalCapabilitiesType temporalCapabilitiesType, org.n52.shetland.ogc.filter.FilterCapabilities sosFilterCaps) throws EncodingException {
// set TemporalOperands
if (sosFilterCaps.getTemporalOperands() != null && !sosFilterCaps.getTemporalOperands().isEmpty()) {
TemporalOperandsType tempOperands = temporalCapabilitiesType.addNewTemporalOperands();
sosFilterCaps.getTemporalOperands().forEach(operand -> tempOperands.addNewTemporalOperand().setName(operand));
}
// set TemporalOperators
if (sosFilterCaps.getTemporalOperators() != null && !sosFilterCaps.getTemporalOperators().isEmpty()) {
TemporalOperatorsType temporalOps = temporalCapabilitiesType.addNewTemporalOperators();
Set<TimeOperator> keys = sosFilterCaps.getTemporalOperators().keySet();
for (TimeOperator temporalOperator : keys) {
TemporalOperatorType operator = temporalOps.addNewTemporalOperator();
operator.setName(getEnum4TemporalOperator(temporalOperator));
TemporalOperandsType bboxGeomOps = operator.addNewTemporalOperands();
sosFilterCaps.getTemporalOperators().get(temporalOperator).forEach(operand -> bboxGeomOps.addNewTemporalOperand().setName(operand));
}
}
}
use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class FesEncoderv20 method setConformance.
/**
* Sets the FES conformance classes in the filter capabilities section.
*
* @param conformance XML FES conformence
* @param sosConformance Service conformance
*
* @throws EncodingException If an error occurs
*/
private void setConformance(final ConformanceType conformance, Collection<OwsDomain> sosConformance) throws EncodingException {
for (OwsDomain owsDomainType : sosConformance) {
XmlObject encodeObjectToXml = encodeObjectToXml(OWSConstants.NS_OWS, owsDomainType);
conformance.addNewConstraint().set(encodeObjectToXml);
}
}
use of org.n52.svalbard.encode.exception.EncodingException in project arctic-sea by 52North.
the class InsertSensorRequestEncoder method addProcedureDescription.
private void addProcedureDescription(InsertSensorRequest request, InsertSensorType insertSensor) throws EncodingException {
XmlObject xmlObj;
if (request.getProcedureDescription() instanceof SosProcedureDescriptionUnknownType && request.getProcedureDescription().isSetXml()) {
try {
xmlObj = XmlHelper.parseXmlString(request.getProcedureDescription().getXml());
} catch (DecodingException de) {
throw new EncodingException("An xml error occured when parsing the request!", de);
}
}
xmlObj = encodeObjectToXml(request.getProcedureDescriptionFormat(), request.getProcedureDescription().getProcedureDescription());
insertSensor.addNewProcedureDescription().set(xmlObj);
}
Aggregations