long countTaxonNodeAgentRelations(UUID taxonUuid, UUID classificationUuid, UUID agentUuid, UUID rankUuid, UUID relTypeUuid);\r
\r
/**\r
- * @param treeIndexClosure\r
- * @param minRankOrderIndex\r
- * @param maxRankOrderIndex\r
+ * Computes a map treeIndex->rank(sortIndex) for each given taxon node treeIndex. Required by #5957.\r
+ * If the taxon represented by the treeindex is not in the given rank range no record is returned for the given\r
+ * treeindex.\r
+ *\r
+ * @param treeIndex the list of treeIndexes\r
+ * @param minRankOrderIndex min rank\r
+ * @param maxRankOrderIndex max rank\r
* @return\r
*/\r
- Map<String, Integer> rankOrderIndexForTreeIndex(List<String> treeIndexClosure, Integer minRankOrderIndex,\r
+ Map<String, Integer> rankOrderIndexForTreeIndex(List<String> treeIndex, Integer minRankOrderIndex,\r
Integer maxRankOrderIndex);\r
\r
/**\r
- * @param keySet\r
- * @return\r
+ * For a given set of taxon node tree indexes the uuid and title cache of the taxon represented\r
+ * by this treeindex is returned.\r
+ * @param treeIndexSet set of taxon node tree indexes\r
+ * @return map with treeindex and uuidAndTitleCache of the represented taxon\r
*/\r
- Map<String, UuidAndTitleCache<?>> taxonUuidsForTreeIndexes(Set<String> keySet);\r
+ Map<String, UuidAndTitleCache<?>> taxonUuidsForTreeIndexes(Set<String> treeIndexSet);\r
\r
}\r
//get treeindex for each taxonUUID
Map<UUID, String> taxonIdTreeIndexMap = dao.treeIndexForTaxonUuids(classificationUuid, originalTaxonUuids);
- //build treeindex tree or list
+ //build treeindex list (or tree)
List<String> treeIndexClosure = new ArrayList<>();
for (String treeIndex : taxonIdTreeIndexMap.values()){
String[] splits = treeIndex.substring(1).split(ITreeNode.separator);
* @author a.mueller
* @date 05.07.2016
*
+ * Comparator for treeindexes.
+ * Compares the tree indexes node by node, sorted by node number.
+ * If one index is shorter than the other one but
*/
public class TreeIndexComparator implements Comparator<String>{
}else if (treeIndex2 == null){
return 1;
}
+ if (treeIndex1.equals(treeIndex2)){
+ return 0;
+ }
+
String[] splits1 = treeIndex1.split(ITreeNode.separator);
String[] splits2 = treeIndex2.split(ITreeNode.separator);
- for (int i=0; i<splits1.length; i++){
- if (splits2.length < i){
+ for (int i=0; i < splits1.length; i++){
+ if (splits2.length <= i){
return 1;
}
int c = splits1[i].compareTo(splits2[i]);
public void setGroupTaxonName(String groupTaxonName) {
this.groupTaxonName = groupTaxonName;
}
+
+//*********************** toString() ***************************/
+ @Override
+ public String toString() {
+ String result = "taxon:" + (taxonUuid == null? "-":taxonUuid.toString())
+ + "; group:" + (groupTaxonUuid == null? "-":groupTaxonUuid.toString())
+ + "; group name:" + (groupTaxonName == null? "-":groupTaxonName.toString());
+ return result;
+ }
+
+
}
--- /dev/null
+// $Id$
+/**
+* Copyright (C) 2016 EDIT
+* European Distributed Institute of Taxonomy
+* http://www.e-taxonomy.eu
+*
+* The contents of this file are subject to the Mozilla Public License Version 1.1
+* See LICENSE.TXT at the top of this package for the full license terms.
+*/
+package eu.etaxonomy.cdm.api.service;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+
+/**
+ * @author a.mueller
+ * @date 12.09.2016
+ *
+ */
+public class TreeIndexComparatorTest {
+
+ @Test
+ public void test() {
+ TreeIndexComparator comparator = new TreeIndexComparator();
+
+ //both null
+ Assert.assertTrue(0 == comparator.compare(null, null));
+ //one null
+ Assert.assertTrue(0 > comparator.compare(null, "#t10#10#"));
+ Assert.assertTrue(0 < comparator.compare("#t10#10#", null));
+ //equal
+ Assert.assertTrue(0 == comparator.compare("#t10#10#", "#t10#10#"));
+
+ //same start
+ Assert.assertTrue(0 > comparator.compare("#t10#10#", "#t10#10#20#"));
+ Assert.assertTrue(0 < comparator.compare("#t10#10#20#", "#t10#10#"));
+
+ //different ends
+ Assert.assertTrue(0 > comparator.compare("#t10#10#20#", "#t10#10#30#"));
+ Assert.assertTrue(0 < comparator.compare("#t10#10#30#", "#t10#10#20#"));
+
+ //different ends
+ Assert.assertTrue(0 > comparator.compare("#t10#10#20#", "#t10#10#30#"));
+ Assert.assertTrue(0 > comparator.compare("#t10#10#20#", "#t10#10#30#11"));
+
+ Assert.assertTrue(0 < comparator.compare("#t10#10#30#", "#t10#10#20#"));
+ Assert.assertTrue(0 < comparator.compare("#t10#10#30#11", "#t10#10#20#"));
+
+ }
+
+}