Skip to content

Commit

Permalink
Merge pull request #19 from TheJacksonLaboratory/enhancement/graph-tr…
Browse files Browse the repository at this point in the history
…aversal

error catching no terms with jakarta validation
  • Loading branch information
iimpulse authored Sep 14, 2023
2 parents 5a871fb + 6646bc4 commit 4a4f1cd
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions src/main/java/org/jacksonlaboratory/service/GraphService.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,32 @@ public GraphService(TermRepository termRepository, TranslationRepository transla

public List<SimpleOntologyTerm> getParents(TermId termId) {
List<TermId> termIdList = this.ontology.graph().getParentsStream(termId, false).collect(Collectors.toList());
List<OntologyTerm> termList = this.termRepository.findByTermIdIn(termIdList).orElse(Collections.emptyList());
if (international){
for (OntologyTerm term: termList) {
term.setTranslation(this.translationRepository.findAllByTerm(term));
if (termIdList.size() == 0){
return Collections.emptyList();
} else {
List<OntologyTerm> termList = this.termRepository.findByTermIdIn(termIdList).orElse(Collections.emptyList());
if (international){
for (OntologyTerm term: termList) {
term.setTranslation(this.translationRepository.findAllByTerm(term));
}
}
return termList.stream().map(SimpleOntologyTerm::new).collect(Collectors.toList());
}
return termList.stream().map(SimpleOntologyTerm::new).collect(Collectors.toList());
}

public List<SimpleOntologyTerm> getChildren(TermId termId) {
List<TermId> termIdList = this.ontology.graph().getChildrenStream(termId, false).collect(Collectors.toList());
List<OntologyTerm> termList = this.termRepository.findByTermIdIn(termIdList).orElse(Collections.emptyList());
if (international){
for (OntologyTerm term: termList) {
term.setTranslation(this.translationRepository.findAllByTerm(term));
if (termIdList.size() == 0){
return Collections.emptyList();
} else {
List<OntologyTerm> termList = this.termRepository.findByTermIdIn(termIdList).orElse(Collections.emptyList());
if (international){
for (OntologyTerm term: termList) {
term.setTranslation(this.translationRepository.findAllByTerm(term));
}
}
return termList.stream().map(SimpleOntologyTerm::new).collect(Collectors.toList());
}
return termList.stream().map(SimpleOntologyTerm::new).collect(Collectors.toList());
}

public MinimalOntology getOntology() {
Expand Down

0 comments on commit 4a4f1cd

Please sign in to comment.