Class BTDispatcherAssistantSchedulableActivitiesClient<T extends DynO>

java.lang.Object
overit.geocall.bl.BusinessTask<DispatcherAssistantSchedulableActivitiesSearchEvent<T>>
overit.geocallapp.wfm.ai.assistant.rc1.dispatcherassistant.schedulableactivities.task.BTDispatcherAssistantSchedulableActivitiesClient<T>
Type Parameters:
T - the type of the output class that extends DynO, representing the structure of the filters returned by the Dispatcher Assistant API
All Implemented Interfaces:
Serializable, Tool

@Event(DispatcherAssistantSchedulableActivitiesSearchEvent.class) public class BTDispatcherAssistantSchedulableActivitiesClient<T extends DynO> extends BusinessTask<DispatcherAssistantSchedulableActivitiesSearchEvent<T>>
Business Task to call Dispatcher Assistant Search API for schedulable activities.

This task handles the communication with the Dispatcher Assistant external service to search for schedulable activities based on the provided input criteria. It performs the following operations:

  • Sends a POST request to the Dispatcher Assistant API endpoint
  • Receives and processes the response containing filters and metadata
  • Maps the response filters to the specified output class type
  • Writes the mapped result to the event journal

The task is generic and can work with any output type that extends DynO, allowing flexibility in the structure of the returned data.

Error handling includes:

  • Permanent errors (validation, malformed response) - throws DAValidateException
  • Transient errors (server, network) - performs automatic retry

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

    • CONFIG_NAME

      protected static final String CONFIG_NAME
      Configuration name for the Dispatcher Assistant REST client
      See Also:
  • Constructor Details

    • BTDispatcherAssistantSchedulableActivitiesClient

      public BTDispatcherAssistantSchedulableActivitiesClient()
  • Method Details

    • body

      Executes the main business logic for the Dispatcher Assistant search task.

      This method orchestrates the following steps:

      1. Calls the Dispatcher Assistant API via requestWithClientAbstractor(overit.geocallapp.wfm.ai.assistant.bl.dispatcherassistant.schedulableactivities.event.DispatcherAssistantSchedulableActivitiesSearchEvent<T>)
      2. Retrieves the output class type from the event input
      3. Maps the API response filters to the specified output class using ModelMapper
      4. Writes the mapped result to the event journal for further processing

      Specified by:
      body in class BusinessTask<DispatcherAssistantSchedulableActivitiesSearchEvent<T extends DynO>>
      Parameters:
      event - the search event containing input parameters and configuration
      pk - the pool kit for database operations
      Throws:
      DAValidateException - if validation fails or a permanent API error occurs
    • handleResponseCost

      protected void handleResponseCost(DispatcherAssistantSchedulableActivitiesResponse response)
      Handles the response cost validation for the Dispatcher Assistant session.

      This method checks if the session cost from the API response metadata has exceeded the maximum allowed cost threshold defined in ConstAIAssistant.CONFIG_MAX_COST_DOLLARS. If the cost limit is exceeded, it adds an extension flag to the response filters to indicate that the maximum cost has been exceeded.

      The cost exceeded flag can be used by the UI layer to display appropriate warnings or notifications to the user, preventing further API calls in the current session.

      Parameters:
      response - the Dispatcher Assistant API response containing metadata with session cost information. If the response or its metadata is null, no action is taken.
    • handleResponseErrors

      protected void handleResponseErrors(DispatcherAssistantSchedulableActivitiesResponse response) throws DAValidateException
      Handles and validates error responses from the dispatcher assistant schedulable activities service.

      This method checks the response for error conditions and throws a validation exception if any errors are detected. It should be called after receiving a response from the dispatcher assistant to ensure the operation completed successfully.

      Parameters:
      response - the DispatcherAssistantSchedulableActivitiesResponse to validate for errors
      Throws:
      DAValidateException - if the response contains error information indicating the operation failed
    • defaultMapper

      public static M2Mapper defaultMapper()
      Creates and configures a default ModelMapper instance for object mapping.

      The mapper is configured with the following settings:

      • Access level: PRIVATE - allows mapping of private fields without requiring getters/setters
      • Collections merge: DISABLED - collections in the destination are replaced rather than merged with source collections
      • Type mapping: ZonedDateTimeRange to DateTimeRange - enables automatic conversion between these date/time types

      This configuration ensures proper mapping of the Dispatcher Assistant API response to the target output class type, handling complex nested objects and date/time conversions.

      Returns:
      a configured M2Mapper instance ready for mapping operations