From 315bcd2825123cfe769d6940fd1f0b47b20d38ca Mon Sep 17 00:00:00 2001 From: GeorgeC Date: Thu, 14 Nov 2024 10:02:51 -0500 Subject: [PATCH] Remove logger and refactor LegacySearchController Removed the logging functionality and refactored LegacySearchController to use an injected LegacySearchQueryMapper. --- .../legacysearch/LegacySearchController.java | 10 ++++------ .../legacysearch/LegacySearchQueryMapper.java | 4 +++- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main/java/edu/harvard/dbmi/avillach/dictionary/legacysearch/LegacySearchController.java b/src/main/java/edu/harvard/dbmi/avillach/dictionary/legacysearch/LegacySearchController.java index c26bf84..c412200 100644 --- a/src/main/java/edu/harvard/dbmi/avillach/dictionary/legacysearch/LegacySearchController.java +++ b/src/main/java/edu/harvard/dbmi/avillach/dictionary/legacysearch/LegacySearchController.java @@ -2,8 +2,6 @@ import edu.harvard.dbmi.avillach.dictionary.legacysearch.model.LegacyResponse; import edu.harvard.dbmi.avillach.dictionary.legacysearch.model.LegacySearchQuery; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -15,18 +13,18 @@ @Controller public class LegacySearchController { - private static final Logger log = LoggerFactory.getLogger(LegacySearchController.class); private final LegacySearchService legacySearchService; + private final LegacySearchQueryMapper legacySearchQueryMapper; @Autowired - public LegacySearchController(LegacySearchService legacySearchService) { + public LegacySearchController(LegacySearchService legacySearchService, LegacySearchQueryMapper legacySearchQueryMapper) { this.legacySearchService = legacySearchService; + this.legacySearchQueryMapper = legacySearchQueryMapper; } @RequestMapping(path = "/search") public ResponseEntity legacySearch(@RequestBody String jsonString) throws IOException { - log.info("legacySearch(): {}", jsonString); - LegacySearchQuery legacySearchQuery = LegacySearchQueryMapper.mapFromJson(jsonString); + LegacySearchQuery legacySearchQuery = legacySearchQueryMapper.mapFromJson(jsonString); return ResponseEntity .ok(new LegacyResponse(legacySearchService.getSearchResults(legacySearchQuery.filter(), legacySearchQuery.pageable()))); } diff --git a/src/main/java/edu/harvard/dbmi/avillach/dictionary/legacysearch/LegacySearchQueryMapper.java b/src/main/java/edu/harvard/dbmi/avillach/dictionary/legacysearch/LegacySearchQueryMapper.java index f5e62f9..aed5eb6 100644 --- a/src/main/java/edu/harvard/dbmi/avillach/dictionary/legacysearch/LegacySearchQueryMapper.java +++ b/src/main/java/edu/harvard/dbmi/avillach/dictionary/legacysearch/LegacySearchQueryMapper.java @@ -6,15 +6,17 @@ import edu.harvard.dbmi.avillach.dictionary.filter.Filter; import edu.harvard.dbmi.avillach.dictionary.legacysearch.model.LegacySearchQuery; import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Component; import java.io.IOException; import java.util.List; +@Component public class LegacySearchQueryMapper { private static final ObjectMapper objectMapper = new ObjectMapper(); - public static LegacySearchQuery mapFromJson(String jsonString) throws IOException { + public LegacySearchQuery mapFromJson(String jsonString) throws IOException { JsonNode rootNode = objectMapper.readTree(jsonString); JsonNode queryNode = rootNode.get("query");