Skip to content

Commit 92e5adf

Browse files
authored
Merge pull request #151 from juanjemdIos/main
Endpoints to get test and benchmark. Still in construction
2 parents 315c9c0 + 723d3b9 commit 92e5adf

2 files changed

Lines changed: 95 additions & 11 deletions

File tree

src/main/java/fair/FOOPS.java

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ public FOOPS(String o, boolean isFromFile){
6363
}
6464
else if (isFromFile) {
6565
checks = benchmark.fileChecks(ontology);
66-
6766
}
6867
else if (custom) {
6968
//Example
@@ -85,10 +84,51 @@ public void fairTest(){
8584

8685
}
8786

88-
public Optional<Check> getCheckByName(String name) {
87+
/**
88+
* In construction
89+
* Method for getting test by name.
90+
* @param name Name test.
91+
* @return ????????
92+
*/
93+
public Optional<Check> getTestByName(String name) {
94+
logger.info("------ Get test -----");
95+
// Gson gson = new GsonBuilder().
96+
// excludeFieldsWithoutExposeAnnotation().
97+
// setPrettyPrinting().
98+
// create();
99+
100+
// checks.forEach(check -> {
101+
// logger.info("Objeto completo del check: " + check);
102+
// String jsonCheck = gson.toJson(check);
103+
// logger.info("JSON completo del check: " + jsonCheck);
104+
// });
105+
return checks.stream()
106+
.peek(check -> logger.info("Verificando check: " + check.getClass().getSimpleName()))
107+
.filter(check -> check.getClass().getSimpleName().equals(name))
108+
.findFirst();
109+
}
110+
/**
111+
* In construction
112+
* Method for getting benchmark by name.
113+
* @param name Name benchmark.
114+
* @return ????????
115+
*/
116+
public Optional<Check> getBenchmarkByName(String name) {
117+
logger.info("------ Get benchmark -----");
118+
// Gson gson = new GsonBuilder().
119+
// excludeFieldsWithoutExposeAnnotation().
120+
// setPrettyPrinting().
121+
// create();
122+
123+
// checks.forEach(check -> {
124+
// logger.info("Objeto completo del check: " + check);
125+
// String jsonCheck = gson.toJson(check);
126+
// logger.info("JSON completo del check: " + jsonCheck);
127+
// });
89128
return checks.stream()
90-
.filter(check -> check.getClass().getSimpleName().equals(name))
91-
.findFirst();
129+
.peek(check -> logger.info("Verificando check: " + check.getClass().getSimpleName()))
130+
.filter(check -> check.getClass().getSimpleName().equals(name))
131+
.findFirst();
92132
}
93133

94134
private float getTotalScore(){

src/main/java/server/FOOPSController.java

Lines changed: 51 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public class FOOPSController {
4141

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

44-
@ApiOperation(value = "Assess GET ontology")
44+
@ApiOperation(value = "Assess GET ontology")
4545
@CrossOrigin(origins = "*")
4646
@GetMapping("/assessOntology")
4747
public String assessGET() {
@@ -127,18 +127,62 @@ public String assessPOST(
127127
}
128128
}
129129

130-
@ApiOperation(value = "In construction: Get test by name")
131-
@GetMapping(path = "/checkByName", produces = "application/json")
132-
public String getCheckByName(
130+
@ApiOperation(
131+
value = "IN CONSTRUCTION: Test by name",
132+
notes = "return JSON TEST obtained by FOOPS."
133+
)
134+
@PostMapping(path = "/test", consumes = "application/json", produces = "application/json")
135+
public String testByNamePOST(
133136
@ApiParam(value = "Name of test", required = true)
137+
@RequestBody String body) {
138+
139+
return "{ \"test\": \"Not found\" }";
140+
}
141+
142+
@ApiOperation(
143+
value = "IN CONSTRUCTION: Test by name",
144+
notes = "return JSON TEST obtained by FOOPS."
145+
)
146+
@GetMapping(path = "/test", produces = "application/json")
147+
public String testByNameGET(
148+
@ApiParam(value = "Name of test", required = true)
149+
@RequestParam String name) {
150+
151+
FOOPS f = null;
152+
Path ontologyPath = null;
153+
ontologyPath = Path.of("ontology");
154+
f = new FOOPS(String.valueOf(ontologyPath), true);
155+
Optional<Check> check = f.getTestByName(name);
156+
return "{ \"test\": \"" + (check.isPresent() ? check.get().toString() : "Not found") + "\" }";
157+
}
158+
159+
@ApiOperation(
160+
value = "IN CONSTRUCTION: Benchmark by name",
161+
notes = "return JSON BENCHMARK obtained by FOOPS."
162+
)
163+
@PostMapping(path = "/benchmark", consumes = "application/json", produces = "application/json")
164+
public String benchmarkByNamePOST(
165+
@ApiParam(value = "Name of benchmark", required = true)
166+
@RequestBody String body) {
167+
168+
return "{ \"benchmark\": \"Not found\" }";
169+
}
170+
171+
@ApiOperation(
172+
value = "IN CONSTRUCTION: Benchmark by name",
173+
notes = "return JSON BENCHMARK obtained by FOOPS."
174+
)
175+
@GetMapping(path = "/benchmark", produces = "application/json")
176+
public String benchmarkByNamePost(
177+
@ApiParam(value = "Name of benchmark", required = true)
134178
@RequestParam String name) {
135179

136180
FOOPS f = null;
137181
Path ontologyPath = null;
138182
ontologyPath = Path.of("ontology");
139-
f = new FOOPS(String.valueOf(ontologyPath), false); // Ajustar los parámetros según tu necesidad
140-
Optional<Check> check = f.getCheckByName(name);
141-
return "{ \"check\": \"" + (check.isPresent() ? check.get().toString() : "Not found") + "\" }";
183+
f = new FOOPS(String.valueOf(ontologyPath), true);
184+
Optional<Check> check = f.getBenchmarkByName(name);
185+
return "{ \"benchmark\": \"" + (check.isPresent() ? check.get().toString() : "Not found") + "\" }";
142186
}
143187
/**
144188
*

0 commit comments

Comments
 (0)