|
|
@@ -545,4 +545,22 @@ public class OpenAPIHandler {
|
|
|
)).encode())
|
|
|
.onFailure(th -> rc.fail(400, th)));
|
|
|
}
|
|
|
+
|
|
|
+ public void sensorsGET(RoutingContext rc) {
|
|
|
+ String host = hostURLFull(rc.request());
|
|
|
+
|
|
|
+ List<String> paramNavigationLinks = rc.queryParam("navigationLinks");
|
|
|
+ boolean navigationLinks = paramNavigationLinks.isEmpty() ? DEFAULT_NAVIGATION_LINKS : parseBoolean(paramNavigationLinks.get(0));
|
|
|
+
|
|
|
+ repo.allSensors()
|
|
|
+ .onSuccess(data -> rc.response().end(new JsonArray(
|
|
|
+ data.stream().map(s -> (navigationLinks ? JsonObject.of(
|
|
|
+ "Sensor@NavigationLink", String.format("%s/sensors/%d", host, s.getSensorId())
|
|
|
+ ) : JsonObject.of()).mergeIn(JsonObject.of(
|
|
|
+ "sensorId", s.getSensorId(),
|
|
|
+ "name", s.getName(),
|
|
|
+ "description", s.getDescription()
|
|
|
+ ))).collect(toList())).encode()))
|
|
|
+ .onFailure(th -> rc.fail(400, th));
|
|
|
+ }
|
|
|
}
|