@Test public void testMatchesClassification() throws Exception { try(Transaction tx = dao.beginTx()) { Node n = idb.create(Origin.DENORMED_CLASSIFICATION, "Abies Mill.", Rank.GENUS, TaxonomicStatus.ACCEPTED, false).node; Node syn = idb.create(Origin.DENORMED_CLASSIFICATION, "Pinus", Rank.GENUS, TaxonomicStatus.SYNONYM, false).node; Node n2 = idb.create(Origin.DENORMED_CLASSIFICATION, "Pinaceae", Rank.FAMILY, TaxonomicStatus.ACCEPTED, false).node; Node n3 = idb.create(Origin.DENORMED_CLASSIFICATION, "Pinales", Rank.ORDER, TaxonomicStatus.ACCEPTED, false).node; Node n4 = idb.create(Origin.DENORMED_CLASSIFICATION, "Plantae", Rank.KINGDOM, TaxonomicStatus.ACCEPTED, false).node; n4.createRelationshipTo(n3, RelType.PARENT_OF); n3.createRelationshipTo(n2, RelType.PARENT_OF); n2.createRelationshipTo(n, RelType.PARENT_OF); syn.createRelationshipTo(n, RelType.SYNONYM_OF); tx.success(); List<RankedName> classification = Lists.newArrayList(); assertTrue(idb.matchesClassification(n4, classification)); assertFalse(idb.matchesClassification(n3, classification)); assertFalse(idb.matchesClassification(n2, classification)); assertFalse(idb.matchesClassification(n, classification)); classification.add(new RankedName("Plantae", Rank.KINGDOM)); assertFalse(idb.matchesClassification(n4, classification)); assertTrue(idb.matchesClassification(n3, classification)); assertFalse(idb.matchesClassification(n2, classification)); assertFalse(idb.matchesClassification(n, classification)); classification.add(0, new RankedName("Pinales", Rank.ORDER)); assertFalse(idb.matchesClassification(n4, classification)); assertFalse(idb.matchesClassification(n3, classification)); assertTrue(idb.matchesClassification(n2, classification)); assertFalse(idb.matchesClassification(n, classification)); classification.add(0, new RankedName("Pinaceae", Rank.SUBFAMILY)); assertFalse(idb.matchesClassification(n4, classification)); assertFalse(idb.matchesClassification(n3, classification)); assertFalse(idb.matchesClassification(n2, classification)); assertFalse(idb.matchesClassification(n, classification)); } }
protected boolean matchesClassification(Node n, List<RankedName> classification) { Iterator<RankedName> clIter = classification.listIterator(); Iterator<Node> nodeIter = Traversals.PARENTS.traverse(n).nodes().iterator(); while (clIter.hasNext()) { if (!nodeIter.hasNext()) { return false; } RankedName rn1 = clIter.next(); RankedName rn2 = dao.readRankedName(nodeIter.next()); if (rn1.rank != rn2.rank || !rn1.name.equals(rn2.name)) { return false; } } return !nodeIter.hasNext(); }
ImportDb { protected boolean matchesClassification(Node n, List<RankedName> classification) { Iterator<RankedName> clIter = classification.listIterator(); Iterator<Node> nodeIter = Traversals.PARENTS.traverse(n).nodes().iterator(); while (clIter.hasNext()) { if (!nodeIter.hasNext()) { return false; } RankedName rn1 = clIter.next(); RankedName rn2 = dao.readRankedName(nodeIter.next()); if (rn1.rank != rn2.rank || !rn1.name.equals(rn2.name)) { return false; } } return !nodeIter.hasNext(); } }
ImportDb { protected boolean matchesClassification(Node n, List<RankedName> classification) { Iterator<RankedName> clIter = classification.listIterator(); Iterator<Node> nodeIter = Traversals.PARENTS.traverse(n).nodes().iterator(); while (clIter.hasNext()) { if (!nodeIter.hasNext()) { return false; } RankedName rn1 = clIter.next(); RankedName rn2 = dao.readRankedName(nodeIter.next()); if (rn1.rank != rn2.rank || !rn1.name.equals(rn2.name)) { return false; } } return !nodeIter.hasNext(); } ImportDb(UUID datasetKey, UsageDao dao); }
ImportDb { protected boolean matchesClassification(Node n, List<RankedName> classification) { Iterator<RankedName> clIter = classification.listIterator(); Iterator<Node> nodeIter = Traversals.PARENTS.traverse(n).nodes().iterator(); while (clIter.hasNext()) { if (!nodeIter.hasNext()) { return false; } RankedName rn1 = clIter.next(); RankedName rn2 = dao.readRankedName(nodeIter.next()); if (rn1.rank != rn2.rank || !rn1.name.equals(rn2.name)) { return false; } } return !nodeIter.hasNext(); } ImportDb(UUID datasetKey, UsageDao dao); UUID getDatasetKey(); }
ImportDb { protected boolean matchesClassification(Node n, List<RankedName> classification) { Iterator<RankedName> clIter = classification.listIterator(); Iterator<Node> nodeIter = Traversals.PARENTS.traverse(n).nodes().iterator(); while (clIter.hasNext()) { if (!nodeIter.hasNext()) { return false; } RankedName rn1 = clIter.next(); RankedName rn2 = dao.readRankedName(nodeIter.next()); if (rn1.rank != rn2.rank || !rn1.name.equals(rn2.name)) { return false; } } return !nodeIter.hasNext(); } ImportDb(UUID datasetKey, UsageDao dao); UUID getDatasetKey();  }