Skip to content
This repository has been archived by the owner on Apr 10, 2018. It is now read-only.

StoreConnect/sensorthings-api-model

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OGC SensorThings API's entity model

Java version of the OGC SensorThings API's entity model.

Covers the Sensing part and want to cover the Tasking part when it will be available.

Within the Sensing part, this model is compatible with:

How to use it

Available on Maven Central

Under submission to Maven Central.

Builder construction pattern

All entities can be constructed via its associated builder. For instance, a HistoricalLocation can be built like this:

final HistoricalLocation historicalLocation = HistoricalLocation.builder()
    .id(new Integer(1))
    .selfLink(new URL("http://example.org/v1.0/HistoricalLocations(1)"))
    .locationsNavigationLink("HistoricalLocations(1)/Locations")
    .thingNavigationLink("HistoricalLocations(1)/Thing")
    .time(TMInstant.builder()
        .instant(OffsetDateTime.parse("2018-03-28T12:00:00+01:00"))
        .build()
    )
    .build();

More example of entities construction can be found in the unit tests.

JSON serialization/deserialization support

All entities supports the use of the Jackson library to allow JSON serialization/deserialization.

In addition, all entities integrates its own Jackson configuration (e.g., specific serializers or deserializers). Hence, only a default Jackson's ObjectMapper instance can be used to manipulate them.

For instance, the basic JSON serialization process of our previous historicalLocation would be:

final String jsonHistoricalLocation = new ObjectMapper().writeValueAsString(historicalLocation);

That will produce the following JSON file:

{
  "@iot.id": 1,
  "@iot.selfLink": "http://example.org/v1.0/HistoricalLocations(1)",
  "Locations@iot.navigationLink": "HistoricalLocations(1)/Locations",
  "Thing@iot.navigationLink": "HistoricalLocations(1)/Thing",
  "time": "2015-01-25T12:00:00-07:00"
}

In the same way, the basic JSON deserialization process would be:

final HistoricalLocation deserializedHistoricalLocation = new ObjectMapper().readValue(jsonHistoricalLocation, HistoricalLocation.class);

And, as we expect, the deserializedHistoricalLocation will be the same as our previous historicalLocation.

More examples of serialization/deserialization can be found in the unit tests.

How to contribute

Feel free to contribute by making a pull request following the contributing instructions.

Releases

No releases published

Packages

No packages published

Languages