Search in sources :

Example 1 with SosInsertionMetadata

use of org.n52.shetland.ogc.sos.SosInsertionMetadata in project arctic-sea by 52North.

the class InsertSensorRequestDecoder method decodeRequest.

@Override
protected InsertSensorRequest decodeRequest(JsonNode node) throws DecodingException {
    final InsertSensorRequest r = new InsertSensorRequest();
    final SosInsertionMetadata meta = new SosInsertionMetadata();
    meta.setFeatureOfInterestTypes(parseStringOrStringList(node.path(JSONConstants.FEATURE_OF_INTEREST_TYPE)));
    meta.setObservationTypes(parseStringOrStringList(node.path(JSONConstants.OBSERVATION_TYPE)));
    r.setMetadata(meta);
    r.setObservableProperty(parseStringOrStringList(node.path(JSONConstants.OBSERVABLE_PROPERTY)));
    r.setProcedureDescriptionFormat(node.path(JSONConstants.PROCEDURE_DESCRIPTION_FORMAT).textValue());
    r.setRelatedFeature(parseFeatureRelationships(node.path(JSONConstants.RELATED_FEATURE)));
    r.setProcedureDescription(parseProcedureDescription(node.path(JSONConstants.PROCEDURE_DESCRIPTION), r.getProcedureDescriptionFormat()));
    return r;
}
Also used : SosInsertionMetadata(org.n52.shetland.ogc.sos.SosInsertionMetadata) InsertSensorRequest(org.n52.shetland.ogc.sos.request.InsertSensorRequest)

Example 2 with SosInsertionMetadata

use of org.n52.shetland.ogc.sos.SosInsertionMetadata in project arctic-sea by 52North.

the class InsertSensorRequestEncoderTest method prepare.

@Before
public void prepare() {
    request = new InsertSensorRequest("service", "version");
    request.setProcedureDescriptionFormat(SensorML20Constants.SENSORML_20_OUTPUT_FORMAT_URL);
    request.setProcedureDescription(createProcedureDescription());
    SosInsertionMetadata metadata = new SosInsertionMetadata();
    metadata.setFeatureOfInterestTypes(CollectionHelper.list("test-foi-type-1", "test-foi-type-2"));
    metadata.setObservationTypes(CollectionHelper.list("test-observation-type-1", "test-observation-type-2"));
    request.setMetadata(metadata);
    request.setObservableProperty(CollectionHelper.list("test-property-1", "test-property-2"));
    encoder = new InsertSensorRequestEncoder();
    encoder.setXmlOptions(() -> new XmlOptions());
    SensorMLEncoderv20 sensorMLEncoderv20 = new SensorMLEncoderv20();
    sensorMLEncoderv20.setXmlOptions(() -> new XmlOptions());
    GmlEncoderv321 gmlEncoder = new GmlEncoderv321();
    gmlEncoder.setXmlOptions(() -> new XmlOptions());
    SosInsertionMetadataTypeEncoder metadataEncoder = new SosInsertionMetadataTypeEncoder();
    metadataEncoder.setXmlOptions(() -> new XmlOptions());
    EncoderRepository encoderRepository = new EncoderRepository();
    encoderRepository.setEncoders(Arrays.asList(encoder, sensorMLEncoderv20, gmlEncoder, metadataEncoder));
    encoderRepository.init();
    encoder.setEncoderRepository(encoderRepository);
    sensorMLEncoderv20.setEncoderRepository(encoderRepository);
    gmlEncoder.setEncoderRepository(encoderRepository);
    metadataEncoder.setEncoderRepository(encoderRepository);
}
Also used : XmlOptions(org.apache.xmlbeans.XmlOptions) SosInsertionMetadata(org.n52.shetland.ogc.sos.SosInsertionMetadata) InsertSensorRequest(org.n52.shetland.ogc.sos.request.InsertSensorRequest) Before(org.junit.Before)

Example 3 with SosInsertionMetadata

use of org.n52.shetland.ogc.sos.SosInsertionMetadata in project arctic-sea by 52North.

the class SosInsertionMetadataTypeEncoderTest method prepare.

@Before
public void prepare() {
    insertionMetadata = new SosInsertionMetadata();
    insertionMetadata.setObservationTypes(CollectionHelper.list("type-1", "type-2"));
    insertionMetadata.setFeatureOfInterestTypes(CollectionHelper.list("f-type-1", "f-type-2"));
    encoder = new SosInsertionMetadataTypeEncoder();
    encoder.setXmlOptions(() -> new XmlOptions());
}
Also used : XmlOptions(org.apache.xmlbeans.XmlOptions) SosInsertionMetadata(org.n52.shetland.ogc.sos.SosInsertionMetadata) Before(org.junit.Before)

Example 4 with SosInsertionMetadata

use of org.n52.shetland.ogc.sos.SosInsertionMetadata in project arctic-sea by 52North.

the class SwesDecoderv20 method parseMetadata.

private SosInsertionMetadata parseMetadata(final Metadata[] metadataArray) throws DecodingException {
    final SosInsertionMetadata sosMetadata = new SosInsertionMetadata();
    try {
        for (final Metadata metadata : metadataArray) {
            SosInsertionMetadataType xbSosInsertionMetadata = null;
            if (metadata.getInsertionMetadata() != null && metadata.getInsertionMetadata().schemaType() == SosInsertionMetadataType.type) {
                xbSosInsertionMetadata = (SosInsertionMetadataType) metadata.getInsertionMetadata();
            } else {
                if (metadata.getDomNode().hasChildNodes()) {
                    final Node node = getNodeFromNodeList(metadata.getDomNode().getChildNodes());
                    final SosInsertionMetadataPropertyType xbMetadata = SosInsertionMetadataPropertyType.Factory.parse(node);
                    xbSosInsertionMetadata = xbMetadata.getSosInsertionMetadata();
                }
            }
            if (xbSosInsertionMetadata != null) {
                // featureOfInterest types
                if (xbSosInsertionMetadata.getFeatureOfInterestTypeArray() != null) {
                    sosMetadata.setFeatureOfInterestTypes(Arrays.asList(xbSosInsertionMetadata.getFeatureOfInterestTypeArray()));
                }
                // observation types
                if (xbSosInsertionMetadata.getObservationTypeArray() != null) {
                    sosMetadata.setObservationTypes(Arrays.asList(xbSosInsertionMetadata.getObservationTypeArray()));
                }
            }
        }
    } catch (final XmlException xmle) {
        throw new DecodingException("An error occurred while parsing the metadata in the http post request", xmle);
    }
    return sosMetadata;
}
Also used : XmlException(org.apache.xmlbeans.XmlException) Node(org.w3c.dom.Node) SosInsertionMetadata(org.n52.shetland.ogc.sos.SosInsertionMetadata) Metadata(net.opengis.swes.x20.InsertSensorType.Metadata) SosInsertionMetadataPropertyType(net.opengis.sos.x20.SosInsertionMetadataPropertyType) SosInsertionMetadata(org.n52.shetland.ogc.sos.SosInsertionMetadata) DecodingException(org.n52.svalbard.decode.exception.DecodingException) SosInsertionMetadataType(net.opengis.sos.x20.SosInsertionMetadataType)

Aggregations

SosInsertionMetadata (org.n52.shetland.ogc.sos.SosInsertionMetadata)4 XmlOptions (org.apache.xmlbeans.XmlOptions)2 Before (org.junit.Before)2 InsertSensorRequest (org.n52.shetland.ogc.sos.request.InsertSensorRequest)2 SosInsertionMetadataPropertyType (net.opengis.sos.x20.SosInsertionMetadataPropertyType)1 SosInsertionMetadataType (net.opengis.sos.x20.SosInsertionMetadataType)1 Metadata (net.opengis.swes.x20.InsertSensorType.Metadata)1 XmlException (org.apache.xmlbeans.XmlException)1 DecodingException (org.n52.svalbard.decode.exception.DecodingException)1 Node (org.w3c.dom.Node)1