@Test void testFindOntologyTermsNoOntologies() { assertEquals( emptyList(), ontologyTermRepository.findOntologyTerms(emptyList(), of("term1"), 100)); verifyNoInteractions(dataService); }
public List<OntologyTerm> findOntologyTerms( List<String> ontologyIds, Set<String> terms, int pageSize) { if (ontologyIds.isEmpty() || terms.isEmpty()) { return Collections.emptyList(); } List<QueryRule> rules = new ArrayList<>(); for (String term : terms) { if (!rules.isEmpty()) { rules.add(new QueryRule(Operator.OR)); } rules.add( new QueryRule(OntologyTermMetadata.ONTOLOGY_TERM_SYNONYM, Operator.FUZZY_MATCH, term)); } rules = Arrays.asList( new QueryRule(ONTOLOGY, Operator.IN, ontologyIds), new QueryRule(Operator.AND), new QueryRule(rules)); final List<QueryRule> finalRules = rules; Iterable<Entity> termEntities = () -> dataService .findAll(ONTOLOGY_TERM, new QueryImpl<>(finalRules).pageSize(pageSize)) .iterator(); return Lists.newArrayList( Iterables.transform(termEntities, OntologyTermRepository::toOntologyTerm)); }
OntologyTermRepository { public List<OntologyTerm> findOntologyTerms( List<String> ontologyIds, Set<String> terms, int pageSize) { if (ontologyIds.isEmpty() || terms.isEmpty()) { return Collections.emptyList(); } List<QueryRule> rules = new ArrayList<>(); for (String term : terms) { if (!rules.isEmpty()) { rules.add(new QueryRule(Operator.OR)); } rules.add( new QueryRule(OntologyTermMetadata.ONTOLOGY_TERM_SYNONYM, Operator.FUZZY_MATCH, term)); } rules = Arrays.asList( new QueryRule(ONTOLOGY, Operator.IN, ontologyIds), new QueryRule(Operator.AND), new QueryRule(rules)); final List<QueryRule> finalRules = rules; Iterable<Entity> termEntities = () -> dataService .findAll(ONTOLOGY_TERM, new QueryImpl<>(finalRules).pageSize(pageSize)) .iterator(); return Lists.newArrayList( Iterables.transform(termEntities, OntologyTermRepository::toOntologyTerm)); } }
OntologyTermRepository { public List<OntologyTerm> findOntologyTerms( List<String> ontologyIds, Set<String> terms, int pageSize) { if (ontologyIds.isEmpty() || terms.isEmpty()) { return Collections.emptyList(); } List<QueryRule> rules = new ArrayList<>(); for (String term : terms) { if (!rules.isEmpty()) { rules.add(new QueryRule(Operator.OR)); } rules.add( new QueryRule(OntologyTermMetadata.ONTOLOGY_TERM_SYNONYM, Operator.FUZZY_MATCH, term)); } rules = Arrays.asList( new QueryRule(ONTOLOGY, Operator.IN, ontologyIds), new QueryRule(Operator.AND), new QueryRule(rules)); final List<QueryRule> finalRules = rules; Iterable<Entity> termEntities = () -> dataService .findAll(ONTOLOGY_TERM, new QueryImpl<>(finalRules).pageSize(pageSize)) .iterator(); return Lists.newArrayList( Iterables.transform(termEntities, OntologyTermRepository::toOntologyTerm)); } OntologyTermRepository(DataService dataService); }
OntologyTermRepository { public List<OntologyTerm> findOntologyTerms( List<String> ontologyIds, Set<String> terms, int pageSize) { if (ontologyIds.isEmpty() || terms.isEmpty()) { return Collections.emptyList(); } List<QueryRule> rules = new ArrayList<>(); for (String term : terms) { if (!rules.isEmpty()) { rules.add(new QueryRule(Operator.OR)); } rules.add( new QueryRule(OntologyTermMetadata.ONTOLOGY_TERM_SYNONYM, Operator.FUZZY_MATCH, term)); } rules = Arrays.asList( new QueryRule(ONTOLOGY, Operator.IN, ontologyIds), new QueryRule(Operator.AND), new QueryRule(rules)); final List<QueryRule> finalRules = rules; Iterable<Entity> termEntities = () -> dataService .findAll(ONTOLOGY_TERM, new QueryImpl<>(finalRules).pageSize(pageSize)) .iterator(); return Lists.newArrayList( Iterables.transform(termEntities, OntologyTermRepository::toOntologyTerm)); } OntologyTermRepository(DataService dataService); List<OntologyTerm> findExcatOntologyTerms(
      List<String> ontologyIds, Set<String> terms, int pageSize); List<OntologyTerm> findOntologyTerms(
      List<String> ontologyIds, Set<String> terms, int pageSize); List<OntologyTerm> getAllOntologyTerms(String ontologyId); OntologyTerm getOntologyTerm(String[] iris); int getOntologyTermDistance(OntologyTerm ontologyTerm1, OntologyTerm ontologyTerm2); int calculateNodePathDistance(String nodePath1, String nodePath2); List<OntologyTerm> getChildren(OntologyTerm ontologyTerm); List<OntologyTerm> getChildOntologyTermsByNodePath(
      Entity ontologyEntity, Entity nodePathEntity); }
OntologyTermRepository { public List<OntologyTerm> findOntologyTerms( List<String> ontologyIds, Set<String> terms, int pageSize) { if (ontologyIds.isEmpty() || terms.isEmpty()) { return Collections.emptyList(); } List<QueryRule> rules = new ArrayList<>(); for (String term : terms) { if (!rules.isEmpty()) { rules.add(new QueryRule(Operator.OR)); } rules.add( new QueryRule(OntologyTermMetadata.ONTOLOGY_TERM_SYNONYM, Operator.FUZZY_MATCH, term)); } rules = Arrays.asList( new QueryRule(ONTOLOGY, Operator.IN, ontologyIds), new QueryRule(Operator.AND), new QueryRule(rules)); final List<QueryRule> finalRules = rules; Iterable<Entity> termEntities = () -> dataService .findAll(ONTOLOGY_TERM, new QueryImpl<>(finalRules).pageSize(pageSize)) .iterator(); return Lists.newArrayList( Iterables.transform(termEntities, OntologyTermRepository::toOntologyTerm)); } OntologyTermRepository(DataService dataService); List<OntologyTerm> findExcatOntologyTerms(
      List<String> ontologyIds, Set<String> terms, int pageSize); List<OntologyTerm> findOntologyTerms(
      List<String> ontologyIds, Set<String> terms, int pageSize); List<OntologyTerm> getAllOntologyTerms(String ontologyId); OntologyTerm getOntologyTerm(String[] iris); int getOntologyTermDistance(OntologyTerm ontologyTerm1, OntologyTerm ontologyTerm2); int calculateNodePathDistance(String nodePath1, String nodePath2); List<OntologyTerm> getChildren(OntologyTerm ontologyTerm); List<OntologyTerm> getChildOntologyTermsByNodePath(
      Entity ontologyEntity, Entity nodePathEntity);  }