vertx/src/main/java/eu/internetofus/common/vertx/ModelResources.java
/**
   * Retrieve a page of models.
   *
   * @param offset   index of the first model to return.
   * @param limit    number maximum of models to return.
   * @param searcher function to obtain the page.
   * @param context  of the request.
   * @param success  to inform to the page.
   */
Retrieve a page of models.
@param offset   index of the first model to return.
@param limit    number maximum of models to return.
@param searcher function to obtain the page.
@param context  of the request.
@param success  to inform to the page.
Retrieve a page of models . @param offset index of the first model to return . @param limit number maximum of models to return . @param searcher function to obtain the page . @param context of the request . @param success to inform to the page .
static public void retrieveModelsPageChain(final int offset, final int limit,
      @NotNull final BiConsumer<ModelsPageContext, Promise<JsonObject>> searcher, @NotNull final ServiceContext context,
      final Consumer<JsonObject> success) {
    final var page = new ModelsPageContext();
    page.offset = offset;
    page.limit = limit;
    final Promise<JsonObject> promise = Promise.promise();
    try {
      searcher.accept(page, promise);
    } catch (final Throwable cause) {
      promise.fail(cause);
    }
    promise.future().onComplete(search -> {
      if (search.failed()) {
        final var cause = search.cause();
        Logger.trace(cause, "Cannot obtain the models.\n{}\n{}", page, context);
        ServiceResponseHandlers.responseFailedWith(context.resultHandler, Status.BAD_REQUEST, cause);
      } else {
        final var found = search.result();
        success.accept(found);
      }
    });
  }
static public void retrieveModelsPageChain ( final int offset , final int limit , @ NotNull final BiConsumer < ModelsPageContext , Promise < JsonObject > > searcher , @ NotNull final ServiceContext context , final Consumer < JsonObject > success ) { final var page = new ModelsPageContext ( ) ; page . offset = offset ; page . limit = limit ; final Promise < JsonObject > promise = Promise . promise ( ) ; try { searcher . accept ( page , promise ) ; } catch ( final Throwable cause ) { promise . fail ( cause ) ; } promise . future ( ) . onComplete ( search -> { if ( search . failed ( ) ) { final var cause = search . cause ( ) ; Logger . trace ( cause , "Cannot obtain the models.\n{}\n{}" , page , context ) ; ServiceResponseHandlers . responseFailedWith ( context . resultHandler , Status . BAD_REQUEST , cause ) ; } else { final var found = search . result ( ) ; success . accept ( found ) ; } } ) ; }
Retrieve a page of models.
Retrieve a page of models .