LogoLogo
timvero.comMaven Repository
  • timveroOS SDK guide
  • timveroOS how-to
  • timveroOS admin-side setup
  • Campaigns in timveroOS
    • 7.11
      • Business Context
      • Introduction
      • Core Concept
        • Entity Diagram
        • Lifecycle Diagram
        • Expression
      • Design and Development of the Campaign Model
        • Campaign model
        • Campaign repository
        • Campaign forms
        • Campaign сontroller
        • UI elements
        • Campaign actions
      • Design and Development of the CampaignExecution Model
        • CampaignExecution model
        • CampaignExecution repository
        • CampaignExecution controller
        • UI elements
      • Expression
      • Services
        • CampaignService
        • CampaignExecutionService
      • Campaign Processing
        • Producer
        • Consumer
      • Post-processing
        • Checker
Powered by GitBook
On this page

Was this helpful?

  1. Campaigns in timveroOS
  2. 7.11
  3. Design and Development of the Campaign Model

Campaign model

Campaign

The Campaign class represents the definition of a campaign and extends HistoryEntity<Long>. This means every change to a campaign is stored as a new version, while the previous one is automatically deactivated. Versioning is managed by the HistoryEntityFormService, so the developer does not need to manually call setActive(false) for the previous version.

Key Fields:

  • name — a string representing the campaign’s display name

  • executionType — MANUAL or AUTOMATIC, determining whether the campaign is launched manually or on a schedule

  • expression — a script (as an Expression object) that defines which clients are included in the campaign

  • creditProductCodes — a list of product codes (e.g., for loans) to which the campaign applies

  • restartable — indicates whether the campaign can be restarted at intervals

  • restartableUnit, restartableUnitType — a numeric value and time unit (hours or days) for cyclic restarts

  • dateTimeExecution — the date and time of the next scheduled automatic launch

  • executions — a list of all CampaignExecution instances associated with the campaign

Impact of AutomaticCampaignStatus and RestartableUnitType Fields:

  • AutomaticCampaignStatus controls the current state of an automatic campaign:

    • SCHEDULED means the campaign is active and ready for execution

    • IDLE means the automatic launch is paused

  • RestartableUnitType (e.g., HOURS, DAYS) defines how restartableUnit is interpreted for recurring launches. These fields are heavily used by the CampaignExecutionProducer component to calculate scheduling.

Model Example:

@Entity
@Table(name = "campaign")
public class Campaign extends HistoryEntity<Long> {

    @Column(nullable = false)
    private String name;

    @Column(nullable = false)
    @Enumerated(EnumType.STRING)
    private CampaignExecutionType executionType;

    @Column
    @Enumerated(EnumType.STRING)
    private AutomaticCampaignStatus automaticCampaignStatus;

    @Embedded
    private Expression expression;

    @ElementCollection
    private Set<String> creditProductCodes;

    private boolean restartable;
    private Integer restartableUnit;

    @Enumerated(EnumType.STRING)
    private RestartableUnitType restartableUnitType;

    private LocalDateTime dateTimeExecution;

    @ManyToOne
    private ProcessSpecification processSpecification;

    @OneToMany(mappedBy = "campaign")
    private List<CampaignExecution> executions;
    
    // getters and setters

    @Transient
    public Optional<CampaignExecution> getLatestExecution() {
       return getExecutions().stream()
           .max(Comparator.comparing(CampaignExecution::getCreatedAt));
    }

    @Transient
    public boolean isNotInExecution() {
       CampaignExecution execution = getLatestExecution();
       return execution == null || execution.getStatus() != CampaignExecutionStatus.IN_PROGRESS;
    }

    @Transient
    public Duration getRestartableDuration() {
       return getRestartableUnitType().getChronoUnit().getDuration().multipliedBy(getRestartableUnit());
    }
}
PreviousDesign and Development of the Campaign ModelNextCampaign repository

Last updated 20 days ago

Was this helpful?