This library provides a Java-based client library for the SensorThingsAPI and aims to simplify development of SensorThings enabled client applications.
Note: This project is still under development and therefore lacks complete support of the SensorThingsAPI.
- CRUD operations
- Queries on entity sets
- Loading of referenced entities
- Batch requests
- $select
- MultiDatastream
- dataArray
- MQTT
The SensorThingsService
class is central to the library. An instance of it represents a SensorThings service and is identified by an URI.
The source code below demonstrates the CRUD operations for Thing objects. Operations for other entities work similarly.
URI serviceEndpoint = URI.create("http://example.org/v1.0/");
SensorThingsService service = new SensorThingsService(serviceEndpoint);
Thing thing = new Thing();
thing.setDescription("I'm a thing!");
service.things().create(thing);
thing = service.things().find(1l);
thing.setDescription("Things change...");
service.things().update(thing);
service.things().delete(thing);
Entity Sets are represented by instances of EntityList<>
. The query parameters specified by the SensorThingsAPI standard can be applied to queries.
EntityList<Thing> things = service.things()
.query()
.count()
.orderBy("description")
.filter("")
.skip(5)
.top(10)
.list();
for (Thing thing : things) {
System.out.println("So many things!");
}
However, $expand
does not work on queries yet.
Loading referenced objects in one operation (and therefore in one request) is supported. The $expand option of the SensorThingsAPI standard is used internally.
Thing thing = service.things().find(1l,
Expansion.of(EntityType.THING)
.with(ExpandedEntity.from(EntityType.LOCATIONS)));
EntityList<Location> locations = thing.getLocations();
This library emerged from a practical work for a lecture at KIT in collaboration with the Fraunhofer IOSB. A server implementation of the SensorThingsAPI, developed by the Fraunhofer IOSB, is available on GitHub as well.
Contributions are welcome!
- Fork this repository
- Commit your changes
- Create a pull request
The code and the documentation of this work is available under the MIT license.