|
|
@@ -912,4 +912,24 @@ public class OpenAPIHandler {
|
|
|
).encode()))
|
|
|
.onFailure(th -> rc.fail(400, th));
|
|
|
}
|
|
|
+
|
|
|
+ public void driverIdActionsGET(RoutingContext rc) {
|
|
|
+ String host = hostURLFull(rc.request());
|
|
|
+
|
|
|
+ int driverId = Integer.parseInt(rc.pathParam("driverId"));
|
|
|
+
|
|
|
+ List<String> paramNavigationLinks = rc.queryParam("navigationLinks");
|
|
|
+ boolean navigationLinks = paramNavigationLinks.isEmpty() ? DEFAULT_NAVIGATION_LINKS : parseBoolean(paramNavigationLinks.get(0));
|
|
|
+
|
|
|
+ repo.findActionsByDriverId(driverId)
|
|
|
+ .onSuccess(actions -> rc.response().end(new JsonArray(
|
|
|
+ actions.stream().map(a -> (navigationLinks ? JsonObject.of(
|
|
|
+ "DriverAction@NavigationLink", String.format("%s/drivers/%d/actions/%d",host, driverId, a.getId())
|
|
|
+ ) : JsonObject.of()).mergeIn(JsonObject.of(
|
|
|
+ "id", a.getId(),
|
|
|
+ "name", a.getName()
|
|
|
+ ))).collect(toList())
|
|
|
+ ).encode()))
|
|
|
+ .onFailure(th -> rc.fail(400, th));
|
|
|
+ }
|
|
|
}
|