Search in sources :

Example 16 with Metadata

use of org.n52.shetland.ogc.om.series.wml.Metadata in project arctic-sea by 52North.

the class SensorMLDecoderV101 method parseCapabilities.

/**
 * Parses the capabilities, processing and removing special insertion metadata
 *
 * @param abstractProcess The AbstractProcess to which capabilities and insertion metadata are added
 * @param capabilitiesArray XML capabilities
 *
 * @throws DecodingException if an error occurs
 */
private void parseCapabilities(final AbstractProcess abstractProcess, final Capabilities[] capabilitiesArray) throws DecodingException {
    for (final Capabilities xbcaps : capabilitiesArray) {
        final SmlCapabilities caps = new SmlCapabilities();
        if (xbcaps.isSetName()) {
            caps.setName(xbcaps.getName());
        }
        if (xbcaps.isSetAbstractDataRecord()) {
            final Object o = decodeXmlElement(xbcaps.getAbstractDataRecord());
            if (o instanceof DataRecord) {
                final DataRecord record = (DataRecord) o;
                caps.setDataRecord(record).setName(xbcaps.getName());
            } else {
                throw new DecodingException(XmlHelper.getLocalName(xbcaps), "Error while parsing the capabilities of the SensorML (the " + "capabilities data record is not of type DataRecordPropertyType)!");
            }
        } else if (xbcaps.isSetHref()) {
            caps.setHref(xbcaps.getHref());
            if (xbcaps.isSetTitle()) {
                caps.setTitle(xbcaps.getTitle());
            }
        }
        if (caps.isSetName()) {
            abstractProcess.addCapabilities(caps);
        }
    }
}
Also used : SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) Capabilities(net.opengis.sensorML.x101.CapabilitiesDocument.Capabilities) SmlCapabilities(org.n52.shetland.ogc.sensorML.elements.SmlCapabilities) XmlObject(org.apache.xmlbeans.XmlObject) DecodingException(org.n52.svalbard.decode.exception.DecodingException) DataRecord(org.n52.shetland.ogc.swe.DataRecord)

Example 17 with Metadata

use of org.n52.shetland.ogc.om.series.wml.Metadata in project arctic-sea by 52North.

the class InsertSensorRequestEncoderTest method shouldThrowExceptionWhenMetadataIsMissing.

@Test
public void shouldThrowExceptionWhenMetadataIsMissing() throws EncodingException {
    thrown.expect(UnsupportedEncoderInputException.class);
    thrown.expectMessage(Is.is("Encoder " + InsertSensorRequestEncoder.class.getSimpleName() + " can not encode 'metadata field missing'"));
    InsertSensorRequest request = new InsertSensorRequest("service", "version");
    request.setProcedureDescriptionFormat("test-format");
    request.setProcedureDescription(createProcedureDescription());
    request.setObservableProperty(CollectionHelper.list("test-property"));
    encoder.create(request);
}
Also used : InsertSensorRequest(org.n52.shetland.ogc.sos.request.InsertSensorRequest) Test(org.junit.Test)

Example 18 with Metadata

use of org.n52.shetland.ogc.om.series.wml.Metadata 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 19 with Metadata

use of org.n52.shetland.ogc.om.series.wml.Metadata in project arctic-sea by 52North.

the class WmlTVPEncoderv20Test method shouldEncodeCumulativeProperty.

@Test
public void shouldEncodeCumulativeProperty() throws EncodingException {
    mv.setMetadata(new Metadata().setTimeseriesmetadata(new MeasurementTimeseriesMetadata().setCumulative(true)));
    XmlObject encodedElement = encoder.encode(mv);
    Assert.assertThat(((MeasurementTimeseriesMetadataType) ((MeasurementTimeseriesDocument) encodedElement).getTimeseries().getMetadata().getTimeseriesMetadata()).getCumulative(), Is.is(true));
}
Also used : DefaultTVPMeasurementMetadata(org.n52.shetland.ogc.om.series.wml.DefaultTVPMeasurementMetadata) DefaultPointMetadata(org.n52.shetland.ogc.om.series.wml.DefaultPointMetadata) Metadata(org.n52.shetland.ogc.om.series.wml.Metadata) MeasurementTimeseriesMetadata(org.n52.shetland.ogc.om.series.wml.MeasurementTimeseriesMetadata) MeasurementTimeseriesMetadata(org.n52.shetland.ogc.om.series.wml.MeasurementTimeseriesMetadata) XmlObject(org.apache.xmlbeans.XmlObject) MeasurementTimeseriesDocument(net.opengis.waterml.x20.MeasurementTimeseriesDocument) Test(org.junit.Test)

Example 20 with Metadata

use of org.n52.shetland.ogc.om.series.wml.Metadata in project series-rest-api by 52North.

the class ChartRendererTest method shouldFormatTitleTemplateWhenPrerenderingTriggerIsActive.

@Test
public void shouldFormatTitleTemplateWhenPrerenderingTriggerIsActive() {
    QuantityDatasetOutput metadata = new QuantityDatasetOutput();
    SeriesParameters parameters = new SeriesParameters();
    parameters.setCategory(createParameter(new CategoryOutput(), "cat_1", "category"));
    parameters.setFeature(createParameter(new FeatureOutput(), "feat_1", "feature"));
    parameters.setOffering(createParameter(new OfferingOutput(), "off_1", "offering"));
    parameters.setPhenomenon(createParameter(new PhenomenonOutput(), "phen_1", "phenomenon"));
    parameters.setProcedure(createParameter(new ProcedureOutput(), "proc_1", "procedure"));
    parameters.setService(createParameter(new ServiceOutput(), "ser_1", "service"));
    metadata.setSeriesParameters(parameters);
    metadata.setId("timeseries");
    metadata.setUom("");
    PlatformOutput platformOutput = new PlatformOutput(PlatformType.STATIONARY_INSITU);
    platformOutput.setId("sta_1");
    platformOutput.setLabel("station");
    parameters.setPlatform(platformOutput);
    // build expected title
    StringBuilder expected = new StringBuilder();
    expected.append(parameters.getPlatform().getLabel());
    expected.append(" ").append(parameters.getPhenomenon().getLabel());
    expected.append(" ").append(parameters.getProcedure().getLabel());
    // expected.append(" ").append(parameters.getCategory().getLabel());
    expected.append(" (4 opted-out)");
    expected.append(" ").append(parameters.getOffering().getLabel());
    expected.append(" ").append(parameters.getFeature().getLabel());
    expected.append(" ").append(parameters.getService().getLabel());
    expected.append(" ").append(metadata.getUom());
    IoParameters ioConfig = createDefaults().extendWith("rendering_trigger", "prerendering");
    IoStyleContext context = IoStyleContext.createContextForSingleSeries(metadata, ioConfig);
    MyChartRenderer chartRenderer = new MyChartRenderer(context);
    // String template = "%1$s %2$s %3$s %4$s %5$s %6$s %7$s %8$s";
    String template = "%1$s %2$s %3$s (4 opted-out) %5$s %6$s %7$s %8$s";
    String actual = chartRenderer.formatTitle(metadata, template);
    assertThat(actual, is(expected.toString()));
}
Also used : OfferingOutput(org.n52.io.response.OfferingOutput) ServiceOutput(org.n52.io.response.ServiceOutput) FeatureOutput(org.n52.io.response.FeatureOutput) IoStyleContext(org.n52.io.IoStyleContext) IoParameters(org.n52.io.request.IoParameters) PlatformOutput(org.n52.io.response.PlatformOutput) CategoryOutput(org.n52.io.response.CategoryOutput) ProcedureOutput(org.n52.io.response.ProcedureOutput) SeriesParameters(org.n52.io.response.dataset.SeriesParameters) QuantityDatasetOutput(org.n52.io.response.dataset.quantity.QuantityDatasetOutput) PhenomenonOutput(org.n52.io.response.PhenomenonOutput) Test(org.junit.Test)

Aggregations

XmlObject (org.apache.xmlbeans.XmlObject)5 QuantityData (org.n52.io.response.dataset.quantity.QuantityData)5 IoParameters (org.n52.io.request.IoParameters)4 DatasetOutput (org.n52.io.response.dataset.DatasetOutput)4 SeriesParameters (org.n52.io.response.dataset.SeriesParameters)4 DecodingException (org.n52.svalbard.decode.exception.DecodingException)4 Test (org.junit.Test)3 QuantityDatasetMetadata (org.n52.io.response.dataset.quantity.QuantityDatasetMetadata)3 InsertSensorRequest (org.n52.shetland.ogc.sos.request.InsertSensorRequest)3 Strings (com.google.common.base.Strings)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 URI (java.net.URI)2 HashMap (java.util.HashMap)2 XmlException (org.apache.xmlbeans.XmlException)2 DateTime (org.joda.time.DateTime)2 RequestStyledParameterSet (org.n52.io.request.RequestStyledParameterSet)2 ParameterOutput (org.n52.io.response.ParameterOutput)2 QuantityValue (org.n52.io.response.dataset.quantity.QuantityValue)2 LocalizedString (org.n52.janmayen.i18n.LocalizedString)2