@Test void testCalculateNodePathDistance() { assertEquals( 1, ontologyTermRepository.calculateNodePathDistance("0[0].0[1]", "0[0].0[1].1[2]")); assertEquals( 1, ontologyTermRepository.calculateNodePathDistance("0[0].0[1].1[2]", "0[0].0[1]")); assertEquals( 4, ontologyTermRepository.calculateNodePathDistance( "0[0].0[1].1[2].2[3]", "0[0].0[1].0[2].2[3]")); assertEquals( 3, ontologyTermRepository.calculateNodePathDistance("0[0].0[1]", "0[0].0[1].0[2].1[3].2[4]")); assertEquals(0, ontologyTermRepository.calculateNodePathDistance("0[0].0[1]", "0[0].0[1]")); }
public int calculateNodePathDistance(String nodePath1, String nodePath2) { String[] nodePathFragment1 = nodePath1.split("\\."); String[] nodePathFragment2 = nodePath2.split("\\."); int overlapBlock = 0; while (overlapBlock < nodePathFragment1.length && overlapBlock < nodePathFragment2.length && nodePathFragment1[overlapBlock].equals(nodePathFragment2[overlapBlock])) { overlapBlock++; } return nodePathFragment1.length + nodePathFragment2.length - overlapBlock * 2; }
OntologyTermRepository { public int calculateNodePathDistance(String nodePath1, String nodePath2) { String[] nodePathFragment1 = nodePath1.split("\\."); String[] nodePathFragment2 = nodePath2.split("\\."); int overlapBlock = 0; while (overlapBlock < nodePathFragment1.length && overlapBlock < nodePathFragment2.length && nodePathFragment1[overlapBlock].equals(nodePathFragment2[overlapBlock])) { overlapBlock++; } return nodePathFragment1.length + nodePathFragment2.length - overlapBlock * 2; } }
OntologyTermRepository { public int calculateNodePathDistance(String nodePath1, String nodePath2) { String[] nodePathFragment1 = nodePath1.split("\\."); String[] nodePathFragment2 = nodePath2.split("\\."); int overlapBlock = 0; while (overlapBlock < nodePathFragment1.length && overlapBlock < nodePathFragment2.length && nodePathFragment1[overlapBlock].equals(nodePathFragment2[overlapBlock])) { overlapBlock++; } return nodePathFragment1.length + nodePathFragment2.length - overlapBlock * 2; } OntologyTermRepository(DataService dataService); }
OntologyTermRepository { public int calculateNodePathDistance(String nodePath1, String nodePath2) { String[] nodePathFragment1 = nodePath1.split("\\."); String[] nodePathFragment2 = nodePath2.split("\\."); int overlapBlock = 0; while (overlapBlock < nodePathFragment1.length && overlapBlock < nodePathFragment2.length && nodePathFragment1[overlapBlock].equals(nodePathFragment2[overlapBlock])) { overlapBlock++; } return nodePathFragment1.length + nodePathFragment2.length - overlapBlock * 2; } 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 int calculateNodePathDistance(String nodePath1, String nodePath2) { String[] nodePathFragment1 = nodePath1.split("\\."); String[] nodePathFragment2 = nodePath2.split("\\."); int overlapBlock = 0; while (overlapBlock < nodePathFragment1.length && overlapBlock < nodePathFragment2.length && nodePathFragment1[overlapBlock].equals(nodePathFragment2[overlapBlock])) { overlapBlock++; } return nodePathFragment1.length + nodePathFragment2.length - overlapBlock * 2; } 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);  }