public Set < String > getIdsForTermWithAncestors ( String s ) { if ( ! indexByName . containsKey ( s ) ) return new HashSet < String > ( ) ; Stack < String > idsToConsider = new Stack < String > ( ) ; idsToConsider . addAll ( getIdsForTerm ( s ) ) ; Set < String > resultIds = new HashSet < String > ( ) ; while ( ! idsToConsider . isEmpty ( ) ) { String id = idsToConsider . pop ( ) ; if ( ! resultIds . contains ( id ) ) { resultIds . add ( id ) ; idsToConsider . addAll ( terms . get ( id ) . getIsA ( ) ) ; } } return resultIds ; }
Look up a term by name and return its ID and the IDs of all of its ancestors .