Interface ScriptHelper


  • public interface ScriptHelper
    Helper for script execution
    • Method Detail

      • addOnAfterEnd

        void addOnAfterEnd​(Consumer<Boolean> callback)
        Adds a listener to be executed when the main transaction ends, regardless of success or failure. The listener itself runs outside a transaction. The given callback receives a Boolean object, which can be:
        • true: The current read-write transaction was committed;
        • false: The current read-write transaction was rolled-back;
        • null: The current read-only transaction has ended.
      • addOnAfterEndTransactional

        void addOnAfterEndTransactional​(Consumer<Boolean> callback)
        Adds a listener to be executed when the main transaction ends, regardless of success or failure. The listener itself runs in a new read-write transaction. The given callback receives a Boolean object, which can be:
        • true: The current read-write transaction was committed;
        • false: The current read-write transaction was rolled-back;
        • null: The current read-only transaction has ended.
      • addOnBeforeEnd

        void addOnBeforeEnd​(Runnable callback)
        Adds a listener to be executed right before the current transaction ends. The listener runs in the current transaction.
      • addOnCommit

        void addOnCommit​(Runnable callback)
        Adds a listener to be executed when the main read-write transaction commits. The listener itself runs outside a transaction. If called in a read-only transaction, an exception is thrown.
      • addOnCommitTransactional

        void addOnCommitTransactional​(Runnable callback)
        Adds a listener to be executed when the main read-write transaction commits. The listener itself runs in a new read-write transaction. If called in a read-only transaction, an exception is thrown.
      • addOnRollback

        void addOnRollback​(Runnable callback)
        Adds a listener to be executed when the main read-write transaction is rolled-back. The listener itself runs outside a transaction. If called in a read-only transaction, an exception is thrown.
      • addOnRollbackTransactional

        void addOnRollbackTransactional​(Runnable callback)
        Adds a listener to be executed when the main read-write transaction is rolled-back. The listener itself runs in a new read-write transaction. If called in a read-only transaction, an exception is thrown.
      • bean

        <T> T bean​(Class<T> beanType)
        Returns a component by type
      • getApplicationContext

        ApplicationContext getApplicationContext()
        Returns the Spring application context
      • maskId

        Long maskId​(Object id)
        Returns a value suitable to be sent to clients, which represents the given entity identifier
      • unmaskId

        Long unmaskId​(Object id)
        Returns a value suitable to be used on server side, given the argument is a masked identifier
      • wrap

        Map<String,​Object> wrap​(Object object,
                                      Collection<? extends CustomField<?,​?,​?>> customFields)
        Same as wrap(Object), but providing an explicit custom fields collection, instead of trying to get from the object. Is useful, for example, when creating a new entity / DTO, when it doesn't yet have a list of custom values