Class BTImmediateSchedulingScheduler

java.lang.Object
overit.geocall.bl.BusinessTask<Void>
overit.geocallapp.wfm.scheduling.bl.immediatescheduling.processing.task.BTImmediateSchedulingScheduler
All Implemented Interfaces:
Serializable, Tool

public class BTImmediateSchedulingScheduler extends BusinessTask<Void>
Business task to schedule immediate scheduling processes based on calendar configuration.
This task checks the immediate scheduling calendar and creates new processing records when the configured interval has elapsed since the last processing.

The task runs periodically and:

  • Retrieves all active calendar entries
  • For each entry, checks if there are any processing records in progress or waiting
  • If not, retrieves the tracking record to check when the last immediate scheduling ended
  • If enough time has elapsed since the last execution, enqueues a new processing record via ImmediateSchedulingEnqueueEvent

The task uses the BOImmediateSchedulingTracking table to efficiently track the last execution dates instead of searching through the history table.

This task should be scheduled to run periodically (e.g., every 1-2 minutes).

Since:
22.0
See Also:
GCApi:
task
  • Constructor Details

    • BTImmediateSchedulingScheduler

      public BTImmediateSchedulingScheduler()
  • Method Details

    • body

      protected void body(Void input, PoolKit poolKit) throws DAException, DAValidateException
      Description copied from class: BusinessTask
      Implements this method to write the specific task logic to handle the input parameter.
      Specified by:
      body in class BusinessTask<Void>
      Parameters:
      input - the object upon which the task will works on
      poolKit - the poolkit containing the reference to the database connection that can be used
      Throws:
      DAException - in case of database error
      DAValidateException - in case of database validation error
    • processCalendarEntry

      protected void processCalendarEntry(BOImmediateSchedulingCalendar calendar, Date now, PoolKit poolKit) throws DAException, DAValidateException
      Process a single calendar entry to determine if a new processing should be scheduled.

      This method:

      • Checks if there are any processing records in progress or waiting
      • Retrieves the tracking record to get the last immediate and reprocessing execution dates
      • Determines if enough time has elapsed for immediate scheduling or reprocessing
      • Schedules a new processing if needed
      Parameters:
      calendar - the calendar entry
      now - the current date/time
      poolKit - the pool kit
      Throws:
      DAException - if a database error occurs
      DAValidateException - if validation fails
    • hasProcessingInProgressOrWaiting

      protected boolean hasProcessingInProgressOrWaiting(Long operationCenter, Long schedulingModel, PoolKit poolKit) throws DAException, DAValidateException
      Check if there are any processing records in progress or waiting for the given operation center and scheduling model
      Parameters:
      operationCenter - the operation center ID
      schedulingModel - the scheduling model ID
      poolKit - the pool kit
      Returns:
      true if there are processing records in progress or waiting
      Throws:
      DAException - if a database error occurs
      DAValidateException - if validation fails
    • getTrackingRecord

      protected BOImmediateSchedulingTracking getTrackingRecord(Long operationCenter, Long schedulingModel, PoolKit poolKit) throws DAException, DAValidateException
      Get the tracking record for the given operation center and scheduling model
      Parameters:
      operationCenter - the operation center ID
      schedulingModel - the scheduling model ID
      poolKit - the pool kit
      Returns:
      the tracking record, or null if none found
      Throws:
      DAException - if a database error occurs
      DAValidateException - if validation fails
    • shouldScheduleProcessing

      protected boolean shouldScheduleProcessing(Long intervalMinutes, Date lastProcessingEndDate, Date now)
      Determine if a new processing should be scheduled based on the interval and last execution date.

      A new processing should be scheduled if:

      • The interval is configured (not null and greater than 0)
      • The last processing end date is before the threshold date (now - interval)
      Parameters:
      intervalMinutes - the interval in minutes (immediate or reprocessing)
      lastProcessingEndDate - the end date of the last processing (null if no last processing)
      now - the current date/time
      Returns:
      true if a new processing should be scheduled
    • scheduleNewProcessing

      protected void scheduleNewProcessing(Long operationCenter, Long schedulingModel, boolean reprocessing, boolean autoValidationEnabled, PoolKit poolKit) throws DAException, DAValidateException
      Schedule a new processing by launching the ImmediateSchedulingEnqueueEvent.

      This method delegates to the BTImmediateSchedulingEnqueue task which will:

      • Search for an existing last processing record
      • Update it or create a new one with state TO_BE_PROCESSED
      • Create a history record
      Parameters:
      operationCenter - the operation center ID
      schedulingModel - the scheduling model ID
      reprocessing - true if this is a reprocessing, false for immediate scheduling
      autoValidationEnabled - true if auto validation is enabled
      poolKit - the pool kit
      Throws:
      DAException - if a database error occurs
      DAValidateException - if validation fails