Project

General

Profile

Download (1.58 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.taxeditor.view.dataimport;
2

    
3
import java.util.Comparator;
4

    
5
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifDataSetProtocol;
6
import eu.etaxonomy.cdm.ext.occurrence.gbif.GbifResponse;
7

    
8
public class GbifResponseComparator implements Comparator<GbifResponse> {
9
	
10
	@Override
11
	public int compare(GbifResponse response1, GbifResponse response2) {
12
		if (response1 == response2){
13
			return 0;
14
		}
15
		if (response1 == null){
16
			return -1;			
17
		}
18
		if (response2 == null){
19
			return 1;
20
		}
21
		
22
		if (!response1.getDataSetProtocol().equals(response2.getDataSetProtocol())){
23
			if (response1.getDataSetProtocol().equals(GbifDataSetProtocol.DWC_ARCHIVE) && response2.getDataSetProtocol().equals(GbifDataSetProtocol.BIOCASE)){
24
				return -1;
25
			}
26
			if (response2.getDataSetProtocol().equals(GbifDataSetProtocol.DWC_ARCHIVE) && response1.getDataSetProtocol().equals(GbifDataSetProtocol.BIOCASE)){
27
				return 1;
28
			}
29
			if (response1.getDataSetProtocol() == null){
30
				return -1;
31
			}
32
			if (response2.getDataSetProtocol() == null){
33
				return 1;
34
			}
35
		} else{
36
			if (response1.getDataSetUri() == response2.getDataSetUri()){
37
				return 0;
38
			}
39
			if (response1.getDataSetUri() == null){
40
				return -1;
41
			}
42
			if (response2.getDataSetUri() == null){
43
				return -2;
44
			}
45
			if (response1.getDataSetProtocol().equals(GbifDataSetProtocol.BIOCASE)){
46
				
47
				return response1.getDataSetUri().compareTo(response2.getDataSetUri());
48
			}
49
			if (response1.getDataSetProtocol().equals(GbifDataSetProtocol.DWC_ARCHIVE)){
50
				return response1.getDataSetUri().compareTo(response2.getDataSetUri());
51
			}
52
		}
53
		
54
		return 0;
55
	}
56

    
57
}
(4-4/8)