@Test void testGetChildOntologyTermsByNodePath() { Entity ontologyEntity = new DynamicEntity(ontologyMetadata); ontologyEntity.set(OntologyMetadata.ONTOLOGY_IRI, "http: ontologyEntity.set(OntologyMetadata.ONTOLOGY_NAME, "molgenis"); Entity nodePathEntity_1 = new DynamicEntity(ontologyTermNodePathMetadata); nodePathEntity_1.set(OntologyTermNodePathMetadata.NODE_PATH, "0[0].1[1]"); Entity nodePathEntity_2 = new DynamicEntity(ontologyTermNodePathMetadata); nodePathEntity_2.set(OntologyTermNodePathMetadata.NODE_PATH, "0[0].1[1].0[2]"); Entity nodePathEntity_3 = new DynamicEntity(ontologyTermNodePathMetadata); nodePathEntity_3.set(OntologyTermNodePathMetadata.NODE_PATH, "0[0].1[1].1[2]"); Entity ontologyTerm_2 = new DynamicEntity(ontologyTermMetadata); ontologyTerm_2.set(ONTOLOGY, ontologyEntity); ontologyTerm_2.set(ONTOLOGY_TERM_IRI, "iri 2"); ontologyTerm_2.set(ONTOLOGY_TERM_NAME, "name 2"); ontologyTerm_2.set( OntologyTermMetadata.ONTOLOGY_TERM_NODE_PATH, asList(nodePathEntity_1, nodePathEntity_2)); ontologyTerm_2.set(ONTOLOGY_TERM_SYNONYM, emptyList()); Entity ontologyTerm_3 = new DynamicEntity(ontologyTermMetadata); ontologyTerm_3.set(ONTOLOGY, ontologyEntity); ontologyTerm_3.set(ONTOLOGY_TERM_IRI, "iri 3"); ontologyTerm_3.set(ONTOLOGY_TERM_NAME, "name 3"); ontologyTerm_3.set( OntologyTermMetadata.ONTOLOGY_TERM_NODE_PATH, singletonList(nodePathEntity_3)); ontologyTerm_3.set(ONTOLOGY_TERM_SYNONYM, emptyList()); when(dataService.findAll( ONTOLOGY_TERM, new QueryImpl<>( new QueryRule( OntologyTermMetadata.ONTOLOGY_TERM_NODE_PATH, QueryRule.Operator.FUZZY_MATCH, "\"0[0].1[1]\"")) .and() .eq(ONTOLOGY, ontologyEntity))) .thenReturn(Stream.of(ontologyTerm_2, ontologyTerm_3)); List<OntologyTerm> childOntologyTermsByNodePath = ontologyTermRepository.getChildOntologyTermsByNodePath(ontologyEntity, nodePathEntity_1); assertEquals(2, childOntologyTermsByNodePath.size()); assertEquals( create("iri 2", "name 2", null, singletonList("name 2")), childOntologyTermsByNodePath.get(0)); assertEquals( create("iri 3", "name 3", null, singletonList("name 3")), childOntologyTermsByNodePath.get(1)); }
public List<OntologyTerm> getChildOntologyTermsByNodePath( Entity ontologyEntity, Entity nodePathEntity) { String nodePath = nodePathEntity.getString(OntologyTermNodePathMetadata.NODE_PATH); Iterable<Entity> relatedOntologyTermEntities = () -> dataService .findAll( OntologyTermMetadata.ONTOLOGY_TERM, new QueryImpl<>( new QueryRule( OntologyTermMetadata.ONTOLOGY_TERM_NODE_PATH, Operator.FUZZY_MATCH, "\"" + nodePath + "\"")) .and() .eq(OntologyTermMetadata.ONTOLOGY, ontologyEntity)) .iterator(); Iterable<Entity> childOntologyTermEntities = FluentIterable.from(relatedOntologyTermEntities) .filter(entity -> qualifiedNodePath(nodePath, entity)) .toList(); return Lists.newArrayList( Iterables.transform(childOntologyTermEntities, OntologyTermRepository::toOntologyTerm)); }
OntologyTermRepository { public List<OntologyTerm> getChildOntologyTermsByNodePath( Entity ontologyEntity, Entity nodePathEntity) { String nodePath = nodePathEntity.getString(OntologyTermNodePathMetadata.NODE_PATH); Iterable<Entity> relatedOntologyTermEntities = () -> dataService .findAll( OntologyTermMetadata.ONTOLOGY_TERM, new QueryImpl<>( new QueryRule( OntologyTermMetadata.ONTOLOGY_TERM_NODE_PATH, Operator.FUZZY_MATCH, "\"" + nodePath + "\"")) .and() .eq(OntologyTermMetadata.ONTOLOGY, ontologyEntity)) .iterator(); Iterable<Entity> childOntologyTermEntities = FluentIterable.from(relatedOntologyTermEntities) .filter(entity -> qualifiedNodePath(nodePath, entity)) .toList(); return Lists.newArrayList( Iterables.transform(childOntologyTermEntities, OntologyTermRepository::toOntologyTerm)); } }
OntologyTermRepository { public List<OntologyTerm> getChildOntologyTermsByNodePath( Entity ontologyEntity, Entity nodePathEntity) { String nodePath = nodePathEntity.getString(OntologyTermNodePathMetadata.NODE_PATH); Iterable<Entity> relatedOntologyTermEntities = () -> dataService .findAll( OntologyTermMetadata.ONTOLOGY_TERM, new QueryImpl<>( new QueryRule( OntologyTermMetadata.ONTOLOGY_TERM_NODE_PATH, Operator.FUZZY_MATCH, "\"" + nodePath + "\"")) .and() .eq(OntologyTermMetadata.ONTOLOGY, ontologyEntity)) .iterator(); Iterable<Entity> childOntologyTermEntities = FluentIterable.from(relatedOntologyTermEntities) .filter(entity -> qualifiedNodePath(nodePath, entity)) .toList(); return Lists.newArrayList( Iterables.transform(childOntologyTermEntities, OntologyTermRepository::toOntologyTerm)); } OntologyTermRepository(DataService dataService); }
OntologyTermRepository { public List<OntologyTerm> getChildOntologyTermsByNodePath( Entity ontologyEntity, Entity nodePathEntity) { String nodePath = nodePathEntity.getString(OntologyTermNodePathMetadata.NODE_PATH); Iterable<Entity> relatedOntologyTermEntities = () -> dataService .findAll( OntologyTermMetadata.ONTOLOGY_TERM, new QueryImpl<>( new QueryRule( OntologyTermMetadata.ONTOLOGY_TERM_NODE_PATH, Operator.FUZZY_MATCH, "\"" + nodePath + "\"")) .and() .eq(OntologyTermMetadata.ONTOLOGY, ontologyEntity)) .iterator(); Iterable<Entity> childOntologyTermEntities = FluentIterable.from(relatedOntologyTermEntities) .filter(entity -> qualifiedNodePath(nodePath, entity)) .toList(); return Lists.newArrayList( Iterables.transform(childOntologyTermEntities, 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> getChildOntologyTermsByNodePath( Entity ontologyEntity, Entity nodePathEntity) { String nodePath = nodePathEntity.getString(OntologyTermNodePathMetadata.NODE_PATH); Iterable<Entity> relatedOntologyTermEntities = () -> dataService .findAll( OntologyTermMetadata.ONTOLOGY_TERM, new QueryImpl<>( new QueryRule( OntologyTermMetadata.ONTOLOGY_TERM_NODE_PATH, Operator.FUZZY_MATCH, "\"" + nodePath + "\"")) .and() .eq(OntologyTermMetadata.ONTOLOGY, ontologyEntity)) .iterator(); Iterable<Entity> childOntologyTermEntities = FluentIterable.from(relatedOntologyTermEntities) .filter(entity -> qualifiedNodePath(nodePath, entity)) .toList(); return Lists.newArrayList( Iterables.transform(childOntologyTermEntities, 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);  }