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