Revision 40d48f6f
Added by Katja Luther over 3 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/description/SourceComparator.java | ||
---|---|---|
26 | 26 |
if (o2 instanceof DescriptionElementSource){ |
27 | 27 |
isDescriptionElementSource2 = true; |
28 | 28 |
} |
29 |
int result = 0; |
|
29 | 30 |
if (isDescriptionElementSource1 != isDescriptionElementSource2){ |
30 | 31 |
if (isDescriptionElementSource1){ |
31 | 32 |
return -1; |
... | ... | |
38 | 39 |
Reference citation1 = o1.getCitation(); |
39 | 40 |
Reference citation2 = o2.getCitation(); |
40 | 41 |
|
41 |
int result = 0; |
|
42 |
|
|
42 | 43 |
|
43 | 44 |
// the newly created should always be on top |
44 | 45 |
if (id1 == 0){ |
45 | 46 |
if(id2!=0) { |
46 |
result = -1;
|
|
47 |
return -1;
|
|
47 | 48 |
} |
48 | 49 |
else{ |
49 | 50 |
result = 0; |
50 | 51 |
} |
51 | 52 |
} else if(id2==0){ |
52 |
result = 1;
|
|
53 |
return 1;
|
|
53 | 54 |
} |
54 | 55 |
|
55 | 56 |
// sort by type (Primary taxonomic > Primary Media > others |
... | ... | |
59 | 60 |
result = 0; |
60 | 61 |
} |
61 | 62 |
else{ |
62 |
result = 1; |
|
63 |
result = -1;
|
|
63 | 64 |
} |
64 | 65 |
} else if (type2 == null){ |
65 |
result = -1;
|
|
66 |
result = 1; |
|
66 | 67 |
} else if(type1.equals(type2)){ |
67 | 68 |
result = 0; |
68 | 69 |
} else if (type1.equals(OriginalSourceType.PrimaryTaxonomicSource)){ |
69 |
result = -1; |
|
70 |
} else if (type2.equals(OriginalSourceType.PrimaryTaxonomicSource)){ |
|
71 | 70 |
result = 1; |
72 |
} else if (type1.equals(OriginalSourceType.PrimaryMediaSource)){
|
|
71 |
} else if (type2.equals(OriginalSourceType.PrimaryTaxonomicSource)){
|
|
73 | 72 |
result = -1; |
74 |
} else if (type2.equals(OriginalSourceType.PrimaryMediaSource)){
|
|
73 |
} else if (type1.equals(OriginalSourceType.PrimaryMediaSource)){
|
|
75 | 74 |
result = 1; |
75 |
} else if (type2.equals(OriginalSourceType.PrimaryMediaSource)){ |
|
76 |
result = -1; |
|
76 | 77 |
} |
77 | 78 |
|
78 | 79 |
//sort by citation title cache if types are equal |
... | ... | |
82 | 83 |
} |
83 | 84 |
|
84 | 85 |
if(o2.getCreated()!=null && o1.getCreated()!=null){ |
85 |
result = o2.getCreated().compareTo(o1.getCreated()); |
|
86 |
result = o1.getCreated().compareTo(o2.getCreated()); |
|
87 |
}else if (o1.getCreated() == null ){ |
|
88 |
if (o2.getCreated() == null){ |
|
89 |
result = 0; |
|
90 |
}else{ |
|
91 |
return -1; |
|
92 |
} |
|
93 |
}else if (o2.getCreated() == null){ |
|
94 |
return 1; |
|
86 | 95 |
} |
87 | 96 |
if (result == 0){ |
88 | 97 |
//default fallback |
89 |
return o1.getId() - o2.getId();
|
|
98 |
return o1.getUuid().compareTo(o2.getUuid());
|
|
90 | 99 |
} |
91 | 100 |
} |
92 | 101 |
return result; |
Also available in: Unified diff
ref #9356: hotfix solution