Skip to content

Commit faa4af7

Browse files
committed
Reuse the OntClass of an OntologyTermImpl when gathering its parents or children
1 parent 93124da commit faa4af7

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

src/ubic/basecode/ontology/jena/AbstractOntologyService.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -737,9 +737,13 @@ public String toString() {
737737

738738
private Set<OntClass> getOntClassesFromTerms( Collection<OntologyTerm> terms ) {
739739
return terms.stream()
740-
.map( OntologyTerm::getUri )
741-
.filter( Objects::nonNull )
742-
.map( model::getOntClass )
740+
.map( o -> {
741+
if ( o instanceof OntologyTermImpl ) {
742+
return ( ( OntologyTermImpl ) o ).getOntClass();
743+
} else {
744+
return o.getUri() != null ? model.getOntClass( o.getUri() ) : null;
745+
}
746+
} )
743747
.filter( Objects::nonNull )
744748
.collect( Collectors.toSet() );
745749
}

src/ubic/basecode/ontology/jena/OntologyTermImpl.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@
2626
import ubic.basecode.ontology.model.OntologyTerm;
2727

2828
import javax.annotation.Nullable;
29-
import java.util.*;
29+
import java.util.Collection;
30+
import java.util.Collections;
31+
import java.util.HashSet;
32+
import java.util.Set;
3033
import java.util.stream.Collectors;
3134

3235
import static ubic.basecode.ontology.jena.JenaUtils.where;
@@ -232,4 +235,8 @@ public boolean isRoot() {
232235
public boolean isTermObsolete() {
233236
return isObsolete();
234237
}
238+
239+
public OntClass getOntClass() {
240+
return ontResource;
241+
}
235242
}

0 commit comments

Comments
 (0)