(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / Rank.java
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 javax.xml.bind.annotation.XmlAccessType;
13 import javax.xml.bind.annotation.XmlAccessorType;
14 import javax.xml.bind.annotation.XmlType;
15 import eu.etaxonomy.cdm.model.common.OrderedTermBase;
16 import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
17
18 import org.apache.log4j.Logger;
19
20 import java.util.*;
21
22 import javax.persistence.*;
23
24 /**
25 * The class representing the taxonomical ranks (like "Family", "Genus" or
26 * "Species") used for {@link TaxonNameBase taxon names} across all {@link NomenclaturalCode nomenclatural codes}
27 * for bacteria (ICNB), viruses (ICVCN), plants and fungi (ICBN),
28 * cultivars (ICNCP) and animals (ICZN).
29 * <P>
30 * A standard (ordered) list of taxonomical rank instances will be automatically
31 * created as the project starts. But this class allows to extend this standard
32 * list by creating new instances of additional taxonomical ranks if needed.
33 * <P>
34 * This class corresponds to: <ul>
35 * <li> TaxonRankTerm according to the TDWG ontology
36 * <li> TaxonomicRankEnum according to the TCS
37 * <li> Rank according to the ABCD schema
38 * </ul>
39 *
40 * @author m.doering
41 * @version 1.0
42 * @created 08-Nov-2007 13:06:46
43 */
44 @XmlAccessorType(XmlAccessType.FIELD)
45 @XmlType(name = "Rank")
46 @Entity
47 public class Rank extends OrderedTermBase<Rank> {
48 private static final Logger logger = Logger.getLogger(Rank.class);
49
50 private static final UUID uuidEmpire = UUID.fromString("ac470211-1586-4b24-95ca-1038050b618d");
51 private static final UUID uuidDomain = UUID.fromString("ffca6ec8-8b88-417b-a6a0-f7c992aac19b");
52 private static final UUID uuidSuperkingdom = UUID.fromString("64223610-7625-4cfd-83ad-b797bf7f0edd");
53 private static final UUID uuidKingdom = UUID.fromString("fbe7109d-66b3-498c-a697-c6c49c686162");
54 private static final UUID uuidSubkingdom = UUID.fromString("a71bd9d8-f3ab-4083-afb5-d89315d71655");
55 private static final UUID uuidInfrakingdom = UUID.fromString("1e37930c-86cf-44f6-90fd-7822928df260");
56 private static final UUID uuidSuperphylum = UUID.fromString("0d0cecb1-e254-4607-b210-6801e7ecbb04");
57 private static final UUID uuidPhylum = UUID.fromString("773430d2-76b4-438c-b817-97a543a33287");
58 private static final UUID uuidSubphylum = UUID.fromString("23a9b6ff-9408-49c9-bd9e-7a2ca5ab4725");
59 private static final UUID uuidInfraphylum = UUID.fromString("1701de3a-7693-42a5-a2d3-42697f944190");
60 private static final UUID uuidSuperdivision = UUID.fromString("a735a48f-4fc8-49a7-ae0c-6a984f658131");
61 private static final UUID uuidDivision = UUID.fromString("7e56f5cc-123a-4fd1-8cbb-6fd80358b581");
62 private static final UUID uuidSubdivision = UUID.fromString("931c840f-7a6b-4d76-ad38-bfdd77d7b2e8");
63 private static final UUID uuidInfradivision = UUID.fromString("c0ede273-be52-4dee-b411-66ee08d30c94");
64 private static final UUID uuidSuperclass = UUID.fromString("e65b4e1a-21ec-428d-9b9f-e87721ab967c");
65 private static final UUID uuidClass = UUID.fromString("f23d14c4-1d34-4ee6-8b4e-eee2eb9a3daf");
66 private static final UUID uuidSubclass = UUID.fromString("8cb26733-e2f5-46cb-ab5c-f99254f877aa");
67 private static final UUID uuidInfraclass = UUID.fromString("ad23cfda-879a-4021-8629-c54d27caf717");
68 private static final UUID uuidSuperorder = UUID.fromString("c8c67a22-301a-4219-b882-4a49121232ff");
69 private static final UUID uuidOrder = UUID.fromString("b0785a65-c1c1-4eb4-88c7-dbd3df5aaad1");
70 private static final UUID uuidSuborder = UUID.fromString("768ad378-fa85-42ab-b668-763225832f57");
71 private static final UUID uuidInfraorder = UUID.fromString("84099182-a6f5-47d7-8586-33c9e9955a10");
72 private static final UUID uuidSuperfamily = UUID.fromString("2cfa510a-dcea-4a03-b66a-b1528f9b0796");
73 private static final UUID uuidFamily = UUID.fromString("af5f2481-3192-403f-ae65-7c957a0f02b6");
74 private static final UUID uuidSubfamily = UUID.fromString("862526ee-7592-4760-a23a-4ff3641541c5");
75 private static final UUID uuidInfrafamily = UUID.fromString("c3f2e3bb-6eef-4a26-9fb7-b14f4c8c5e4f");
76 private static final UUID uuidSupertribe = UUID.fromString("11e94828-8c61-499b-87d6-1de35ce2c51c");
77 private static final UUID uuidTribe = UUID.fromString("4aa6890b-0363-4899-8d7c-ee0cb78e6166");
78 private static final UUID uuidSubtribe = UUID.fromString("ae41ecc5-5165-4126-9d24-79939ae5d822");
79 private static final UUID uuidInfratribe = UUID.fromString("1ec02e8f-f2b7-4c65-af9f-b436b34c79a3");
80 private static final UUID uuidSupragenericTaxon = UUID.fromString("1fdc0b93-c354-441a-8406-091e0303ff5c");
81 private static final UUID uuidGenus = UUID.fromString("1b11c34c-48a8-4efa-98d5-84f7f66ef43a");
82 private static final UUID uuidSubgenus = UUID.fromString("78786e16-2a70-48af-a608-494023b91904");
83 private static final UUID uuidInfragenus = UUID.fromString("a9972969-82cd-4d54-b693-a096422f13fa");
84 private static final UUID uuidSection = UUID.fromString("3edff68f-8527-49b5-bf91-7e4398bb975c");
85 private static final UUID uuidSubsection = UUID.fromString("d20f5b61-d463-4448-8f8a-c1ff1f262f59");
86 private static final UUID uuidSeries = UUID.fromString("d7381ecf-48f8-429b-9c54-f461656978cd");
87 private static final UUID uuidSubseries = UUID.fromString("80c9a263-f4db-4a13-b6c2-b7fec1aa1200");
88 private static final UUID uuidSpeciesAggregate = UUID.fromString("1ecae058-4217-4f75-9c27-6d8ba099ac7a");
89 private static final UUID uuidInfragenericTaxon = UUID.fromString("41bcc6ac-37d3-4fd4-bb80-3cc5b04298b9");
90 private static final UUID uuidSpecies = UUID.fromString("b301f787-f319-4ccc-a10f-b4ed3b99a86d");
91 private static final UUID uuidSubspecificAggregate = UUID.fromString("72c248b9-027d-4402-b375-dd4f0850c9ad");
92 private static final UUID uuidSubspecies = UUID.fromString("462a7819-8b00-4190-8313-88b5be81fad5");
93 private static final UUID uuidInfraspecies = UUID.fromString("f28ebc9e-bd50-4194-9af1-42f5cb971a2c");
94 private static final UUID uuidVariety = UUID.fromString("d5feb6a5-af5c-45ef-9878-bb4f36aaf490");
95 private static final UUID uuidBioVariety = UUID.fromString("a3a364cb-1a92-43fc-a717-3c44980a0991");
96 private static final UUID uuidPathoVariety = UUID.fromString("2f4f4303-a099-47e3-9048-d749d735423b");
97 private static final UUID uuidSubvariety = UUID.fromString("9a83862a-7aee-480c-a98d-4bceaf8712ca");
98 private static final UUID uuidSubsubvariety = UUID.fromString("bff22f84-553a-4429-a4e7-c4b3796c3a18");
99 private static final UUID uuidConvar = UUID.fromString("2cc740c9-cebb-43c8-9b06-1bef79e6a56a");
100 private static final UUID uuidForm = UUID.fromString("0461281e-458a-47b9-8d41-19a3d39356d5");
101 private static final UUID uuidSpecialForm = UUID.fromString("bed20aee-2f5a-4635-9c02-eff06246d067");
102 private static final UUID uuidSubform = UUID.fromString("47cfc5b0-0fb7-4ceb-b61d-e1dd8de8b569");
103 private static final UUID uuidSubsubform = UUID.fromString("1c8ac389-4349-4ae0-87be-7239f6635068");
104 private static final UUID uuidInfraspecificTaxon = UUID.fromString("eb75c27d-e154-4570-9d96-227b2df60474");
105 private static final UUID uuidCandidate = UUID.fromString("ead9a1f5-dfd4-4de2-9121-70a47accb10b");
106 private static final UUID uuidDenominationClass = UUID.fromString("49bdf74a-2170-40ed-8be2-887a0db517bf");
107 private static final UUID uuidGrex = UUID.fromString("08dcb4ff-ac58-48a3-93af-efb3d836ac84");
108 private static final UUID uuidGraftChimaera = UUID.fromString("6b4063bc-f934-4796-9bf3-0ef3aea5c1cb");
109 private static final UUID uuidCultivarGroup = UUID.fromString("d763e7d3-e7de-4bb1-9d75-225ca6948659");
110 private static final UUID uuidCultivar = UUID.fromString("5e98415b-dc6e-440b-95d6-ea33dbb39ad0");
111 private static final UUID uuidUnknownRank = UUID.fromString("5c4d6755-2cf6-44ca-9220-cccf8881700b");
112
113 // ************* CONSTRUCTORS *************/
114 /**
115 * Class constructor: creates a new empty rank instance.
116 *
117 * @see #Rank(String, String, String)
118 */
119 public Rank() {
120 super();
121 }
122
123 /**
124 * Class constructor: creates an additional rank instance with a description
125 * (in the {@link eu.etaxonomy.cdm.model.common.Language#DEFAULT() default language}), a label and a label abbreviation.
126 *
127 * @param term the string (in the default language) describing the
128 * new rank to be created
129 * @param label the string identifying the new rank to be created
130 * @param labelAbbrev the string identifying (in abbreviated form) the
131 * new rank to be created
132 * @see #Rank()
133 */
134 public Rank(String term, String label, String labelAbbrev) {
135 super(term, label, labelAbbrev);
136 }
137
138 //********* METHODS **************************************/
139
140 /**
141 * Returns the taxonomical rank identified through its immutable universally
142 * unique identifier (UUID).
143 *
144 * @param uuid the universally unique identifier
145 * @return the rank corresponding to the given universally unique
146 * identifier
147 */
148 public static final Rank getByUuid(UUID uuid){
149 return (Rank) findByUuid(uuid);
150 }
151
152 public static final Rank EMPIRE(){
153 return getByUuid(uuidEmpire);
154 }
155 public static final Rank DOMAIN(){
156 return getByUuid(uuidDomain);
157 }
158 public static final Rank SUPERKINGDOM(){
159 return getByUuid(uuidSuperkingdom);
160 }
161 public static final Rank KINGDOM(){
162 return getByUuid(uuidKingdom);
163 }
164 public static final Rank SUBKINGDOM(){
165 return getByUuid(uuidSubkingdom);
166 }
167 public static final Rank INFRAKINGDOM(){
168 return getByUuid(uuidInfrakingdom);
169 }
170 public static final Rank SUPERPHYLUM(){
171 return getByUuid(uuidSuperphylum);
172 }
173 public static final Rank PHYLUM(){
174 return getByUuid(uuidPhylum);
175 }
176 public static final Rank SUBPHYLUM(){
177 return getByUuid(uuidSubphylum);
178 }
179 public static final Rank INFRAPHYLUM(){
180 return getByUuid(uuidInfraphylum);
181 }
182 public static final Rank SUPERDIVISION(){
183 return getByUuid(uuidSuperdivision);
184 }
185 public static final Rank DIVISION(){
186 return getByUuid(uuidDivision);
187 }
188 public static final Rank SUBDIVISION(){
189 return getByUuid(uuidSubdivision);
190 }
191 public static final Rank INFRADIVISION(){
192 return getByUuid(uuidInfradivision);
193 }
194 public static final Rank SUPERCLASS(){
195 return getByUuid(uuidSuperclass);
196 }
197 public static final Rank CLASS(){
198 return getByUuid(uuidClass);
199 }
200 public static final Rank SUBCLASS(){
201 return getByUuid(uuidSubclass);
202 }
203 public static final Rank INFRACLASS(){
204 return getByUuid(uuidInfraclass);
205 }
206 public static final Rank SUPERORDER(){
207 return getByUuid(uuidSuperorder);
208 }
209 public static final Rank ORDER(){
210 return getByUuid(uuidOrder);
211 }
212 public static final Rank SUBORDER(){
213 return getByUuid(uuidSuborder);
214 }
215 public static final Rank INFRAORDER(){
216 return getByUuid(uuidInfraorder);
217 }
218 public static final Rank SUPERFAMILY(){
219 return getByUuid(uuidSuperfamily);
220 }
221 public static final Rank FAMILY(){
222 return getByUuid(uuidFamily);
223 }
224 public static final Rank SUBFAMILY(){
225 return getByUuid(uuidSubfamily);
226 }
227 public static final Rank INFRAFAMILY(){
228 return getByUuid(uuidInfrafamily);
229 }
230 public static final Rank SUPERTRIBE(){
231 return getByUuid(uuidSupertribe);
232 }
233 public static final Rank TRIBE(){
234 return getByUuid(uuidTribe);
235 }
236 public static final Rank SUBTRIBE(){
237 return getByUuid(uuidSubtribe);
238 }
239 public static final Rank INFRATRIBE(){
240 return getByUuid(uuidInfratribe);
241 }
242 public static final Rank SUPRAGENERICTAXON(){
243 return getByUuid(uuidSupragenericTaxon);
244 }
245 public static final Rank GENUS(){
246 return getByUuid(uuidGenus);
247 }
248 public static final Rank SUBGENUS(){
249 return getByUuid(uuidSubgenus);
250 }
251 public static final Rank INFRAGENUS(){
252 return getByUuid(uuidInfragenus);
253 }
254 public static final Rank SECTION(){
255 return getByUuid(uuidSection);
256 }
257 public static final Rank SUBSECTION(){
258 return getByUuid(uuidSubsection);
259 }
260 public static final Rank SERIES(){
261 return getByUuid(uuidSeries);
262 }
263 public static final Rank SUBSERIES(){
264 return getByUuid(uuidSubseries);
265 }
266 public static final Rank SPECIESAGGREGATE(){
267 return getByUuid(uuidSpeciesAggregate);
268 }
269 public static final Rank INFRAGENERICTAXON(){
270 return getByUuid(uuidInfragenericTaxon);
271 }
272 public static final Rank SPECIES(){
273 return getByUuid(uuidSpecies);
274 }
275 public static final Rank SUBSPECIFICAGGREGATE(){
276 return getByUuid(uuidSubspecificAggregate);
277 }
278 public static final Rank SUBSPECIES(){
279 return getByUuid(uuidSubspecies);
280 }
281 public static final Rank INFRASPECIES(){
282 return getByUuid(uuidInfraspecies);
283 }
284 public static final Rank VARIETY(){
285 return getByUuid(uuidVariety);
286 }
287 public static final Rank BIOVARIETY(){
288 return getByUuid(uuidBioVariety);
289 }
290 public static final Rank PATHOVARIETY(){
291 return getByUuid(uuidPathoVariety);
292 }
293 public static final Rank SUBVARIETY(){
294 return getByUuid(uuidSubvariety);
295 }
296 public static final Rank SUBSUBVARIETY(){
297 return getByUuid(uuidSubsubvariety);
298 }
299 public static final Rank CONVAR(){
300 return getByUuid(uuidConvar);
301 }
302 public static final Rank FORM(){
303 return getByUuid(uuidForm);
304 }
305 public static final Rank SPECIALFORM(){
306 return getByUuid(uuidSpecialForm);
307 }
308 public static final Rank SUBFORM(){
309 return getByUuid(uuidSubform);
310 }
311 public static final Rank SUBSUBFORM(){
312 return getByUuid(uuidSubsubform);
313 }
314 public static final Rank INFRASPECIFICTAXON(){
315 return getByUuid(uuidInfraspecificTaxon);
316 }
317 public static final Rank CANDIDATE(){
318 return getByUuid(uuidCandidate);
319 }
320 public static final Rank DENOMINATIONCLASS(){
321 return getByUuid(uuidDenominationClass);
322 }
323 public static final Rank GREX(){
324 return getByUuid(uuidGrex);
325 }
326 public static final Rank GRAFTCHIMAERA(){
327 return getByUuid(uuidGraftChimaera);
328 }
329 public static final Rank CULTIVARGROUP(){
330 return getByUuid(uuidCultivarGroup);
331 }
332 public static final Rank CULTIVAR(){
333 return getByUuid(uuidCultivar);
334 }
335 public static final Rank UNKNOWN_RANK(){
336 return getByUuid(uuidUnknownRank);
337 }
338
339
340
341
342 /**
343 * Returns the boolean value indicating whether <i>this</i> rank is higher than
344 * the genus rank (true) or not (false). Returns false if <i>this</i> rank is null.
345 *
346 * @see #isGenus()
347 * @see #isInfraGeneric()
348 * @see #isSpecies()
349 * @see #isInfraSpecific()
350 */
351 @Transient
352 public boolean isSupraGeneric(){
353 return (this.isHigher(Rank.GENUS()));
354 }
355
356 /**
357 * Returns the boolean value indicating whether <i>this</i> rank is the genus rank
358 * (true) or not (false). Returns false if <i>this</i> rank is null.
359 *
360 * @see #isSupraGeneric()
361 * @see #isInfraGeneric()
362 * @see #isSpecies()
363 * @see #isInfraSpecific()
364 */
365 @Transient
366 public boolean isGenus(){
367 return (this.equals(Rank.GENUS()));
368 }
369
370 /**
371 * Returns the boolean value indicating whether <i>this</i> rank is higher than the
372 * species rank and lower than the genus rank (true) or not (false).
373 * Returns false if <i>this</i> rank is null.
374 *
375 * @see #isSupraGeneric()
376 * @see #isGenus()
377 * @see #isSpecies()
378 * @see #isInfraSpecific()
379 */
380 @Transient
381 public boolean isInfraGeneric(){
382 return (this.isLower(Rank.GENUS()) && this.isHigher(Rank.SPECIES()));
383 }
384
385 /**
386 * Returns the boolean value indicating whether <i>this</i> rank is the species
387 * rank (true) or not (false). Returns false if <i>this</i> rank is null.
388 *
389 * @see #isSupraGeneric()
390 * @see #isGenus()
391 * @see #isInfraGeneric()
392 * @see #isInfraSpecific()
393 */
394 @Transient
395 public boolean isSpecies(){
396 return (this.equals(Rank.SPECIES()));
397 }
398
399 /**
400 * Returns the boolean value indicating whether <i>this</i> rank is lower than the
401 * species rank (true) or not (false). Returns false if <i>this</i> rank is null.
402 *
403 * @see #isSupraGeneric()
404 * @see #isGenus()
405 * @see #isInfraGeneric()
406 * @see #isSpecies()
407 */
408 @Transient
409 public boolean isInfraSpecific(){
410 return (this.isLower(Rank.SPECIES()));
411 }
412
413
414 /**
415 * Returns the rank identified through a name (abbreviated or not).
416 * Preliminary implementation for BotanicalNameParser.
417 *
418 * @param strRank the string identifying the rank
419 * @return the rank
420 */
421 @Transient
422 public static Rank getRankByNameOrAbbreviation(String strRank)
423 throws UnknownCdmTypeException{
424 return getRankByNameOrAbbreviation(strRank, false);
425 }
426
427 // TODO
428 // Preliminary implementation for BotanicalNameParser.
429 // not yet complete
430 /**
431 * Returns the rank identified through a name (abbreviated or not).
432 * Preliminary implementation for BotanicalNameParser.
433 *
434 * @param strRank the string identifying the rank
435 * @param useUnknown if true the rank UNKNOWN_RANK is returned if the abbrev is
436 * unknown or not yet implemented
437 * @return the rank
438 */
439 @Transient
440 public static Rank getRankByNameOrAbbreviation(String strRank, boolean useUnknown)
441 throws UnknownCdmTypeException{
442 try {
443 return getRankByAbbreviation(strRank);
444 } catch (UnknownCdmTypeException e) {
445 return getRankByName(strRank, useUnknown);
446 }
447 }
448
449
450 /**
451 * Returns the rank identified through an abbreviated name.
452 * Preliminary implementation for BotanicalNameParser.
453 *
454 * @param abbrev the string for the name abbreviation
455 * @return the rank
456 */
457 @Transient
458 public static Rank getRankByAbbreviation(String abbrev)
459 throws UnknownCdmTypeException{
460 return getRankByAbbreviation(abbrev, false);
461 }
462
463 // TODO
464 // Preliminary implementation for BotanicalNameParser.
465 // not yet complete
466 /**
467 * Returns the rank identified through an abbreviated name.
468 * Preliminary implementation for BotanicalNameParser.
469 *
470 * @param abbrev the string for the name abbreviation
471 * @param useUnknown if true the rank UNKNOWN_RANK is returned if the abbrev is
472 * unknown or not yet implemented
473 * @return the rank
474 */
475 @Transient
476 public static Rank getRankByAbbreviation(String abbrev, boolean useUnknown)
477 throws UnknownCdmTypeException{
478 if (abbrev == null){ throw new NullPointerException("abbrev is 'null' in getRankByAbbreviation");
479 }else if (abbrev.equalsIgnoreCase("reg.")){ return Rank.KINGDOM();
480 }else if (abbrev.equalsIgnoreCase("subreg.")){ return Rank.SUBKINGDOM();
481 }else if (abbrev.equalsIgnoreCase("phyl.")){return Rank.PHYLUM();
482 }else if (abbrev.equalsIgnoreCase("subphyl.")) { return Rank.SUBPHYLUM();
483 }else if (abbrev.equalsIgnoreCase("div.")) { return Rank.DIVISION();
484 }else if (abbrev.equalsIgnoreCase("subdiv.")) { return Rank.SUBDIVISION();
485 }else if (abbrev.equalsIgnoreCase("cl.")) { return Rank.CLASS();
486 }else if (abbrev.equalsIgnoreCase("subcl.")) { return Rank.SUBCLASS();
487 }else if (abbrev.equalsIgnoreCase("superor.")) { return Rank.SUPERORDER();
488 }else if (abbrev.equalsIgnoreCase("ordo")) { return Rank.ORDER();
489 }else if (abbrev.equalsIgnoreCase("subor.")) { return Rank.SUBORDER();
490 }else if (abbrev.equalsIgnoreCase("fam.")) { return Rank.FAMILY();
491 }else if (abbrev.equalsIgnoreCase("subfam.")) { return Rank.SUBFAMILY();
492 }else if (abbrev.equalsIgnoreCase("trib.")) { return Rank.TRIBE();
493 }else if (abbrev.equalsIgnoreCase("subtrib.")) { return Rank.SUBTRIBE();
494 }else if (abbrev.equalsIgnoreCase("gen.")) { return Rank.GENUS();
495 }else if (abbrev.equalsIgnoreCase("subg.")) { return Rank.SUBGENUS();
496 }else if (abbrev.equalsIgnoreCase("sect.")) { return Rank.SECTION();
497 }else if (abbrev.equalsIgnoreCase("subsect.")) { return Rank.SUBSECTION();
498 }else if (abbrev.equalsIgnoreCase("ser.")) { return Rank.SERIES();
499 }else if (abbrev.equalsIgnoreCase("subser.")) { return Rank.SUBSERIES();
500 }else if (abbrev.equalsIgnoreCase("aggr.")) { return Rank.SPECIESAGGREGATE();
501 //TODO
502 //}else if (abbrev.equalsIgnoreCase("group")) { return Rank.SPECIESGROUP();
503 }else if (abbrev.equalsIgnoreCase("sp.")) { return Rank.SPECIES();
504 }else if (abbrev.equalsIgnoreCase("subsp.")) { return Rank.SUBSPECIES();
505 }else if (abbrev.equalsIgnoreCase("convar.")) { return Rank.CONVAR();
506 }else if (abbrev.equalsIgnoreCase("var.")) { return Rank.VARIETY();
507 }else if (abbrev.equalsIgnoreCase("subvar.")) { return Rank.SUBVARIETY();
508 }else if (abbrev.equalsIgnoreCase("f.")) { return Rank.FORM();
509 }else if (abbrev.equalsIgnoreCase("subf.")) { return Rank.SUBFORM();
510 //TODO
511 //}else if (abbrev.equalsIgnoreCase("f.spec.")) { return Rank.FORMA_SPEC();
512 }else if (abbrev.equalsIgnoreCase("t.infgen.")) { return Rank.INFRAGENERICTAXON();
513 }else if (abbrev.equalsIgnoreCase("t.infr.")) { return Rank.INFRASPECIFICTAXON();
514 }else {
515 if (abbrev == null){
516 abbrev = "(null)";
517 }
518 if (useUnknown){
519 logger.warn("Unknown rank name: " + abbrev+". Rank 'UNKNOWN_RANK' created instead");
520 return Rank.UNKNOWN_RANK();
521 }else{
522 if (abbrev == null){
523 abbrev = "(null)";
524 }
525 throw new UnknownCdmTypeException("Unknown rank abbreviation: " + abbrev);
526 }
527 }
528 }
529
530 // TODO
531 // Preliminary implementation for BotanicalNameParser.
532 // not yet complete
533 /**
534 * Returns the rank identified through a name.
535 * Preliminary implementation for BotanicalNameParser.
536 *
537 * @param rankName the string for the name of the rank
538 * @return the rank
539 */
540 @Transient
541 public static Rank getRankByName(String rankName)throws UnknownCdmTypeException{
542 return getRankByName(rankName, false);
543 }
544
545
546 /**
547 * Returns the rank identified through a name.
548 * Preliminary implementation for BotanicalNameParser.
549 *
550 * @param rankName the string for the name of the rank
551 * @param useUnknown if true the rank UNKNOWN_RANK is returned if the rank name is
552 * unknown or not yet implemented
553 * @return the rank
554 */
555 @Transient
556 public static Rank getRankByName(String rankName, boolean useUnknown)
557 throws UnknownCdmTypeException{
558 if (rankName.equalsIgnoreCase("Regnum")){ return Rank.KINGDOM();
559 }else if (rankName.equalsIgnoreCase("Subregnum")){ return Rank.SUBKINGDOM();
560 }else if (rankName.equalsIgnoreCase("Phylum")){ return Rank.PHYLUM();
561 }else if (rankName.equalsIgnoreCase("subphylum")){ return Rank.SUBPHYLUM();
562 }else if (rankName.equalsIgnoreCase("Divisio")){ return Rank.DIVISION();
563 }else if (rankName.equalsIgnoreCase("Subdivisio")){ return Rank.SUBDIVISION();
564 }else if (rankName.equalsIgnoreCase("Classis")){ return Rank.CLASS();
565 }else if (rankName.equalsIgnoreCase("Subclassis")){ return Rank.SUBCLASS();
566 }else if (rankName.equalsIgnoreCase("Superordo")){ return Rank.SUPERORDER();
567 }else if (rankName.equalsIgnoreCase("Ordo")){ return Rank.ORDER();
568 }else if (rankName.equalsIgnoreCase("Subordo")){ return Rank.SUBORDER();
569 }else if (rankName.equalsIgnoreCase("Familia")){ return Rank.FAMILY();
570 }else if (rankName.equalsIgnoreCase("Subfamilia")){ return Rank.SUBFAMILY();
571 }else if (rankName.equalsIgnoreCase("Tribus")){ return Rank.TRIBE();
572 }else if (rankName.equalsIgnoreCase("Subtribus")){ return Rank.SUBTRIBE();
573 }else if (rankName.equalsIgnoreCase("Genus")){ return Rank.GENUS();
574 }else if (rankName.equalsIgnoreCase("Subgenus")){ return Rank.SUBGENUS();
575 }else if (rankName.equalsIgnoreCase("Sectio")){ return Rank.SECTION();
576 }else if (rankName.equalsIgnoreCase("Subsectio")){ return Rank.SUBSECTION();
577 }else if (rankName.equalsIgnoreCase("Series")){ return Rank.SERIES();
578 }else if (rankName.equalsIgnoreCase("Subseries")){ return Rank.SUBSERIES();
579 }else if (rankName.equalsIgnoreCase("Aggregate")){ return Rank.SPECIESAGGREGATE();
580 //TODO
581 //}else if (rankName.equalsIgnoreCase("Speciesgroup")){ return Rank.SPECIESGROUP();
582 }else if (rankName.equalsIgnoreCase("Species")){ return Rank.SPECIES();
583 }else if (rankName.equalsIgnoreCase("Subspecies")){ return Rank.SUBSPECIES();
584 }else if (rankName.equalsIgnoreCase("Convarietas")){ return Rank.CONVAR();
585 }else if (rankName.equalsIgnoreCase("Varietas")){ return Rank.VARIETY();
586 }else if (rankName.equalsIgnoreCase("Subvarietas")){ return Rank.SUBVARIETY();
587 }else if (rankName.equalsIgnoreCase("Forma")){ return Rank.FORM();
588 }else if (rankName.equalsIgnoreCase("Subforma")){ return Rank.SUBFORM();
589 }else if (rankName.equalsIgnoreCase("Forma spec.")){ return Rank.SPECIALFORM();
590 }else if (rankName.equalsIgnoreCase("tax.infragen.")){ return Rank.INFRAGENERICTAXON();
591 }else if (rankName.equalsIgnoreCase("tax.infrasp.")){ return Rank.INFRASPECIFICTAXON();
592 // old ranks
593 }else if (rankName.equalsIgnoreCase("proles")){ return Rank.INFRASPECIFICTAXON(); //to create the name put prol. and the infraspeciesepi to the field unnamed namephrase
594 }else if (rankName.equalsIgnoreCase("race")){ return Rank.INFRASPECIFICTAXON(); //to create the name put prol. and the infraspeciesepi to the field unnamed namephrase
595 }else if (rankName.equalsIgnoreCase("taxon")){ return Rank.INFRASPECIFICTAXON(); //to create the name put prol. and the infraspeciesepi to the field unnamed namephrase
596 }else if (rankName.equalsIgnoreCase("sublusus")){ return Rank.INFRASPECIFICTAXON(); //to create the name put prol. and the infraspeciesepi to the field unnamed namephrase
597
598 }else{
599 if (rankName == null){
600 rankName = "(null)";
601 }
602 if (useUnknown){
603 logger.warn("Unknown rank name: " + rankName+". Rank 'UNKNOWN_RANK' created instead");
604 return Rank.UNKNOWN_RANK();
605 }else{
606 if (rankName == null){
607 rankName = "(null)";
608 }
609 throw new UnknownCdmTypeException("Unknown rank name: " + rankName);
610 }
611 }
612 }
613
614 //TODO
615 //dummy implementation for BerlinModelImport
616 // not yet complete
617 /**
618 * Returns the abbreviated rank name for <i>this</i> rank according to the
619 * Berlin Model. Preliminary implementation for BerlinModelImport.
620 *
621 * @return the abbreviation string for <i>this</i> rank
622 */
623 @Transient
624 public String getAbbreviation(){
625 if (this.equals(Rank.ORDER()) ){return "ordo";}
626 if (this.equals(Rank.FAMILY()) ){return "fam.";}
627 else if (this.equals(Rank.SUBFAMILY()) ){return "subfam.";}
628 else if (this.equals(Rank.TRIBE()) ){return "trib.";}
629 else if (this.equals(Rank.SUBTRIBE()) ){return "subtrib.";}
630 else if (this.equals(Rank.GENUS()) ){return "gen.";}
631 else if (this.equals(Rank.SUBGENUS()) ){return "subg.";}
632 else if (this.equals(Rank.SECTION()) ){return "sect.";}
633 else if (this.equals(Rank.SUBSECTION()) ){return "subsect.";}
634 else if (this.equals(Rank.SERIES()) ){return "ser.";}
635 //else if (this.equals(Rank.AGGREGATE()) ){return "aggr.";}
636 else if (this.equals(Rank.SPECIES()) ){return "sp.";}
637 else if (this.equals(Rank.SUBSPECIES()) ){return "subsp.";}
638 else if (this.equals(Rank.VARIETY()) ){return "var.";}
639 else if (this.equals(Rank.CONVAR()) ){return "convar.";}
640 else if (this.equals(Rank.SUBVARIETY()) ){return "subvar.";}
641 else if (this.equals(Rank.FORM()) ){return "f.";}
642 else if (this.equals(Rank.SPECIALFORM()) ){return "f.spec.";}
643 else if (this.equals(Rank.INFRAGENERICTAXON()) ){return "t.infgen.";}
644 else if (this.equals(Rank.INFRASPECIFICTAXON()) ){return "t.infr.";}
645 else {
646 logger.warn("Abbreviation for this Rank " + this.toString() + " not yet implemented");
647 return "xxx.";
648 }
649
650
651
652 }
653
654
655
656
657 }