From 4622c49ceec8e7252c67425e8cbabc3a34909aef Mon Sep 17 00:00:00 2001 From: atusa17 Date: Thu, 21 Mar 2019 10:59:14 -0600 Subject: [PATCH] PAN-52 Fixed issue with the Theorems API --- .../tsp/persistence/controller/TheoremController.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/persistence/src/main/java/edu/msudenver/tsp/persistence/controller/TheoremController.java b/persistence/src/main/java/edu/msudenver/tsp/persistence/controller/TheoremController.java index 71d5e62..d6bae87 100644 --- a/persistence/src/main/java/edu/msudenver/tsp/persistence/controller/TheoremController.java +++ b/persistence/src/main/java/edu/msudenver/tsp/persistence/controller/TheoremController.java @@ -45,13 +45,20 @@ public class TheoremController { @GetMapping("/branch") public @ResponseBody - ResponseEntity> getAllTheoremsByBranch(@RequestParam("branch") final String branch) { + ResponseEntity> getAllTheoremsByBranch(@RequestParam("branch") String branch) { LOG.info("Received request to query for theorems related to the {} branch of mathematics", branch); if (branch == null) { LOG.error("ERROR: branch was null"); return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } + branch = branch.toLowerCase(); + + if (branch.contains("_") || branch.contains("-")) { + branch = branch.replace("_", "\\s"); + branch = branch.replace("-", "\\s"); + } + LOG.debug("Querying for theorems with branch {}", branch); final StopWatch stopWatch = new StopWatch(); @@ -188,8 +195,6 @@ public class TheoremController { return new ResponseEntity<>(HttpStatus.BAD_REQUEST); } - theorem.setName(theorem.getName().toLowerCase()); - LOG.debug("Saving new theorem"); final StopWatch stopWatch = new StopWatch();