|
|
@@ -1023,4 +1023,60 @@ public class OpenAPIHandler {
|
|
|
)).encode())
|
|
|
.onFailure(th -> rc.fail(400, th)));
|
|
|
}
|
|
|
+
|
|
|
+ public void driverIdUnitIdActionIdEventsGET(RoutingContext rc) {
|
|
|
+ String host = hostURLFull(rc.request());
|
|
|
+
|
|
|
+ int driverId = Integer.parseInt(rc.pathParam("driverId"));
|
|
|
+ int actionId = Integer.parseInt(rc.pathParam("actionId"));
|
|
|
+ long unitId = Integer.parseInt(rc.pathParam("unitId"));
|
|
|
+
|
|
|
+ List<String> paramZone = rc.queryParam("zone");
|
|
|
+ ZoneId zone = paramZone.isEmpty() ? DEFAULT_ZONE_ID : ZoneId.of(paramZone.get(0));
|
|
|
+
|
|
|
+ List<String> paramNavigationLinks = rc.queryParam("navigationLinks");
|
|
|
+ boolean navigationLinks = paramNavigationLinks.isEmpty() ? DEFAULT_NAVIGATION_LINKS : parseBoolean(paramNavigationLinks.get(0));
|
|
|
+
|
|
|
+ repo.findEventsByDriverIdAndUnitIdAndActionId(driverId, unitId, actionId)
|
|
|
+ .onSuccess(events -> rc.response().end(new JsonArray(
|
|
|
+ events.stream().map(e -> (navigationLinks ? JsonObject.of(
|
|
|
+ "Event@NavigationLink", String.format("%s/events/%d",host, e.getId())
|
|
|
+ ) : JsonObject.of()).mergeIn(JsonObject.of(
|
|
|
+ "id", e.getId(),
|
|
|
+ "fromTime", DATE_TIME_FORMATTER.apply(e.getFromTime(), zone),
|
|
|
+ "description", DATE_TIME_FORMATTER.apply(e.getToTime(), zone)
|
|
|
+ ))).collect(toList())
|
|
|
+ ).encode()))
|
|
|
+ .onFailure(th -> rc.fail(400, th));
|
|
|
+ }
|
|
|
+
|
|
|
+ public void eventIdGET(RoutingContext rc) {
|
|
|
+ String host = hostURLFull(rc.request());
|
|
|
+
|
|
|
+ int eventId = Integer.parseInt(rc.pathParam("eventId"));
|
|
|
+
|
|
|
+ List<String> paramZone = rc.queryParam("zone");
|
|
|
+ ZoneId zone = paramZone.isEmpty() ? DEFAULT_ZONE_ID : ZoneId.of(paramZone.get(0));
|
|
|
+
|
|
|
+ List<String> paramNavigationLinks = rc.queryParam("navigationLinks");
|
|
|
+ boolean navigationLinks = paramNavigationLinks.isEmpty() ? DEFAULT_NAVIGATION_LINKS : parseBoolean(paramNavigationLinks.get(0));
|
|
|
+
|
|
|
+ repo.findEventById(eventId)
|
|
|
+ .onSuccess(e -> rc.response().end((navigationLinks ? JsonObject.of(
|
|
|
+ "self@NavigationLink", String.format("%s/events/%d", host, e.getId()),
|
|
|
+ "Driver@NavigationLink", String.format("%s/drivers/%d", host, e.getDriverId()),
|
|
|
+ "DriverUnit@NavigationLink", String.format("%s/drivers/%d/units/%d", host, e.getDriverId(), e.getUnitId()),
|
|
|
+ "Actions@NavigationLink", String.format("%s/actions/%d", host, e.getActionId()),
|
|
|
+ "Observations@NavigationLink", String.format("%s/events/%d/observations", host, e.getId()),
|
|
|
+ "Locations@NavigationLink", String.format("%s/events/%d/observations/locations", host, e.getId())
|
|
|
+ ) : JsonObject.of()).mergeIn(JsonObject.of(
|
|
|
+ "id", e.getId(),
|
|
|
+ "driverId", e.getDriverId(),
|
|
|
+ "actionId", e.getActionId(),
|
|
|
+ "unitId", e.getUnitId(),
|
|
|
+ "fromTime", DATE_TIME_FORMATTER.apply(e.getFromTime(), zone),
|
|
|
+ "description", DATE_TIME_FORMATTER.apply(e.getToTime(), zone)
|
|
|
+ )).encode())
|
|
|
+ .onFailure(th -> rc.fail(400, th)));
|
|
|
+ }
|
|
|
}
|