Class ScriptListenerServiceImpl
java.lang.Object
ch.tocco.nice2.scripting.impl.groovy.listener.ScriptListenerServiceImpl
- All Implemented Interfaces:
ScriptListenerService
-
Nested Class Summary
Nested classes/interfaces inherited from interface ch.tocco.nice2.scripting.api.groovy.listener.ScriptListenerService
ScriptListenerService.EntityData
-
Constructor Summary
ConstructorDescriptionScriptListenerServiceImpl
(Context context, QueryBuilderFactory queryBuilderFactory, GroovyEvaluationService groovyEvaluationService, SecurityManager securityManager) -
Method Summary
Modifier and TypeMethodDescription@Nullable GroovyEvaluationService.ScriptResult
applyListener
(Entity listener, ScriptListenerService.EntityData target, boolean force) Run the given 'Dynamic_listener' entity with theGroovyEvaluationService
.void
applyListenersToEntities
(Collection<ScriptListenerService.EntityData> entities, String event, boolean afterCommit) Finds all Dynamic_listener entities that are registered on any of the given entity models for the specified event and applies the relevant listeners to each provided entity.Get an invoker to run code without invoking script listeners
-
Constructor Details
-
ScriptListenerServiceImpl
public ScriptListenerServiceImpl(Context context, QueryBuilderFactory queryBuilderFactory, GroovyEvaluationService groovyEvaluationService, SecurityManager securityManager)
-
-
Method Details
-
applyListenersToEntities
public void applyListenersToEntities(Collection<ScriptListenerService.EntityData> entities, String event, boolean afterCommit) Description copied from interface:ScriptListenerService
Finds all Dynamic_listener entities that are registered on any of the given entity models for the specified event and applies the relevant listeners to each provided entity. This fires one query per distinct entity model.- Specified by:
applyListenersToEntities
in interfaceScriptListenerService
- Parameters:
entities
- allScriptListenerService.EntityData
instances for which the given event has occurredevent
- the occurred event to search registered listeners for (create, update or delete)afterCommit
- whether or not to search for after commit listeners
-
applyListener
@Nullable public @Nullable GroovyEvaluationService.ScriptResult applyListener(Entity listener, ScriptListenerService.EntityData target, boolean force) Description copied from interface:ScriptListenerService
Run the given 'Dynamic_listener' entity with theGroovyEvaluationService
. The parameter 'target' is added to the binding of the script (with the name 'entity').- Specified by:
applyListener
in interfaceScriptListenerService
- Parameters:
force
- force execution (ignoreScriptListenerService.EntityData.getChangedFields()
-
withoutScriptListener
Description copied from interface:ScriptListenerService
Get an invoker to run code without invoking script listeners- Specified by:
withoutScriptListener
in interfaceScriptListenerService
-