Skip to content

Commit

Permalink
- Add logic for preferredRoots API endpoint (#714)
Browse files Browse the repository at this point in the history
  • Loading branch information
haideriqbal authored Aug 7, 2024
1 parent 6e6a366 commit b66a71d
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,17 @@ public Page<V1Term> getRoots(String ontologyId, boolean obsolete, String lang, P
// @Query (countQuery = "MATCH (n:PreferredRootTerm) WHERE n.ontology_name = {0} AND n.is_obsolete = {1} RETURN count(n)",
// value = "MATCH (n:PreferredRootTerm) WHERE n.ontology_name = {0} AND n.is_obsolete = {1} RETURN n")
public Page<V1Term> getPreferredRootTerms(String ontologyId, boolean obsolete, String lang, Pageable pageable) {
throw new RuntimeException();

OlsSolrQuery query = new OlsSolrQuery();
query.addFilter("type", List.of("class"), SearchType.WHOLE_FIELD);
query.addFilter("ontologyId", List.of(ontologyId), SearchType.WHOLE_FIELD);
query.addFilter("isPreferredRoot", List.of("true"), SearchType.WHOLE_FIELD);

if (!obsolete)
query.addFilter(IS_OBSOLETE.getText(), List.of(Boolean.toString(obsolete)), SearchType.WHOLE_FIELD);

return solrClient.searchSolrPaginated(query, pageable)
.map(result -> V1TermMapper.mapTerm(result, lang));
}

// @Query (value = "MATCH (n:PreferredRootTerm) WHERE n.ontology_name = {0} AND n.is_obsolete = {1} RETURN count(n)")
Expand Down

0 comments on commit b66a71d

Please sign in to comment.