Package org.cyclos.impl.system
Interface ScriptHelper
-
public interface ScriptHelperHelper for script execution
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddOnAfterEnd(Consumer<Boolean> callback)Adds a listener to be executed when the main transaction ends, regardless of success or failure.voidaddOnAfterEndTransactional(Consumer<Boolean> callback)Adds a listener to be executed when the main transaction ends, regardless of success or failure.voidaddOnBeforeEnd(Runnable callback)Adds a listener to be executed right before the current transaction ends.voidaddOnCommit(Runnable callback)Adds a listener to be executed when the main read-write transaction commits.voidaddOnCommitTransactional(Runnable callback)Adds a listener to be executed when the main read-write transaction commits.voidaddOnRollback(Runnable callback)Adds a listener to be executed when the main read-write transaction is rolled-back.voidaddOnRollbackTransactional(Runnable callback)Adds a listener to be executed when the main read-write transaction is rolled-back.<T> Tbean(Class<T> beanType)Returns a component by typeObjectbean(String name)Returns a component by short name.ApplicationContextgetApplicationContext()Returns the Spring application contextMap<String,Object>getBeanMap()Returns a Map with all beans accessible bybean(String)ConcurrentMap<String,Object>getGlobals()Returns the globals mapLongmaskId(Object id)Returns a value suitable to be sent to clients, which represents the given entity identifier<T> longprocessBatch(Iterable<T> iterable, Consumer<T> closure)<T> longprocessBatch(Iterator<T> iterator, Consumer<T> closure)LongunmaskId(Object id)Returns a value suitable to be used on server side, given the argument is a masked identifierMap<String,Object>wrap(Object object)Wraps an object in aMap, providing access to object properties as map keys.Map<String,Object>wrap(Object object, Collection<? extends CustomField<?,?,?>> customFields)Same aswrap(Object), but providing an explicit custom fields collection, instead of trying to get from the object.
-
-
-
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
-
bean
Object bean(String name)
Returns a component by short name. For example, userService returns theUserServiceLocal, invokerHandler returnsInvokerHandlerand so on.
-
getApplicationContext
ApplicationContext getApplicationContext()
Returns the Spring application context
-
getBeanMap
Map<String,Object> getBeanMap()
Returns a Map with all beans accessible bybean(String)
-
getGlobals
ConcurrentMap<String,Object> getGlobals()
Returns the globals map
-
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)
Wraps an object in aMap, providing access to object properties as map keys. For objects with custom fields (that implement eitherModelWithCustomValuesorEntityWithCustomValues), custom fields can be accessed via the field internal name. So, for example, for a user, user.gender would return theCustomFieldPossibleValue, assuming it is an enumerated custom field.
-
wrap
Map<String,Object> wrap(Object object, Collection<? extends CustomField<?,?,?>> customFields)
Same aswrap(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
-
-