fix NPE with abbrev == null in Rank
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / SpecimenTypeDesignationStatus.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
13
14
15 import java.util.HashMap;
16 import java.util.Map;
17 import java.util.UUID;
18
19 import javax.persistence.Entity;
20 import javax.persistence.Transient;
21 import javax.xml.bind.annotation.XmlAccessType;
22 import javax.xml.bind.annotation.XmlAccessorType;
23 import javax.xml.bind.annotation.XmlType;
24
25 import org.apache.log4j.Logger;
26 import org.hibernate.envers.Audited;
27 import org.hibernate.search.annotations.Indexed;
28
29 import eu.etaxonomy.cdm.model.common.TermVocabulary;
30
31 /**
32 * The class representing status (categories) of {@link SpecimenTypeDesignation specimen type designations}
33 * for a {@link TaxonNameBase taxon name} or a set of them. Within this set {@link NameRelationshipType#BASIONYM() basionyms}
34 * or {@link NameRelationshipType#REPLACED_SYNONYM() replaced synonyms}, in case of reclassifications,
35 * will be here referred as "type-bringing" taxon names.
36 * <P>
37 * The different status indicate whether the {@link eu.etaxonomy.cdm.model.occurrence.Specimen specimens} used as types
38 * in a designation are duplicates, replacements, related specimens etc.
39 * <P>
40 * A standard (ordered) list of type designation status instances will be
41 * automatically created as the project starts. But this class allows to extend
42 * this standard list by creating new instances of additional type designation
43 * status if needed.
44 * <P>
45 * This class corresponds to: <ul>
46 * <li> NomencalturalTypeTypeTerm according to the TDWG ontology
47 * <li> NomenclaturalTypeStatusOfUnitsEnum according to the TCS
48 * </ul>
49 *
50 * @author m.doering
51 * @version 1.0
52 * @created 08-Nov-2007 13:07:00
53 */
54 @XmlAccessorType(XmlAccessType.FIELD)
55 @XmlType(name = "SpecimenTypeDesignationStatus")
56 @Entity
57 @Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
58 @Audited
59 public class SpecimenTypeDesignationStatus extends TypeDesignationStatusBase<SpecimenTypeDesignationStatus> {
60 private static final long serialVersionUID = -7918261741824966182L;
61 @SuppressWarnings("unused")
62 private static final Logger logger = Logger.getLogger(SpecimenTypeDesignationStatus.class);
63
64 protected static Map<UUID, SpecimenTypeDesignationStatus> termMap = null;
65
66 private static final UUID uuidType = UUID.fromString("7194020b-a326-4b47-9bfe-9f31a30aba7f");
67 private static final UUID uuidHolotype = UUID.fromString("a407dbc7-e60c-46ff-be11-eddf4c5a970d");
68 private static final UUID uuidLectotype = UUID.fromString("05002d46-083e-4b27-8731-2e7c28a8825c");
69 private static final UUID uuidNeotype = UUID.fromString("26e13359-8f77-4e40-a85a-56c01782fce0");
70 private static final UUID uuidEpitype = UUID.fromString("989a2715-71d5-4fbe-aa9a-db9168353744");
71 private static final UUID uuidIsolectotype = UUID.fromString("7a1a8a53-78f4-4fc0-89f7-782e94992d08");
72 private static final UUID uuidIsoneotype = UUID.fromString("7afc2f4f-f70a-4aa5-80a5-87764f746bde");
73 private static final UUID uuidIsotype = UUID.fromString("93ef8257-0a08-47bb-9b36-542417ae7560");
74 private static final UUID uuidParaneotype = UUID.fromString("0c39e2a5-2fe0-4d4f-819a-f609b5340339");
75 private static final UUID uuidParatype = UUID.fromString("eb7df2e5-d9a7-479d-970c-c6f2b0a761d7");
76 private static final UUID uuidSecondStepLectotype = UUID.fromString("01d91053-7004-4984-aa0d-9f4de59d6205");
77 private static final UUID uuidSecondStepNeotype = UUID.fromString("8d2fed1f-242e-4bcf-bbd7-e85133e479dc");
78 private static final UUID uuidSyntype = UUID.fromString("f3b60bdb-4638-4ca9-a0c7-36e77d8459bb");
79 private static final UUID uuidParalectotype = UUID.fromString("7244bc51-14d8-41a6-9524-7dc5303bba29");
80 private static final UUID uuidIsoepitype = UUID.fromString("95b90696-e103-4bc0-b60b-c594983fb566");
81 private static final UUID uuidIconotype = UUID.fromString("643513d0-32f5-46ba-840b-d9b9caf8160f");
82 private static final UUID uuidPhototype = UUID.fromString("b7807acc-f559-474e-ad4a-e7a41e085e34");
83 private static final UUID uuidUnspecified = UUID.fromString("230fd762-b143-49de-ac2e-744bcc48a63b");
84 private static final UUID uuidOriginalMaterial = UUID.fromString("49c96cae-6be6-401e-9b36-1bc12d9dc8f9");
85 private static final UUID uuidIsosyntype = UUID.fromString("052a5ff0-8e9a-4355-b24f-5e4bb6071f44");
86
87
88 // ************* CONSTRUCTORS *************/
89 /**
90 * Class constructor: creates a new empty type designation status instance.
91 *
92 * @see #TypeDesignationStatus(String, String, String)
93 */
94 public SpecimenTypeDesignationStatus() {
95 }
96
97
98 /**
99 * Class constructor: creates an additional type designation status instance
100 * with a description (in the {@link eu.etaxonomy.cdm.model.common.Language#DEFAULT() default language}), a label
101 * and a label abbreviation.
102 *
103 * @param term the string (in the default language) describing the
104 * new type designation status to be created
105 * @param label the string identifying the new type designation
106 * status to be created
107 * @param labelAbbrev the string identifying (in abbreviated form) the
108 * new type designation status to be created
109 * @see #TypeDesignationStatus()
110 */
111 public SpecimenTypeDesignationStatus(String term, String label, String labelAbbrev) {
112 super(term, label, labelAbbrev);
113 }
114
115 //************************** METHODS ********************************
116
117 /* (non-Javadoc)
118 * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
119 */
120 @Override
121 public void resetTerms(){
122 termMap = null;
123 }
124
125
126 protected static SpecimenTypeDesignationStatus findTermByUuid(UUID uuid){
127 if (termMap == null){
128 return null;
129 }
130 return (SpecimenTypeDesignationStatus)termMap.get(uuid);
131 }
132
133
134 /**
135 * Returns the boolean value indicating whether <i>this</i> type designation
136 * status is itself "lectotype" or a kind of "lectotype" (true) or not
137 * (false). Returns false if <i>this</i> type designation status is null.<BR>
138 * A lectotype is a {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase specimen or illustration} designated as the
139 * nomenclatural type, when no holotype was indicated at the time of
140 * publication of the "type-bringing" {@link TaxonNameBase taxon name}, when the
141 * holotype is found to be assigned to taxon names belonging to more than
142 * one {@link HomotypicalGroup homotypical group}, or as long as it is missing.
143 *
144 * @see #LECTOTYPE()
145 * @see #HOLOTYPE()
146 * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#getKindOf()
147 */
148 @Transient
149 public boolean isLectotype(){
150 if (this.equals(LECTOTYPE()) ||
151 this.equals(ISOLECTOTYPE()) ||
152 this.equals(SECOND_STEP_LECTOTYPE()) ||
153 this.equals(PARALECTOTYPE()) ){
154 return true;
155 }else{
156 return false;
157 }
158 }
159
160 /**
161 * Returns the "unknown" designation status. One may choose this status to indicate that the type
162 * designation is not
163 *
164 */
165 public static final SpecimenTypeDesignationStatus TYPE(){
166 return findTermByUuid(uuidType);
167 }
168
169 /**
170 * Returns the "holotype" designation status. A holotype of a
171 * set of names is the one {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase specimen or illustration}
172 * designated as the nomenclatural type by the {@link NonViralName#getCombinationAuthorTeam() author} of the
173 * "type-bringing" {@link TaxonNameBase taxon name} (or by the author of a later validated
174 * "invalid" taxon name).
175 *
176 * @see NameRelationshipType#VALIDATED_BY_NAME()
177 */
178 public static final SpecimenTypeDesignationStatus HOLOTYPE(){
179 return findTermByUuid(uuidHolotype);
180 }
181
182 /**
183 * Returns the "lectotype" designation status. A lectotype is a
184 * {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase specimen or illustration} designated as the nomenclatural type,
185 * when no holotype was indicated at the time of publication of the
186 * "type-bringing" {@link TaxonNameBase taxon name}, when the
187 * holotype is found to to be assigned to taxon names belonging to more than one
188 * {@link HomotypicalGroup homotypical group}, or as long as it is missing.
189 *
190 * @see #HOLOTYPE()
191 */
192 public static final SpecimenTypeDesignationStatus LECTOTYPE(){
193 return findTermByUuid(uuidLectotype);
194 }
195
196 /**
197 * Returns the "neotype" designation status. A neotype is a
198 * {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase specimen or illustration} selected to serve as nomenclatural type
199 * as long as all of the material on which the "type-bringing" {@link TaxonNameBase taxon name} was based
200 * is missing.
201 *
202 * @see #HOLOTYPE()
203 */
204 public static final SpecimenTypeDesignationStatus NEOTYPE(){
205 return findTermByUuid(uuidNeotype);
206 }
207
208 /**
209 * Returns the "epitype" designation status. An epitype is a
210 * {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase specimen or illustration} selected to serve as an interpretative type
211 * when the holotype, lectotype or previously designated neotype, or all
212 * original material associated with the {@link NomenclaturalStatusType#VALID() validly} published "type-bringing"
213 * {@link TaxonNameBase taxon name}, is demonstrably ambiguous and cannot be critically
214 * identified for purposes of the precise application of the taxon name.
215 * When an epitype is designated, the holotype, lectotype or neotype that
216 * the epitype supports must be explicitly cited.
217 *
218 * @see #HOLOTYPE()
219 * @see #LECTOTYPE()
220 * @see #NEOTYPE()
221 */
222 public static final SpecimenTypeDesignationStatus EPITYPE(){
223 return findTermByUuid(uuidEpitype);
224 }
225
226 /**
227 * Returns the "isotype" designation status. </BR>An isotype is any duplicate of
228 * the holotype; it is always a {@link eu.etaxonomy.cdm.model.occurrence.Specimen specimen}.
229 *
230 * @see #HOLOTYPE()
231 */
232 public static final SpecimenTypeDesignationStatus ISOTYPE(){
233 return findTermByUuid(uuidIsotype);
234 }
235
236 /**
237 * Returns the "syntype" designation status. </BR>A syntype is any one of two or
238 * more {@link eu.etaxonomy.cdm.model.occurrence.Specimen specimens} cited in the {@link TaxonNameBase#getNomenclaturalReference() protologue} of the
239 * "type-bringing" {@link TaxonNameBase taxon name} when no holotype was designated,
240 * or any one of two or more specimens simultaneously designated as types.
241 *
242 * @see #HOLOTYPE()
243 */
244 public static final SpecimenTypeDesignationStatus SYNTYPE(){
245 return findTermByUuid(uuidSyntype);
246 }
247
248 /**
249 * Returns the "isosyntype" designation status. </BR>An isosyntype is any
250 * {@link eu.etaxonomy.cdm.model.occurrence.Specimen specimen} cited in the
251 * protologue of the type-bringing {@link TaxonNameBase taxon name} which is
252 * a duplicate of a {@link eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus#SYNTYPE() syntype}.
253 * See also article 9.10 of the ICBN
254 *
255 * @see #HOLOTYPE()
256 */
257 public static final SpecimenTypeDesignationStatus ISOSYNTYPE(){
258 return findTermByUuid(uuidIsosyntype);
259 }
260
261 /**
262 * Returns the "paratype" designation status. </BR>A paratype is a {@link eu.etaxonomy.cdm.model.occurrence.Specimen specimen}
263 * cited in the {@link TaxonNameBase#getNomenclaturalReference() protologue} of the "type-bringing"
264 * {@link TaxonNameBase taxon name} that is neither the holotype nor an isotype,
265 * nor one of the syntypes if two or more specimens were simultaneously
266 * designated as types.
267 *
268 * @see #HOLOTYPE()
269 * @see #ISOTYPE()
270 * @see #SYNTYPE()
271 */
272 public static final SpecimenTypeDesignationStatus PARATYPE(){
273 return findTermByUuid(uuidParatype);
274 }
275
276 /**
277 * Returns the "isolectotype" designation status. </BR>
278 * An isolectotype is any
279 * duplicate of the lectotype; it is always a {@link eu.etaxonomy.cdm.model.occurrence.Specimen specimen}.
280 *
281 * @see #LECTOTYPE()
282 */
283 public static final SpecimenTypeDesignationStatus ISOLECTOTYPE(){
284 return findTermByUuid(uuidIsolectotype);
285 }
286
287 /**
288 * Returns the "isoneotype" designation status. </BR>
289 * An isoneotype is any
290 * duplicate of the neotype; it is always a {@link eu.etaxonomy.cdm.model.occurrence.Specimen specimen}.
291 *
292 * @see #NEOTYPE()
293 */
294 public static final SpecimenTypeDesignationStatus ISONEOTYPE(){
295 return findTermByUuid(uuidIsoneotype);
296 }
297 /**
298 * Returns the "paraneotype" designation status. </BR>
299 * A paraneotype is a {@link eu.etaxonomy.cdm.model.occurrence.Specimen specimen},
300 * cited when selecting a neotype, other than the neotype itself. Also
301 * called "neoparatype" in zoology.
302 *
303 * @see #NEOTYPE()
304 */
305 public static final SpecimenTypeDesignationStatus PARANEOTYPE(){
306 return findTermByUuid(uuidParaneotype);
307 }
308
309 /**
310 * Returns the "second step lectotype" designation status. </BR>
311 * A second step lectotype is a {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase specimen or illustration}, designated as lectotype
312 * in order to substitute another already existing lectotype.
313 *
314 * @see #LECTOTYPE()
315 */
316 public static final SpecimenTypeDesignationStatus SECOND_STEP_LECTOTYPE(){
317 return findTermByUuid(uuidSecondStepLectotype);
318 }
319
320 /**
321 * Returns the "second step neotype" designation status. </BR>
322 * A second step neotype is a {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase specimen or illustration}, designated as neotype
323 * in order to substitute another already existing neotype.
324 *
325 * @see #LECTOTYPE()
326 */
327 public static final SpecimenTypeDesignationStatus SECOND_STEP_NEOTYPE(){
328 return findTermByUuid(uuidSecondStepNeotype);
329 }
330
331 /**
332 * Returns the "paralectotype" designation status. </BR>
333 * A paralectotype is a {@link eu.etaxonomy.cdm.model.occurrence.Specimen specimen}, cited when designating a lectotype, other than
334 * the lectotype itself. Also called "lectoparatype" in zoology.
335 *
336 * @see #LECTOTYPE()
337 */
338 public static final SpecimenTypeDesignationStatus PARALECTOTYPE(){
339 return findTermByUuid(uuidParalectotype);
340 }
341
342 /**
343 * Returns the "isoepitype" designation status. An isoepitype is any
344 * duplicate of the epitype; it is always a {@link eu.etaxonomy.cdm.model.occurrence.Specimen specimen}.
345 *
346 * @see #EPITYPE()
347 */
348 public static final SpecimenTypeDesignationStatus ISOEPITYPE(){
349 return findTermByUuid(uuidIsoepitype);
350 }
351
352 /**
353 * Returns the "iconotype" designation status. An iconotype is a holotype or
354 * a lectotype that is a {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase drawing}
355 * and not a {@link eu.etaxonomy.cdm.model.occurrence.Specimen specimen}.
356 * "Iconotype" does not have type status according to the ICBN.
357 *
358 * @see #HOLOTYPE()
359 * @see #LECTOTYPE()
360 */
361 public static final SpecimenTypeDesignationStatus ICONOTYPE(){
362 return findTermByUuid(uuidIconotype);
363 }
364
365 /**
366 * Returns the "unspecific" type designation status. Used if from literature where it is not
367 * clear if it refers to another publication not cited or if it is a new designation.
368 *
369 */
370 public static final SpecimenTypeDesignationStatus UNSPECIFIC(){
371 return findTermByUuid(uuidUnspecified);
372 }
373
374 /**
375 * Returns the "original material" type designation status.
376 * Botanical term for material from which a lectotype can be designated.
377 * "Original material" does not have type status according to the ICBN.
378 *
379 */
380 public static final SpecimenTypeDesignationStatus ORIGINAL_MATERIAL(){
381 return findTermByUuid(uuidOriginalMaterial);
382 }
383
384
385 /**
386 * Returns the "phototype" type designation status.
387 * "Phototype" does not have type status according to the ICBN.
388 *
389 */
390 public static final SpecimenTypeDesignationStatus PHOTOTYPE(){
391 return findTermByUuid(uuidPhototype);
392 }
393
394 @Override
395 protected void setDefaultTerms(TermVocabulary<SpecimenTypeDesignationStatus> termVocabulary) {
396 termMap = new HashMap<UUID, SpecimenTypeDesignationStatus>();
397 for (SpecimenTypeDesignationStatus term : termVocabulary.getTerms()){
398 termMap.put(term.getUuid(), term);
399 }
400
401 }
402
403 }