Class BTDispatcherAssistantSchedulableActivitiesClient<T extends DynO>
- Type Parameters:
T- the type of the output class that extendsDynO, representing the structure of the filters returned by the Dispatcher Assistant API
- All Implemented Interfaces:
Serializable,Tool
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 Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringConfiguration name for the Dispatcher Assistant REST client -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidExecutes the main business logic for the Dispatcher Assistant search task.static M2MapperCreates and configures a default ModelMapper instance for object mapping.protected voidHandles the response cost validation for the Dispatcher Assistant session.protected voidHandles and validates error responses from the dispatcher assistant schedulable activities service.Methods inherited from class overit.geocall.bl.BusinessTask
start, start, startAlone, startInBackground
-
Field Details
-
CONFIG_NAME
Configuration name for the Dispatcher Assistant REST client- See Also:
-
-
Constructor Details
-
BTDispatcherAssistantSchedulableActivitiesClient
public BTDispatcherAssistantSchedulableActivitiesClient()
-
-
Method Details
-
body
protected void body(DispatcherAssistantSchedulableActivitiesSearchEvent<T> event, PoolKit pk) throws DAValidateException Executes the main business logic for the Dispatcher Assistant search task.This method orchestrates the following steps:
- Calls the Dispatcher Assistant API via
requestWithClientAbstractor(overit.geocallapp.wfm.ai.assistant.bl.dispatcherassistant.schedulableactivities.event.DispatcherAssistantSchedulableActivitiesSearchEvent<T>) - Retrieves the output class type from the event input
- Maps the API response filters to the specified output class using ModelMapper
- Writes the mapped result to the event journal for further processing
- Specified by:
bodyin classBusinessTask<DispatcherAssistantSchedulableActivitiesSearchEvent<T extends DynO>>- Parameters:
event- the search event containing input parameters and configurationpk- the pool kit for database operations- Throws:
DAValidateException- if validation fails or a permanent API error occurs
- Calls the Dispatcher Assistant API via
-
handleResponseCost
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- theDispatcherAssistantSchedulableActivitiesResponseto validate for errors- Throws:
DAValidateException- if the response contains error information indicating the operation failed
-
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:
ZonedDateTimeRangetoDateTimeRange- 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
M2Mapperinstance ready for mapping operations
-