Skip to content

Commit 86e8518

Browse files
authored
Only query for ontology classes (#1315)
Without a type definition all types of `class,property,individual,ontology` are returned. As `property` does not provide a parseable curie/obo_id, our integration fails for every query where a property or ontology is returned. By specifying the type to be a `class`, we get only expected results. Documentation on the API: https://api.terminology.tib.eu/swagger-ui/index.html?urls.primaryName=version1 Co-authored-by: KochTobi <kochtobi@users.noreply.github.com>
1 parent 8a6f5cf commit 86e8518

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

project-management-infrastructure/src/main/java/life/qbic/projectmanagement/infrastructure/ontology/TIBTerminologyServiceIntegration.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@
1717
import java.net.http.HttpResponse.BodyHandlers;
1818
import java.nio.charset.StandardCharsets;
1919
import java.time.Duration;
20-
import java.time.Instant;
2120
import java.util.ArrayList;
22-
import java.util.Comparator;
2321
import java.util.List;
2422
import java.util.Objects;
2523
import java.util.Optional;
26-
import java.util.stream.Collectors;
2724
import life.qbic.logging.api.Logger;
2825
import life.qbic.projectmanagement.application.ontology.LookupException;
2926
import life.qbic.projectmanagement.application.ontology.OntologyClass;
@@ -243,7 +240,8 @@ private List<TibTerm> fullSearch(String searchTerm, int offset, int limit)
243240
searchTerm,
244241
StandardCharsets.UTF_8)
245242
+ "&rows=" + limit + "&start=" + offset
246-
+ "&ontology=" + createOntologyFilterQueryParameter()))
243+
+ "&ontology=" + createOntologyFilterQueryParameter()
244+
+ "&type=class"))
247245
.header("Content-Type", "application/json").GET().build();
248246
var response = HTTP_CLIENT.send(termSelectQuery, BodyHandlers.ofString());
249247
return parseResponse(response).stream().toList();
@@ -273,7 +271,8 @@ private List<TibTerm> select(String searchTerm, int offset, int limit)
273271
selectEndpointAbsoluteUrl.toString() +
274272
"?q=" + URLEncoder.encode(searchTerm, StandardCharsets.UTF_8) + "&rows="
275273
+ limit + "&start=" + offset + "&ontology="
276-
+ createOntologyFilterQueryParameter()))
274+
+ createOntologyFilterQueryParameter()
275+
+ "&type=class"))
277276
.header("Content-Type", "application/json").GET().build();
278277
var response = HTTP_CLIENT.send(termSelectQuery, BodyHandlers.ofString());
279278
return parseResponse(response).stream().toList();
@@ -304,7 +303,8 @@ private List<TibTerm> searchByOboId(String oboId, int offset, int limit)
304303
oboId.replace("_", ":"), StandardCharsets.UTF_8)
305304
+ "&queryFields=obo_id"
306305
+ "&rows=" + limit + "&start=" + offset
307-
+ "&ontology=" + createOntologyFilterQueryParameter()))
306+
+ "&ontology=" + createOntologyFilterQueryParameter()
307+
+ "&type=class"))
308308
.header("Content-Type", "application/json").GET().build();
309309
var response = HTTP_CLIENT.send(termSelectQuery, BodyHandlers.ofString());
310310
return parseResponse(response);
@@ -333,7 +333,8 @@ private Optional<TibTerm> searchByOboIdExact(String oboId)
333333
oboId.replace("_", ":"), StandardCharsets.UTF_8)
334334
+ "&queryFields=obo_id"
335335
+ "&exact=true"
336-
+ "&ontology=" + createOntologyFilterQueryParameter()))
336+
+ "&ontology=" + createOntologyFilterQueryParameter()
337+
+ "&type=class"))
337338
.header("Content-Type", "application/json").GET().build();
338339
var response = HTTP_CLIENT.send(termSelectQuery, BodyHandlers.ofString());
339340
log.debug("Received response code '%d' for term query %s".formatted(response.statusCode(), oboId));

0 commit comments

Comments
 (0)