Revision 46360ec1
Added by Patrick Plitzner almost 7 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/supplemental/AbstractOriginalSourceElement.java | ||
---|---|---|
64 | 64 |
|
65 | 65 |
/** |
66 | 66 |
* Sorts source type combo alphabetically <b>except</b> for PrimaryTaxonomicSource resp. |
67 |
* PrimaryMediaSource which are alway on top depending on the IdentifiableSource; |
|
67 |
* PrimaryMediaSource which are always on top depending on the IdentifiableSource; |
|
68 |
* <br> |
|
69 |
* The last two are always "Other" followed by "Unknown" |
|
68 | 70 |
* @author pplitzner |
69 | 71 |
* @date Jan 6, 2017 |
70 | 72 |
* |
... | ... | |
82 | 84 |
*/ |
83 | 85 |
@Override |
84 | 86 |
public int compare(OriginalSourceType o1, OriginalSourceType o2) { |
85 |
if(o1!=null && o2==null){ |
|
86 |
return 1; |
|
87 |
if(o1==null){ |
|
88 |
if(o2==null){ |
|
89 |
return 0; |
|
90 |
} |
|
91 |
else{ |
|
92 |
return -1; |
|
93 |
} |
|
87 | 94 |
} |
88 |
else if(o1==null && o2!=null){
|
|
89 |
return -1;
|
|
95 |
if(o2==null){
|
|
96 |
return 1; |
|
90 | 97 |
} |
91 |
else if(o1!=null && o2 !=null){ |
|
92 |
//both are either taxonomic or media |
|
93 |
if(o1.equals(OriginalSourceType.PrimaryTaxonomicSource) |
|
94 |
&& o2.equals(OriginalSourceType.PrimaryMediaSource)){ |
|
95 |
if(entity.getType().equals(OriginalSourceType.PrimaryMediaSource)){ |
|
96 |
return 1; |
|
97 |
} |
|
98 |
else{ |
|
99 |
return -1; |
|
100 |
} |
|
98 |
//both are either taxonomic or media |
|
99 |
else if(o1.equals(OriginalSourceType.PrimaryTaxonomicSource) |
|
100 |
&& o2.equals(OriginalSourceType.PrimaryMediaSource)){ |
|
101 |
if(entity.getType().equals(OriginalSourceType.PrimaryMediaSource)){ |
|
102 |
return 1; |
|
101 | 103 |
} |
102 |
else if(o2.equals(OriginalSourceType.PrimaryTaxonomicSource)
|
|
103 |
&& o1.equals(OriginalSourceType.PrimaryMediaSource)){
|
|
104 |
if(entity.getType().equals(OriginalSourceType.PrimaryMediaSource)){
|
|
105 |
return -1;
|
|
106 |
}
|
|
107 |
else{
|
|
108 |
return 1;
|
|
109 |
}
|
|
104 |
else{
|
|
105 |
return -1;
|
|
106 |
}
|
|
107 |
}
|
|
108 |
else if(o2.equals(OriginalSourceType.PrimaryTaxonomicSource)
|
|
109 |
&& o1.equals(OriginalSourceType.PrimaryMediaSource)){
|
|
110 |
if(entity.getType().equals(OriginalSourceType.PrimaryMediaSource)){
|
|
111 |
return -1;
|
|
110 | 112 |
} |
111 |
//one is not taxonomic or media |
|
112 | 113 |
else{ |
113 |
if(o1.equals(OriginalSourceType.PrimaryTaxonomicSource) |
|
114 |
||o1.equals(OriginalSourceType.PrimaryMediaSource)){ |
|
115 |
return -1; |
|
114 |
return 1; |
|
115 |
} |
|
116 |
} |
|
117 |
//one is not taxonomic or media |
|
118 |
else if(o1.equals(OriginalSourceType.PrimaryTaxonomicSource) |
|
119 |
||o1.equals(OriginalSourceType.PrimaryMediaSource)){ |
|
120 |
return -1; |
|
116 | 121 |
|
117 |
} |
|
118 |
else if(o2.equals(OriginalSourceType.PrimaryTaxonomicSource) |
|
119 |
|| o2.equals(OriginalSourceType.PrimaryMediaSource)){ |
|
120 |
return 1; |
|
121 |
} |
|
122 |
String message1 = o1.getKey(); |
|
123 |
String message2 = o2.getKey(); |
|
124 |
return message1.compareTo(message2); |
|
122 |
} |
|
123 |
else if(o2.equals(OriginalSourceType.PrimaryTaxonomicSource) |
|
124 |
|| o2.equals(OriginalSourceType.PrimaryMediaSource)){ |
|
125 |
return 1; |
|
126 |
} |
|
127 |
//The last two are always "Other" followed by "Unknown" |
|
128 |
else if(o1.equals(OriginalSourceType.Other)){ |
|
129 |
if(o2.equals(OriginalSourceType.Unknown)){ |
|
130 |
return -11; |
|
125 | 131 |
} |
132 |
else{ |
|
133 |
return 1; |
|
134 |
} |
|
135 |
} |
|
136 |
if(o2.equals(OriginalSourceType.Other)){ |
|
137 |
return 1; |
|
138 |
} |
|
139 |
else{ |
|
140 |
String message1 = o1.getKey(); |
|
141 |
String message2 = o2.getKey(); |
|
142 |
return message1.compareTo(message2); |
|
126 | 143 |
} |
127 |
return 0; |
|
128 | 144 |
} |
129 | 145 |
|
130 | 146 |
} |
Also available in: Unified diff
ref #5714 The last two terms are always "Other" followed by "Unknown"