Merge branch 'develop' of ssh://dev.e-taxonomy.eu/var/git/taxeditor into develop
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / model / DefaultTermComparator.java
index 5918cda845a3ba126fc62521e56e78a2d0096d08..9be427d3e3cda2361fc88234b559acb3e712dba9 100644 (file)
@@ -1,9 +1,8 @@
-// $Id$
 /**
 * Copyright (C) 2009 EDIT
-* European Distributed Institute of Taxonomy 
+* 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.
 */
@@ -11,14 +10,14 @@ package eu.etaxonomy.taxeditor.model;
 
 import java.util.Comparator;
 
-import eu.etaxonomy.cdm.model.common.DefinedTermBase;
+import eu.etaxonomy.cdm.model.term.DefinedTermBase;
 import eu.etaxonomy.taxeditor.store.CdmStore;
 
 /**
  * Implements a {@link Comparator} for {@link DefinedTermBase} objects based on the term's label.
  * The compare algorithm compares a term's label. Example: If used on an unsorted list of terms, the
  * list will be alphabetically  sorted by label afterwards.
- * 
+ *
  * @author n.hoffmann
  * @date Jan 18, 2012
  *
@@ -37,6 +36,10 @@ public class DefaultTermComparator<T extends DefinedTermBase> implements Compara
                }
                String label1 = o1.getLabel(CdmStore.getDefaultLanguage()) != null ? o1.getLabel(CdmStore.getDefaultLanguage()) : o1.getTitleCache();
                String label2 = o2.getLabel(CdmStore.getDefaultLanguage()) != null ? o2.getLabel(CdmStore.getDefaultLanguage()) : o2.getTitleCache();
-               return label1.compareTo(label2);
+               int result = label1.compareTo(label2);
+               if (result == 0){
+                   return o1.getUuid().compareTo(o2.getUuid());
+               }
+               return result;
        }
 };