Checker
π Purpose
CreateApplicationExecutionChecker
is a component that automatically reacts to the completion of a campaign execution (CampaignExecution
) and creates applications for the clients who were selected.
It implements the observer pattern for entity changes using the EntityChecker
abstraction provided by the timveroOS framework.
ποΈ Inheritance from EntityChecker
EntityChecker
EntityChecker<E, ID>
is a base class in the platform used to observe changes to entity fields.The implementation must override:
registerListeners(...)
β to specify which fields to monitorisAvailable(...)
β to define when the checker should triggerperform(...)
β to define the actions to perform upon trigger
π Reacting to FINISHED
Status
FINISHED
StatusregisterListeners
subscribes the checker to changes in thestatus
fieldisAvailable
ensuresperform(...)
is only called when the status becomesFINISHED
π οΈ Core Logic in perform(...)
perform(...)
β What happens here:
Transaction-safe execution: Uses
TransactionUtils.afterTransaction(...)
to defer logic until after the current transaction completes β important for compatibility with Spring@Transactional
Application creation: For each selected client, it triggers
createApplicationService.create(...)
with a reference to the current campaign execution
π¦ Components and Dependencies
CreateApplicationService
is the internal service responsible for creating applications
π How It Works in the System
A campaign finishes execution β
CampaignExecution.status
becomesFINISHED
The
EntityChecker
detects the status changeperform(...)
is triggered after the transaction endsApplications are created for each selected client
π§ͺ Example Usage
Campaign A has a filter like
client.score > 800
and selects 3 clientsAfter execution completes:
CampaignExecution.status
βFINISHED
CreateApplicationExecutionChecker
is triggered3 applications are created β one for each selected client, linked to the campaign
π Summary
Inherits from
EntityChecker<CampaignExecution, Long>
Monitors changes to the
status
fieldTrigger condition:
status == FINISHED
Executes after transaction completes
Main logic: notifying on completion and creating applications for clients
Depends on:
CreateApplicationService
Last updated
Was this helpful?