PAN-52 Fixed issue with the Theorems API

This commit is contained in:
2019-03-21 11:20:52 -06:00
parent d0cde837e9
commit c9a2a978fc
6 changed files with 29 additions and 7 deletions
@@ -75,13 +75,18 @@ public class ProofController {
@GetMapping("/branch")
public @ResponseBody
ResponseEntity<List<Proof>> getAllProofsByBranch(@RequestParam("branch") final String branch) {
ResponseEntity<List<Proof>> getAllProofsByBranch(@RequestParam("branch") String branch) {
LOG.info("Received request to query for proofs related to the {} branch of mathematics", branch);
if (branch == null) {
LOG.error("ERROR: branch was null");
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
if (branch.contains("_") || branch.contains("-")) {
branch = branch.replace("_"," ");
branch = branch.replace("-", " ");
}
LOG.debug("Querying for proofs with branch {}", branch);
final StopWatch stopWatch = new StopWatch();
@@ -105,13 +110,18 @@ public class ProofController {
@GetMapping("/theorem_name")
public @ResponseBody
ResponseEntity<List<Proof>> getAllProofsByTheoremName(@RequestParam("theorem_name") final String theoremName) {
ResponseEntity<List<Proof>> getAllProofsByTheoremName(@RequestParam("theorem_name") String theoremName) {
LOG.info("Received request to query for proofs of the theorem {}", theoremName);
if (theoremName == null) {
LOG.error("ERROR: theorem name was null");
return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
}
if (theoremName.contains("_") || theoremName.contains("-")) {
theoremName = theoremName.replace("_"," ");
theoremName = theoremName.replace("-", " ");
}
LOG.debug("Querying for proofs of the theorem {}", theoremName);
final StopWatch stopWatch = new StopWatch();
@@ -8,6 +8,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.util.Date;
@@ -22,6 +23,9 @@ public class Proof extends BaseDto implements Serializable {
@Size(min = 1, max = 512, message = "The name must be at least 1 character and at most 512 characters")
@Column(name = "theorem_name")
private String theoremName;
@NotNull(groups = Insert.class)
@Size(min = 1, max = 4096, message = "The proof must be at least 1 character and at most 4096 characters")
private String proof;
@NotBlank(groups = Insert.class)
@Size(min = 1, max = 512, message = "The branch must be at least 1 character and at most 512 characters")
private String branch;