fix #6570: use treeMap for getKeyLabelPairs() to sort the ranks
authorKatja Luther <k.luther@bgbm.org>
Thu, 20 Apr 2017 09:17:55 +0000 (11:17 +0200)
committerKatja Luther <k.luther@bgbm.org>
Thu, 20 Apr 2017 09:18:53 +0000 (11:18 +0200)
eu.etaxonomy.taxeditor.bulkeditor/src/main/java/eu/etaxonomy/taxeditor/bulkeditor/input/entitycreator/NameCreator.java

index 8cb943b83e54437cd233063ba04b74b9f4d8216a..98458d1b5d2bf4f089516f097166cb2087deb003 100644 (file)
@@ -1,16 +1,17 @@
 /**
 * Copyright (C) 2007 EDIT
 /**
 * Copyright (C) 2007 EDIT
-* European Distributed Institute of Taxonomy 
+* European Distributed Institute of Taxonomy
 * http://www.e-taxonomy.eu
 * 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.taxeditor.bulkeditor.input.entitycreator;
 
 * 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.taxeditor.bulkeditor.input.entitycreator;
 
-import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
+import java.util.TreeMap;
 
 import eu.etaxonomy.cdm.model.name.Rank;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
 
 import eu.etaxonomy.cdm.model.name.Rank;
 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
@@ -32,7 +33,8 @@ public class NameCreator implements IEntityCreator<TaxonNameBase> {
         * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityCreator#createEntity(java.lang.String)
         */
        /** {@inheritDoc} */
         * @see eu.etaxonomy.taxeditor.bulkeditor.IEntityCreator#createEntity(java.lang.String)
         */
        /** {@inheritDoc} */
-       public TaxonNameBase createEntity(String text) {
+    @Override
+    public TaxonNameBase createEntity(String text) {
                TaxonNameBase name = PreferencesUtil.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null);
                name.setTitleCache(text, true);
                //name.setTitleCache(text);
                TaxonNameBase name = PreferencesUtil.getPreferredNomenclaturalCode().getNewTaxonNameInstance(null);
                name.setTitleCache(text, true);
                //name.setTitleCache(text);
@@ -43,7 +45,8 @@ public class NameCreator implements IEntityCreator<TaxonNameBase> {
         * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#createEntity(java.lang.Class, java.lang.String)
         */
        /** {@inheritDoc} */
         * @see eu.etaxonomy.taxeditor.annotatedlineeditor.IEntityCreator#createEntity(java.lang.Class, java.lang.String)
         */
        /** {@inheritDoc} */
-       public TaxonNameBase createEntity(Object key, String text) {
+    @Override
+    public TaxonNameBase createEntity(Object key, String text) {
                return ParseHandler.parseName(text, (Rank) key);
        }
 
                return ParseHandler.parseName(text, (Rank) key);
        }
 
@@ -55,9 +58,11 @@ public class NameCreator implements IEntityCreator<TaxonNameBase> {
         *
         * @return a {@link java.util.Map} object.
         */
         *
         * @return a {@link java.util.Map} object.
         */
-       public Map<Object, String> getKeyLabelPairs() {
-               Map<Object, String> result = new HashMap<Object, String>();
-               for (Rank rank : CdmStore.getTermManager().getPreferredTerms(Rank.class)) {
+        @Override
+    public Map<Object, String> getKeyLabelPairs() {
+               Map<Object, String> result = new TreeMap<Object, String>();
+               List<Rank> ranks = CdmStore.getTermManager().getPreferredTerms(Rank.class);
+               for (Rank rank : ranks) {
                        result.put(rank, rank.getLabel());
                }
                return result;
                        result.put(rank, rank.getLabel());
                }
                return result;