Project

General

Profile

Download (37.4 KB) Statistics
| Branch: | Tag: | Revision:
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
import java.util.ArrayList;
15
import java.util.HashMap;
16
import java.util.List;
17
import java.util.Map;
18
import java.util.UUID;
19

    
20
import javax.persistence.Entity;
21
import javax.persistence.Transient;
22
import javax.xml.bind.annotation.XmlAccessType;
23
import javax.xml.bind.annotation.XmlAccessorType;
24
import javax.xml.bind.annotation.XmlType;
25

    
26
import org.apache.log4j.Logger;
27
import org.hibernate.envers.Audited;
28

    
29
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
30
import eu.etaxonomy.cdm.model.common.Language;
31
import eu.etaxonomy.cdm.model.common.OrderedTermBase;
32
import eu.etaxonomy.cdm.model.common.Representation;
33
import eu.etaxonomy.cdm.model.common.TermType;
34
import eu.etaxonomy.cdm.model.common.TermVocabulary;
35
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
36

    
37
/**
38
 * The class representing categories of nomenclatural status (like "invalid",
39
 * "conserved" or "novum") to qualify the use of a particular taxon name string
40
 * depending on its {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference nomenclatural reference} (original publication),
41
 * on its {@link NomenclaturalCode nomenclatural code} and on possible decisions of the corresponding
42
 * competent authorities. Unfortunately the ICBN and the ICZN use sometimes
43
 * different words for the same meaning or the same word for different meanings
44
 * (for instance "valid" and "legitimate").
45
 * <P>
46
 * A standard (ordered) list of nomenclatural status type instances will be
47
 * automatically created as the project starts. But this class allows to extend
48
 * this standard list by creating new instances of additional nomenclatural
49
 * status types if needed. The present standard list follows the ICBN
50
 * terminology.
51
 * <P>
52
 * This class corresponds more or less to: <ul>
53
 * <li> NomenclaturalNoteTypeTerm according to the TDWG ontology
54
 * <li> NomenclaturalNoteType  according to the TCS
55
 * </ul>
56
 *
57
 * @author a.mueller
58
 * @created 10.07.2008
59
 */
60
@XmlAccessorType(XmlAccessType.FIELD)
61
@XmlType(name = "NomenclaturalStatusType")
62
@Entity
63
//@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
64
//@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
65
@Audited
66
public class NomenclaturalStatusType extends OrderedTermBase<NomenclaturalStatusType> {
67

    
68
	private static final long serialVersionUID = 1337101678484153972L;
69

    
70
	private static Logger logger = Logger.getLogger(NomenclaturalStatusType.class);
71

    
72
	//Botanical uuids
73
	public static final UUID uuidIcnafpNomStatusVocabulary = UUID.fromString("bb28cdca-2f8a-4f11-9c21-517e9ae87f1f");
74

    
75
	private static final UUID uuidAmbiguous = UUID.fromString("90f5012b-705b-4488-b4c6-002d2bc5198e");
76
	private static final UUID uuidDoubtful = UUID.fromString("0ffeb39e-872e-4c0f-85ba-a4150d9f9e7d");
77
	private static final UUID uuidConfusum = UUID.fromString("24955174-aa5c-4e71-a2fd-3efc79e885db");
78
	private static final UUID uuidIllegitimate = UUID.fromString("b7c544cf-a375-4145-9d3e-4b97f3f18108");
79
	private static final UUID uuidSuperfluous = UUID.fromString("6890483a-c6ba-4ae1-9ab1-9fbaa5736ce9");
80
	private static final UUID uuidRejected = UUID.fromString("48107cc8-7a5b-482e-b438-efbba050b851");
81
	private static final UUID uuidUtiqueRejected = UUID.fromString("04338fdd-c12a-402f-a1ca-68b4bf0be042");
82
	private static final UUID uuidConservedProp = UUID.fromString("82bab006-5aed-4301-93ec-980deb30cbb1");
83
	private static final UUID uuidOrthographyConservedProp = UUID.fromString("02f82bc5-1066-454b-a023-11967cba9092");
84
	private static final UUID uuidLegitimate = UUID.fromString("51a3613c-b53b-4561-b0cd-9163d91c15aa");
85
	private static final UUID uuidAlternative = UUID.fromString("3b8a8519-420f-4dfa-b050-b410cc257961");
86
	private static final UUID uuidNovum = UUID.fromString("05fcb68f-af60-4851-b912-892512058897");
87
	private static final UUID uuidUtiqueRejectedProp = UUID.fromString("643ee07f-026c-426c-b838-c778c8613383");
88
	private static final UUID uuidOrthographyConserved = UUID.fromString("34a7d383-988b-4117-b8c0-52b947f8c711");
89
	private static final UUID uuidRejectedProp = UUID.fromString("248e44c2-5436-4526-a352-f7467ecebd56");
90
	private static final UUID uuidConserved = UUID.fromString("6330f719-e2bc-485f-892b-9f882058a966");
91
	private static final UUID uuidSanctioned = UUID.fromString("1afe55c4-76aa-46c0-afce-4dc07f512733");
92
	private static final UUID uuidInvalid = UUID.fromString("b09d4f51-8a77-442a-bbce-e7832aaf46b7");
93
	private static final UUID uuidNudum = UUID.fromString("e0d733a8-7777-4b27-99a3-05ab50e9f312");
94
	private static final UUID uuidCombinationInvalid = UUID.fromString("f858e619-7b7f-4225-913b-880a2143ec83");
95
	private static final UUID uuidCombinationIllegitimate = UUID.fromString("d901d455-4e01-45cb-b653-01a840b97eed");
96
	private static final UUID uuidProvisional = UUID.fromString("a277507e-ad93-4978-9419-077eb889c951");
97
	private static final UUID uuidValid = UUID.fromString("bd036217-5499-4ccd-8f4c-72e06158db93");
98
	private static final UUID uuidOpusUtiqueOppr = UUID.fromString("a5055d80-dbba-4660-b091-a1835d59fe7c");
99
	private static final UUID uuidSubnudum = UUID.fromString("92a76bd0-6ea8-493f-98e0-4be0b98c092f");
100
	private static final UUID uuidCombNov = UUID.fromString("ed508710-deef-44b1-96f6-1ce6d2c9c884");
101
	private static final UUID uuidOrthographyRejected = UUID.fromString("39a25673-f716-4ec7-ae27-2498fce43166");
102
	private static final UUID uuidConservedDesig = UUID.fromString("4e9c9702-a74d-4033-9d47-792ad123712c");
103
	private static final UUID uuidIned = UUID.fromString("51429574-c6f9-4aa1-bab9-0bbc5b160ba1");
104

    
105
	//zoological uuids
106
	public static final UUID uuidIcznNomStatusVocabulary = UUID.fromString("5e3c08e9-13a9-498e-861e-b9b5656ab6ac");
107

    
108
	private static final UUID uuidZooNotAvailable = UUID.fromString("6d9ed462-b761-4da3-9304-4749e883d4eb");
109
	private static final UUID uuidZooInvalid = UUID.fromString("2bef7039-c129-410b-815e-2a1f7249127b");
110
	private static final UUID uuidZooSuppressed = UUID.fromString("a61602c7-fbd4-4eb4-98a2-44919db8920b");
111

    
112

    
113

    
114
	public static NomenclaturalStatusType NewInstance(String description, String label, String labelAbbrev, Language language) {
115
		return new NomenclaturalStatusType(description, label, labelAbbrev, language);
116
	}
117

    
118
	public static NomenclaturalStatusType NewInstance(String description, String label, String labelAbbrev) {
119
		return new NomenclaturalStatusType(description, label, labelAbbrev);
120
	}
121

    
122

    
123
	protected static Map<UUID, NomenclaturalStatusType> termMap = null;
124
	private static Map<String, UUID> abbrevMap = null;
125
	private static Map<String, UUID> labelMap = null;
126

    
127

    
128
	protected static Map<UUID, NomenclaturalStatusType> zooTermMap = null;
129
	private static Map<String, UUID> zooAbbrevMap = null;
130
	private static Map<String, UUID> zooLabelMap = null;
131

    
132

    
133

    
134
	protected static NomenclaturalStatusType getTermByUuid(UUID uuid){
135
	    if ((termMap == null || termMap.isEmpty()) && (zooTermMap == null || zooTermMap.isEmpty())){
136
	        return getTermByClassAndUUID(NomenclaturalStatusType.class, uuid);
137

    
138
	    }
139
		NomenclaturalStatusType result = null;
140
		if (termMap != null){
141
			result = termMap.get(uuid);
142
		}
143
		if (result == null && zooTermMap != null){
144
			result = zooTermMap.get(uuid);
145
		}
146
		return result;
147
	}
148

    
149

    
150
//********************************** Constructor *********************************/
151

    
152
  	//for hibernate use only
153
  	@Deprecated
154
  	protected NomenclaturalStatusType() {
155
		super(TermType.NomenclaturalStatusType);
156
	}
157

    
158
	/**
159
	 * Class constructor: creates an additional nomenclatural status type
160
	 * instance with a description (in the {@link eu.etaxonomy.cdm.model.common.Language#DEFAULT() default language}), a label
161
	 * and a label abbreviation.
162
	 *
163
	 * @param	term  		 the string (in the default language) describing the
164
	 * 						 new nomenclatural status type to be created
165
	 * @param	label  		 the string identifying the new nomenclatural status
166
	 * 						 type to be created
167
	 * @param	labelAbbrev  the string identifying (in abbreviated form) the
168
	 * 						 new nomenclatural status type to be created
169
	 * @see 				 #NomenclaturalStatusType()
170
	 * @see 				 #readCsvLine(List, Language)
171
	 * @see 				 #readCsvLine(List)
172
	 */
173
	private NomenclaturalStatusType(String term, String label, String labelAbbrev) {
174
		super(TermType.NomenclaturalStatusType, term, label, labelAbbrev);
175
	}
176

    
177
	private NomenclaturalStatusType(String term, String label, String labelAbbrev, Language language) {
178
		super(TermType.NomenclaturalStatusType);
179
		this.addRepresentation(new Representation(term, label, labelAbbrev, language));
180
	}
181

    
182
//********* METHODS **************************************
183

    
184

    
185
	@Override
186
	public void resetTerms(){
187
		termMap = null;
188
		zooTermMap = null;
189
	}
190

    
191
	/**
192
	 * Returns the boolean value indicating whether <i>this</i> nomenclatural status
193
	 * type is itself "invalid" or a kind of "invalid" (true) or not (false) -
194
	 * this corresponds to "not available" for {@link IZoologicalName zoological names} -.
195
	 * Returns false if <i>this</i> nomenclatural status type is null. The use
196
	 * of "invalid" {@link TaxonNameBase taxon names} should be avoided.<BR>
197
	 * A taxon name is "invalid" if it is not "valid"; this means that
198
	 * the taxon name:<ul>
199
	 * <li>has not been effectively published or
200
	 * <li>has a form which does not comply with the rules of the
201
	 * 	   {@link NomenclaturalCode nomenclature code} or
202
	 * <li>is not accompanied by a description or diagnosis or by a reference to
203
	 * 	   such a previously published description or diagnosis
204
	 * </ul>
205
	 *
206
	 * @see  #VALID()
207
	 * @see  #isIllegitimateType()
208
	 * @see  eu.etaxonomy.cdm.model.common.DefinedTermBase#getKindOf()
209
	 */
210
	@Transient
211
	public boolean isInvalidType(){
212
		if (this.equals(INVALID())
213
			|| this.equals(NUDUM())
214
			|| 	this.equals(PROVISIONAL())
215
			||  this.equals(INED())
216
			|| 	this.equals(COMBINATION_INVALID())
217
			|| 	this.equals(OPUS_UTIQUE_OPPR())
218
			||  this.equals(ZOO_NOT_AVAILABLE())
219
			){
220
			return true;
221
		}else{
222
			return false;
223
		}
224
	}
225

    
226
	/**
227
	 * Returns the boolean value indicating whether <i>this</i> nomenclatural status
228
	 * type is itself "legitimate" or a kind of "legitimate" (true)
229
	 * or not (false). Corresponds to "valid" for {@link IZoologicalName zoological names}.<BR>
230
	 * Returns false if <i>this</i> nomenclatural status type is null.<BR>
231
	 * A "valid" (zool.: "available") {@link TaxonNameBase taxon name}, unless "rejected",
232
	 * is "legitimate" if it was not "superfluous" when published
233
	 * or has been later "conserved".<BR>
234
	 *
235
	 * @see  #isInvalidType()
236
	 * @see  #isIllegitimateType()
237
	 * @see  eu.etaxonomy.cdm.model.common.DefinedTermBase#getKindOf()
238
	 */
239
	@Transient
240
	public boolean isLegitimateType(){
241
		if (this.equals(LEGITIMATE()) ||
242
				this.equals(NOVUM()) ||
243
				this.equals(ALTERNATIVE()) ||
244
				this.equals(CONSERVED()) ||
245
				this.equals(ORTHOGRAPHY_CONSERVED()) ||
246
				this.equals(REJECTED_PROP()) ||
247
				this.equals(UTIQUE_REJECTED_PROP()) ||
248
				this.equals(COMB_NOV())||
249
				this.equals(CONSERVED_DESIG())
250
			){
251
			return true;
252
		}else{
253
			return false;
254
		}
255
	}
256

    
257
	/**
258
	 * Returns the boolean value indicating whether <i>this</i> nomenclatural status
259
	 * type is itself "illegitimate" or a kind of "illegitimate" (true)
260
	 * or not (false) - this corresponds to "invalid" for {@link IZoologicalName zoological names} -.
261
	 * Returns false if <i>this</i> nomenclatural status type is null.<BR>
262
	 * A "valid" ("available") {@link TaxonNameBase taxon name}, unless "conserved" or
263
	 * "sanctioned", is "illegitimate" if it was "superfluous" when published
264
	 * or has been later "rejected".
265
	 *
266
	 * @see  #VALID()
267
	 * @see  #isInvalidType()
268
	 * @see  #ILLEGITIMATE()
269
	 * @see  #CONSERVED()
270
	 * @see  #SANCTIONED()
271
	 * @see  eu.etaxonomy.cdm.model.common.DefinedTermBase#getKindOf()
272
	 */
273
	@Transient
274
	public boolean isIllegitimateType(){
275
		if (this.equals(ILLEGITIMATE()) ||
276
				this.equals(SUPERFLUOUS()) ||
277
				this.equals(REJECTED()) ||
278
				this.equals(UTIQUE_REJECTED()) ||
279
				this.equals(CONSERVED_PROP()) ||
280
				this.equals(ORTHOGRAPHY_CONSERVED_PROP()) ||
281
				this.equals(ZOO_INVALID()) ||
282
				this.equals(ZOO_SUPPRESSED()) ||
283
				this.equals(ORTHOGRAPHY_REJECTED())
284
			){
285
			return true;
286
		}else{
287
			return false;
288
		}
289
	}
290

    
291

    
292
	/**
293
	 * Returns the nomenclatural status type "ambiguous". A "valid"
294
	 * ("available") {@link TaxonNameBase taxon name} is "ambiguous" if it has been used so long
295
	 * by different authors in different senses (other than the originally
296
	 * intended) that it has become a persistent cause of error and confusion.<BR>
297
	 * An "ambiguous" taxon name is treated as if "rejected" and is therefore
298
	 * also "illegitimate" ("invalid" for {@link IZoologicalName zoological names}).
299
	 *
300
	 * @see  #VALID()
301
	 * @see  #REJECTED()
302
	 * @see  #isIllegitimateType()
303
	 */
304
	public static final NomenclaturalStatusType AMBIGUOUS(){
305
		return getTermByUuid(uuidAmbiguous);
306
	}
307

    
308
	/**
309
	 * Returns the nomenclatural status type "doubtful" (dubious). A "valid"
310
	 * ("available") {@link TaxonNameBase taxon name} is "doubtful" if its
311
	 * application is uncertain; the confusion being derived from an incomplete
312
	 * or confusing description.<BR>
313
	 * A "doubtful" taxon name is treated as if "rejected" and is therefore
314
	 * also "illegitimate" (("invalid" for {@link IZoologicalName zoological names}).
315
	 *
316
	 * @see  #VALID()
317
	 * @see  #REJECTED()
318
	 * @see  #isIllegitimateType()
319
	 */
320
	public static final NomenclaturalStatusType DOUBTFUL(){
321
		return getTermByUuid(uuidDoubtful);
322
	}
323

    
324
	/**
325
	 * Returns the nomenclatural status type "confusum". A "valid" ("available")
326
	 * {@link TaxonNameBase taxon name} is "confusum" if it has been widely
327
	 * and persistently used for a taxon or taxa not including its type.<BR>
328
	 * A "confusum" taxon name is treated as if "rejected" and is therefore
329
	 * also "illegitimate" ("invalid" for {@link IZoologicalName zoological names}).
330
	 *
331
	 * @see  #VALID()
332
	 * @see  #REJECTED()
333
	 * @see  #isIllegitimateType()
334
	 */
335
	public static final NomenclaturalStatusType CONFUSUM(){
336
		return getTermByUuid(uuidConfusum);
337
	}
338

    
339
	/**
340
	 * Returns the nomenclatural status type "illegitimate" ("invalid" for
341
	 * {@link IZoologicalName zoological names}). A "valid" ("available")
342
	 * {@link TaxonNameBase taxon name}, unless "conserved" or "sanctioned", is "illegitimate"
343
	 * if it was "superfluous" when published or has been later "rejected".<BR>
344
	 *
345
	 * @see  #VALID()
346
	 * @see  #SUPERFLUOUS()
347
	 * @see  #REJECTED()
348
	 */
349
	public static final NomenclaturalStatusType ILLEGITIMATE(){
350
		return getTermByUuid(uuidIllegitimate);
351
	}
352

    
353
	/**
354
	 * Returns the nomenclatural status type "superfluous". A "valid"
355
	 * ("available") {@link TaxonNameBase taxon name} is "superfluous" if, when published,
356
	 * the taxon to which it was applied, as circumscribed by its {@link NonViralName#getCombinationAuthorship() author},
357
	 * definitely included the type of a name which ought to have been adopted,
358
	 * or of which the epithet ought to have been adopted, under the rules of
359
	 * the {@link NomenclaturalCode nomenclature code}, and if it has not been later declared
360
	 * "conserved" or "sanctioned" by the competent authorities.<BR>
361
	 * A "superfluous" taxon name is therefore also "illegitimate" ("invalid" for
362
	 * {@link IZoologicalName zoological names}).
363
	 *
364
	 * @see  #VALID()
365
	 * @see  #CONSERVED()
366
	 * @see  #SANCTIONED()
367
	 * @see  #isIllegitimateType()
368
	 */
369
	public static final NomenclaturalStatusType SUPERFLUOUS(){
370
		return getTermByUuid(uuidSuperfluous);
371
	}
372

    
373
	/**
374
	 * Returns the nomenclatural status type "rejected". A "valid" ("available")
375
	 * {@link TaxonNameBase taxon name} is "rejected" if, even though by the strict
376
	 * application of the rules of the {@link NomenclaturalCode nomenclature code}, and especially
377
	 * of the principle of priority, it should be "legitimate" ("valid" for
378
	 * {@link IZoologicalName zoological names}), competent authorities decided to handle
379
	 * it as "illegitimate".<BR>
380
	 * A "rejected" taxon name is therefore also "illegitimate" ("invalid" for
381
	 * zoological names). A "rejected" taxon name is always rejected in favour
382
	 * of a "conserved" taxon name.
383
	 *
384
	 * @see  #VALID()
385
	 * @see  #isLegitimateType()
386
	 * @see  #isIllegitimateType()
387
	 * @see  #CONSERVED()
388
	 * @see  NameRelationshipType#CONSERVED_AGAINST()
389
	 */
390
	public static final NomenclaturalStatusType REJECTED(){
391
		return getTermByUuid(uuidRejected);
392
	}
393

    
394
	/**
395
	 * Returns the nomenclatural status type "utique rejected". A "valid"
396
	 * ("available") {@link TaxonNameBase taxon name} is "utique rejected" if it is rejected
397
	 * outright (without being rejected in favour of a "conserved" taxon name).<BR>
398
	 * An "utique rejected" taxon name is therefore also "illegitimate"
399
	 * ("invalid" for zoological names).
400
	 *
401
	 * @see  #REJECTED()
402
	 * @see  #VALID()
403
	 * @see  #isIllegitimateType()
404
	 * @see  #CONSERVED()
405
	 */
406
	public static final NomenclaturalStatusType UTIQUE_REJECTED(){
407
		return getTermByUuid(uuidUtiqueRejected);
408
	}
409

    
410
	/**
411
	 * Returns the nomenclatural status type "proposed to be conserved". A
412
	 * "valid" ("available") {@link TaxonNameBase taxon name} is "proposed to be conserved"
413
	 * if, even though by the strict application of the rules of
414
	 * the {@link NomenclaturalCode nomenclature code}, and especially of the principle of priority,
415
	 * it is "illegitimate" ("invalid" for {@link IZoologicalName zoological names}),
416
	 * it has been submitted to competent authorities in order to decide whether
417
	 * it should be handled as "legitimate".<BR>
418
	 * A "proposed to be conserved" taxon name is therefore still "illegitimate"
419
	 * ("invalid" for zoological names).
420
	 *
421
	 * {@link https://dev.e-taxonomy.eu/trac/ticket/5662}
422
	 *
423
	 * @see  #VALID()
424
	 * @see  #isIllegitimateType()
425
	 * @see  #isLegitimateType()
426
	 * @see  #CONSERVED()
427
	 * @see  #CONSERVED_DESIG()
428
	 * @see  NameRelationshipType#CONSERVED_AGAINST()
429
	 */
430
	public static final NomenclaturalStatusType CONSERVED_PROP(){
431
		return getTermByUuid(uuidConservedProp);
432
	}
433

    
434
    /**
435
     * Returns the nomenclatural status type "designated to be conserved". A
436
     * "valid" ("available") {@link TaxonNameBase taxon name} is "designated to be conserved".
437
     * The name is considered to be legitimate as it has been decided by the General Committee
438
     * though not yet ratified by the Int. Bot./Zool. Congr.
439
     *
440
     * NOTE: This interpretation needs further clarification.
441
     *
442
     * {@link https://dev.e-taxonomy.eu/trac/ticket/5662}
443
     *
444
     * @see  #VALID()
445
     * @see  #isIllegitimateType()
446
     * @see  #isLegitimateType()
447
     * @see  #CONSERVED()
448
     * @see  #CONSERVED_PROP()()
449
     * @see  NameRelationshipType#CONSERVED_AGAINST()
450
     */
451
    public static final NomenclaturalStatusType CONSERVED_DESIG(){
452
        return getTermByUuid(uuidConservedDesig);
453
    }
454

    
455

    
456

    
457
	/**
458
	 * Returns the nomenclatural status type "proposed to be conserved
459
	 * (orthography)". A {@link TaxonNameBase taxon name} is "proposed to be conserved
460
	 * (orthography)" if, even though originally published with another
461
	 * spelling, it has been submitted to competent authorities in order to
462
	 * decide whether the proposed alternative spelling should be "conserved".<BR>
463
	 * A "proposed to be conserved (orthography)" taxon name is therefore still
464
	 * "illegitimate" ("invalid" for {@link IZoologicalName zoological names}).
465
	 *
466
	 * @see  #isIllegitimateType()
467
	 * @see  #CONSERVED_PROP()
468
	 * @see  #CONSERVED()
469
	 * @see  NameRelationshipType#ORTHOGRAPHIC_VARIANT()
470
	 * @see  NameRelationshipType#CONSERVED_AGAINST()
471
	 */
472
	public static final NomenclaturalStatusType ORTHOGRAPHY_CONSERVED_PROP(){
473
		return getTermByUuid(uuidOrthographyConservedProp);
474
	}
475

    
476
	/**
477
	 * Returns the nomenclatural status type "legitimate" ("valid" for
478
	 * {@link IZoologicalName zoological names}). A "valid" ("available")
479
	 * {@link TaxonNameBase taxon name}, unless "rejected", is "legitimate" if it was not
480
	 * "superfluous" when published or has been later "conserved".<BR>
481
	 *
482
	 * @see  #VALID()
483
	 * @see  #SUPERFLUOUS()
484
	 * @see  #CONSERVED()
485
	 */
486
	public static final NomenclaturalStatusType LEGITIMATE(){
487
		return getTermByUuid(uuidLegitimate);
488
	}
489

    
490
	/**
491
	 * Returns the nomenclatural status type "alternative". A family
492
	 * {@link BotanicalName botanical name} is "alternative" if it is a classical name
493
	 * long in use, in some cases even before 1753, and is considered as
494
	 * {@link NomenclaturalStatusType#VALID() "valid"} although it does not follow the rules for
495
	 * family names (see Article 18 of the ICBN).<BR>
496
	 * An "alternative" taxon name is treated as if "conserved" and is therefore
497
	 * also "legitimate".
498
	 *
499
	 * @see  #VALID()
500
	 * @see  #CONSERVED()
501
	 * @see  #isLegitimateType()
502
	 * @see  NameRelationshipType#ALTERNATIVE_NAME()
503
	 */
504
	public static final NomenclaturalStatusType ALTERNATIVE(){
505
		return getTermByUuid(uuidAlternative);
506
	}
507

    
508
	/**
509
	 * Returns the nomenclatural status type "novum". A "valid"
510
	 * ("available") {@link TaxonNameBase taxon name} is "novum" if it has been created
511
	 * in order either to replace an earlier name that is "illegitimate" or to
512
	 * avoid the building of a "later homonym".<BR>
513
	 * A "novum" taxon name is therefore also "legitimate" ("valid" for
514
	 * {@link IZoologicalName zoological names}).
515
	 *
516
	 * @see  #VALID()
517
	 * @see  #isIllegitimateType()
518
	 * @see  NameRelationshipType#REPLACED_SYNONYM()
519
	 * @see  NameRelationshipType#BLOCKING_NAME_FOR()
520
	 */
521
	public static final NomenclaturalStatusType NOVUM(){
522
		return getTermByUuid(uuidNovum);
523
	}
524

    
525
	/**
526
	 * Returns the nomenclatural status type "proposed to be utique rejected". A
527
	 * "valid" ("available") {@link TaxonNameBase taxon name} is "proposed to be utique rejected"
528
	 * if, even though by the strict application of the rules of
529
	 * the {@link NomenclaturalCode nomenclature code}, and especially of the principle of priority,
530
	 * it is "legitimate" ("valid" for {@link IZoologicalName zoological names}),
531
	 * it has been submitted to competent authorities in order to decide whether
532
	 * it should be handled as "illegitimate" (without to be rejected in favour
533
	 * of a "conserved" taxon name).<BR>
534
	 * A "proposed to be utique rejected" taxon name is therefore still "legitimate"
535
	 * ("valid" for zoological names).
536
	 *
537
	 * @see  #VALID()
538
	 * @see  #isLegitimateType()
539
	 * @see  #isIllegitimateType()
540
	 * @see  #REJECTED()
541
	 * @see  #REJECTED_PROP()
542
	 */
543
	public static final NomenclaturalStatusType UTIQUE_REJECTED_PROP(){
544
		return getTermByUuid(uuidUtiqueRejectedProp);
545
	}
546

    
547
	/**
548
	 * Returns the nomenclatural status type "conserved (orthography)". A
549
	 * {@link TaxonNameBase taxon name} is "conserved (orthography)" if competent authorities
550
	 * decided to conserve a different spelling to the one published originally.<BR>
551
	 * A "conserved (orthography)" taxon name is "conserved" and hence
552
	 * "legitimate" ("valid" for {@link IZoologicalName zoological names}).
553
	 *
554
	 * @see  #isLegitimateType()
555
	 * @see  #CONSERVED()
556
	 * @see  #ORTHOGRAPHY_CONSERVED_PROP()
557
	 * @see  NameRelationshipType#ORTHOGRAPHIC_VARIANT()
558
	 * @see  NameRelationshipType#CONSERVED_AGAINST()
559
	 */
560
	public static final NomenclaturalStatusType ORTHOGRAPHY_CONSERVED(){
561
		return getTermByUuid(uuidOrthographyConserved);
562
	}
563

    
564

    
565

    
566

    
567
    /**
568
     * Returns the nomenclatural status type "orthography rejected". <BR>
569
     * TBC.
570
     * See also {@link http://dev.e-taxonomy.eu/trac/ticket/5649}
571
     *
572
     * @see  #ORTHOGRAPHY_CONSERVED()
573
     * @see  #REJECTED()
574
     * @see  #isIllegitimateType()
575
     */
576
    public static final NomenclaturalStatusType ORTHOGRAPHY_REJECTED(){
577
        return getTermByUuid(uuidOrthographyRejected);
578
    }
579

    
580
	/**
581
	 * Returns the nomenclatural status type "proposed to be rejected". A
582
	 * "valid" ("available") {@link TaxonNameBase taxon name} is "proposed to be rejected"
583
	 * if, even though by the strict application of the rules of
584
	 * the {@link NomenclaturalCode nomenclature code}, and especially of the principle of priority,
585
	 * it should be "legitimate" ("valid" for {@link IZoologicalName zoological names}),
586
	 * it has been submitted to competent authorities in order to decide whether
587
	 * it should be handled as "illegitimate".<BR>
588
	 * A "proposed to be rejected" taxon name is therefore still "legitimate"
589
	 * ("valid" for zoological names). A "proposed to be rejected" taxon name is always
590
	 * to be rejected in favour of a "proposed to be conserved" taxon name.
591
	 *
592
	 * @see  #VALID()
593
	 * @see  #isLegitimateType()
594
	 * @see  #isIllegitimateType()
595
	 * @see  #REJECTED()
596
	 * @see  #CONSERVED_PROP()
597
	 * @see  NameRelationshipType#CONSERVED_AGAINST()
598
	 */
599
	public static final NomenclaturalStatusType REJECTED_PROP(){
600
		return getTermByUuid(uuidRejectedProp);
601
	}
602

    
603

    
604
	/**
605
	 * Returns the nomenclatural status type "conserved". A "valid"
606
	 * ("available") {@link TaxonNameBase taxon name} is "conserved" if, even though by the strict
607
	 * application of the rules of the {@link NomenclaturalCode nomenclature code}, and especially of
608
	 * the principle of priority, it should be "illegitimate" ("invalid" for
609
	 * {@link IZoologicalName zoological names}), competent authorities decided to handle
610
	 * it as "legitimate".<BR>
611
	 * A "conserved" taxon name is therefore also "legitimate" ("valid" for
612
	 * zoological names).
613
	 *
614
	 * @see  #VALID()
615
	 * @see  #isIllegitimateType()
616
	 * @see  #isLegitimateType()
617
	 * @see  NameRelationshipType#CONSERVED_AGAINST()
618
	 */
619
	public static final NomenclaturalStatusType CONSERVED(){
620
		return getTermByUuid(uuidConserved);
621
	}
622

    
623
	/**
624
	 * Returns the nomenclatural status type "sanctioned". {@link BotanicalName Botanical names}
625
	 * for fungi are "sanctioned" if they were published in the opera mentioned
626
	 * in Article 13.1d of the {@link NomenclaturalCode#ICBN() ICBN}.<BR>
627
	 * A "sanctioned" taxon name is treated as if "conserved" and is therefore
628
	 * also "legitimate".
629
	 *
630
	 * @see  #VALID()
631
	 * @see  #CONSERVED()
632
	 * @see  #isLegitimateType()
633
	 */
634
	public static final NomenclaturalStatusType SANCTIONED(){
635
		return getTermByUuid(uuidSanctioned);
636
	}
637

    
638
	/**
639
	 * Returns the nomenclatural status type "invalid" (this corresponds to
640
	 * "not available" for {@link IZoologicalName zoological names}). The use of "invalid"
641
	 * {@link TaxonNameBase taxon names} should be avoided.<BR>
642
	 * A taxon name is "invalid" if it is not "valid"; this means that
643
	 * the taxon name:<ul>
644
	 * <li>has not been effectively published or
645
	 * <li>has a form which does not comply with the rules of the
646
	 * 	   {@link NomenclaturalCode nomenclature code} or
647
	 * <li>is not accompanied by a description or diagnosis or by a reference to
648
	 * 	   such a previously published description or diagnosis
649
	 * </ul>
650
	 *
651
	 * @see  #VALID()
652
	 * @see  #isInvalidType()
653
	 * @see  #ILLEGITIMATE()
654
	 */
655
	public static final NomenclaturalStatusType INVALID(){
656
		return getTermByUuid(uuidInvalid);
657
	}
658

    
659
	/**
660
	 * Returns the nomenclatural status type "nudum". A {@link TaxonNameBase taxon name} is "nudum"
661
	 * if its publication is not accompanied by a description or diagnosis or
662
	 * by a reference to such a previously published description or diagnosis.<BR>
663
	 * A "nudum" taxon name is therefore also "invalid" ("not available" for
664
	 * {@link IZoologicalName zoological names}).
665
	 *
666
	 * @see  #isInvalidType()
667
	 */
668
	public static final NomenclaturalStatusType NUDUM(){
669
		return getTermByUuid(uuidNudum);
670
	}
671

    
672
	/**
673
	 * Returns the nomenclatural status type "invalid combination". A
674
	 * {@link TaxonNameBase bi- or trinomial} is an "invalid combination" if its
675
	 * {@link NonViralName#getCombinationAuthorship() author} did not definitely associate the final
676
	 * epithet with the name of the genus or species, or with its abbreviation.<BR>
677
	 * An "invalid combination" taxon name is therefore also "invalid"
678
	 * ("not available" for {@link IZoologicalName zoological names}).
679
	 *
680
	 * @see  #isInvalidType()
681
	 */
682
	public static final NomenclaturalStatusType COMBINATION_INVALID(){
683
		return getTermByUuid(uuidCombinationInvalid);
684
	}
685

    
686
	/**
687
	 * Returns the nomenclatural status type "illegitimate combination".
688
	 * TODO explanation
689
	 *
690
	 * @see  #isInvalidType()
691
	 */
692
	public static final NomenclaturalStatusType COMBINATION_ILLEGITIMATE(){
693
		return getTermByUuid(uuidCombinationIllegitimate);
694
	}
695

    
696
	/**
697
	 * Returns the nomenclatural status type "provisional". A {@link TaxonNameBase taxon name} is
698
	 * "provisional" if it is not validly published, because not finally accepted by the author<BR>
699
	 * Some people use it in the same way as {@link #INED() ined.}
700
	 *
701
	 * @see #INED()
702
	 * @see  #isInvalidType()
703
	 */
704
	public static final NomenclaturalStatusType PROVISIONAL(){
705
		return getTermByUuid(uuidProvisional);
706
	}
707

    
708
    /**
709
     * Returns the nomenclatural status type "ined.". A {@link TaxonNameBase taxon name} is
710
     * "inedited" if it it has not yet been published.<BR>
711
     * An inedited taxon name is therefore also "invalid" (bot.) / "not available (zool.)
712
     *<BR>
713
     * see also http://dev.e-taxonomy.eu/trac/ticket/5896
714
     *
715
     * @see #PROVISIONAL()
716
     * @see  #isInvalidType()
717
     * @return
718
     */
719
    public static final NomenclaturalStatusType INED(){
720
        return getTermByUuid(uuidIned);
721
    }
722

    
723
	/**
724
	 * Returns the nomenclatural status type "valid" (this corresponds to
725
	 * "available" for {@link IZoologicalName zoological names}).<BR>
726
	 * A {@link TaxonNameBase taxon name} is "valid" if it:<ul>
727
	 * <li>has been effectively published and
728
	 * <li>has a form which complies with the rules of the
729
	 * 	   {@link NomenclaturalCode nomenclature code} and
730
	 * <li>is accompanied by a description or diagnosis or by a reference to
731
	 * 	   such a previously published description or diagnosis
732
	 * </ul>
733
	 *
734
	 * @see  #INVALID()
735
	 * @see  #LEGITIMATE()
736
	 */
737
	public static final NomenclaturalStatusType VALID(){
738
		return getTermByUuid(uuidValid);
739
	}
740

    
741
	/**
742
	 * Returns the nomenclatural status type "subnudum". This type is not
743
	 * covered by {@link NomenclaturalCode nomenclature codes}. It appears sometimes in literature and
744
	 * represents the opinion of the author who considers the {@link TaxonNameBase taxon name} to be
745
	 * unusable for an unambiguous taxonomic use.
746
	 *
747
	 * @see  #AMBIGUOUS()
748
	 * @see  #CONFUSUM()
749
	 *
750
	 */
751
	public static final NomenclaturalStatusType SUBNUDUM(){
752
		return getTermByUuid(uuidSubnudum);
753
	}
754

    
755
	/**
756
	 * Returns the nomenclatural status type "comb. nov.". No further information available for now.
757
	 * @return
758
	 */
759
	//TODO javadoc. this term was added for Flore du Gabon
760
	public static final NomenclaturalStatusType COMB_NOV(){
761
		return getTermByUuid(uuidCombNov);
762
	}
763

    
764
	/**
765
	 * Returns the nomenclatural status type "opus utique oppressum". This type
766
	 * relates to article 32.7 (old ICBN) and article 32.9 as well as App. 6
767
	 * (new {@link NomenclaturalCode#ICBN() ICBN}). This is a reference list of botanical opera, in which all
768
	 * {@link BotanicalName taxon names} (or names of a certain rank) are oppressed. Such a name has the
769
	 * status "invalid" but in contrary to "rejected" not a single name
770
	 * is rejected by the commission but an opus with regard to the validity of
771
	 * all taxon names occurring in it.<BR>
772
	 * An "opus utique oppressum" taxon name is therefore also "invalid"
773
	 * ("not available" for {@link IZoologicalName zoological names}).
774
	 *
775
	 * @see  #isInvalidType()
776
	 */
777
	public static final NomenclaturalStatusType OPUS_UTIQUE_OPPR(){
778
		return getTermByUuid(uuidOpusUtiqueOppr);
779
	}
780

    
781
	/**
782
	 * TODO
783
	 * @return
784
	 */
785
	public static final  NomenclaturalStatusType ZOO_NOT_AVAILABLE (){
786
		return getTermByUuid(uuidZooNotAvailable);
787
	}
788

    
789
	/**
790
	 * TODO
791
	 * @return
792
	 */
793
	public static final  NomenclaturalStatusType ZOO_INVALID (){
794
		return getTermByUuid(uuidZooInvalid);
795
	}
796

    
797
	/**
798
	 * TODO
799
	 * @return
800
	 */
801
	public static final  NomenclaturalStatusType ZOO_SUPPRESSED (){
802
		return getTermByUuid(uuidZooSuppressed);
803
	}
804

    
805
	//TODO further Zoological status
806

    
807

    
808
	//TODO Soraya
809
	//	orth. var.: orthographic variant
810
	//	pro syn.: pro synonymo
811

    
812
	// TODO
813
	// Preliminary implementation for BotanicalNameParser.
814
	// not yet complete
815
	/**
816
	 * Returns the nomenclatural status type identified through its label
817
	 * abbreviation. Preliminary implementation for BotanicalNameParser.
818
	 *
819
	 * @param statusAbbreviation	the label abbreviation
820
	 * @param name                  the taxon name
821
	 * @return  					the nomenclatural status type
822
	 *
823
	 */
824
	public static NomenclaturalStatusType getNomenclaturalStatusTypeByAbbreviation(String statusAbbreviation, ITaxonNameBase name) throws UnknownCdmTypeException{
825
		if (statusAbbreviation == null){
826
			throw new NullPointerException("Abbreviation is NULL in getNomenclaturalStatusTypeByAbbreviation");
827
		}
828
		NomenclaturalStatusType result = null;
829

    
830
		//TODO handle undefined names correctly
831
		boolean isZooname = name.getNomenclaturalCode().equals(NomenclaturalCode.ICZN);
832

    
833
		Map<String, UUID> map = isZooname ? zooAbbrevMap : abbrevMap;
834
		if (map == null ){
835
			return null;
836
		}
837
		//non unique abbrev
838
		if (! isZooname && statusAbbreviation.equalsIgnoreCase("nom. alternativ.")){
839
			return NomenclaturalStatusType.ALTERNATIVE();
840
		}
841
		UUID uuid = map.get(statusAbbreviation);
842
		if (uuid != null ){
843
			result = getTermByUuid(uuid);
844
		}
845
		if (result != null){
846
			return result;
847
		}else {
848
			if (statusAbbreviation == null){
849
				statusAbbreviation = "(null)";
850
			}
851
			throw new UnknownCdmTypeException("Unknown nom. status abbreviation: " + statusAbbreviation);
852
		}
853
	}
854

    
855
	/**
856
	 * Returns the nomenclatural status type identified through its label.
857
	 *
858
	 * @param	statusLabel	the nomenclatural status label
859
	 * @return  the nomenclatural status type
860
	 *
861
	 */
862
	public static NomenclaturalStatusType getNomenclaturalStatusTypeByLabel(String statusLabel) throws UnknownCdmTypeException{
863
		if (statusLabel == null){
864
			throw new NullPointerException("Status label is NULL in getNomenclaturalStatusTypeBylabel");
865
		}
866
		NomenclaturalStatusType result = null;
867
		if (labelMap == null){
868
			return null;
869
		}
870
		statusLabel = statusLabel.toLowerCase();
871
		UUID uuid = labelMap.get(statusLabel);
872
		if (uuid != null ){
873
			result = getTermByUuid(uuid);
874
		}
875
		if (result != null){
876
			return result;
877
		}else {
878
			if (statusLabel == null){
879
				statusLabel = "(null)";
880
			}
881
			throw new UnknownCdmTypeException("Unknown nom. status label: " + statusLabel);
882
		}
883
	}
884

    
885

    
886
	/**
887
	 * Fills <i>this</i> nomenclatural status type with contents (uuid, uri,
888
	 * description text, label and label abbreviation) coming from a csv line.
889
	 * The implicit language for the description text is "latin".
890
	 * This method overrides the method of {@link eu.etaxonomy.cdm.model.common.DefinedTermBase DefinedTermBase}.
891
	 *
892
	 * @param	csvLine 	the (ordered) list of substrings from a csv string
893
	 * 						to be used to fill <i>this</i> nomenclatural status type
894
	 * @see					#NomenclaturalStatusType(String, String, String)
895
	 * @see					#readCsvLine(List, Language)
896
	 * @see					eu.etaxonomy.cdm.model.common.DefinedTermBase#readCsvLine(List)
897
	 */
898

    
899
	@Override
900
    public NomenclaturalStatusType readCsvLine(Class<NomenclaturalStatusType> termClass, List<String> csvLine, Map<UUID,DefinedTermBase> terms, boolean abbrevAsId) {   //TODO should be List<String> but makes error for some strange reason
901
		try {
902
			NomenclaturalStatusType newInstance = termClass.newInstance();
903
			DefinedTermBase.readCsvLine(newInstance, csvLine, Language.LATIN(), abbrevAsId);
904
			return newInstance;
905
		} catch (Exception e) {
906
			e.printStackTrace();
907
			throw new RuntimeException(e);
908
		}
909
	}
910

    
911
	@Override
912
	protected void setDefaultTerms(TermVocabulary<NomenclaturalStatusType> termVocabulary) {
913
		if (termVocabulary.getUuid().equals(uuidIcnafpNomStatusVocabulary)){
914
			termMap = new HashMap<UUID, NomenclaturalStatusType>();
915
			abbrevMap = new HashMap<String, UUID>();
916
			labelMap = new HashMap<String, UUID>();
917
			for (NomenclaturalStatusType term : termVocabulary.getTerms()){
918
				termMap.put(term.getUuid(), term);
919
				addStatusType(term, abbrevMap, labelMap);
920
			}
921
		}else if (termVocabulary.getUuid().equals(uuidIcznNomStatusVocabulary)){
922
			zooTermMap = new HashMap<UUID, NomenclaturalStatusType>();
923
			zooAbbrevMap = new HashMap<String, UUID>();
924
			zooLabelMap = new HashMap<String, UUID>();
925
			for (NomenclaturalStatusType term : termVocabulary.getTerms()){
926
				zooTermMap.put(term.getUuid(), term);
927
				addStatusType(term, zooAbbrevMap, zooLabelMap);
928
			}
929
		}else{
930
			throw new IllegalArgumentException("Unknown Nom.Status Vocabulary");
931
		}
932
	}
933

    
934
	public static void initDefaultTerms() {
935
        TermVocabulary<NomenclaturalStatusType> vocabulary = getTermByUuid(uuidDoubtful).getVocabulary();
936

    
937
        (new NomenclaturalStatusType()).setDefaultTerms(vocabulary);
938
    }
939

    
940
	/**
941
	 * Adds the status type to the (abbreviated) label maps
942
	 * @param term
943
	 */
944
	private void addStatusType(NomenclaturalStatusType statusType, Map<String, UUID> abbrevMap, Map<String, UUID> labelMap ) {
945
		if (statusType == null){
946
			logger.warn("statusType is NULL");
947
			return;
948
		}
949
		List<Language> list = new ArrayList<Language>();
950
		list.add(Language.LATIN());
951
		list.add(Language.ENGLISH());
952
		list.add(Language.DEFAULT());
953

    
954
		Representation representation = statusType.getPreferredRepresentation(list);
955
		if (representation != null){
956

    
957
			String abbrevLabel = representation.getAbbreviatedLabel();
958
			String label = representation.getLabel();
959
			if (abbrevLabel == null){
960
				logger.warn("label is NULL");
961
				return;
962
			}
963

    
964
			//add to map
965
			abbrevMap.put(abbrevLabel, statusType.getUuid());
966
			labelMap.put(label.toLowerCase(), statusType.getUuid());
967
		}
968

    
969
	}
970

    
971

    
972

    
973
	/**
974
	 * NomenclaturalStatusType should always be shown in latin, therefore the only existing representation
975
	 * is the latin one. In case we pass in another Language to this method it will return a <code>null</code> representation.
976
	 *
977
	 * In case the representation becomes null, we fall back to the latin representation.
978
	 *
979
	 */
980
	@Override
981
	public Representation getRepresentation(Language lang) {
982
		Representation representation = super.getRepresentation(lang);
983

    
984
		if(representation == null){
985
			representation = super.getRepresentation(Language.LATIN());
986
		}
987

    
988
		return representation;
989
	}
990

    
991

    
992
}
(23-23/37)