Skip to content

Commit

Permalink
Merge pull request #151 from juanjemdIos/main
Browse files Browse the repository at this point in the history
Endpoints to get test and benchmark. Still in construction
  • Loading branch information
dgarijo authored Jan 22, 2025
2 parents 315c9c0 + 723d3b9 commit 92e5adf
Show file tree
Hide file tree
Showing 2 changed files with 95 additions and 11 deletions.
48 changes: 44 additions & 4 deletions src/main/java/fair/FOOPS.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public FOOPS(String o, boolean isFromFile){
}
else if (isFromFile) {
checks = benchmark.fileChecks(ontology);

}
else if (custom) {
//Example
Expand All @@ -85,10 +84,51 @@ public void fairTest(){

}

public Optional<Check> getCheckByName(String name) {
/**
* In construction
* Method for getting test by name.
* @param name Name test.
* @return ????????
*/
public Optional<Check> getTestByName(String name) {
logger.info("------ Get test -----");
// Gson gson = new GsonBuilder().
// excludeFieldsWithoutExposeAnnotation().
// setPrettyPrinting().
// create();

// checks.forEach(check -> {
// logger.info("Objeto completo del check: " + check);
// String jsonCheck = gson.toJson(check);
// logger.info("JSON completo del check: " + jsonCheck);
// });
return checks.stream()
.peek(check -> logger.info("Verificando check: " + check.getClass().getSimpleName()))
.filter(check -> check.getClass().getSimpleName().equals(name))
.findFirst();
}
/**
* In construction
* Method for getting benchmark by name.
* @param name Name benchmark.
* @return ????????
*/
public Optional<Check> getBenchmarkByName(String name) {
logger.info("------ Get benchmark -----");
// Gson gson = new GsonBuilder().
// excludeFieldsWithoutExposeAnnotation().
// setPrettyPrinting().
// create();

// checks.forEach(check -> {
// logger.info("Objeto completo del check: " + check);
// String jsonCheck = gson.toJson(check);
// logger.info("JSON completo del check: " + jsonCheck);
// });
return checks.stream()
.filter(check -> check.getClass().getSimpleName().equals(name))
.findFirst();
.peek(check -> logger.info("Verificando check: " + check.getClass().getSimpleName()))
.filter(check -> check.getClass().getSimpleName().equals(name))
.findFirst();
}

private float getTotalScore(){
Expand Down
58 changes: 51 additions & 7 deletions src/main/java/server/FOOPSController.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public class FOOPSController {

Logger logger = LoggerFactory.getLogger(FOOPSController.class);

@ApiOperation(value = "Assess GET ontology")
@ApiOperation(value = "Assess GET ontology")
@CrossOrigin(origins = "*")
@GetMapping("/assessOntology")
public String assessGET() {
Expand Down Expand Up @@ -127,18 +127,62 @@ public String assessPOST(
}
}

@ApiOperation(value = "In construction: Get test by name")
@GetMapping(path = "/checkByName", produces = "application/json")
public String getCheckByName(
@ApiOperation(
value = "IN CONSTRUCTION: Test by name",
notes = "return JSON TEST obtained by FOOPS."
)
@PostMapping(path = "/test", consumes = "application/json", produces = "application/json")
public String testByNamePOST(
@ApiParam(value = "Name of test", required = true)
@RequestBody String body) {

return "{ \"test\": \"Not found\" }";
}

@ApiOperation(
value = "IN CONSTRUCTION: Test by name",
notes = "return JSON TEST obtained by FOOPS."
)
@GetMapping(path = "/test", produces = "application/json")
public String testByNameGET(
@ApiParam(value = "Name of test", required = true)
@RequestParam String name) {

FOOPS f = null;
Path ontologyPath = null;
ontologyPath = Path.of("ontology");
f = new FOOPS(String.valueOf(ontologyPath), true);
Optional<Check> check = f.getTestByName(name);
return "{ \"test\": \"" + (check.isPresent() ? check.get().toString() : "Not found") + "\" }";
}

@ApiOperation(
value = "IN CONSTRUCTION: Benchmark by name",
notes = "return JSON BENCHMARK obtained by FOOPS."
)
@PostMapping(path = "/benchmark", consumes = "application/json", produces = "application/json")
public String benchmarkByNamePOST(
@ApiParam(value = "Name of benchmark", required = true)
@RequestBody String body) {

return "{ \"benchmark\": \"Not found\" }";
}

@ApiOperation(
value = "IN CONSTRUCTION: Benchmark by name",
notes = "return JSON BENCHMARK obtained by FOOPS."
)
@GetMapping(path = "/benchmark", produces = "application/json")
public String benchmarkByNamePost(
@ApiParam(value = "Name of benchmark", required = true)
@RequestParam String name) {

FOOPS f = null;
Path ontologyPath = null;
ontologyPath = Path.of("ontology");
f = new FOOPS(String.valueOf(ontologyPath), false); // Ajustar los parámetros según tu necesidad
Optional<Check> check = f.getCheckByName(name);
return "{ \"check\": \"" + (check.isPresent() ? check.get().toString() : "Not found") + "\" }";
f = new FOOPS(String.valueOf(ontologyPath), true);
Optional<Check> check = f.getBenchmarkByName(name);
return "{ \"benchmark\": \"" + (check.isPresent() ? check.get().toString() : "Not found") + "\" }";
}
/**
*
Expand Down

0 comments on commit 92e5adf

Please sign in to comment.