vertx/src/main/java/eu/internetofus/common/vertx/ModelResources.java
/**
   * Update a model into the DB.
   *
   * @param model   context of the model to update.
   * @param updater the function used to store a model.
   * @param context of the request.
   * @param success component to process the updated model.
   *
   * @param <T>     type of model to update.
   * @param <I>     type of the model identifier.
   * @param <C>     type of validation context to use.
   */
Update a model into the DB.
@param model   context of the model to update.
@param updater the function used to store a model.
@param context of the request.
@param success component to process the updated model.

@param      type of model to update.
@param      type of the model identifier.
@param      type of validation context to use.
Update a model into the DB . @param model context of the model to update . @param updater the function used to store a model . @param context of the request . @param success component to process the updated model . @param type of model to update . @param type of the model identifier . @param type of validation context to use .
static public <T extends Model, I, C extends ValidateContext<C>> void updateModelChain(
      @NotNull final ModelContext<T, I, C> model, @NotNull final BiConsumer<T, Handler<AsyncResult<Void>>> updater,
      @NotNull final ServiceContext context, @NotNull final Runnable success) {
    if (model.value instanceof CreateUpdateTsDetails) {
      final var now = TimeManager.now();
      ((CreateUpdateTsDetails) model.value)._lastUpdateTs = now;
    }
    updater.accept(model.value, stored -> {
      if (stored.failed()) {
        final var cause = stored.cause();
        Logger.trace(cause, "Cannot update {}.\n{}", model, context);
        ServiceResponseHandlers.responseFailedWith(context.resultHandler, Status.BAD_REQUEST, cause);
      } else {
        Logger.trace("Updated {}.\n{}", model, context);
        success.run();
      }
    });
  }
static public < T extends Model , I , C extends ValidateContext < C > > void updateModelChain ( @ NotNull final ModelContext < T , I , C > model , @ NotNull final BiConsumer < T , Handler < AsyncResult < Void > > > updater , @ NotNull final ServiceContext context , @ NotNull final Runnable success ) { if ( model . value instanceof CreateUpdateTsDetails ) { final var now = TimeManager . now ( ) ; ( ( CreateUpdateTsDetails ) model . value ) . _lastUpdateTs = now ; } updater . accept ( model . value , stored -> { if ( stored . failed ( ) ) { final var cause = stored . cause ( ) ; Logger . trace ( cause , "Cannot update {}.\n{}" , model , context ) ; ServiceResponseHandlers . responseFailedWith ( context . resultHandler , Status . BAD_REQUEST , cause ) ; } else { Logger . trace ( "Updated {}.\n{}" , model , context ) ; success . run ( ) ; } } ) ; }
Update a model into the DB.
Update a model into the DB .