Skip to content

Commit

Permalink
Remove logger and refactor LegacySearchController
Browse files Browse the repository at this point in the history
Removed the logging functionality and refactored LegacySearchController to use an injected LegacySearchQueryMapper.
  • Loading branch information
Gcolon021 committed Nov 14, 2024
1 parent 5ec9256 commit 315bcd2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<LegacyResponse> 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())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit 315bcd2

Please sign in to comment.