Skip to content
This repository has been archived by the owner on Oct 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #82 from EHJ-52n/fix/server-generated-offering-ide…
Browse files Browse the repository at this point in the history
…ntifier

Fix server generated offering identifier
  • Loading branch information
EHJ-52n authored Jun 27, 2017
2 parents 4ec03a6 + 61671a7 commit e0e4385
Show file tree
Hide file tree
Showing 7 changed files with 434 additions and 1 deletion.
1 change: 1 addition & 0 deletions RELEASE_NOTES
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ For a complete Release Notes overview visit
* #nn: Fix bug in unix time parsing
* #nn: Fix typo in xml schema: expresssion -> expression
* #78: NullPointerException when parsing Date/Time
* #76: Server generated offering identifier


# Release Notes for SOS-Importer 0.4.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ public final class Configuration {

private static final Logger LOG = LoggerFactory.getLogger(Configuration.class);

private static final String OFFERING_SUFFIX = "-offering";

private static final String POSITION_PARSEPATTERN_LATITUDE = "LAT";
private static final String POSITION_PARSEPATTERN_LONGITUDE = "LON";
private static final String POSITION_PARSEPATTERN_ALTITUDE = "ALT";
Expand Down Expand Up @@ -1146,7 +1148,7 @@ public Offering getOffering(final Sensor s) {
LOG.trace("getOffering()");
if (importConf.getSosMetadata().getOffering().isSetGenerate() &&
importConf.getSosMetadata().getOffering().getGenerate()) {
return new Offering(s.getName(), s.getUri());
return new Offering(s.getName() + OFFERING_SUFFIX, s.getUri() + OFFERING_SUFFIX);
} else {
final String o = importConf.getSosMetadata().getOffering().getStringValue();
return new Offering(o, o);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/**
* Copyright (C) 2011-2016 52°North Initiative for Geospatial Open Source
* Software GmbH
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 as published
* by the Free Software Foundation.
*
* If the program is linked with libraries which are licensed under one of
* the following licenses, the combination of the program with the linked
* library is not considered a "derivative work" of the program:
*
* - Apache License, version 2.0
* - Apache Software License, version 1.0
* - GNU Lesser General Public License, version 3
* - Mozilla Public License, versions 1.0, 1.1 and 2.0
* - Common Development and Distribution License (CDDL), version 1.0
*
* Therefore the distribution of the program linked with libraries licensed
* under the aforementioned licenses, is permitted by the copyright holders
* if the distribution is compliant with both the GNU General Public
* License version 2 and the aforementioned licenses.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
* Public License for more details.
*/
package org.n52.sos.importer.feeder;

import java.io.IOException;

import org.apache.xmlbeans.XmlException;
import org.hamcrest.Matchers;
import org.junit.Assert;
import org.junit.Test;
import org.n52.sos.importer.feeder.model.Offering;
import org.n52.sos.importer.feeder.model.Sensor;

public class TestIssue76ServerGeneratedOfferingIdentifier {

@Test
public void procedureAndOfferingShouldDifferWhenGenerated() throws XmlException, IOException {
// given
Configuration config = new Configuration("src/test/resources/issue-076/config.xml");
Sensor sensor = new Sensor("test-sensor-name", "test-sensor-uri");

// when
Offering offering = config.getOffering(sensor);

// then
Assert.assertThat(sensor.getName(), Matchers.not(offering.getName()));
Assert.assertThat(sensor.getUri(), Matchers.not(offering.getUri()));
Assert.assertThat(offering.getName(), Matchers.startsWith(sensor.getName()));
Assert.assertThat(offering.getUri(), Matchers.startsWith(sensor.getUri()));
Assert.assertThat(offering.getName(), Matchers.is("test-sensor-name-offering"));
Assert.assertThat(offering.getUri(), Matchers.is("test-sensor-uri-offering"));
}

}
189 changes: 189 additions & 0 deletions feeder/src/test/resources/issue-076/InserSensor.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<swes:InsertSensor xmlns:swe1="http://www.opengis.net/swe/1.0" xmlns:ogc="http://www.opengis.net/ogc" xmlns:srv="http://www.isotc211.org/2005/srv" xmlns:gts="http://www.isotc211.org/2005/gts" xmlns:icism="urn:us:gov:ic:ism:v2" xmlns:sml1="http://www.opengis.net/sensorML/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gmx="http://www.isotc211.org/2005/gmx" xmlns:gmi="http://www.isotc211.org/2005/gmi" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sos="http://www.opengis.net/sos/2.0" xmlns:ns13="http://www.opengis.net/sos/1.0" xmlns:swe="http://www.opengis.net/swe/1.0.1" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:sampling="http://www.opengis.net/sampling/1.0" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:om="http://www.opengis.net/om/1.0" xmlns:ns20="http://www.opengis.net/gml" xmlns:swes="http://www.opengis.net/swes/2.0" xmlns:ns22="http://www.w3.org/2005/08/addressing" xmlns:ns23="http://www.opengis.net/om/2.0" xmlns:ns24="http://www.opengis.net/sampling/2.0" xmlns:samplingspatial="http://www.opengis.net/samplingSpatial/2.0" xmlns:ns26="http://www.opengis.net/swe/2.0" xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:ns28="http://docs.oasis-open.org/wsn/t-1" xmlns:ns29="http://www.opengis.net/gml/" xmlns:sml="http://www.opengis.net/sensorML/1.0.1" version="2.0.0" service="SOS">
<swes:procedureDescriptionFormat>http://www.opengis.net/sensorML/1.0.1</swes:procedureDescriptionFormat>
<swes:procedureDescription>
<sml:SensorML version="1.0.1">
<sml:member>
<sml:System>
<sml:keywords>
<sml:KeywordList>
<sml:keyword>foi1</sml:keyword>
<sml:keyword>csv-sensor</sml:keyword>
<sml:keyword>Water</sml:keyword>
<sml:keyword>Krypton</sml:keyword>
<sml:keyword>Propan</sml:keyword>
</sml:KeywordList>
</sml:keywords>
<sml:identification>
<sml:IdentifierList>
<sml:identifier name="uniqueID">
<sml:Term definition="urn:ogc:def:identifier:OGC:1.0:uniqueID">
<sml:value>urn:sensor:csv-sensor</sml:value>
</sml:Term>
</sml:identifier>
<sml:identifier name="longName">
<sml:Term definition="urn:ogc:def:identifier:OGC:1.0:longName">
<sml:value>csv-sensor</sml:value>
</sml:Term>
</sml:identifier>
<sml:identifier name="shortName">
<sml:Term definition="urn:ogc:def:identifier:OGC:1.0:shortName">
<sml:value>csv-sensor</sml:value>
</sml:Term>
</sml:identifier>
</sml:IdentifierList>
</sml:identification>
<sml:classification>
<sml:ClassifierList>
<sml:classifier name="intendedApplication">
<sml:Term definition="urn:ogc:def:classifier:OGC:1.0:application">
<sml:value>Water, Krypton, Propan</sml:value>
</sml:Term>
</sml:classifier>
</sml:ClassifierList>
</sml:classification>
<sml:validTime>
<ns20:TimePeriod>
<ns20:beginPosition>2017-04-18T16:57:21+02:00</ns20:beginPosition>
<ns20:endPosition indeterminatePosition="unknown"></ns20:endPosition>
</ns20:TimePeriod>
</sml:validTime>
<sml:capabilities name="observedBBOX">
<swe:DataRecord>
<swe:field name="observedBBOX">
<swe:Envelope referenceFrame="urn:ogc:def:crs:EPSG::4326" definition="urn:ogc:def:property:OGC:1.0:observedBBOX">
<swe:lowerCorner>
<swe:Vector>
<swe:coordinate name="easting">
<swe:Quantity axisID="x">
<swe:uom code="deg"/>
<swe:value>12.0</swe:value>
</swe:Quantity>
</swe:coordinate>
<swe:coordinate name="northing">
<swe:Quantity axisID="y">
<swe:uom code="deg"/>
<swe:value>20.0</swe:value>
</swe:Quantity>
</swe:coordinate>
</swe:Vector>
</swe:lowerCorner>
<swe:upperCorner>
<swe:Vector>
<swe:coordinate name="easting">
<swe:Quantity axisID="x">
<swe:uom code="deg"/>
<swe:value>12.0</swe:value>
</swe:Quantity>
</swe:coordinate>
<swe:coordinate name="northing">
<swe:Quantity axisID="y">
<swe:uom code="deg"/>
<swe:value>20.0</swe:value>
</swe:Quantity>
</swe:coordinate>
</swe:Vector>
</swe:upperCorner>
</swe:Envelope>
</swe:field>
</swe:DataRecord>
</sml:capabilities>
<sml:capabilities name="featuresOfInterest">
<swe:DataRecord>
<swe:field name="featureOfInterestID">
<swe:Text definition="http://www.opengis.net/def/featureOfInterest/identifier">
<swe:value>unr:foi:geomatys:foi1</swe:value>
</swe:Text>
</swe:field>
</swe:DataRecord>
</sml:capabilities>
<sml:capabilities name="collectingStatus">
<swe:DataRecord>
<swe:field name="status">
<swe:Boolean definition="urn:ogc:def:classifier:OGC:1.0:collectingStatus">
<swe:value>true</swe:value>
</swe:Boolean>
</swe:field>
</swe:DataRecord>
</sml:capabilities>
<sml:capabilities name="offerings">
<swe:SimpleDataRecord>
<swe:field name="csv-sensor">
<swe:Text definition="urn:ogc:def:identifier:OGC:1.0:offeringID">
<swe:value>urn:sensor:csv-sensor</swe:value>
</swe:Text>
</swe:field>
</swe:SimpleDataRecord>
</sml:capabilities>
<sml:position name="sensorPosition">
<swe:Position referenceFrame="urn:ogc:def:crs:EPSG::4326">
<swe:location>
<swe:Vector ns20:id="SYSTEM_LOCATION">
<swe:coordinate name="easting">
<swe:Quantity axisID="x">
<swe:uom code="deg"/>
<swe:value>12.0</swe:value>
</swe:Quantity>
</swe:coordinate>
<swe:coordinate name="northing">
<swe:Quantity axisID="y">
<swe:uom code="deg"/>
<swe:value>20.0</swe:value>
</swe:Quantity>
</swe:coordinate>
<swe:coordinate name="altitude">
<swe:Quantity axisID="z">
<swe:uom code="meters"/>
<swe:value>0.0</swe:value>
</swe:Quantity>
</swe:coordinate>
</swe:Vector>
</swe:location>
</swe:Position>
</sml:position>
<sml:inputs>
<sml:InputList>
<sml:input name="Water">
<swe:ObservableProperty definition="urn:phenomenon:Water"/>
</sml:input>
<sml:input name="Krypton">
<swe:ObservableProperty definition="urn:phenomenon:Krypton"/>
</sml:input>
<sml:input name="Propan">
<swe:ObservableProperty definition="urn:phenomenon:Propan"/>
</sml:input>
</sml:InputList>
</sml:inputs>
<sml:outputs>
<sml:OutputList>
<sml:output name="Water">
<swe:Quantity definition="urn:phenomenon:Water">
<swe:uom code="kg"/>
</swe:Quantity>
</sml:output>
<sml:output name="Krypton">
<swe:Quantity definition="urn:phenomenon:Krypton">
<swe:uom code="kg"/>
</swe:Quantity>
</sml:output>
<sml:output name="Propan">
<swe:Quantity definition="urn:phenomenon:Propan">
<swe:uom code="kg"/>
</swe:Quantity>
</sml:output>
</sml:OutputList>
</sml:outputs>
</sml:System>
</sml:member>
</sml:SensorML>
</swes:procedureDescription>
<swes:observableProperty>urn:phenomenon:Water</swes:observableProperty>
<swes:observableProperty>urn:phenomenon:Krypton</swes:observableProperty>
<swes:observableProperty>urn:phenomenon:Propan</swes:observableProperty>
<swes:metadata>
<sos:SosInsertionMetadata>
<sos:observationType>http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement</sos:observationType>
<sos:featureOfInterestType>http://www.opengis.net/def/samplingFeatureType/OGC-OM/2.0/SF_SamplingPoint</sos:featureOfInterestType>
</sos:SosInsertionMetadata>
</swes:metadata>
</swes:InsertSensor>
5 changes: 5 additions & 0 deletions feeder/src/test/resources/issue-076/InserSensorResponse.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<swes:InsertSensorResponse xmlns:swe1="http://www.opengis.net/swe/1.0" xmlns:ogc="http://www.opengis.net/ogc" xmlns:srv="http://www.isotc211.org/2005/srv" xmlns:gts="http://www.isotc211.org/2005/gts" xmlns:icism="urn:us:gov:ic:ism:v2" xmlns:sml1="http://www.opengis.net/sensorML/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:gmx="http://www.isotc211.org/2005/gmx" xmlns:gmi="http://www.isotc211.org/2005/gmi" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sos="http://www.opengis.net/sos/2.0" xmlns:ns13="http://www.opengis.net/sos/1.0" xmlns:swe="http://www.opengis.net/swe/1.0.1" xmlns:ows="http://www.opengis.net/ows/1.1" xmlns:sampling="http://www.opengis.net/sampling/1.0" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:om="http://www.opengis.net/om/1.0" xmlns:ns20="http://www.opengis.net/gml" xmlns:swes="http://www.opengis.net/swes/2.0" xmlns:ns22="http://www.w3.org/2005/08/addressing" xmlns:ns23="http://www.opengis.net/om/2.0" xmlns:ns24="http://www.opengis.net/sampling/2.0" xmlns:samplingspatial="http://www.opengis.net/samplingSpatial/2.0" xmlns:ns26="http://www.opengis.net/swe/2.0" xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:ns28="http://docs.oasis-open.org/wsn/t-1" xmlns:ns29="http://www.opengis.net/gml/" xmlns:sml="http://www.opengis.net/sensorML/1.0.1" xsi:schemaLocation="http://www.opengis.net/sos/2.0 http://schemas.opengis.net/sos/2.0/sos.xsd http://www.opengis.net/samplingSpatial/2.0 http://schemas.opengis.net/samplingSpatial/2.0/spatialSamplingFeature.xsd">
<swes:assignedProcedure>urn:sensor:csv-sensor</swes:assignedProcedure>
<swes:assignedOffering>offering-urn:sensor:csv-sensor</swes:assignedOffering>
</swes:InsertSensorResponse>
Loading

0 comments on commit e0e4385

Please sign in to comment.