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 new file mode 100644 index 0000000..72a9333 --- /dev/null +++ b/src/main/java/edu/harvard/dbmi/avillach/dictionary/legacysearch/LegacySearchController.java @@ -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 legacySearch(@RequestBody String jsonString) throws IOException { + LegacySearchQuery legacySearchQuery = LegacySearchQueryMapper.mapFromJson(jsonString); + return ResponseEntity.ok(legacySearchService.getSearchResults(legacySearchQuery.filter(), legacySearchQuery.pageable())); + } + +} diff --git a/src/main/java/edu/harvard/dbmi/avillach/dictionary/legacysearch/LegacySearchService.java b/src/main/java/edu/harvard/dbmi/avillach/dictionary/legacysearch/LegacySearchService.java new file mode 100644 index 0000000..03d4d01 --- /dev/null +++ b/src/main/java/edu/harvard/dbmi/avillach/dictionary/legacysearch/LegacySearchService.java @@ -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)); + } + +}