Skip to content

Commit

Permalink
Add LegacySearch functionality
Browse files Browse the repository at this point in the history
Introduced `LegacySearchController` and `LegacySearchService` to handle legacy search requests.
  • Loading branch information
Gcolon021 committed Nov 12, 2024
1 parent dac181d commit af5e9ba
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package edu.harvard.dbmi.avillach.dictionary.legacysearch;

import edu.harvard.dbmi.avillach.dictionary.legacysearch.model.LegacySearchQuery;
import edu.harvard.dbmi.avillach.dictionary.legacysearch.model.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.IOException;

@Controller
public class LegacySearchController {

private final LegacySearchService legacySearchService;

@Autowired
public LegacySearchController(LegacySearchService legacySearchService) {
this.legacySearchService = legacySearchService;
}

@RequestMapping(path = "/search")
public ResponseEntity<Results> legacySearch(@RequestBody String jsonString) throws IOException {
LegacySearchQuery legacySearchQuery = LegacySearchQueryMapper.mapFromJson(jsonString);
return ResponseEntity.ok(legacySearchService.getSearchResults(legacySearchQuery.filter(), legacySearchQuery.pageable()));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package edu.harvard.dbmi.avillach.dictionary.legacysearch;

import edu.harvard.dbmi.avillach.dictionary.concept.ConceptService;
import edu.harvard.dbmi.avillach.dictionary.filter.Filter;
import edu.harvard.dbmi.avillach.dictionary.legacysearch.model.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

@Service
public class LegacySearchService {

private final ConceptService conceptService;

@Autowired
public LegacySearchService(ConceptService conceptService) {
this.conceptService = conceptService;
}

public Results getSearchResults(Filter filter, Pageable pageable) {
return new Results(conceptService.getLegacySearchResults(filter, pageable));
}

}

0 comments on commit af5e9ba

Please sign in to comment.