fix in taxonomic tree and some comments
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / NameTypeDesignationStatus.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10
11 package eu.etaxonomy.cdm.model.name;
12
13 import java.util.HashMap;
14 import java.util.Map;
15 import java.util.UUID;
16
17 import javax.persistence.Entity;
18 import javax.persistence.Transient;
19 import javax.xml.bind.annotation.XmlAccessType;
20 import javax.xml.bind.annotation.XmlAccessorType;
21 import javax.xml.bind.annotation.XmlType;
22
23 import org.apache.log4j.Logger;
24 import org.hibernate.envers.Audited;
25
26 import eu.etaxonomy.cdm.model.common.DefinedTermBase;
27 import eu.etaxonomy.cdm.model.common.OrderedTermBase;
28 import eu.etaxonomy.cdm.model.common.TermVocabulary;
29
30 /**
31 *
32 * @author a.babadshanjan
33 * @version 1.0
34 * @created 20.03.2009
35 */
36 @XmlAccessorType(XmlAccessType.FIELD)
37 @XmlType(name = "NameTypeDesignationStatus")
38 @Entity
39 @Audited
40 public class NameTypeDesignationStatus extends TypeDesignationStatusBase<NameTypeDesignationStatus> {
41 static Logger logger = Logger.getLogger(NameTypeDesignationStatus.class);
42
43 private static final UUID uuidAutomatic = UUID.fromString("e89d8b21-615a-4602-913f-1625bf39a69f");
44 private static final UUID uuidFirstRevisor = UUID.fromString("a14ec046-c48f-4a73-939f-bd57880c7565");
45 private static final UUID uuidMonotypy = UUID.fromString("3fc639b2-9a64-45f8-9a81-657a4043ad74");
46 private static final UUID uuidNotApplicable = UUID.fromString("91a9d6a9-7754-41cd-9f7e-be136f599f7e");
47 private static final UUID uuidOriginalDesignation = UUID.fromString("40032a44-973b-4a64-b25e-76f86c3a753c");
48 private static final UUID uuidPresentDesignation = UUID.fromString("e5f38f5d-995d-4470-a036-1a9792a543fc");
49 private static final UUID uuidSubsequentMonotypy = UUID.fromString("2b5806d8-31b0-406e-a32a-4adac0c89ae4");
50 private static final UUID uuidSubsequentDesignation = UUID.fromString("3e449e7d-a03c-4431-a7d3-aa258406f6b2");
51 private static final UUID uuidTautonymy = UUID.fromString("84521f09-3e10-43f5-aa6f-2173a55a6790");
52
53 protected static Map<UUID, NameTypeDesignationStatus> termMap = null;
54
55 protected static NameTypeDesignationStatus findTermByUuid(UUID uuid){
56 if (termMap == null){
57 return null;
58 }
59 return (NameTypeDesignationStatus)termMap.get(uuid);
60 }
61
62 // ************* CONSTRUCTORS *************/
63
64 /**
65 * Class constructor: creates a new empty name type designation status instance.
66 *
67 * @see #NameTypeDesignationStatus(String, String, String)
68 */
69 public NameTypeDesignationStatus() {
70 }
71
72 /**
73 * Class constructor: creates an additional type designation status instance
74 * with a description (in the {@link eu.etaxonomy.cdm.model.common.Language#DEFAULT() default language}), a label
75 * and a label abbreviation.
76 *
77 * @param term the string (in the default language) describing the
78 * new name type designation status to be created
79 * @param label the string identifying the new name type designation
80 * status to be created
81 * @param labelAbbrev the string identifying (in abbreviated form) the
82 * new name type designation status to be created
83 */
84 public NameTypeDesignationStatus(String term, String label, String labelAbbrev) {
85 super(term, label, labelAbbrev);
86 }
87
88 //********* METHODS **************************************
89
90
91 /**
92 * Returns the "automatic" name type designation status.
93 * If a new name has to be established for a genus name this new name automatically gets
94 * the same type species as the old name.
95 */
96 public static final NameTypeDesignationStatus AUTOMATIC(){
97 return findTermByUuid(uuidAutomatic);
98 }
99
100 /**
101 * Returns the "first revisor" name type designation status.
102 * Used in the BDWD for incorrect original spellings only. This is only a way of dealing
103 * with misspellings in the database, not an actual type designation.
104 */
105 public static final NameTypeDesignationStatus FIRST_REVISOR(){
106 return findTermByUuid(uuidFirstRevisor);
107 }
108
109 /**
110 * Returns the "monotypy" name type designation status.
111 * Only one species was included in original genus description.
112 */
113 public static final NameTypeDesignationStatus MONOTYPY(){
114 return findTermByUuid(uuidMonotypy);
115 }
116
117 /**
118 * Returns the "not applicable" name type designation status.
119 * Used in the BDWD for nomina nuda, emendations and misspellings.
120 */
121 public static final NameTypeDesignationStatus NOT_APPLICABLE(){
122 return findTermByUuid(uuidNotApplicable);
123 }
124
125 /**
126 * Returns the "original designation" name type designation status.
127 * The type species is designated in the original genus description
128 * (this includes indication in the species name typicus).
129 */
130 public static final NameTypeDesignationStatus ORIGINAL_DESIGNATION(){
131 return findTermByUuid(uuidOriginalDesignation);
132 }
133
134 /**
135 * Returns the "present designation" name type designation status.
136 * The type species is designated now (maybe possible in future,
137 * after ICZN has changed).
138 */
139 public static final NameTypeDesignationStatus PRESENT_DESIGNATION(){
140 return findTermByUuid(uuidPresentDesignation);
141 }
142
143 /**
144 * Returns the "subsequent monotypy" name type designation status.
145 * If only one nominal species was first subsequently included
146 * in a nominal genus or subgenus established without included species,
147 * that nominal species is automatically fixed as the type species,
148 * by subsequent monotypy.
149 */
150 public static final NameTypeDesignationStatus SUBSEQUENT_MONOTYPY(){
151 return findTermByUuid(uuidSubsequentMonotypy);
152 }
153
154 /**
155 * Returns the "subsequent designation" name type designation status.
156 * Several species were included in the original genus description.
157 * One of these has been designated as type species in a later publication.
158 */
159 public static final NameTypeDesignationStatus SUBSEQUENT_DESIGNATION(){
160 return findTermByUuid(uuidSubsequentDesignation);
161 }
162
163 /**
164 * Returns the "tautonomy" name type designation status.
165 * The genus name is the same as the species name of one of the included species.
166 */
167 public static final NameTypeDesignationStatus TAUTONYMY(){
168 return findTermByUuid(uuidTautonymy);
169 }
170
171 @Override
172 protected void setDefaultTerms(TermVocabulary<NameTypeDesignationStatus> termVocabulary) {
173 termMap = new HashMap<UUID, NameTypeDesignationStatus>();
174 for (NameTypeDesignationStatus term : termVocabulary.getTerms()){
175 termMap.put(term.getUuid(), term);
176 }
177 }
178 }