Package org.cyclos.impl.system
Class ScriptHelperImpl
- java.lang.Object
-
- org.cyclos.impl.AbstractServerComponent
-
- org.cyclos.impl.AbstractNetworkedServerComponent
-
- org.cyclos.impl.BaseNetworkedHandlerImpl
-
- org.cyclos.impl.system.ScriptHelperImpl
-
- All Implemented Interfaces:
ScriptHelper
@Component public class ScriptHelperImpl extends BaseNetworkedHandlerImpl implements ScriptHelper
Implementation forScriptHelper
-
-
Field Summary
-
Fields inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
authHandler, conversionHandler, customFieldValueHandler, entityManagerHandler, groupsHandler, productsHandler, restBeanPropertyMapping, userLocatorHandler
-
Fields inherited from class org.cyclos.impl.AbstractServerComponent
accountHandler, configurationHandler, dataTranslationHandler, notificationHandler, transactionHandler, translationHandler
-
-
Constructor Summary
Constructors Constructor Description ScriptHelperImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddOnCommit(Runnable runnable)Adds a listener to be executed when the main transaction commits, which is not executed in a database transactionvoidaddOnCommitTransactional(Runnable runnable)Adds a listener to be executed when the main transaction commits, which is executed inside a new transactionvoidaddOnRollback(Runnable runnable)Adds a listener to be executed when the main transaction rollbacks, which is not executed in a database transactionvoidaddOnRollbackTransactional(Runnable runnable)Adds a listener to be executed when the main transaction is rolled-back, which is executed inside a new transaction<T> Tbean(Class<T> beanType)Returns a bean by typeObjectbean(String name)Returns a bean by short name.ApplicationContextgetApplicationContext()Returns the Spring application contextMap<String,Object>getBeanMap()Returns a Map with all beans accessible byScriptHelper.bean(String)voidinitialize()LongmaskId(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)SeeQueryHelper#processBatch(CloseableIterator, Consumer, BaseEntityManagerHandler)<T> longprocessBatch(Iterator<T> iterator, Consumer<T> closure)SeeQueryHelper#processBatch(CloseableIterator, Consumer, BaseEntityManagerHandler)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 asScriptHelper.wrap(Object), but providing an explicit custom fields collection, instead of trying to get from the object.-
Methods inherited from class org.cyclos.impl.AbstractNetworkedServerComponent
canManage, checkManagesUser, checkPermission, checkRelatesToUser, checkValue, clearAlreadyValidated, getBaseEntityManagerHandler, getConfiguration, getLoggedBasicUser, getLoggedUser, getProducts, getTranslatedName, getTranslatedValue, hasPermission, hasValue, inSameNetwork, inSameNetworkOrGlobal, isAdmin, isAlreadyValidated, isBroker, isGlobalAdmin, isGlobalAdminInNetwork, isGuest, isLoggedIn, isMember, isMemberOnly, isNetworkAdmin, isOperator, isRelatedToUser, isSystem, isUserManager, isUserManagerOf, message, message, permission, permission, permissionOptionalValue, permissionOptionalValue, setAlreadyValidated, toDate, toDateTime, validate
-
Methods inherited from class org.cyclos.impl.AbstractServerComponent
dataTranslationProxy, dataTranslationProxy, delete, detach, doDataTranslationProxy, find, flush, from, getFormatter, getFormatter, getFormatter, getLogger, getRemoteAddress, getSessionData, mailContentBuilder, message, message, persist, refresh, remove, selectFrom, subQuery, update
-
-
-
-
Method Detail
-
addOnCommit
public void addOnCommit(Runnable runnable)
Description copied from interface:ScriptHelperAdds a listener to be executed when the main transaction commits, which is not executed in a database transaction- Specified by:
addOnCommitin interfaceScriptHelper
-
addOnCommitTransactional
public void addOnCommitTransactional(Runnable runnable)
Description copied from interface:ScriptHelperAdds a listener to be executed when the main transaction commits, which is executed inside a new transaction- Specified by:
addOnCommitTransactionalin interfaceScriptHelper
-
addOnRollback
public void addOnRollback(Runnable runnable)
Description copied from interface:ScriptHelperAdds a listener to be executed when the main transaction rollbacks, which is not executed in a database transaction- Specified by:
addOnRollbackin interfaceScriptHelper
-
addOnRollbackTransactional
public void addOnRollbackTransactional(Runnable runnable)
Description copied from interface:ScriptHelperAdds a listener to be executed when the main transaction is rolled-back, which is executed inside a new transaction- Specified by:
addOnRollbackTransactionalin interfaceScriptHelper
-
bean
public <T> T bean(Class<T> beanType)
Description copied from interface:ScriptHelperReturns a bean by type- Specified by:
beanin interfaceScriptHelper
-
bean
public Object bean(String name)
Description copied from interface:ScriptHelperReturns a bean by short name. For example, userService returns theUserServiceLocal, invokerHandler returnsInvokerHandlerand so on.- Specified by:
beanin interfaceScriptHelper
-
getApplicationContext
public ApplicationContext getApplicationContext()
Description copied from interface:ScriptHelperReturns the Spring application context- Specified by:
getApplicationContextin interfaceScriptHelper- Overrides:
getApplicationContextin classAbstractServerComponent
-
getBeanMap
public Map<String,Object> getBeanMap()
Description copied from interface:ScriptHelperReturns a Map with all beans accessible byScriptHelper.bean(String)- Specified by:
getBeanMapin interfaceScriptHelper
-
initialize
@PostConstruct public void initialize()
-
maskId
public Long maskId(Object id)
Description copied from interface:ScriptHelperReturns a value suitable to be sent to clients, which represents the given entity identifier- Specified by:
maskIdin interfaceScriptHelper
-
processBatch
public <T> long processBatch(Iterable<T> iterable, Consumer<T> closure)
Description copied from class:AbstractServerComponentSeeQueryHelper#processBatch(CloseableIterator, Consumer, BaseEntityManagerHandler)- Specified by:
processBatchin interfaceScriptHelper- Overrides:
processBatchin classAbstractServerComponent
-
processBatch
public <T> long processBatch(Iterator<T> iterator, Consumer<T> closure)
Description copied from class:AbstractServerComponentSeeQueryHelper#processBatch(CloseableIterator, Consumer, BaseEntityManagerHandler)- Specified by:
processBatchin interfaceScriptHelper- Overrides:
processBatchin classAbstractServerComponent
-
unmaskId
public Long unmaskId(Object id)
Description copied from interface:ScriptHelperReturns a value suitable to be used on server side, given the argument is a masked identifier- Specified by:
unmaskIdin interfaceScriptHelper
-
wrap
public Map<String,Object> wrap(Object object)
Description copied from interface:ScriptHelperWraps 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.- Specified by:
wrapin interfaceScriptHelper
-
wrap
public Map<String,Object> wrap(Object object, Collection<? extends CustomField<?,?,?>> customFields)
Description copied from interface:ScriptHelperSame asScriptHelper.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- Specified by:
wrapin interfaceScriptHelper
-
-