From 6c03a7d15d78c0168fe9f678b460bf10721bee3a Mon Sep 17 00:00:00 2001 From: Maria Martinez Date: Mon, 25 Nov 2024 09:26:44 -0800 Subject: [PATCH] feat(be): Added javadocs --- .../controller/ClientSearchController.java | 16 ++++++++++++++++ .../legacy/service/ClientSearchService.java | 15 +++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/main/java/ca/bc/gov/api/oracle/legacy/controller/ClientSearchController.java b/src/main/java/ca/bc/gov/api/oracle/legacy/controller/ClientSearchController.java index d6684ab..8d4ac8f 100644 --- a/src/main/java/ca/bc/gov/api/oracle/legacy/controller/ClientSearchController.java +++ b/src/main/java/ca/bc/gov/api/oracle/legacy/controller/ClientSearchController.java @@ -116,6 +116,22 @@ public Flux searchClients( .putIfAbsent(ApplicationConstants.X_TOTAL_COUNT, List.of(dto.getCount().toString()))); } + /** + * Searches for clients based on the provided parameters using a fuzzy match algorithm. + * The search is case-insensitive and has a threshold cutout of 0.8 for the fuzzy match. + * + * @param page the one-based page number to retrieve, defaults to 0 if not provided. + * @param size the number of results per page, defaults to 10 if not provided. + * @param name the name of the client to search for (optional). + * @param acronym the acronym of the client to search for (optional). + * @param number the unique number of the client to search for (optional). + * @param serverResponse the {@link ServerHttpResponse} to include response headers. + * @return a reactive stream of {@link ClientPublicViewDto} objects representing matching + * clients. + * + * @apiNote This method provides a paginated, fuzzy search for client details. Results + * include a total record count in the response headers under {@code X-Total-Count}. + */ @GetMapping("/by") @Operation( summary = "Search for clients", diff --git a/src/main/java/ca/bc/gov/api/oracle/legacy/service/ClientSearchService.java b/src/main/java/ca/bc/gov/api/oracle/legacy/service/ClientSearchService.java index 43e2b17..c19f4e8 100644 --- a/src/main/java/ca/bc/gov/api/oracle/legacy/service/ClientSearchService.java +++ b/src/main/java/ca/bc/gov/api/oracle/legacy/service/ClientSearchService.java @@ -109,6 +109,21 @@ public Flux searchClientByQuery( .doOnNext(client -> log.info("Found client with id {}", client.getClientNumber())); } + /** + * Constructs a search {@link Criteria} object based on the provided client name, acronym, or + * number. + * This method normalizes input values for case-insensitive searches and validates the client + * number. + * + * @param name the name of the client to search for, or null if not specified. + * @param acronym the acronym of the client to search for, or null if not specified. + * @param number the unique number of the client to search for, or null if not specified. + * @return a {@link Mono} emitting the constructed {@link Criteria} object for the search. + * + * @implNote Input values are transformed to uppercase for case-insensitivity. The client + * number is validated using {@link #checkClientNumber(String)}. Repository results are + * mapped to a search criteria object. + */ public Mono searchByAcronymNameNumber(String name, String acronym, String number) { log.info("Searching for clients with name {}, acronym {} or number {}", name, acronym, number);