Class AfterCommitTask

java.lang.Object
ch.tocco.nice2.persist.core.api.util.AfterCommitTask
All Implemented Interfaces:
PersistTask<Object,Void>

public abstract class AfterCommitTask extends Object implements PersistTask<Object,Void>
  • Constructor Details

    • AfterCommitTask

      public AfterCommitTask()
  • Method Details

    • run

      public final Void run(Optional<Object> a, CommandContext commandContext) throws Exception
      Specified by:
      run in interface PersistTask<Object,Void>
      Throws:
      Exception
    • getValue

      protected final <V> V getValue(Mode.Key<V> key)
    • getValueOrNull

      @Nullable protected final <V> V getValueOrNull(Mode.Key<V> key)
    • onAfterCommit

      public abstract void onAfterCommit(CommandContext commandContext) throws Exception
      Implement this method for logic to be executed asynchronously after the commit. To retrieve the affected entities consider the below methods.
      Parameters:
      commandContext - commandContext
      Throws:
      Exception
      See Also:
    • getContext

      public final Context getContext()
      Use this method to retrieve the context.
      Important note: Do not inject your own context, but always use the one returned by this method.
      Returns:
      a context to work with
    • getCreatedEntities

      protected final Iterable<Entity> getCreatedEntities()
      get all entities that were created during the transaction
      Returns:
      -
    • getCreatedEntityIds

      protected final Iterable<EntityId> getCreatedEntityIds()
    • getUpdatedEntities

      protected final Iterable<Entity> getUpdatedEntities()
      get all entities that were update during the transaction
      Returns:
      -
    • getUpdatedEntityIds

      protected final Iterable<EntityId> getUpdatedEntityIds()
    • getDeletedEntities

      protected final Iterable<EntityId> getDeletedEntities()
      get all entities that were deleted during the transaction
      Returns:
      -
    • setCollectedEntities

      protected void setCollectedEntities(Set<EntityId> createdEntities, Set<EntityId> updatedEntities, Set<EntityId> deletedEntities)