protected OntologyTerm newInternalOntologyTerm(OntologySearcher searcher, String id, String name, Set<OntologyTerm> synonyms) throws SolrServerException { return new LazyLoadedOntologyTerm( searcher, id, name, synonyms ); }
public LazyLoadedOntologyTerm(OntologySearcher searcher, String id, String name) throws SolrServerException { this.searcher = searcher; this.id = id; this.name = findNameAndSynonyms(searcher, id, name); }
@Override public Set<OntologyTerm> getAllParentsToRoot(boolean includeSynonyms) { return getAllParentsToRoot(this, includeSynonyms); }
public List<OntologyTerm> getChildren() { return getChildren(false); }
private void createAndRegisterInteractionTerm(FieldCount fieldCount, String db, LazyLoadedOntologyTerm term) { // register the term InteractionOntologyTerm interactionTerm = new InteractionOntologyTerm(term.getName(), term.getId()); registerOntologyTermResults(fieldCount, db, interactionTerm); // register synonyms if (term.getSynonymsStr() != null){ for (String synonym : term.getSynonymsStr()){ InteractionOntologyTerm termSynonym = new InteractionOntologyTerm(synonym, term.getId()); registerOntologyTermResults(fieldCount, db, termSynonym); } } }
private List<OntologyTerm> processOntologyTermHits( final QueryResponse queryResponse, final String id, final String termIdKey, final String termNameKey, final String termSynonymsKey) throws SolrServerException { final SolrDocumentList results = queryResponse.getResults(); List<OntologyTerm> terms = new ArrayList<OntologyTerm>( results.size() ); List<String> processedIds = new ArrayList<String>( results.size() + 1 ); processedIds.add(id); for ( SolrDocument solrDocument : results ) { String parentId = (String) solrDocument.getFieldValue( termIdKey ); String parentName = (String) solrDocument.getFieldValue( termNameKey ); Collection<Object> fieldValues = solrDocument.getFieldValues(termSynonymsKey); Set<OntologyTerm> synonyms = new HashSet<OntologyTerm>(); if (parentId != null && fieldValues != null) { for (Object fieldValue : fieldValues) { synonyms.add(new LazyLoadedOntologyTerm(searcher, parentId, fieldValue.toString(), Collections.EMPTY_SET)); } } if (parentId != null && !processedIds.contains(parentId)) { terms.add(newInternalOntologyTerm(searcher, parentId, parentName, synonyms)); processedIds.add(parentId); } } return terms; }
public List<OntologyTerm> getParents() { return getParents(false); }
public List<OntologyTerm> getChildren(boolean includeCyclic) { if (children != null) { return children; } this.children = new ArrayList<OntologyTerm>(); try { final QueryResponse queryResponse = searcher.searchByParentId(id, 0, Integer.MAX_VALUE); children.addAll(processChildrenHits(queryResponse, id)); } catch (Exception e) { throw new IllegalStateException("Problem getting children for document: "+id, e); } return children; }
public List<OntologyTerm> getChildren() { return getChildren(false); }
public List<OntologyTerm> getParents() { return getParents(false); }
private OntologyTerm newInternalOntologyTerm(String id, String name, Set<OntologyTerm> synonyms) throws SolrServerException { return new LazyLoadedOntologyTerm( this, id, name, synonyms ); }
@Override public Set<OntologyTerm> getAllParentsToRoot(boolean includeSynonyms) { return getAllParentsToRoot(this, includeSynonyms); }
public Collection<OntologyTerm> getChildrenAtDepth(int depth) { return getChildren(this, 0, depth).get(depth); }
public LazyLoadedOntologyTerm(OntologySearcher searcher, String id, String name) throws SolrServerException { this.searcher = searcher; this.id = id; this.name = findNameAndSynonyms(searcher, id, name); }
public OntologyTerm findOntologyTermByName(String name) throws SolrServerException { if (ontologySearcher == null) { return null; } String cacheKey = "_"+name; if (ontologyTermCache.containsKey(cacheKey)) { return ontologyTermCache.get(cacheKey); } final LazyLoadedOntologyTerm term = new LazyLoadedOntologyTerm(ontologySearcher, null, name); ontologyTermCache.put( cacheKey, term ); return term; }
public Set<OntologyTerm> getAllParentsToRoot() { return getAllParentsToRoot(this, false); }
public Collection<OntologyTerm> getChildrenAtDepth(int depth) { return getChildren(this, 0, depth).get(depth); }
public OntologyTerm findOntologyTerm(String id, String name) throws SolrServerException { if (ontologySearcher == null) { return null; } String cacheKey = id+"_"+name; if (ontologyTermCache.containsKey(cacheKey)) { return ontologyTermCache.get(cacheKey); } final LazyLoadedOntologyTerm term = new LazyLoadedOntologyTerm(ontologySearcher, id, name); ontologyTermCache.put( cacheKey, term ); return term; }
public Set<OntologyTerm> getAllParentsToRoot() { return getAllParentsToRoot(this, false); }
protected Multimap<Integer, OntologyTerm> getChildren(OntologyTerm term, int currentDepth, int maxDepth) { if (currentDepth > maxDepth) { return HashMultimap.create(); } Multimap<Integer,OntologyTerm> terms = HashMultimap.create(); terms.put(currentDepth, term); for (OntologyTerm child : term.getChildren()) { terms.putAll(getChildren(child, currentDepth+1, maxDepth)); } return terms; }