line endings again...
authorKatja Luther <k.luther@bgbm.org>
Fri, 12 Aug 2016 08:03:25 +0000 (10:03 +0200)
committerKatja Luther <k.luther@bgbm.org>
Fri, 12 Aug 2016 08:07:02 +0000 (10:07 +0200)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/GbifResponseComparator.java [new file with mode: 0755]

diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/GbifResponseComparator.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/view/dataimport/GbifResponseComparator.java
new file mode 100755 (executable)
index 0000000..a376ea9
--- /dev/null
@@ -0,0 +1,57 @@
+package eu.etaxonomy.taxeditor.view.dataimport;
+
+import java.util.Comparator;
+
+import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifDataSetProtocol;
+import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse;
+
+public class GbifResponseComparator implements Comparator<GbifResponse> {
+       
+       @Override
+       public int compare(GbifResponse response1, GbifResponse response2) {
+               if (response1 == response2){
+                       return 0;
+               }
+               if (response1 == null){
+                       return -1;                      
+               }
+               if (response2 == null){
+                       return 1;
+               }
+               
+               if (!response1.getDataSetProtocol().equals(response2.getDataSetProtocol())){
+                       if (response1.getDataSetProtocol().equals(GbifDataSetProtocol.DWC_ARCHIVE) && response2.getDataSetProtocol().equals(GbifDataSetProtocol.BIOCASE)){
+                               return -1;
+                       }
+                       if (response2.getDataSetProtocol().equals(GbifDataSetProtocol.DWC_ARCHIVE) && response1.getDataSetProtocol().equals(GbifDataSetProtocol.BIOCASE)){
+                               return 1;
+                       }
+                       if (response1.getDataSetProtocol() == null){
+                               return -1;
+                       }
+                       if (response2.getDataSetProtocol() == null){
+                               return 1;
+                       }
+               } else{
+                       if (response1.getDataSetUri() == response2.getDataSetUri()){
+                               return 0;
+                       }
+                       if (response1.getDataSetUri() == null){
+                               return -1;
+                       }
+                       if (response2.getDataSetUri() == null){
+                               return -2;
+                       }
+                       if (response1.getDataSetProtocol().equals(GbifDataSetProtocol.BIOCASE)){
+                               
+                               return response1.getDataSetUri().compareTo(response2.getDataSetUri());
+                       }
+                       if (response1.getDataSetProtocol().equals(GbifDataSetProtocol.DWC_ARCHIVE)){
+                               return response1.getDataSetUri().compareTo(response2.getDataSetUri());
+                       }
+               }
+               
+               return 0;
+       }
+
+}