Search in sources :

Example 1 with InsertSensorDocument

use of net.opengis.swes.x20.InsertSensorDocument in project arctic-sea by 52North.

the class SwesDecoderv20 method decode.

@Override
public OwsServiceRequest decode(XmlObject xmlObject) throws DecodingException {
    LOGGER.debug("REQUESTTYPE:" + xmlObject.getClass());
    XmlHelper.validateDocument(xmlObject);
    if (xmlObject instanceof DescribeSensorDocument) {
        return parseDescribeSensor((DescribeSensorDocument) xmlObject);
    } else if (xmlObject instanceof InsertSensorDocument) {
        return parseInsertSensor((InsertSensorDocument) xmlObject);
    } else if (xmlObject instanceof UpdateSensorDescriptionDocument) {
        return parseUpdateSensorDescription((UpdateSensorDescriptionDocument) xmlObject);
    } else if (xmlObject instanceof DeleteSensorDocument) {
        return parseDeleteSensor((DeleteSensorDocument) xmlObject);
    } else {
        throw new UnsupportedDecoderXmlInputException(this, xmlObject);
    }
}
Also used : InsertSensorDocument(net.opengis.swes.x20.InsertSensorDocument) DeleteSensorDocument(net.opengis.swes.x20.DeleteSensorDocument) DescribeSensorDocument(net.opengis.swes.x20.DescribeSensorDocument) UnsupportedDecoderXmlInputException(org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException) UpdateSensorDescriptionDocument(net.opengis.swes.x20.UpdateSensorDescriptionDocument)

Example 2 with InsertSensorDocument

use of net.opengis.swes.x20.InsertSensorDocument in project arctic-sea by 52North.

the class SwesDecoderv20 method parseInsertSensor.

private OwsServiceRequest parseInsertSensor(final InsertSensorDocument xbInsSensDoc) throws DecodingException {
    final InsertSensorRequest request = new InsertSensorRequest();
    final InsertSensorType xbInsertSensor = xbInsSensDoc.getInsertSensor();
    request.setService(xbInsertSensor.getService());
    request.setVersion(xbInsertSensor.getVersion());
    // format
    request.setProcedureDescriptionFormat(xbInsertSensor.getProcedureDescriptionFormat());
    // observable properties
    if (CollectionHelper.isNotNullOrEmpty(xbInsertSensor.getObservablePropertyArray())) {
        request.setObservableProperty(Arrays.asList(xbInsertSensor.getObservablePropertyArray()));
    }
    // related features
    if (CollectionHelper.isNotNullOrEmpty(xbInsertSensor.getRelatedFeatureArray())) {
        request.setRelatedFeature(parseRelatedFeature(xbInsertSensor.getRelatedFeatureArray()));
    }
    // metadata
    if (CollectionHelper.isNotNullOrEmpty(xbInsertSensor.getMetadataArray())) {
        request.setMetadata(parseMetadata(xbInsertSensor.getMetadataArray()));
    }
    // extensions
    request.setExtensions(parseExtensibleRequest(xbInsertSensor));
    try {
        final XmlObject xbProcedureDescription = XmlObject.Factory.parse(getNodeFromNodeList(xbInsertSensor.getProcedureDescription().getDomNode().getChildNodes()));
        checkFormatWithNamespace(xbInsertSensor.getProcedureDescriptionFormat(), XmlHelper.getNamespace(xbProcedureDescription));
        final Decoder<?, XmlObject> decoder = getDecoder(new XmlNamespaceDecoderKey(xbInsertSensor.getProcedureDescriptionFormat(), xbProcedureDescription.getClass()));
        if (decoder != null) {
            final Object decodedProcedureDescription = decoder.decode(xbProcedureDescription);
            if (decodedProcedureDescription instanceof SosProcedureDescription) {
                request.setProcedureDescription((SosProcedureDescription) decodedProcedureDescription);
            } else if (decodedProcedureDescription instanceof AbstractFeature) {
                request.setProcedureDescription(new SosProcedureDescription<>((AbstractFeature) decodedProcedureDescription));
            }
        }
    } catch (final XmlException xmle) {
        throw new DecodingException("Error while parsing procedure description of InsertSensor request!", xmle);
    }
    return request;
}
Also used : XmlException(org.apache.xmlbeans.XmlException) InsertSensorType(net.opengis.swes.x20.InsertSensorType) SosProcedureDescription(org.n52.shetland.ogc.sos.SosProcedureDescription) AbstractFeature(org.n52.shetland.ogc.gml.AbstractFeature) XmlObject(org.apache.xmlbeans.XmlObject) OwsServiceCommunicationObject(org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) InsertSensorRequest(org.n52.shetland.ogc.sos.request.InsertSensorRequest)

Example 3 with InsertSensorDocument

use of net.opengis.swes.x20.InsertSensorDocument in project arctic-sea by 52North.

the class InsertSensorRequestEncoderTest method shouldEncodeObservableProperty.

@Test
public void shouldEncodeObservableProperty() throws EncodingException {
    XmlObject xmlObject = encoder.create(request);
    Assert.assertThat(xmlObject, CoreMatchers.instanceOf(InsertSensorDocument.class));
    List<String> observableProperties = Arrays.asList(((InsertSensorDocument) xmlObject).getInsertSensor().getObservablePropertyArray());
    Assert.assertThat(observableProperties, Matchers.hasSize(2));
    Assert.assertThat(observableProperties, Matchers.containsInAnyOrder("test-property-1", "test-property-2"));
}
Also used : InsertSensorDocument(net.opengis.swes.x20.InsertSensorDocument) XmlObject(org.apache.xmlbeans.XmlObject) Test(org.junit.Test)

Example 4 with InsertSensorDocument

use of net.opengis.swes.x20.InsertSensorDocument in project arctic-sea by 52North.

the class InsertSensorRequestEncoder method create.

@Override
protected XmlObject create(InsertSensorRequest request) throws EncodingException {
    validateInput(request);
    InsertSensorDocument doc = InsertSensorDocument.Factory.newInstance(getXmlOptions());
    InsertSensorType insertSensor = doc.addNewInsertSensor();
    addVersion(insertSensor);
    addService(insertSensor);
    addProcedureDescriptionFormat(request, insertSensor);
    addProcedureDescription(request, insertSensor);
    addObservableProperties(request, insertSensor);
    addMetadata(request, insertSensor);
    return doc;
}
Also used : InsertSensorDocument(net.opengis.swes.x20.InsertSensorDocument) InsertSensorType(net.opengis.swes.x20.InsertSensorType)

Example 5 with InsertSensorDocument

use of net.opengis.swes.x20.InsertSensorDocument in project arctic-sea by 52North.

the class InsertSensorRequestEncoderTest method shouldEncodeProcedureDescription.

@Test
public void shouldEncodeProcedureDescription() throws EncodingException {
    InsertSensorDocument isd = (InsertSensorDocument) encoder.create(request);
    ProcedureDescription description = isd.getInsertSensor().getProcedureDescription();
    Assert.assertThat(description, CoreMatchers.notNullValue());
    Assert.assertThat(description, CoreMatchers.instanceOf(ProcedureDescription.class));
}
Also used : InsertSensorDocument(net.opengis.swes.x20.InsertSensorDocument) SosProcedureDescription(org.n52.shetland.ogc.sos.SosProcedureDescription) ProcedureDescription(net.opengis.swes.x20.InsertSensorType.ProcedureDescription) Test(org.junit.Test)

Aggregations

InsertSensorDocument (net.opengis.swes.x20.InsertSensorDocument)6 Test (org.junit.Test)4 XmlObject (org.apache.xmlbeans.XmlObject)3 InsertSensorType (net.opengis.swes.x20.InsertSensorType)2 SosProcedureDescription (org.n52.shetland.ogc.sos.SosProcedureDescription)2 SosInsertionMetadataType (net.opengis.sos.x20.SosInsertionMetadataType)1 DeleteSensorDocument (net.opengis.swes.x20.DeleteSensorDocument)1 DescribeSensorDocument (net.opengis.swes.x20.DescribeSensorDocument)1 ProcedureDescription (net.opengis.swes.x20.InsertSensorType.ProcedureDescription)1 UpdateSensorDescriptionDocument (net.opengis.swes.x20.UpdateSensorDescriptionDocument)1 XmlException (org.apache.xmlbeans.XmlException)1 AbstractFeature (org.n52.shetland.ogc.gml.AbstractFeature)1 OwsServiceCommunicationObject (org.n52.shetland.ogc.ows.service.OwsServiceCommunicationObject)1 InsertSensorRequest (org.n52.shetland.ogc.sos.request.InsertSensorRequest)1 DecodingException (org.n52.svalbard.decode.exception.DecodingException)1 UnsupportedDecoderXmlInputException (org.n52.svalbard.decode.exception.UnsupportedDecoderXmlInputException)1