Revision 9dc896c9
Added by Andreas Müller almost 7 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/taxon/TaxonComparator.java | ||
---|---|---|
19 | 19 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatus; |
20 | 20 |
import eu.etaxonomy.cdm.model.name.NomenclaturalStatusType; |
21 | 21 |
import eu.etaxonomy.cdm.model.name.Rank; |
22 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase;
|
|
22 |
import eu.etaxonomy.cdm.model.name.TaxonName; |
|
23 | 23 |
import eu.etaxonomy.cdm.model.reference.Reference; |
24 | 24 |
|
25 | 25 |
/** |
26 | 26 |
* This class makes available a method to compare two {@link TaxonBase taxa} by |
27 | 27 |
* comparing the publication dates of the corresponding |
28 |
* {@link eu.etaxonomy.cdm.model.name.TaxonNameBase taxon names}.
|
|
28 |
* {@link eu.etaxonomy.cdm.model.name.TaxonName taxon names}. |
|
29 | 29 |
* |
30 | 30 |
* @author a.mueller |
31 | 31 |
* @created 11.06.2008 |
... | ... | |
56 | 56 |
/** |
57 | 57 |
* Returns an integer generated by comparing first the nomenclatural status and then the |
58 | 58 |
* {@link eu.etaxonomy.cdm.model.name.INomenclaturalReference#getYear() publication years} |
59 |
* of both {@link eu.etaxonomy.cdm.model.name.TaxonNameBase taxon names}
|
|
59 |
* of both {@link eu.etaxonomy.cdm.model.name.TaxonName taxon names} |
|
60 | 60 |
* used in the given {@link TaxonBase taxa}. |
61 | 61 |
* If 1 name has status of type nom. inval. or nom. nudum the name is put to the end of a |
62 | 62 |
* list (returns +1 for a status in taxon1 and -1 for a status in taxon2). If both do have |
... | ... | |
86 | 86 |
return 0; |
87 | 87 |
} |
88 | 88 |
|
89 |
TaxonNameBase<?,?> name1 = taxonBase1.getName();
|
|
90 |
TaxonNameBase<?,?> name2 = taxonBase2.getName();
|
|
89 |
TaxonName name1 = taxonBase1.getName(); |
|
90 |
TaxonName name2 = taxonBase2.getName(); |
|
91 | 91 |
|
92 | 92 |
//set to end if a taxon has nomenclatural status "nom. inval." or "nom. nud." |
93 | 93 |
int statusCompareWeight = compareStatus(name1, name2); |
... | ... | |
122 | 122 |
|
123 | 123 |
|
124 | 124 |
/** |
125 |
* @param taxonNameBase
|
|
126 |
* @param taxonNameBase2
|
|
125 |
* @param taxonName |
|
126 |
* @param taxonName2 |
|
127 | 127 |
* @param statusCompareWeight |
128 | 128 |
* @return |
129 | 129 |
*/ |
130 |
protected int compareStatus(TaxonNameBase<?,?> taxonNameBase, TaxonNameBase<?,?> taxonNameBase2) {
|
|
130 |
protected int compareStatus(TaxonName taxonName, TaxonName taxonName2) {
|
|
131 | 131 |
int statusCompareWeight = 0; |
132 |
statusCompareWeight += computeStatusCompareWeight(taxonNameBase);
|
|
133 |
statusCompareWeight -= computeStatusCompareWeight(taxonNameBase2);
|
|
132 |
statusCompareWeight += computeStatusCompareWeight(taxonName); |
|
133 |
statusCompareWeight -= computeStatusCompareWeight(taxonName2); |
|
134 | 134 |
return statusCompareWeight; |
135 | 135 |
} |
136 | 136 |
|
... | ... | |
140 | 140 |
* @param statusCompareWeight |
141 | 141 |
* @return |
142 | 142 |
*/ |
143 |
private int computeStatusCompareWeight(TaxonNameBase<?,?> taxonNameBase) {
|
|
143 |
private int computeStatusCompareWeight(TaxonName taxonName) {
|
|
144 | 144 |
int result = 0; |
145 |
if (taxonNameBase == null || taxonNameBase.getStatus() == null){
|
|
145 |
if (taxonName == null || taxonName.getStatus() == null){
|
|
146 | 146 |
return 0; |
147 | 147 |
} |
148 |
Set<NomenclaturalStatus> status1 = taxonNameBase.getStatus();
|
|
148 |
Set<NomenclaturalStatus> status1 = taxonName.getStatus(); |
|
149 | 149 |
for (NomenclaturalStatus nomStatus1 : status1){ |
150 | 150 |
NomenclaturalStatusType type = nomStatus1.getType(); |
151 | 151 |
if (type != null && type.isInvalidType()){ |
... | ... | |
166 | 166 |
return result; |
167 | 167 |
} |
168 | 168 |
|
169 |
protected int compareNomIlleg(TaxonNameBase<?,?> taxonNameBase1, TaxonNameBase<?,?> taxonNameBase2) {
|
|
170 |
int isNomIlleg1 = isNomIlleg(taxonNameBase1);
|
|
171 |
int isNomIlleg2 = isNomIlleg(taxonNameBase2);
|
|
169 |
protected int compareNomIlleg(TaxonName taxonName1, TaxonName taxonName2) {
|
|
170 |
int isNomIlleg1 = isNomIlleg(taxonName1); |
|
171 |
int isNomIlleg2 = isNomIlleg(taxonName2); |
|
172 | 172 |
return isNomIlleg1 - isNomIlleg2; |
173 | 173 |
} |
174 | 174 |
|
175 |
private int isNomIlleg(TaxonNameBase<?,?> taxonNameBase) {
|
|
176 |
if (taxonNameBase == null || taxonNameBase.getStatus() == null){
|
|
175 |
private int isNomIlleg(TaxonName taxonName) {
|
|
176 |
if (taxonName == null || taxonName.getStatus() == null){
|
|
177 | 177 |
return 0; |
178 | 178 |
} |
179 |
Set<NomenclaturalStatus> status = taxonNameBase.getStatus();
|
|
179 |
Set<NomenclaturalStatus> status = taxonName.getStatus(); |
|
180 | 180 |
for (NomenclaturalStatus nomStatus : status){ |
181 | 181 |
if (nomStatus.getType() != null){ |
182 | 182 |
if (nomStatus.getType().equals(NomenclaturalStatusType.ILLEGITIMATE())){ |
... | ... | |
188 | 188 |
} |
189 | 189 |
|
190 | 190 |
|
191 |
private Integer getIntegerDate(TaxonNameBase<?,?> name){
|
|
191 |
private Integer getIntegerDate(TaxonName name){ |
|
192 | 192 |
Integer result; |
193 | 193 |
|
194 | 194 |
if (name == null){ |
... | ... | |
232 | 232 |
* without status nom. illeg. |
233 | 233 |
* @return |
234 | 234 |
*/ |
235 |
protected int compare(TaxonNameBase<?,?> name1, TaxonNameBase<?,?> name2, boolean includeNomIlleg) {
|
|
235 |
protected int compare(TaxonName name1, TaxonName name2, boolean includeNomIlleg) {
|
|
236 | 236 |
int result; |
237 | 237 |
|
238 | 238 |
//dates |
Also available in: Unified diff
fix #6368 rename table and class TaxonNameBase