Search in sources :

Example 76 with DecodingException

use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.

the class SosDecoderv20 method parseGetFeatureOfInterest.

// private SwesExtensions parseSwesExtensions(final XmlObject[]
// extensionArray) throws OwsExceptionReport
// {
// final SwesExtensions extensions = new SwesExtensions();
// for (final XmlObject xbSwesExtension : extensionArray) {
// 
// final Object obj = CodingHelper.decodeXmlElement(xbSwesExtension);
// if (obj instanceof SwesExtension<?>) {
// extensions.addSwesExtension((SwesExtension<?>) obj);
// }
// }
// return extensions;
// }
/**
 * parses the passes XmlBeans document and creates a SOS
 * getFeatureOfInterest request
 *
 * @param getFoiDoc
 *            XmlBeans document representing the getFeatureOfInterest
 *            request
 * @return Returns SOS getFeatureOfInterest request
 *
 * @throws DecodingException
 *             * if validation of the request failed
 */
private OwsServiceRequest parseGetFeatureOfInterest(final GetFeatureOfInterestDocument getFoiDoc) throws DecodingException {
    final GetFeatureOfInterestRequest getFoiRequest = new GetFeatureOfInterestRequest();
    final GetFeatureOfInterestType getFoiType = getFoiDoc.getGetFeatureOfInterest();
    getFoiRequest.setService(getFoiType.getService());
    getFoiRequest.setVersion(getFoiType.getVersion());
    getFoiRequest.setFeatureIdentifiers(Arrays.asList(getFoiType.getFeatureOfInterestArray()));
    getFoiRequest.setObservedProperties(Arrays.asList(getFoiType.getObservedPropertyArray()));
    getFoiRequest.setProcedures(Arrays.asList(getFoiType.getProcedureArray()));
    getFoiRequest.setSpatialFilters(parseSpatialFilters4GetFeatureOfInterest(getFoiType.getSpatialFilterArray()));
    getFoiRequest.setExtensions(parseExtensibleRequest(getFoiType));
    return getFoiRequest;
}
Also used : GetFeatureOfInterestRequest(org.n52.shetland.ogc.sos.request.GetFeatureOfInterestRequest) GetFeatureOfInterestType(net.opengis.sos.x20.GetFeatureOfInterestType)

Example 77 with DecodingException

use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.

the class SosDecoderv20 method parseInsertResultTemplate.

private OwsServiceRequest parseInsertResultTemplate(final InsertResultTemplateDocument insertResultTemplateDoc) throws DecodingException {
    InsertResultTemplateRequest sosInsertResultTemplate = new InsertResultTemplateRequest();
    InsertResultTemplateType insertResultTemplate = insertResultTemplateDoc.getInsertResultTemplate();
    sosInsertResultTemplate.setService(insertResultTemplate.getService());
    sosInsertResultTemplate.setVersion(insertResultTemplate.getVersion());
    ResultTemplateType resultTemplate = insertResultTemplate.getProposedTemplate().getResultTemplate();
    sosInsertResultTemplate.setIdentifier(resultTemplate.getIdentifier());
    OmObservationConstellation sosObservationConstellation = parseObservationTemplate(resultTemplate.getObservationTemplate());
    sosObservationConstellation.addOffering(resultTemplate.getOffering());
    sosInsertResultTemplate.setObservationTemplate(sosObservationConstellation);
    try {
        sosInsertResultTemplate.setResultStructure(parseResultStructure(XmlObject.Factory.parse(resultTemplate.getResultStructure().xmlText())));
        sosInsertResultTemplate.setResultEncoding(parseResultEncoding(XmlObject.Factory.parse(resultTemplate.getResultEncoding().xmlText())));
    } catch (XmlException e) {
        throw new DecodingException(e, "Error while parsing InsertResultTemplate request!");
    }
    sosInsertResultTemplate.setExtensions(parseExtensibleRequest(insertResultTemplate));
    return sosInsertResultTemplate;
}
Also used : InsertResultTemplateType(net.opengis.sos.x20.InsertResultTemplateType) XmlException(org.apache.xmlbeans.XmlException) DecodingException(org.n52.svalbard.decode.exception.DecodingException) OmObservationConstellation(org.n52.shetland.ogc.om.OmObservationConstellation) ResultTemplateType(net.opengis.sos.x20.ResultTemplateType) GetResultTemplateType(net.opengis.sos.x20.GetResultTemplateType) InsertResultTemplateType(net.opengis.sos.x20.InsertResultTemplateType) InsertResultTemplateRequest(org.n52.shetland.ogc.sos.request.InsertResultTemplateRequest)

Example 78 with DecodingException

use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.

the class SosDecoderv20 method parseGetObservationById.

private OwsServiceRequest parseGetObservationById(final GetObservationByIdDocument getObsByIdDoc) throws DecodingException {
    final GetObservationByIdRequest getObsByIdRequest = new GetObservationByIdRequest();
    final GetObservationByIdType getObsByIdType = getObsByIdDoc.getGetObservationById();
    getObsByIdRequest.setService(getObsByIdType.getService());
    getObsByIdRequest.setVersion(getObsByIdType.getVersion());
    getObsByIdRequest.setObservationIdentifier(Arrays.asList(getObsByIdType.getObservationArray()));
    getObsByIdRequest.setExtensions(parseExtensibleRequest(getObsByIdType));
    return getObsByIdRequest;
}
Also used : GetObservationByIdType(net.opengis.sos.x20.GetObservationByIdType) GetObservationByIdRequest(org.n52.shetland.ogc.sos.request.GetObservationByIdRequest)

Example 79 with DecodingException

use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.

the class SosDecoderv20 method parseGetCapabilities.

/**
 * parses the XmlBean representing the getCapabilities request and creates a
 * SosGetCapabilities request
 *
 * @param getCapsDoc
 *            XmlBean created from the incoming request stream
 * @return Returns SosGetCapabilitiesRequest representing the request
 *
 * @throws DecodingException
 *             * If parsing the XmlBean failed
 */
private OwsServiceRequest parseGetCapabilities(final GetCapabilitiesDocument getCapsDoc) throws DecodingException {
    final GetCapabilitiesType getCapsType = getCapsDoc.getGetCapabilities2();
    final GetCapabilitiesRequest request = new GetCapabilitiesRequest(getCapsType.getService());
    if (getCapsType.getAcceptFormats() != null && getCapsType.getAcceptFormats().sizeOfOutputFormatArray() != 0) {
        request.setAcceptFormats(Arrays.asList(getCapsType.getAcceptFormats().getOutputFormatArray()));
    }
    if (getCapsType.getAcceptVersions() != null && getCapsType.getAcceptVersions().sizeOfVersionArray() != 0) {
        request.setAcceptVersions(Arrays.asList(getCapsType.getAcceptVersions().getVersionArray()));
    }
    if (getCapsType.getSections() != null && getCapsType.getSections().getSectionArray().length != 0) {
        request.setSections(Arrays.asList(getCapsType.getSections().getSectionArray()));
    }
    if (getCapsType.getExtensionArray() != null && getCapsType.getExtensionArray().length > 0) {
        request.setExtensions(parseExtensibleRequestExtension(getCapsType.getExtensionArray()));
    }
    return request;
}
Also used : GetCapabilitiesRequest(org.n52.shetland.ogc.ows.service.GetCapabilitiesRequest) GetCapabilitiesType(net.opengis.sos.x20.GetCapabilitiesType)

Example 80 with DecodingException

use of org.n52.svalbard.decode.exception.DecodingException in project arctic-sea by 52North.

the class SpecimenDecoderv20 method parseSpatialSamplingFeature.

private AbstractFeature parseSpatialSamplingFeature(final SFSpecimenType sfst) throws DecodingException {
    final SfSpecimen specimen = new SfSpecimen(null, sfst.getId());
    // parse identifier, names, description
    parseAbstractFeatureType(sfst, specimen);
    specimen.setSampledFeatures(getSampledFeatures(sfst.getSampledFeatureArray()));
    specimen.setXml(getXmlDescription(sfst));
    if (sfst.getParameterArray() != null) {
        specimen.setParameters(parseNamedValueTypeArray(sfst.getParameterArray()));
    }
    // TODO
    sfst.getMaterialClass();
    specimen.setMaterialClass((ReferenceType) decodeXmlElement(sfst.getMaterialClass()));
    specimen.setSamplingTime(getSamplingTime(sfst));
    // samplingLocation
    if (sfst.isSetSamplingLocation()) {
        specimen.setSamplingLocation(getGeometry(sfst));
    }
    // sfst.getProcessingDetailsArray();
    if (sfst.isSetSize()) {
        specimen.setSize(getSize(sfst.getSize()));
    }
    // }
    if (sfst.isSetSpecimenType()) {
        specimen.setSpecimenType((ReferenceType) decodeXmlElement(sfst.getSpecimenType()));
    }
    return specimen;
}
Also used : SfSpecimen(org.n52.shetland.ogc.om.features.samplingFeatures.SfSpecimen)

Aggregations

Test (org.junit.Test)92 DecodingException (org.n52.svalbard.decode.exception.DecodingException)63 XmlObject (org.apache.xmlbeans.XmlObject)52 JsonNode (com.fasterxml.jackson.databind.JsonNode)25 SweField (org.n52.shetland.ogc.swe.SweField)25 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)23 XmlException (org.apache.xmlbeans.XmlException)23 GetObservationRequest (org.n52.shetland.ogc.sos.request.GetObservationRequest)22 UnsupportedDecoderInputException (org.n52.svalbard.decode.exception.UnsupportedDecoderInputException)21 AbstractProcess (org.n52.shetland.ogc.sensorML.AbstractProcess)13 SystemType (net.opengis.sensorML.x101.SystemType)12 TimeInstant (org.n52.shetland.ogc.gml.time.TimeInstant)12 Before (org.junit.Before)11 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)11 SensorMLDocument (net.opengis.sensorML.x101.SensorMLDocument)10 DateTime (org.joda.time.DateTime)10 SweAbstractDataComponent (org.n52.shetland.ogc.swe.SweAbstractDataComponent)10 XmlString (org.apache.xmlbeans.XmlString)9 SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)8 Geometry (org.locationtech.jts.geom.Geometry)8