ref #5714 Fix ordering of source types
authorPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 18 Jan 2017 16:54:12 +0000 (17:54 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Wed, 18 Jan 2017 16:54:12 +0000 (17:54 +0100)
 - order by key instead of message
 - always have either taxonomic or media source as first and the other
as second

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/AbstractOriginalSourceElement.java

index 9f1a896794ef7da0554f7e5f5342bc515afe676e..92dd2fdb5d4f0d76ec8a43ed7488c4f2853aab1f 100644 (file)
@@ -89,25 +89,40 @@ public abstract class AbstractOriginalSourceElement<T extends OriginalSourceBase
                 return -1;
             }
             else if(o1!=null && o2 !=null){
-                if(entity.getType().equals(OriginalSourceType.PrimaryMediaSource)){
-                    if(o1.equals(OriginalSourceType.PrimaryMediaSource)){
+                //both are either taxonomic or media
+                if(o1.equals(OriginalSourceType.PrimaryTaxonomicSource)
+                        && o2.equals(OriginalSourceType.PrimaryMediaSource)){
+                    if(entity.getType().equals(OriginalSourceType.PrimaryMediaSource)){
+                        return 1;
+                    }
+                    else{
+                        return -1;
+                    }
+                }
+                else if(o2.equals(OriginalSourceType.PrimaryTaxonomicSource)
+                        && o1.equals(OriginalSourceType.PrimaryMediaSource)){
+                    if(entity.getType().equals(OriginalSourceType.PrimaryMediaSource)){
                         return -1;
                     }
-                    else if(o2.equals(OriginalSourceType.PrimaryMediaSource)){
+                    else{
                         return 1;
                     }
                 }
+                //one is not taxonomic or media
                 else{
-                    if(o1.equals(OriginalSourceType.PrimaryTaxonomicSource)){
+                    if(o1.equals(OriginalSourceType.PrimaryTaxonomicSource)
+                            ||o1.equals(OriginalSourceType.PrimaryMediaSource)){
                         return -1;
+
                     }
-                    else if(o2.equals(OriginalSourceType.PrimaryTaxonomicSource)){
+                    else if(o2.equals(OriginalSourceType.PrimaryTaxonomicSource)
+                            || o2.equals(OriginalSourceType.PrimaryMediaSource)){
                         return 1;
                     }
+                    String message1 = o1.getKey();
+                    String message2 = o2.getKey();
+                    return message1.compareTo(message2);
                 }
-                String message1 = o1.getMessage();
-                String message2 = o2.getMessage();
-                return message1.compareTo(message2);
             }
             return 0;
         }