--- /dev/null
+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;
+ }
+
+}