CampaignExecutionService

CampaignExecutionService

The CampaignExecutionService is responsible for all aspects of campaign execution, including:

This service integrates with ScriptManager, ClientRepository, and ExceptionEntityService.


🔧 CampaignExecution createExecution(Campaign campaign)

Creates a new CampaignExecutionarrow-up-right linked to the provided campaign.

@Transactional(propagation = Propagation.MANDATORY)
public CampaignExecution createExecution(Campaign campaign) {
    CampaignExecution execution = new CampaignExecution();
    execution.setCampaign(campaign);
    return executionRepository.saveAndFlush(execution);
}

🔐 _runExecution(CampaignExecution execution)

Private method containing the main business logic for campaign execution.

What it does:

  • Retrieves a list of clients matching the Expressionarrow-up-right

  • Clears the exception if successful

  • On error, stores an ExceptionEntity and marks the execution as EXCEPTION_OCCURRED

  • Sets the final status to FINISHED


🔍 Set<Client> getSuitedBorrowers(...)

Filters clients based on the campaign expression.


🔍 Optional<Client> evaluateClient(...)

Evaluates a single client using the script.

  • The script must return true or false

  • Only matching clients are included


🧰 Script getClientMatchingScript(...)

Compiles the Expression arrow-up-rightinto a Script.

  • Throws a RuntimeException on compilation failure


💡 Object evaluateExpression(UUID clientId, Expression expression)

Allows manual evaluation of an expression for a single client — useful in the UI.


Example service

Last updated

Was this helpful?