Search in sources :

Example 61 with EncodingException

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

Example 62 with EncodingException

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);
}
Also used : EnvironmentalMonitoringFacilityDocument(eu.europa.ec.inspire.schemas.ef.x40.EnvironmentalMonitoringFacilityDocument) EnvironmentalMonitoringFacility(org.n52.shetland.inspire.ef.EnvironmentalMonitoringFacility) UnsupportedEncoderInputException(org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)

Example 63 with EncodingException

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));
        }
    }
}
Also used : TimeOperator(org.n52.shetland.ogc.filter.FilterConstants.TimeOperator) TemporalOperatorType(net.opengis.fes.x20.TemporalOperatorType) TemporalOperatorsType(net.opengis.fes.x20.TemporalOperatorsType) TemporalOperandsType(net.opengis.fes.x20.TemporalOperandsType)

Example 64 with EncodingException

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);
    }
}
Also used : OwsDomain(org.n52.shetland.ogc.ows.OwsDomain) XmlObject(org.apache.xmlbeans.XmlObject)

Example 65 with EncodingException

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);
}
Also used : EncodingException(org.n52.svalbard.encode.exception.EncodingException) SosProcedureDescriptionUnknownType(org.n52.shetland.ogc.sos.SosProcedureDescriptionUnknownType) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)124 Test (org.junit.Test)93 EncodingException (org.n52.svalbard.encode.exception.EncodingException)60 SweField (org.n52.shetland.ogc.swe.SweField)29 UnsupportedEncoderInputException (org.n52.svalbard.encode.exception.UnsupportedEncoderInputException)29 SimpleDataRecordType (net.opengis.swe.x101.SimpleDataRecordType)22 SweDataRecord (org.n52.shetland.ogc.swe.SweDataRecord)21 XmlException (org.apache.xmlbeans.XmlException)20 DateTime (org.joda.time.DateTime)19 OmObservation (org.n52.shetland.ogc.om.OmObservation)19 TimePeriod (org.n52.shetland.ogc.gml.time.TimePeriod)17 Time (org.n52.shetland.ogc.gml.time.Time)15 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)15 SweCount (org.n52.shetland.ogc.swe.simpleType.SweCount)13 SweQuantity (org.n52.shetland.ogc.swe.simpleType.SweQuantity)13 AnyScalarPropertyType (net.opengis.swe.x101.AnyScalarPropertyType)12 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)12 SweText (org.n52.shetland.ogc.swe.simpleType.SweText)12 SystemType (net.opengis.sensorML.x101.SystemType)11 DataRecordType (net.opengis.swe.x101.DataRecordType)11