/** * @param field the field for which we want to get the parents * @param includeItself if true, the passed field will be part of the collection (its description updated from the index) * @return list of cv terms with parents and itself */ public Collection<Field> getAllParents(psidev.psi.mi.tab.model.builder.Field field, boolean includeItself, boolean includeSynonyms) throws SolrServerException { if (ontologySearcher == null) { return Collections.EMPTY_LIST; } List<psidev.psi.mi.tab.model.builder.Field> allParents = null; final String type = field.getType(); String identifier = field.getValue(); if (cvCache.containsKey(identifier)) { return cvCache.get(identifier); } // fetch parents and fill the field list final OntologyTerm ontologyTerm = findOntologyTerm(field); final Set<OntologyTerm> parents = ontologyTerm.getAllParentsToRoot(includeSynonyms); allParents = convertTermsToFieldsIncludingSynonyms(type, parents); if (includeItself) { Collection<Field> itselfAndSynonyms = convertTermToFieldIncludingSynonyms(type, ontologyTerm); allParents.addAll(itselfAndSynonyms); } cvCache.put(identifier, allParents); return (allParents != null ? allParents : Collections.EMPTY_LIST); }
/** * @param field the field for which we want to get the parents * @param includeItself if true, the passed field will be part of the collection (its description updated from the index) * @return list of cv terms with parents and itself */ public Collection<Field> getAllParents(Field field, boolean includeItself, boolean includeSynonyms) throws SolrServerException { if (ontologySearcher == null) { return Collections.EMPTY_LIST; } List<Field> allParents = null; final String type = field.get(CalimochoKeys.DB); String identifier = field.get(CalimochoKeys.VALUE); if (getOntologyTermsToIgnore().contains(identifier)){ return Collections.EMPTY_LIST; } if (getCvCache().containsKey(identifier)) { return getCvCache().get(identifier); } // fetch parents and fill the field list final OntologyTerm ontologyTerm = findOntologyTerm(field); final Set<OntologyTerm> parents = ontologyTerm.getAllParentsToRoot(includeSynonyms); allParents = convertTermsToFieldsIncludingSynonyms(type, parents); if (includeItself) { Collection<Field> itselfAndSynonyms = convertTermToFieldIncludingSynonyms(type, ontologyTerm); allParents.addAll(itselfAndSynonyms); } getCvCache().put(identifier, allParents); return (allParents != null ? allParents : Collections.EMPTY_LIST); }
public void enrichOrganism(Interaction interaction, SolrInputDocument solrDocument) throws SolrServerException { // retrieve the ontology term for this interaction (using BioSource) final OntologyTerm ontologyTerm = findOrganism(interaction) ; // add name, all synonyms and tax id to complex_organism if ( ontologyTerm != null ) { // enrich exact organism enrichOrganism(ComplexFieldNames.COMPLEX_ORGANISM_EXACT, null, solrDocument, ontologyTerm); // enrich organism for query enrichOrganism(ComplexFieldNames.COMPLEX_ORGANISM, ComplexFieldNames.COMPLEX_ORGANISM_F, solrDocument, ontologyTerm); // sort field solrDocument.addField(ComplexFieldNames.COMPLEX_ORGANISM_SORT, ontologyTerm.getId()); // stored field to retrieve from the index solrDocument.addField(ComplexFieldNames.ORGANISM_NAME, ontologyTerm.getName()+"; "+ontologyTerm.getId()); // add parents to complex_organism_ontology for ( OntologyTerm parent : ontologyTerm.getAllParentsToRoot ( true ) ) { enrichOrganism(ComplexFieldNames.COMPLEX_ORGANISM, null, solrDocument, parent); } } }
for ( OntologyTerm parent : ontologyTerm_aux.getAllParentsToRoot ( true ) ) { solrDocument.addField ( xrefFieldName, parent.getId() ) ; solrDocument.addField ( xrefFieldName, parent.getName ( ) ) ;