1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
6
|
* The contents of this file are subject to the Mozilla Public License Version 1.1
|
7
|
* See LICENSE.TXT at the top of this package for the full license terms.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.model.name;
|
11
|
|
12
|
import java.util.HashMap;
|
13
|
import java.util.List;
|
14
|
import java.util.Map;
|
15
|
import java.util.UUID;
|
16
|
|
17
|
import javax.persistence.Entity;
|
18
|
import javax.persistence.Transient;
|
19
|
import javax.validation.constraints.NotNull;
|
20
|
import javax.xml.bind.annotation.XmlAccessType;
|
21
|
import javax.xml.bind.annotation.XmlAccessorType;
|
22
|
import javax.xml.bind.annotation.XmlAttribute;
|
23
|
import javax.xml.bind.annotation.XmlType;
|
24
|
|
25
|
import org.apache.commons.lang.StringUtils;
|
26
|
import org.apache.log4j.Logger;
|
27
|
import org.hibernate.annotations.Type;
|
28
|
import org.hibernate.envers.Audited;
|
29
|
import org.hibernate.search.annotations.Indexed;
|
30
|
|
31
|
import eu.etaxonomy.cdm.common.CdmUtils;
|
32
|
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
33
|
import eu.etaxonomy.cdm.model.common.Language;
|
34
|
import eu.etaxonomy.cdm.model.common.OrderedTermBase;
|
35
|
import eu.etaxonomy.cdm.model.common.Representation;
|
36
|
import eu.etaxonomy.cdm.model.common.TermType;
|
37
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
38
|
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
|
39
|
|
40
|
/**
|
41
|
* The class representing the taxonomical ranks (like "Family", "Genus" or
|
42
|
* "Species") used for {@link TaxonNameBase taxon names} across all {@link NomenclaturalCode nomenclatural codes}
|
43
|
* for bacteria (ICNB), viruses (ICVCN), plants and fungi (ICBN),
|
44
|
* cultivars (ICNCP) and animals (ICZN).
|
45
|
* <P>
|
46
|
* A standard (ordered) list of taxonomical rank instances will be automatically
|
47
|
* created as the project starts. But this class allows to extend this standard
|
48
|
* list by creating new instances of additional taxonomical ranks if needed.
|
49
|
* <P>
|
50
|
* This class corresponds to: <ul>
|
51
|
* <li> TaxonRankTerm according to the TDWG ontology
|
52
|
* <li> TaxonomicRankEnum according to the TCS
|
53
|
* <li> Rank according to the ABCD schema
|
54
|
* </ul>
|
55
|
*
|
56
|
* @author m.doering
|
57
|
* @version 1.0
|
58
|
* @created 08-Nov-2007 13:06:46
|
59
|
*/
|
60
|
@XmlAccessorType(XmlAccessType.FIELD)
|
61
|
@XmlType(name = "Rank")
|
62
|
@Entity
|
63
|
@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
|
64
|
@Audited
|
65
|
public class Rank extends OrderedTermBase<Rank> {
|
66
|
private static final long serialVersionUID = -8648081681348758485L;
|
67
|
private static final Logger logger = Logger.getLogger(Rank.class);
|
68
|
|
69
|
private static final UUID uuidEmpire = UUID.fromString("ac470211-1586-4b24-95ca-1038050b618d");
|
70
|
private static final UUID uuidDomain = UUID.fromString("ffca6ec8-8b88-417b-a6a0-f7c992aac19b");
|
71
|
private static final UUID uuidSuperkingdom = UUID.fromString("64223610-7625-4cfd-83ad-b797bf7f0edd");
|
72
|
private static final UUID uuidKingdom = UUID.fromString("fbe7109d-66b3-498c-a697-c6c49c686162");
|
73
|
private static final UUID uuidSubkingdom = UUID.fromString("a71bd9d8-f3ab-4083-afb5-d89315d71655");
|
74
|
private static final UUID uuidInfrakingdom = UUID.fromString("1e37930c-86cf-44f6-90fd-7822928df260");
|
75
|
private static final UUID uuidSuperphylum = UUID.fromString("0d0cecb1-e254-4607-b210-6801e7ecbb04");
|
76
|
private static final UUID uuidPhylum = UUID.fromString("773430d2-76b4-438c-b817-97a543a33287");
|
77
|
private static final UUID uuidSubphylum = UUID.fromString("23a9b6ff-9408-49c9-bd9e-7a2ca5ab4725");
|
78
|
private static final UUID uuidInfraphylum = UUID.fromString("1701de3a-7693-42a5-a2d3-42697f944190");
|
79
|
private static final UUID uuidSuperdivision = UUID.fromString("a735a48f-4fc8-49a7-ae0c-6a984f658131");
|
80
|
private static final UUID uuidDivision = UUID.fromString("7e56f5cc-123a-4fd1-8cbb-6fd80358b581");
|
81
|
private static final UUID uuidSubdivision = UUID.fromString("931c840f-7a6b-4d76-ad38-bfdd77d7b2e8");
|
82
|
private static final UUID uuidInfradivision = UUID.fromString("c0ede273-be52-4dee-b411-66ee08d30c94");
|
83
|
private static final UUID uuidSuperclass = UUID.fromString("e65b4e1a-21ec-428d-9b9f-e87721ab967c");
|
84
|
private static final UUID uuidClass = UUID.fromString("f23d14c4-1d34-4ee6-8b4e-eee2eb9a3daf");
|
85
|
private static final UUID uuidSubclass = UUID.fromString("8cb26733-e2f5-46cb-ab5c-f99254f877aa");
|
86
|
private static final UUID uuidInfraclass = UUID.fromString("ad23cfda-879a-4021-8629-c54d27caf717");
|
87
|
private static final UUID uuidSuperorder = UUID.fromString("c8c67a22-301a-4219-b882-4a49121232ff");
|
88
|
private static final UUID uuidOrder = UUID.fromString("b0785a65-c1c1-4eb4-88c7-dbd3df5aaad1");
|
89
|
private static final UUID uuidSuborder = UUID.fromString("768ad378-fa85-42ab-b668-763225832f57");
|
90
|
private static final UUID uuidInfraorder = UUID.fromString("84099182-a6f5-47d7-8586-33c9e9955a10");
|
91
|
private static final UUID uuidSectionZoology = UUID.fromString("691d371e-10d7-43f0-93db-3d7fa1a62c54");
|
92
|
private static final UUID uuidSubsectionZoology = UUID.fromString("0ed32d28-adc4-4303-a9ca-68e2acd67e33");
|
93
|
private static final UUID uuidSuperfamily = UUID.fromString("2cfa510a-dcea-4a03-b66a-b1528f9b0796");
|
94
|
private static final UUID uuidFamily = UUID.fromString("af5f2481-3192-403f-ae65-7c957a0f02b6");
|
95
|
private static final UUID uuidSubfamily = UUID.fromString("862526ee-7592-4760-a23a-4ff3641541c5");
|
96
|
private static final UUID uuidInfrafamily = UUID.fromString("c3f2e3bb-6eef-4a26-9fb7-b14f4c8c5e4f");
|
97
|
private static final UUID uuidSupertribe = UUID.fromString("11e94828-8c61-499b-87d6-1de35ce2c51c");
|
98
|
private static final UUID uuidTribe = UUID.fromString("4aa6890b-0363-4899-8d7c-ee0cb78e6166");
|
99
|
private static final UUID uuidSubtribe = UUID.fromString("ae41ecc5-5165-4126-9d24-79939ae5d822");
|
100
|
private static final UUID uuidInfratribe = UUID.fromString("1ec02e8f-f2b7-4c65-af9f-b436b34c79a3");
|
101
|
private static final UUID uuidSupragenericTaxon = UUID.fromString("1fdc0b93-c354-441a-8406-091e0303ff5c");
|
102
|
public static final UUID uuidGenus = UUID.fromString("1b11c34c-48a8-4efa-98d5-84f7f66ef43a");
|
103
|
private static final UUID uuidSubgenus = UUID.fromString("78786e16-2a70-48af-a608-494023b91904");
|
104
|
private static final UUID uuidInfragenus = UUID.fromString("a9972969-82cd-4d54-b693-a096422f13fa");
|
105
|
private static final UUID uuidSectionBotany = UUID.fromString("3edff68f-8527-49b5-bf91-7e4398bb975c");
|
106
|
private static final UUID uuidSubsectionBotany = UUID.fromString("d20f5b61-d463-4448-8f8a-c1ff1f262f59");
|
107
|
private static final UUID uuidSeries = UUID.fromString("d7381ecf-48f8-429b-9c54-f461656978cd");
|
108
|
private static final UUID uuidSubseries = UUID.fromString("80c9a263-f4db-4a13-b6c2-b7fec1aa1200");
|
109
|
private static final UUID uuidSpeciesAggregate = UUID.fromString("1ecae058-4217-4f75-9c27-6d8ba099ac7a");
|
110
|
private static final UUID uuidSpeciesGroup = UUID.fromString("d1988a11-292b-46fa-8fb7-bc64ea6d8fc6");
|
111
|
public static final UUID uuidInfragenericTaxon = UUID.fromString("41bcc6ac-37d3-4fd4-bb80-3cc5b04298b9");
|
112
|
public static final UUID uuidSpecies = UUID.fromString("b301f787-f319-4ccc-a10f-b4ed3b99a86d");
|
113
|
private static final UUID uuidSubspecificAggregate = UUID.fromString("72c248b9-027d-4402-b375-dd4f0850c9ad");
|
114
|
private static final UUID uuidSubspecies = UUID.fromString("462a7819-8b00-4190-8313-88b5be81fad5");
|
115
|
private static final UUID uuidInfraspecies = UUID.fromString("f28ebc9e-bd50-4194-9af1-42f5cb971a2c");
|
116
|
private static final UUID uuidNatio = UUID.fromString("965f2f38-7f97-4270-ab5a-1999bf050a22");
|
117
|
private static final UUID uuidVariety = UUID.fromString("d5feb6a5-af5c-45ef-9878-bb4f36aaf490");
|
118
|
private static final UUID uuidBioVariety = UUID.fromString("a3a364cb-1a92-43fc-a717-3c44980a0991");
|
119
|
private static final UUID uuidPathoVariety = UUID.fromString("2f4f4303-a099-47e3-9048-d749d735423b");
|
120
|
private static final UUID uuidSubvariety = UUID.fromString("9a83862a-7aee-480c-a98d-4bceaf8712ca");
|
121
|
private static final UUID uuidSubsubvariety = UUID.fromString("bff22f84-553a-4429-a4e7-c4b3796c3a18");
|
122
|
|
123
|
private static final UUID uuidProles = UUID.fromString("8810d1ba-6a34-4ae3-a355-919ccd1cd1a5");
|
124
|
private static final UUID uuidRace = UUID.fromString("196dee39-cfd8-4460-8bf0-88b83da27f62");
|
125
|
private static final UUID uuidSublusus = UUID.fromString("1fafa596-a8e7-4e62-a378-3cc8cb3627ca");
|
126
|
|
127
|
private static final UUID uuidConvar = UUID.fromString("2cc740c9-cebb-43c8-9b06-1bef79e6a56a");
|
128
|
private static final UUID uuidForm = UUID.fromString("0461281e-458a-47b9-8d41-19a3d39356d5");
|
129
|
private static final UUID uuidSpecialForm = UUID.fromString("bed20aee-2f5a-4635-9c02-eff06246d067");
|
130
|
private static final UUID uuidSubform = UUID.fromString("47cfc5b0-0fb7-4ceb-b61d-e1dd8de8b569");
|
131
|
private static final UUID uuidSubsubform = UUID.fromString("1c8ac389-4349-4ae0-87be-7239f6635068");
|
132
|
public static final UUID uuidInfraspecificTaxon = UUID.fromString("eb75c27d-e154-4570-9d96-227b2df60474");
|
133
|
private static final UUID uuidCandidate = UUID.fromString("ead9a1f5-dfd4-4de2-9121-70a47accb10b");
|
134
|
private static final UUID uuidDenominationClass = UUID.fromString("49bdf74a-2170-40ed-8be2-887a0db517bf");
|
135
|
private static final UUID uuidGrex = UUID.fromString("08dcb4ff-ac58-48a3-93af-efb3d836ac84");
|
136
|
private static final UUID uuidGraftChimaera = UUID.fromString("6b4063bc-f934-4796-9bf3-0ef3aea5c1cb");
|
137
|
private static final UUID uuidCultivarGroup = UUID.fromString("d763e7d3-e7de-4bb1-9d75-225ca6948659");
|
138
|
private static final UUID uuidCultivar = UUID.fromString("5e98415b-dc6e-440b-95d6-ea33dbb39ad0");
|
139
|
private static final UUID uuidUnknownRank = UUID.fromString("5c4d6755-2cf6-44ca-9220-cccf8881700b");
|
140
|
|
141
|
private static Map<String, UUID> idInVocMap = null;
|
142
|
private static Map<String, UUID> labelMap = null;
|
143
|
|
144
|
protected static Map<UUID, Rank> termMap = null;
|
145
|
|
146
|
//*********************** Factory methods ********************************************/
|
147
|
|
148
|
// /**
|
149
|
// * Creates a new empty rank.
|
150
|
// *
|
151
|
// * @see #NewInstance(String, String, String)
|
152
|
// */
|
153
|
// private static Rank NewInstance(){
|
154
|
// return new Rank();
|
155
|
// }
|
156
|
|
157
|
/**
|
158
|
* Creates an additional rank with a description (in the {@link Language#DEFAULT() default language}),
|
159
|
* a label and a label abbreviation.
|
160
|
*
|
161
|
* @param term the string (in the default language) describing the
|
162
|
* new rank to be created
|
163
|
* @param label the string identifying the new rank to be created
|
164
|
* @param labelAbbrev the string identifying (in abbreviated form) the
|
165
|
* new rank to be created
|
166
|
* @see #NewInstance()
|
167
|
*/
|
168
|
public static Rank NewInstance(RankClass rankClass, String term, String label, String labelAbbrev){
|
169
|
return new Rank(rankClass, term, label, labelAbbrev);
|
170
|
}
|
171
|
|
172
|
/**
|
173
|
* The {@link RankClass rank class} of a rank. It is usually needed for correct formatting of a
|
174
|
* rank by using e.g. isSupraGeneric(). Prior to v3.3 this was computed by comparison of ranks.
|
175
|
*/
|
176
|
@XmlAttribute(name ="RankClass")
|
177
|
@NotNull
|
178
|
@Type(type = "eu.etaxonomy.cdm.hibernate.EnumUserType",
|
179
|
parameters = {@org.hibernate.annotations.Parameter(name="enumClass", value="eu.etaxonomy.cdm.model.name.RankClass")}
|
180
|
)
|
181
|
@Audited
|
182
|
private RankClass rankClass;
|
183
|
|
184
|
|
185
|
//********************************** Constructor *********************************/
|
186
|
|
187
|
//for hibernate use only
|
188
|
@Deprecated
|
189
|
protected Rank() {
|
190
|
super(TermType.Rank);
|
191
|
}
|
192
|
|
193
|
/**
|
194
|
* Class constructor: creates an additional rank instance with a description
|
195
|
* (in the {@link eu.etaxonomy.cdm.model.common.Language#DEFAULT() default language}), a label and a label abbreviation.
|
196
|
*
|
197
|
* @param term the string (in the default language) describing the
|
198
|
* new rank to be created
|
199
|
* @param label the string identifying the new rank to be created
|
200
|
* @param labelAbbrev the string identifying (in abbreviated form) the
|
201
|
* new rank to be created
|
202
|
* @see #Rank()
|
203
|
*/
|
204
|
protected Rank(RankClass rankClass, String term, String label, String labelAbbrev) {
|
205
|
super(TermType.Rank, term, label, labelAbbrev);
|
206
|
this.rankClass = rankClass;
|
207
|
}
|
208
|
|
209
|
|
210
|
//********* METHODS **************************************/
|
211
|
|
212
|
/* (non-Javadoc)
|
213
|
* @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
|
214
|
*/
|
215
|
@Override
|
216
|
public void resetTerms(){
|
217
|
termMap = null;
|
218
|
}
|
219
|
|
220
|
|
221
|
|
222
|
protected static Rank getTermByUuid(UUID uuid){
|
223
|
if (termMap == null || termMap.isEmpty()){
|
224
|
return getTermByClassAndUUID(Rank.class, uuid);
|
225
|
} else {
|
226
|
return termMap.get(uuid);
|
227
|
}
|
228
|
}
|
229
|
|
230
|
public static final Rank EMPIRE(){
|
231
|
return getTermByUuid(uuidEmpire);
|
232
|
}
|
233
|
public static final Rank DOMAIN(){
|
234
|
return getTermByUuid(uuidDomain);
|
235
|
}
|
236
|
public static final Rank SUPERKINGDOM(){
|
237
|
return getTermByUuid(uuidSuperkingdom);
|
238
|
}
|
239
|
public static final Rank KINGDOM(){
|
240
|
return getTermByUuid(uuidKingdom);
|
241
|
}
|
242
|
public static final Rank SUBKINGDOM(){
|
243
|
return getTermByUuid(uuidSubkingdom);
|
244
|
}
|
245
|
public static final Rank INFRAKINGDOM(){
|
246
|
return getTermByUuid(uuidInfrakingdom);
|
247
|
}
|
248
|
public static final Rank SUPERPHYLUM(){
|
249
|
return getTermByUuid(uuidSuperphylum);
|
250
|
}
|
251
|
public static final Rank PHYLUM(){
|
252
|
return getTermByUuid(uuidPhylum);
|
253
|
}
|
254
|
public static final Rank SUBPHYLUM(){
|
255
|
return getTermByUuid(uuidSubphylum);
|
256
|
}
|
257
|
public static final Rank INFRAPHYLUM(){
|
258
|
return getTermByUuid(uuidInfraphylum);
|
259
|
}
|
260
|
public static final Rank SUPERDIVISION(){
|
261
|
return getTermByUuid(uuidSuperdivision);
|
262
|
}
|
263
|
public static final Rank DIVISION(){
|
264
|
return getTermByUuid(uuidDivision);
|
265
|
}
|
266
|
public static final Rank SUBDIVISION(){
|
267
|
return getTermByUuid(uuidSubdivision);
|
268
|
}
|
269
|
public static final Rank INFRADIVISION(){
|
270
|
return getTermByUuid(uuidInfradivision);
|
271
|
}
|
272
|
public static final Rank SUPERCLASS(){
|
273
|
return getTermByUuid(uuidSuperclass);
|
274
|
}
|
275
|
public static final Rank CLASS(){
|
276
|
return getTermByUuid(uuidClass);
|
277
|
}
|
278
|
public static final Rank SUBCLASS(){
|
279
|
return getTermByUuid(uuidSubclass);
|
280
|
}
|
281
|
public static final Rank INFRACLASS(){
|
282
|
return getTermByUuid(uuidInfraclass);
|
283
|
}
|
284
|
public static final Rank SUPERORDER(){
|
285
|
return getTermByUuid(uuidSuperorder);
|
286
|
}
|
287
|
public static final Rank ORDER(){
|
288
|
return getTermByUuid(uuidOrder);
|
289
|
}
|
290
|
public static final Rank SUBORDER(){
|
291
|
return getTermByUuid(uuidSuborder);
|
292
|
}
|
293
|
public static final Rank INFRAORDER(){
|
294
|
return getTermByUuid(uuidInfraorder);
|
295
|
}
|
296
|
public static final Rank SUPERFAMILY(){
|
297
|
return getTermByUuid(uuidSuperfamily);
|
298
|
}
|
299
|
public static final Rank FAMILY(){
|
300
|
return getTermByUuid(uuidFamily);
|
301
|
}
|
302
|
public static final Rank SUBFAMILY(){
|
303
|
return getTermByUuid(uuidSubfamily);
|
304
|
}
|
305
|
public static final Rank INFRAFAMILY(){
|
306
|
return getTermByUuid(uuidInfrafamily);
|
307
|
}
|
308
|
public static final Rank SUPERTRIBE(){
|
309
|
return getTermByUuid(uuidSupertribe);
|
310
|
}
|
311
|
public static final Rank TRIBE(){
|
312
|
return getTermByUuid(uuidTribe);
|
313
|
}
|
314
|
public static final Rank SUBTRIBE(){
|
315
|
return getTermByUuid(uuidSubtribe);
|
316
|
}
|
317
|
public static final Rank INFRATRIBE(){
|
318
|
return getTermByUuid(uuidInfratribe);
|
319
|
}
|
320
|
public static final Rank SUPRAGENERICTAXON(){
|
321
|
return getTermByUuid(uuidSupragenericTaxon);
|
322
|
}
|
323
|
public static final Rank GENUS(){
|
324
|
return getTermByUuid(uuidGenus);
|
325
|
}
|
326
|
public static final Rank SUBGENUS(){
|
327
|
return getTermByUuid(uuidSubgenus);
|
328
|
}
|
329
|
public static final Rank INFRAGENUS(){
|
330
|
return getTermByUuid(uuidInfragenus);
|
331
|
}
|
332
|
public static final Rank SECTION_BOTANY(){
|
333
|
return getTermByUuid(uuidSectionBotany);
|
334
|
}
|
335
|
public static final Rank SUBSECTION_BOTANY(){
|
336
|
return getTermByUuid(uuidSubsectionBotany);
|
337
|
}
|
338
|
public static final Rank SECTION_ZOOLOGY(){
|
339
|
return getTermByUuid(uuidSectionZoology);
|
340
|
}
|
341
|
public static final Rank SUBSECTION_ZOOLOGY(){
|
342
|
return getTermByUuid(uuidSubsectionZoology);
|
343
|
}
|
344
|
public static final Rank SERIES(){
|
345
|
return getTermByUuid(uuidSeries);
|
346
|
}
|
347
|
public static final Rank SUBSERIES(){
|
348
|
return getTermByUuid(uuidSubseries);
|
349
|
}
|
350
|
public static final Rank SPECIESAGGREGATE(){
|
351
|
return getTermByUuid(uuidSpeciesAggregate);
|
352
|
}
|
353
|
public static final Rank SPECIESGROUP(){
|
354
|
return getTermByUuid(uuidSpeciesGroup);
|
355
|
}
|
356
|
/**
|
357
|
* 'Unranked infrageneric'. An infrageneric rank which is on purpose not further defined.
|
358
|
* This sometimes holds for names from the 19th century.
|
359
|
*/
|
360
|
public static final Rank INFRAGENERICTAXON(){
|
361
|
return getTermByUuid(uuidInfragenericTaxon);
|
362
|
}
|
363
|
public static final Rank SPECIES(){
|
364
|
return getTermByUuid(uuidSpecies);
|
365
|
}
|
366
|
public static final Rank SUBSPECIFICAGGREGATE(){
|
367
|
return getTermByUuid(uuidSubspecificAggregate);
|
368
|
}
|
369
|
public static final Rank SUBSPECIES(){
|
370
|
return getTermByUuid(uuidSubspecies);
|
371
|
}
|
372
|
public static final Rank INFRASPECIES(){
|
373
|
return getTermByUuid(uuidInfraspecies);
|
374
|
}
|
375
|
public static final Rank VARIETY(){
|
376
|
return getTermByUuid(uuidVariety);
|
377
|
}
|
378
|
public static final Rank BIOVARIETY(){
|
379
|
return getTermByUuid(uuidBioVariety);
|
380
|
}
|
381
|
public static final Rank PATHOVARIETY(){
|
382
|
return getTermByUuid(uuidPathoVariety);
|
383
|
}
|
384
|
public static final Rank SUBVARIETY(){
|
385
|
return getTermByUuid(uuidSubvariety);
|
386
|
}
|
387
|
public static final Rank SUBSUBVARIETY(){
|
388
|
return getTermByUuid(uuidSubsubvariety );
|
389
|
}
|
390
|
public static final Rank PROLES(){
|
391
|
return getTermByUuid(uuidProles);
|
392
|
}
|
393
|
public static final Rank RACE(){
|
394
|
return getTermByUuid(uuidRace);
|
395
|
}
|
396
|
public static final Rank SUBLUSUS(){
|
397
|
return getTermByUuid(uuidSublusus);
|
398
|
}
|
399
|
|
400
|
public static final Rank CONVAR(){
|
401
|
return getTermByUuid(uuidConvar);
|
402
|
}
|
403
|
public static final Rank FORM(){
|
404
|
return getTermByUuid(uuidForm);
|
405
|
}
|
406
|
public static final Rank SPECIALFORM(){
|
407
|
return getTermByUuid(uuidSpecialForm);
|
408
|
}
|
409
|
public static final Rank SUBFORM(){
|
410
|
return getTermByUuid(uuidSubform);
|
411
|
}
|
412
|
public static final Rank SUBSUBFORM(){
|
413
|
return getTermByUuid(uuidSubsubform);
|
414
|
}
|
415
|
/**
|
416
|
* 'Unranked infraspecific'. An infraspecific rank which is on purpose not further defined.
|
417
|
* This sometimes holds for names from the 19th century.
|
418
|
*/
|
419
|
public static final Rank INFRASPECIFICTAXON(){
|
420
|
return getTermByUuid(uuidInfraspecificTaxon);
|
421
|
}
|
422
|
public static final Rank CANDIDATE(){
|
423
|
return getTermByUuid(uuidCandidate);
|
424
|
}
|
425
|
public static final Rank DENOMINATIONCLASS(){
|
426
|
return getTermByUuid(uuidDenominationClass);
|
427
|
}
|
428
|
public static final Rank GREX(){
|
429
|
return getTermByUuid(uuidGrex);
|
430
|
}
|
431
|
public static final Rank GRAFTCHIMAERA(){
|
432
|
return getTermByUuid(uuidGraftChimaera);
|
433
|
}
|
434
|
public static final Rank CULTIVARGROUP(){
|
435
|
return getTermByUuid(uuidCultivarGroup);
|
436
|
}
|
437
|
public static final Rank CULTIVAR(){
|
438
|
return getTermByUuid(uuidCultivar);
|
439
|
}
|
440
|
public static final Rank UNKNOWN_RANK(){
|
441
|
return getTermByUuid(uuidUnknownRank);
|
442
|
}
|
443
|
public static final Rank NATIO(){
|
444
|
return getTermByUuid(uuidNatio);
|
445
|
}
|
446
|
/**
|
447
|
* @see #INFRASPECIFICTAXON()
|
448
|
*/
|
449
|
public static final Rank UNRANKED_INFRASPECIFIC(){
|
450
|
return getTermByUuid(uuidInfraspecificTaxon);
|
451
|
}
|
452
|
/**
|
453
|
* @see #INFRAGENERICTAXON()
|
454
|
*/
|
455
|
public static final Rank UNRANKED_INFRAGENERIC(){
|
456
|
return getTermByUuid(uuidInfragenericTaxon);
|
457
|
}
|
458
|
|
459
|
// ************************ GETTER / SETTER **********************************/
|
460
|
|
461
|
public RankClass getRankClass() {
|
462
|
return rankClass;
|
463
|
}
|
464
|
|
465
|
public void setRankClass(RankClass rankClass) {
|
466
|
this.rankClass = rankClass;
|
467
|
}
|
468
|
|
469
|
// ******************************** METHODS ***************************************/
|
470
|
|
471
|
/**
|
472
|
* Returns the boolean value indicating whether <i>this</i> rank is higher than
|
473
|
* the genus rank (true) or not (false). Returns false if <i>this</i> rank is null.
|
474
|
*
|
475
|
* @see #isGenus()
|
476
|
* @see #isInfraGeneric()
|
477
|
* @see #isSpecies()
|
478
|
* @see #isInfraSpecific()
|
479
|
*/
|
480
|
@Transient
|
481
|
public boolean isSupraGeneric(){
|
482
|
return this.rankClass.equals(RankClass.Suprageneric); // (this.isHigher(Rank.GENUS()));
|
483
|
}
|
484
|
|
485
|
/**
|
486
|
* Returns the boolean value indicating whether <i>this</i> rank is the genus rank
|
487
|
* (true) or not (false). Returns false if <i>this</i> rank is null.
|
488
|
*
|
489
|
* @see #isSupraGeneric()
|
490
|
* @see #isInfraGeneric()
|
491
|
* @see #isSpecies()
|
492
|
* @see #isInfraSpecific()
|
493
|
*/
|
494
|
@Transient
|
495
|
public boolean isGenus(){
|
496
|
return this.rankClass.equals(RankClass.Genus); // (this.equals(Rank.GENUS()));
|
497
|
}
|
498
|
|
499
|
/**
|
500
|
* Returns the boolean value indicating whether <i>this</i> rank is higher than the
|
501
|
* species rank and lower than the genus rank (true) or not (false). Species groups or
|
502
|
* aggregates are also handled as infrageneric ranks.
|
503
|
* Returns false if <i>this</i> rank is null.
|
504
|
*
|
505
|
* @see #isSupraGeneric()
|
506
|
* @see #isGenus()
|
507
|
* @see #isSpeciesAggregate()
|
508
|
* @see #isSpecies()
|
509
|
* @see #isInfraSpecific()
|
510
|
*/
|
511
|
@Transient
|
512
|
public boolean isInfraGeneric(){
|
513
|
return this.rankClass.equals(RankClass.Infrageneric) || this.rankClass.equals(RankClass.SpeciesGroup) ; //(this.isLower(Rank.GENUS()) && this.isHigher(Rank.SPECIES()));
|
514
|
}
|
515
|
|
516
|
/**
|
517
|
* Returns true if this rank indicates a rank that aggregates species
|
518
|
* like species aggregates or species groups, false otherwise.
|
519
|
* @return
|
520
|
*/
|
521
|
@Transient
|
522
|
public boolean isSpeciesAggregate(){
|
523
|
return this.rankClass.equals(RankClass.SpeciesGroup); //(this.equals(Rank.SPECIESAGGREGATE()) || (this.isLower(Rank.SPECIESAGGREGATE()) && this.isHigher(Rank.SPECIES())));
|
524
|
}
|
525
|
|
526
|
/**
|
527
|
* Returns the boolean value indicating whether <i>this</i> rank is the species
|
528
|
* rank (true) or not (false). Returns false if <i>this</i> rank is null.
|
529
|
*
|
530
|
* @see #isSupraGeneric()
|
531
|
* @see #isGenus()
|
532
|
* @see #isInfraGeneric()
|
533
|
* @see #isInfraSpecific()
|
534
|
*/
|
535
|
@Transient
|
536
|
public boolean isSpecies(){
|
537
|
return this.rankClass.equals(RankClass.Species); //(this.equals(Rank.SPECIES()));
|
538
|
}
|
539
|
|
540
|
/**
|
541
|
* Returns the boolean value indicating whether <i>this</i> rank is lower than the
|
542
|
* species rank (true) or not (false). Returns false if <i>this</i> rank is null.
|
543
|
*
|
544
|
* @see #isSupraGeneric()
|
545
|
* @see #isGenus()
|
546
|
* @see #isInfraGeneric()
|
547
|
* @see #isSpecies()
|
548
|
*/
|
549
|
@Transient
|
550
|
public boolean isInfraSpecific(){
|
551
|
return this.rankClass.equals(RankClass.Infraspecific); // (this.isLower(Rank.SPECIES()));
|
552
|
}
|
553
|
|
554
|
|
555
|
/**
|
556
|
* Returns the rank identified through a label or the identifier within the vocabulary
|
557
|
* Preliminary implementation for BotanicalNameParser.
|
558
|
*
|
559
|
* @param strRank the string identifying the rank
|
560
|
* @return the rank
|
561
|
*/
|
562
|
public static Rank getRankByNameOrIdInVoc(String strRank) throws UnknownCdmTypeException{
|
563
|
return getRankByNameOrIdInVoc(strRank, false);
|
564
|
}
|
565
|
|
566
|
/**
|
567
|
* Returns the rank identified through a label or the identifier within the vocabulary
|
568
|
* for a given nomenclatural code.
|
569
|
* Preliminary implementation for BotanicalNameParser.
|
570
|
*
|
571
|
* @param strRank the string identifying the rank
|
572
|
* @param nc the nomenclatural code
|
573
|
* @return the rank
|
574
|
*/
|
575
|
public static Rank getRankByNameOrIdInVoc(String strRank, NomenclaturalCode nc) throws UnknownCdmTypeException{
|
576
|
return getRankByNameOrIdInVoc(strRank, nc, false);
|
577
|
}
|
578
|
|
579
|
// TODO
|
580
|
// Preliminary implementation for BotanicalNameParser.
|
581
|
// not yet complete
|
582
|
/**
|
583
|
* Returns the rank identified through a label or the identifier within the vocabulary.
|
584
|
* Preliminary implementation for BotanicalNameParser.
|
585
|
*
|
586
|
* @param strRank the string identifying the rank
|
587
|
* @param useUnknown if true the rank UNKNOWN_RANK is returned if the abbrev is
|
588
|
* unknown or not yet implemented
|
589
|
* @return the rank
|
590
|
*/
|
591
|
public static Rank getRankByNameOrIdInVoc(String strRank, boolean useUnknown) throws UnknownCdmTypeException{
|
592
|
try {
|
593
|
return getRankByIdInVoc(strRank);
|
594
|
} catch (UnknownCdmTypeException e) {
|
595
|
return getRankByName(strRank, useUnknown);
|
596
|
}
|
597
|
}
|
598
|
|
599
|
// TODO
|
600
|
// Preliminary implementation for BotanicalNameParser.
|
601
|
// not yet complete
|
602
|
/**
|
603
|
* Returns the rank identified through a label or the identifier within the vocabulary.
|
604
|
* Preliminary implementation for BotanicalNameParser.
|
605
|
*
|
606
|
* @param strRank the string identifying the rank
|
607
|
* @param nc the nomenclatural code
|
608
|
* @param useUnknown if true the rank UNKNOWN_RANK is returned if the abbrev is
|
609
|
* unknown or not yet implemented
|
610
|
* @return the rank
|
611
|
*/
|
612
|
public static Rank getRankByNameOrIdInVoc(String strRank, NomenclaturalCode nc, boolean useUnknown)
|
613
|
throws UnknownCdmTypeException{
|
614
|
try {
|
615
|
return getRankByIdInVoc(strRank, nc);
|
616
|
} catch (UnknownCdmTypeException e) {
|
617
|
return getRankByName(strRank, nc, useUnknown);
|
618
|
}
|
619
|
}
|
620
|
|
621
|
/**
|
622
|
* Returns the rank identified through the vocabulary identifier.
|
623
|
* Preliminary implementation for BotanicalNameParser.<BR>
|
624
|
* Note: For abbrev = "[unranked]" the result is undefined.
|
625
|
* It maybe the infrageneric unranked or the infraspecific unranked.
|
626
|
* You need to define by context which one is correct.
|
627
|
*
|
628
|
* @param abbrev the string for the name abbreviation
|
629
|
* @return the rank
|
630
|
*/
|
631
|
public static Rank getRankByIdInVoc(String abbrev) throws UnknownCdmTypeException{
|
632
|
return getRankByIdInVoc(abbrev, false);
|
633
|
}
|
634
|
|
635
|
/**
|
636
|
* Returns the rank identified through an abbreviated name for a given nomenclatural code.
|
637
|
* See also {@link #getRankByIdInVoc(String, boolean)}
|
638
|
*
|
639
|
* @param abbrev the string for the name abbreviation
|
640
|
* @param nc the nomenclatural code
|
641
|
* @return the rank
|
642
|
*/
|
643
|
public static Rank getRankByIdInVoc(String abbrev, NomenclaturalCode nc) throws UnknownCdmTypeException{
|
644
|
return getRankByIdInVoc(abbrev, nc, false);
|
645
|
}
|
646
|
|
647
|
// TODO
|
648
|
// Preliminary implementation for BotanicalNameParser.
|
649
|
// not yet complete
|
650
|
/**
|
651
|
* Returns the rank identified through an abbreviated representation.
|
652
|
* At the moment it uses the English abbreviations (being Latin because
|
653
|
* we do not have Latin representations yet.
|
654
|
* TODO
|
655
|
* If no according abbreviation is available it throws either an UnknownCdmTypeException
|
656
|
* or an #Rank.UNKNOWN() object depending on the useUnknown flag.
|
657
|
*
|
658
|
* @param idInVoc the string for the name abbreviation
|
659
|
* @param useUnknown if true the rank UNKNOWN_RANK is returned if the abbrev is
|
660
|
* unknown or not yet existent
|
661
|
* @return the rank
|
662
|
*/
|
663
|
public static Rank getRankByIdInVoc(String idInVoc, boolean useUnknown) throws UnknownCdmTypeException{
|
664
|
Rank result = null;
|
665
|
if (idInVoc == null){
|
666
|
throw new NullPointerException("idInVoc is NULL in getRankByIdInVoc");
|
667
|
}
|
668
|
if (StringUtils.isBlank(idInVoc)){
|
669
|
//handle empty idInVoc as unknown
|
670
|
idInVoc = "oijas34\u0155";
|
671
|
}
|
672
|
if (idInVocMap == null){
|
673
|
return null;
|
674
|
}
|
675
|
idInVoc = normalizeSectionAndSubsection(idInVoc);
|
676
|
idInVoc = normalizeSpecialForm(idInVoc);
|
677
|
UUID uuid = idInVocMap.get(idInVoc);
|
678
|
if (uuid != null ){
|
679
|
result = getTermByUuid(uuid);
|
680
|
}
|
681
|
if (result != null){
|
682
|
return result;
|
683
|
}else {
|
684
|
if (idInVoc == null){
|
685
|
idInVoc = "(null)";
|
686
|
}
|
687
|
if (useUnknown){
|
688
|
logger.info("Unknown rank name: " + idInVoc + ". Rank 'UNKNOWN_RANK' created instead");
|
689
|
return Rank.UNKNOWN_RANK();
|
690
|
}else{
|
691
|
throw new UnknownCdmTypeException("Unknown rank abbreviation: " + idInVoc);
|
692
|
}
|
693
|
}
|
694
|
}
|
695
|
|
696
|
private static String normalizeSectionAndSubsection(String idInVoc) {
|
697
|
if (idInVoc.equals("sect.")){
|
698
|
return "sect.(bot.)";
|
699
|
}else if (idInVoc.equals("subsect.")){
|
700
|
return "subsect.(bot.)";
|
701
|
}
|
702
|
return idInVoc;
|
703
|
}
|
704
|
|
705
|
private static String normalizeSpecialForm(String idInVoc) {
|
706
|
if (idInVoc.equals("f.sp.") || idInVoc.equals("f. sp.")){
|
707
|
return "f.spec.";
|
708
|
}
|
709
|
return idInVoc;
|
710
|
}
|
711
|
|
712
|
// TODO
|
713
|
// Preliminary implementation to cover Botany and Zoology.
|
714
|
/**
|
715
|
* Returns the rank identified through an abbreviated name for a given nomenclatural code.
|
716
|
* Preliminary implementation for ICBN and ICZN.
|
717
|
* See also {@link #getRankByIdInVoc(String, boolean)}
|
718
|
|
719
|
*
|
720
|
* @param abbrev the string for the name abbreviation
|
721
|
* @param nc the nomenclatural code
|
722
|
* @param useUnknown if true the rank UNKNOWN_RANK is returned if the abbrev is
|
723
|
* unknown or not yet implemented
|
724
|
* @return the rank
|
725
|
*/
|
726
|
public static Rank getRankByIdInVoc(String abbrev, NomenclaturalCode nc, boolean useUnknown)
|
727
|
throws UnknownCdmTypeException{
|
728
|
|
729
|
if (nc != null && nc.equals(NomenclaturalCode.ICZN)) {
|
730
|
if (abbrev != null){
|
731
|
if (abbrev.equalsIgnoreCase("sect.")) {
|
732
|
return Rank.SECTION_ZOOLOGY();
|
733
|
} else if (abbrev.equalsIgnoreCase("subsect.")) {
|
734
|
return Rank.SUBSECTION_ZOOLOGY();
|
735
|
}
|
736
|
}
|
737
|
}else if (nc != null && nc.equals(NomenclaturalCode.ICNAFP)) {
|
738
|
if (abbrev != null){
|
739
|
if (abbrev.equalsIgnoreCase("sect.")) {
|
740
|
return Rank.SECTION_BOTANY();
|
741
|
} else if (abbrev.equalsIgnoreCase("subsect.")) {
|
742
|
return Rank.SUBSECTION_BOTANY();
|
743
|
}
|
744
|
}
|
745
|
}
|
746
|
return getRankByIdInVoc(abbrev, useUnknown);
|
747
|
}
|
748
|
|
749
|
// TODO
|
750
|
// Preliminary implementation for BotanicalNameParser.
|
751
|
// not yet complete
|
752
|
/**
|
753
|
* Returns the rank identified through a name.
|
754
|
* Preliminary implementation for BotanicalNameParser.
|
755
|
*
|
756
|
* @param rankName the string for the name of the rank
|
757
|
* @return the rank
|
758
|
*/
|
759
|
public static Rank getRankByName(String rankName) throws UnknownCdmTypeException{
|
760
|
return getRankByName(rankName, false);
|
761
|
}
|
762
|
|
763
|
|
764
|
// TODO
|
765
|
// Preliminary implementation for ICBN and ICZN.
|
766
|
// not yet complete
|
767
|
/**
|
768
|
* Returns the rank identified through a name for a given nomenclatural code.
|
769
|
* Preliminary implementation for ICBN and ICZN.
|
770
|
*
|
771
|
* @param rankName the string for the name of the rank
|
772
|
* @param nc the nomenclatural code
|
773
|
* @return the rank
|
774
|
*/
|
775
|
public static Rank getRankByName(String rankName, NomenclaturalCode nc) throws UnknownCdmTypeException{
|
776
|
return getRankByName(rankName, nc, false);
|
777
|
}
|
778
|
|
779
|
/**
|
780
|
* Returns the rank identified through a name.
|
781
|
* Preliminary implementation for BotanicalNameParser.
|
782
|
* TODO At the moment we do not have Latin representations yet.
|
783
|
*
|
784
|
* @param rankName the string for the name of the rank
|
785
|
* @param useUnknown if true the rank UNKNOWN_RANK is returned if the rank name is
|
786
|
* unknown or not yet implemented
|
787
|
* @return the rank
|
788
|
*/
|
789
|
public static Rank getRankByName(String rankName, boolean useUnknown)
|
790
|
throws UnknownCdmTypeException{
|
791
|
if (rankName.equalsIgnoreCase("Regnum")){ return Rank.KINGDOM();
|
792
|
}else if (rankName.equalsIgnoreCase("Subregnum")){ return Rank.SUBKINGDOM();
|
793
|
}else if (rankName.equalsIgnoreCase("Phylum")){ return Rank.PHYLUM();
|
794
|
}else if (rankName.equalsIgnoreCase("Subphylum")){ return Rank.SUBPHYLUM();
|
795
|
}else if (rankName.equalsIgnoreCase("Divisio")){ return Rank.DIVISION();
|
796
|
}else if (rankName.equalsIgnoreCase("Subdivisio")){ return Rank.SUBDIVISION();
|
797
|
}else if (rankName.equalsIgnoreCase("Classis")){ return Rank.CLASS();
|
798
|
}else if (rankName.equalsIgnoreCase("Subclassis")){ return Rank.SUBCLASS();
|
799
|
}else if (rankName.equalsIgnoreCase("Superordo")){ return Rank.SUPERORDER();
|
800
|
}else if (rankName.equalsIgnoreCase("Ordo")){ return Rank.ORDER();
|
801
|
}else if (rankName.equalsIgnoreCase("Subordo")){ return Rank.SUBORDER();
|
802
|
}else if (rankName.equalsIgnoreCase("Familia")){ return Rank.FAMILY();
|
803
|
}else if (rankName.equalsIgnoreCase("Subfamilia")){ return Rank.SUBFAMILY();
|
804
|
}else if (rankName.equalsIgnoreCase("Tribus")){ return Rank.TRIBE();
|
805
|
}else if (rankName.equalsIgnoreCase("Subtribus")){ return Rank.SUBTRIBE();
|
806
|
}else if (rankName.equalsIgnoreCase("Genus")){ return Rank.GENUS();
|
807
|
}else if (rankName.equalsIgnoreCase("Subgenus")){ return Rank.SUBGENUS();
|
808
|
}else if (rankName.equalsIgnoreCase("Sectio")){ return Rank.SECTION_BOTANY();
|
809
|
}else if (rankName.equalsIgnoreCase("Subsectio")){ return Rank.SUBSECTION_BOTANY();
|
810
|
}else if (rankName.equalsIgnoreCase("Series")){ return Rank.SERIES();
|
811
|
}else if (rankName.equalsIgnoreCase("Subseries")){ return Rank.SUBSERIES();
|
812
|
}else if (rankName.equalsIgnoreCase("Aggregate")){ return Rank.SPECIESAGGREGATE();
|
813
|
}else if (rankName.equalsIgnoreCase("Speciesgroup")){ return Rank.SPECIESGROUP();
|
814
|
}else if (rankName.equalsIgnoreCase("Species")){ return Rank.SPECIES();
|
815
|
}else if (rankName.equalsIgnoreCase("Subspecies")){ return Rank.SUBSPECIES();
|
816
|
}else if (rankName.equalsIgnoreCase("Convarietas")){ return Rank.CONVAR();
|
817
|
}else if (rankName.equalsIgnoreCase("Varietas")){ return Rank.VARIETY();
|
818
|
}else if (rankName.equalsIgnoreCase("Subvarietas")){ return Rank.SUBVARIETY();
|
819
|
}else if (rankName.equalsIgnoreCase("Forma")){ return Rank.FORM();
|
820
|
}else if (rankName.equalsIgnoreCase("Subforma")){ return Rank.SUBFORM();
|
821
|
}else if (rankName.equalsIgnoreCase("Forma spec.")){ return Rank.SPECIALFORM();
|
822
|
}else if (rankName.equalsIgnoreCase("tax.infragen.")){ return Rank.INFRAGENERICTAXON();
|
823
|
}else if (rankName.equalsIgnoreCase("tax.infrasp.")){ return Rank.INFRASPECIFICTAXON();
|
824
|
// old ranks
|
825
|
}else if (rankName.equalsIgnoreCase("proles")){ return Rank.PROLES();
|
826
|
}else if (rankName.equalsIgnoreCase("race")){ return Rank.RACE();
|
827
|
}else if (rankName.equalsIgnoreCase("sublusus")){ return Rank.SUBLUSUS();
|
828
|
|
829
|
}else if (rankName.equalsIgnoreCase("taxon")){ return Rank.INFRASPECIFICTAXON(); //to create the name put 'taxon' and the infraspeciesepi to the field unnamed namephrase
|
830
|
|
831
|
}else{
|
832
|
if (rankName == null){
|
833
|
rankName = "(null)"; //see NPE above
|
834
|
}
|
835
|
if (useUnknown){
|
836
|
if (logger.isInfoEnabled()){logger.info("Unknown rank name: " + rankName+". Rank 'UNKNOWN_RANK' created instead");}
|
837
|
return Rank.UNKNOWN_RANK();
|
838
|
}else{
|
839
|
throw new UnknownCdmTypeException("Unknown rank name: " + rankName);
|
840
|
}
|
841
|
}
|
842
|
}
|
843
|
|
844
|
/**
|
845
|
* Defines the rank according to the English name.
|
846
|
* @param rankName English rank name.
|
847
|
* @param nc Defines the handling of the section and subsection ranks. These are in different orders depending on the
|
848
|
* nomenclatural code.
|
849
|
* @param useUnknown if true, the "Unknown" rank is returned as a placeholder.
|
850
|
* @return
|
851
|
* @throws UnknownCdmTypeException never thrown if useUnknown is true
|
852
|
*/
|
853
|
public static Rank getRankByEnglishName(String rankName, NomenclaturalCode nc, boolean useUnknown) throws UnknownCdmTypeException{
|
854
|
Rank result = null;
|
855
|
if (rankName == null){
|
856
|
throw new NullPointerException("Abbrev is NULL in getRankByAbbreviation");
|
857
|
}
|
858
|
if (labelMap == null){
|
859
|
return null;
|
860
|
}
|
861
|
//handle section and subsection (not unique representations)
|
862
|
if (rankName.equalsIgnoreCase("Section")){
|
863
|
if (nc != null && nc.equals(NomenclaturalCode.ICZN)){ return Rank.SECTION_ZOOLOGY();
|
864
|
}else if (nc != null && nc.equals(NomenclaturalCode.ICNAFP)){return Rank.SECTION_BOTANY();
|
865
|
}else{
|
866
|
String errorWarning = "Section is only defined for ICZN and ICNAFP at the moment but here needed for " + ((nc == null)? "(null)": nc.toString());
|
867
|
logger.warn(errorWarning);
|
868
|
throw new UnknownCdmTypeException (errorWarning);
|
869
|
}
|
870
|
}else if (rankName.equalsIgnoreCase("Subsection")){
|
871
|
if (nc != null && nc.equals(NomenclaturalCode.ICZN)){ return Rank.SUBSECTION_ZOOLOGY();
|
872
|
}else if (nc != null && nc.equals(NomenclaturalCode.ICNAFP)){ return Rank.SUBSECTION_BOTANY();
|
873
|
}else{
|
874
|
String errorWarning = "Subsection is only defined for ICZN and ICBN at the moment but here needed for " + ((nc == null)? "(null)": nc.toString());
|
875
|
logger.warn(errorWarning);
|
876
|
throw new UnknownCdmTypeException (errorWarning);
|
877
|
}
|
878
|
}
|
879
|
|
880
|
rankName = rankName.toLowerCase();
|
881
|
|
882
|
UUID uuid = labelMap.get(rankName);
|
883
|
if (uuid != null ){
|
884
|
result = getTermByUuid(uuid);
|
885
|
}
|
886
|
if (result != null){
|
887
|
return result;
|
888
|
}else {
|
889
|
if (rankName == null){
|
890
|
rankName = "(null)";
|
891
|
}
|
892
|
if (useUnknown){
|
893
|
if (logger.isInfoEnabled()){logger.info("Unknown rank name: " + rankName + ". Rank 'UNKNOWN_RANK' created instead");}
|
894
|
return Rank.UNKNOWN_RANK();
|
895
|
}else{
|
896
|
throw new UnknownCdmTypeException("Unknown rank: " + rankName);
|
897
|
}
|
898
|
}
|
899
|
}
|
900
|
|
901
|
|
902
|
public static Rank getRankByName(String rankName, NomenclaturalCode nc, boolean useUnknown)
|
903
|
throws UnknownCdmTypeException {
|
904
|
|
905
|
if (nc.equals(NomenclaturalCode.ICZN)) {
|
906
|
if (rankName.equalsIgnoreCase("Sectio")) { return Rank.SECTION_ZOOLOGY();
|
907
|
}else if (rankName.equalsIgnoreCase("Subsectio")) { return Rank.SUBSECTION_ZOOLOGY();
|
908
|
}
|
909
|
}
|
910
|
return getRankByName(rankName, useUnknown);
|
911
|
}
|
912
|
|
913
|
/**
|
914
|
* Returns the abbreviated rank name for <i>this</i> rank according to the English representation
|
915
|
* abbreviated label.
|
916
|
* TODO Needs to be changed to Latin as soon as Latin representations are available.
|
917
|
*
|
918
|
* @return the abbreviation string for <i>this</i> rank
|
919
|
*/
|
920
|
public String getAbbreviation(){
|
921
|
Language language = Language.getLanguageFromUuid(Language.uuidEnglish);
|
922
|
String result = this.getRepresentation(language).getAbbreviatedLabel();
|
923
|
if (result== null) {
|
924
|
logger.warn("Abbreviation for this Rank " + this.toString() + " not yet implemented");
|
925
|
return "no abbreviation available.";
|
926
|
}else{
|
927
|
return result;
|
928
|
}
|
929
|
}
|
930
|
@Transient
|
931
|
public String getInfraGenericMarker() throws UnknownCdmTypeException{
|
932
|
String result = null;
|
933
|
if (! this.isInfraGeneric()){
|
934
|
throw new IllegalStateException("An infrageneric marker is only available for a infrageneric rank but was asked for rank: " + this.toString());
|
935
|
}else{
|
936
|
result = this.getAbbreviation();
|
937
|
}
|
938
|
if (result == null){
|
939
|
throw new UnknownCdmTypeException("Abbreviation for rank unknown: " + this.toString());
|
940
|
}
|
941
|
return result;
|
942
|
}
|
943
|
|
944
|
|
945
|
|
946
|
@Override
|
947
|
public Rank readCsvLine(Class<Rank> termClass, List<String> csvLine, Map<UUID, DefinedTermBase> terms, boolean abbrevAsId) {
|
948
|
Rank rank = super.readCsvLine(termClass, csvLine, terms, abbrevAsId);
|
949
|
RankClass rankClass = RankClass.getByKey(csvLine.get(5));
|
950
|
assert rankClass != null: "XXXXXXXXXXXXXXXXXXXXX Rank class must not be null: " + csvLine ;
|
951
|
rank.setRankClass(rankClass);
|
952
|
return rank;
|
953
|
}
|
954
|
|
955
|
@Override
|
956
|
protected void setDefaultTerms(TermVocabulary<Rank> termVocabulary) {
|
957
|
termMap = new HashMap<UUID, Rank>();
|
958
|
for (Rank term : termVocabulary.getTerms()){
|
959
|
termMap.put(term.getUuid(), term);
|
960
|
addRank(term);
|
961
|
}
|
962
|
}
|
963
|
|
964
|
/**
|
965
|
* @param term
|
966
|
*/
|
967
|
private void addRank(Rank rank) {
|
968
|
if (rank == null){
|
969
|
logger.warn("rank is NULL");
|
970
|
return;
|
971
|
}
|
972
|
if (rank.getUuid().equals(uuidSectionZoology) || rank.getUuid().equals(uuidSubsectionZoology )){
|
973
|
//sect./subsect. is used for botanical sections, see also #getRankByAbbreviation(String, NomenclaturalCode, boolean)
|
974
|
return;
|
975
|
}
|
976
|
Language lang = Language.DEFAULT(); //TODO should be Latin but at the moment we have only English representations
|
977
|
Representation representation = rank.getRepresentation(lang);
|
978
|
String abbrevLabel = representation.getAbbreviatedLabel();
|
979
|
String label = representation.getLabel();
|
980
|
|
981
|
//initialize maps
|
982
|
if (idInVocMap == null){
|
983
|
idInVocMap = new HashMap<String, UUID>();
|
984
|
}
|
985
|
if (labelMap == null){
|
986
|
labelMap = new HashMap<String, UUID>();
|
987
|
}
|
988
|
labelMap.put(label.toLowerCase(), rank.getUuid());
|
989
|
//add to map
|
990
|
if (StringUtils.isBlank(abbrevLabel)){
|
991
|
if (logger.isDebugEnabled()){logger.info("Abbreviated label for rank is NULL or empty.Can't add rank to abbrevLabel map: " + CdmUtils.Nz(rank.getLabel()));}
|
992
|
}else{
|
993
|
idInVocMap.put(abbrevLabel, rank.getUuid());
|
994
|
}
|
995
|
}
|
996
|
|
997
|
|
998
|
/**
|
999
|
* It is necessary to skip the vocabulary check, otherwise we would have
|
1000
|
* problems in some CacheStrategies, due to uninitialized Vocabularies.
|
1001
|
*
|
1002
|
* @see eu.etaxonomy.cdm.model.common.OrderedTermBase#compareTo(eu.etaxonomy.cdm.model.common.OrderedTermBase)
|
1003
|
*/
|
1004
|
@Override
|
1005
|
public int compareTo(Rank orderedTerm) {
|
1006
|
return performCompareTo(orderedTerm, true);
|
1007
|
}
|
1008
|
|
1009
|
}
|