diff --git a/.gitignore b/.gitignore index a6d8afd..12d000b 100644 --- a/.gitignore +++ b/.gitignore @@ -42,4 +42,8 @@ build/ # System files .DS_Store +node_modules/ + +src/frontend/.next/ + /src/frontend/ \ No newline at end of file diff --git a/src/main/java/org/semantics/apigateway/controller/GatewayController.java b/src/main/java/org/semantics/apigateway/controller/GatewayController.java index f88a97f..dc7c18e 100644 --- a/src/main/java/org/semantics/apigateway/controller/GatewayController.java +++ b/src/main/java/org/semantics/apigateway/controller/GatewayController.java @@ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses; import org.apache.http.HttpStatus; import org.apache.jena.rdf.model.ResourceFactory; +import org.apache.lucene.queryparser.classic.ParseException; import org.semantics.apigateway.service.search.SearchService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; @@ -33,38 +34,13 @@ public GatewayController(SearchService searchService) { public void home(HttpServletRequest request, HttpServletResponse response) throws IOException { response.sendRedirect(request.getContextPath() + "/swagger-ui/index.html?configUrl=/api-gateway/openapi/swagger-config"); } - - - @CrossOrigin - @Operation(summary = "Search all of the content in a catalogue.", description = "The returned data should include a description of the type of data that is being returned. For example the returned content could be SKOS Concepts or OWL Classes.", tags = {"Search"}) - @ApiResponses(value = { - @ApiResponse(responseCode = "200", description = ""), - - @ApiResponse(responseCode = "404", description = "")}) - @GetMapping("/search") - public CompletableFuture> performDynFederatedSearch(@RequestParam String query, - @RequestParam(required = false) String database, - @RequestParam(required = false) String format, - @RequestParam(required = false) String targetDbSchema) { - return searchService.performDynFederatedSearch(query, database, format, targetDbSchema) - .>thenApply(ResponseEntity::ok) - .exceptionally(e -> { - if (e.getCause() instanceof IllegalArgumentException) { - return ResponseEntity - .status(HttpStatus.SC_BAD_REQUEST) - .body("Error: " + e.getCause().getMessage()); - } - return ResponseEntity - .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) - .body("Error: An internal server error occurred"); - }); - } + @CrossOrigin @Operation(summary = "", description = "", tags = {"OLS"}) @GetMapping("/ols/api/select") public CompletableFuture> - performDynFederatedSearchInOLSTargetDBSchema(@RequestParam Map allParams) { + performDynFederatedSearchInOLSTargetDBSchema(@RequestParam Map allParams) throws IOException, ParseException { String query; if (allParams.containsKey("q") || allParams.containsKey("query")) { @@ -77,7 +53,7 @@ public CompletableFuture> performDynFederatedSearch(@RequestPa query = "*"; } - return searchService.performDynFederatedSearch(query + "*", allParams.get("database"), allParams.get("format"), "ols") + return searchService.performSearch(query + "*", allParams.get("database"), allParams.get("format"), "ols") .>thenApply(ResponseEntity::ok) .exceptionally(e -> { if (e.getCause() instanceof IllegalArgumentException) { diff --git a/src/main/java/org/semantics/apigateway/controller/SearchController.java b/src/main/java/org/semantics/apigateway/controller/SearchController.java new file mode 100644 index 0000000..faf8111 --- /dev/null +++ b/src/main/java/org/semantics/apigateway/controller/SearchController.java @@ -0,0 +1,52 @@ +package org.semantics.apigateway.controller; + +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import org.apache.http.HttpStatus; +import org.apache.lucene.queryparser.classic.ParseException; +import org.semantics.apigateway.service.search.SearchService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; + +import java.io.IOException; +import java.util.concurrent.CompletableFuture; + + +@RestController +@RequestMapping("/") +public class SearchController { + private final SearchService searchService; + + @Autowired + public SearchController(SearchService searchService) { + this.searchService = searchService; + } + + + @Operation(summary = "Search all of the content in a catalogue.", description = "The returned data should include a description of the type of data that is being returned. For example the returned content could be SKOS Concepts or OWL Classes.", tags={ "Search" }) + @ApiResponses(value = { + @ApiResponse(responseCode = "200", description = ""), + + @ApiResponse(responseCode = "404", description = "") }) + @CrossOrigin + @GetMapping("/search") + public CompletableFuture> performDynFederatedSearch(@RequestParam String query, + @RequestParam(required = false) String database, + @RequestParam(required = false) String format, + @RequestParam(required = false) String targetDbSchema) throws IOException, ParseException { + return searchService.performSearch(query, database, format, targetDbSchema) + .>thenApply(ResponseEntity::ok) + .exceptionally(e -> { + if (e.getCause() instanceof IllegalArgumentException) { + return ResponseEntity + .status(HttpStatus.SC_BAD_REQUEST) + .body("Error: " + e.getCause().getMessage()); + } + return ResponseEntity + .status(HttpStatus.SC_INTERNAL_SERVER_ERROR) + .body("Error: An internal server error occurred"); + }); + } +}