Skip to content

Commit

Permalink
Merge pull request #70 from TheJacksonLaboratory/feature/ancestors
Browse files Browse the repository at this point in the history
Feature/ancestors
  • Loading branch information
iimpulse authored Aug 28, 2024
2 parents 05f324f + 3d31ef6 commit 14d0100
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ plugins {
id("com.dorongold.task-tree") version "3.0.0"
}

version = "0.5.15"
version = "0.5.16"
group = "org.jacksonlaboratory"

repositories {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/jacksonlaboratory/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
info = @Info(
title = "ontology-service-${ontology}",
description = "A restful service for the ${ontology} ontology.",
version = "0.5.15",
version = "0.5.16",
contact = @Contact(name = "Michael Gargano", email = "[email protected]")
)
)
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/org/jacksonlaboratory/controller/TermController.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,15 @@ public List<SimpleOntologyTerm> descendants(@Schema(minLength = 1, maxLength = 2
return this.graphService.getDescendants(termId);
}

/**
* Get the ancestors of the ontology id
* @param id The ontology term id
* @return The ancestors of the term id
*/
@Get(uri="/{id}/ancestors", produces="application/json")
public List<SimpleOntologyTerm> ancestors(@Schema(minLength = 1, maxLength = 20, type = "string", pattern = ".*") @PathVariable String id){
TermId termId = TermId.of(id);
return this.graphService.getAncestors(termId);
}

}
5 changes: 5 additions & 0 deletions src/main/java/org/jacksonlaboratory/service/GraphService.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ public List<SimpleOntologyTerm> getDescendants(TermId termId){
return unpack(termIdList);
}

public List<SimpleOntologyTerm> getAncestors(TermId termId){
Collection<TermId> termIdList = this.ontology.graph().extendWithAncestors(termId, false);
return unpack(termIdList);
}

List<SimpleOntologyTerm> unpack(Collection<TermId> termIdList){
if (termIdList.isEmpty()){
return Collections.emptyList();
Expand Down

0 comments on commit 14d0100

Please sign in to comment.