FraunhoferIOSB / FROST-Server

A Complete Server implementation of the OGC SensorThings API
https://fraunhoferiosb.github.io/FROST-Server/
GNU Lesser General Public License v3.0
194 stars 70 forks source link

Patch on MultiDatastreams #71

Open Jabst opened 5 years ago

Jabst commented 5 years ago

Hello,

I am trying to do a PATCH request on a MultiDatastream with the following Body:

{ "description": "Number two multidatastream edited", "name": "Multidatastream #2", "observationType": "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_ComplexObservation", "multiObservationDataTypes": [ "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement", "http://www.opengis.net/def/observationType/OGC-OM/2.0/OM_Measurement" ], "unitOfMeasurements": [ { "name": "Salinity", "symbol": "ppm/m^3", "definition": "Number of ions per volume" }, { "name": "Salinity", "symbol": "ppm/m^3", "definition": "Number of ions per volume" } ], "Thing": { "@iot.id": 1 }, "ObservedProperties": [ { "@iot.id": 1 }, { "@iot.id": 2 } ], "Sensor": { "@iot.id": 3 } }

However, I get the following error(400) message:

New number of unitOfMeasurements does not match new number of ObservedProperties.

As far as I can see the provided number of ObservedProperties clearly is the same as the number of distinct Units of Measurement

mjacoby commented 5 years ago

This behavior is not an error but rather defined by the standard. The reason for this is that unitOfMeasurements is a simple/primitive property of MultiDatastream but ObseredProperties is a navigation property (see Figure 3 of the standard document http://docs.opengeospatial.org/is/15-078r6/15-078r6.html#77). In Section 10.3.1 of the standard (http://docs.opengeospatial.org/is/15-078r6/15-078r6.html#66) it is specified that...

The semantics of PATCH, as defined in [RFC5789], are to merge the content in the request payload with the entity’s current state, applying the update only to those components specified in the request body. The properties provided in the payload corresponding to updatable properties SHALL replace the value of the corresponding property in the entity.

and

For single-valued navigation properties this replaces the relationship. For collection-valued navigation properties this adds to the relationship.

So what's happening when executing this HTTP PATCH is that unitOfMeasurements is updated but for ObservedProperties the two inlined values are added to the collection. Therefore, there are now more values for ObservedProperties than inlined (which ist stated in the error message).

hylkevds commented 5 years ago

This is actually an issue that I mentioned on the SensorThings github here: https://github.com/opengeospatial/sensorthings/issues/19 Currently it's impossible to remove items from many-to-many relations.