Package su.onno.ui

Class BatchRunner

java.lang.Object
su.onno.ui.BatchRunner
All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean

public class BatchRunner extends Object implements org.springframework.beans.factory.DisposableBean
Runs a bulk row action over a set of ids and reports {ok, failed, total}. The list's multi-row selection posts every selected id in one request; each id is handled independently — its own transaction, continue-on-failure — so the set is resolved concurrently on a bounded pool. onno.ui.batch.parallelism caps the fan-out (1 runs inline, exactly the old sequential behaviour). Shared by the action-batch and the catalog/document batch-delete endpoints.

Spring Security is an optional dependency of this module (see UiAccessService), so the caller's SecurityContext is propagated to worker threads reflectively — a no-op when Security isn't on the classpath — letting consumer action handlers that read SecurityContextHolder keep working under fan-out. The authenticated Principal is also passed to handlers explicitly by the callers, so the framework's own write path never relies on this.

  • Constructor Details

    • BatchRunner

      public BatchRunner(int parallelism)
  • Method Details

    • run

      public Map<String,Object> run(List<UUID> ids, Consumer<UUID> perId)
      Apply perId to every id and tally the outcome. A per-id RuntimeException is caught and that id recorded in failed (order-stable, in the input order) while the rest of the batch proceeds. Returns {ok, failed, total}.
    • destroy

      public void destroy()
      Specified by:
      destroy in interface org.springframework.beans.factory.DisposableBean