Project

General

Profile

Download (42.7 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

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

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

    
111

    
112

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

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

    
121

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

    
126

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

    
131

    
132

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

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

    
148

    
149
//********************************** Constructor *********************************/
150

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

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

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

    
181
//********* METHODS **************************************
182

    
183

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

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

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

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

    
289

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

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

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

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

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

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

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

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

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

    
453

    
454

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

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

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

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

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

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

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

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

    
598

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

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

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

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

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

    
681
	/**
682
	 * Returns the nomenclatural status type "illegitimate combination".
683
	 * TODO explanation
684
	 *
685
	 * @see  #isInvalidType()
686
	 */
687
	public static final NomenclaturalStatusType COMBINATION_ILLEGITIMATE(){
688
		return getTermByUuid(uuidCombinationIllegitimate);
689
	}
690

    
691
	/**
692
	 * Returns the nomenclatural status type "provisional". A {@link TaxonNameBase taxon name} is
693
	 * "provisional" if it has not been yet effectively published.<BR>
694
	 * A "provisional" taxon name is therefore also "invalid"
695
	 * ("not available" for {@link ZoologicalName zoological names}).
696
	 *
697
	 * @see  #isInvalidType()
698
	 */
699
	public static final NomenclaturalStatusType PROVISIONAL(){
700
		return getTermByUuid(uuidProvisional);
701
	}
702

    
703
	/**
704
	 * Returns the nomenclatural status type "valid" (this corresponds to
705
	 * "available" for {@link ZoologicalName zoological names}).<BR>
706
	 * A {@link TaxonNameBase taxon name} is "valid" if it:<ul>
707
	 * <li>has been effectively published and
708
	 * <li>has a form which complies with the rules of the
709
	 * 	   {@link NomenclaturalCode nomenclature code} and
710
	 * <li>is accompanied by a description or diagnosis or by a reference to
711
	 * 	   such a previously published description or diagnosis
712
	 * </ul>
713
	 *
714
	 * @see  #INVALID()
715
	 * @see  #LEGITIMATE()
716
	 */
717
	public static final NomenclaturalStatusType VALID(){
718
		return getTermByUuid(uuidValid);
719
	}
720

    
721
	/**
722
	 * Returns the nomenclatural status type "subnudum". This type is not
723
	 * covered by {@link NomenclaturalCode nomenclature codes}. It appears sometimes in literature and
724
	 * represents the opinion of the author who considers the {@link TaxonNameBase taxon name} to be
725
	 * unusable for an unambiguous taxonomic use.
726
	 *
727
	 * @see  #AMBIGUOUS()
728
	 * @see  #CONFUSUM()
729
	 *
730
	 */
731
	public static final NomenclaturalStatusType SUBNUDUM(){
732
		return getTermByUuid(uuidSubnudum);
733
	}
734

    
735
	/**
736
	 * Returns the nomenclatural status type "comb. nov.". No further information available for now.
737
	 * @return
738
	 */
739
	//TODO javadoc. this term was added for Flore du Gabon
740
	public static final NomenclaturalStatusType COMB_NOV(){
741
		return getTermByUuid(uuidCombNov);
742
	}
743

    
744
	/**
745
	 * Returns the nomenclatural status type "opus utique oppressum". This type
746
	 * relates to article 32.7 (old ICBN) and article 32.9 as well as App. 6
747
	 * (new {@link NomenclaturalCode#ICBN() ICBN}). This is a reference list of botanical opera, in which all
748
	 * {@link BotanicalName taxon names} (or names of a certain rank) are oppressed. Such a name has the
749
	 * status "invalid" but in contrary to "rejected" not a single name
750
	 * is rejected by the commission but an opus with regard to the validity of
751
	 * all taxon names occurring in it.<BR>
752
	 * An "opus utique oppressum" taxon name is therefore also "invalid"
753
	 * ("not available" for {@link ZoologicalName zoological names}).
754
	 *
755
	 * @see  #isInvalidType()
756
	 */
757
	public static final NomenclaturalStatusType OPUS_UTIQUE_OPPR(){
758
		return getTermByUuid(uuidOpusUtiqueOppr);
759
	}
760

    
761
	/**
762
	 * TODO
763
	 * @return
764
	 */
765
	public static final  NomenclaturalStatusType ZOO_NOT_AVAILABLE (){
766
		return getTermByUuid(uuidZooNotAvailable);
767
	}
768

    
769
	/**
770
	 * TODO
771
	 * @return
772
	 */
773
	public static final  NomenclaturalStatusType ZOO_INVALID (){
774
		return getTermByUuid(uuidZooInvalid);
775
	}
776

    
777
	/**
778
	 * TODO
779
	 * @return
780
	 */
781
	public static final  NomenclaturalStatusType ZOO_SUPPRESSED (){
782
		return getTermByUuid(uuidZooSuppressed);
783
	}
784

    
785
	//TODO further Zoological status
786

    
787

    
788
	//TODO Soraya
789
	//	orth. var.: orthographic variant
790
	//	pro syn.: pro synonymo
791

    
792
	// TODO
793
	// Preliminary implementation for BotanicalNameParser.
794
	// not yet complete
795
	/**
796
	 * Returns the nomenclatural status type identified through its label
797
	 * abbreviation. Preliminary implementation for BotanicalNameParser.
798
	 *
799
	 * @param	statusAbbreviation	the label abbreviation
800
	 * @param name
801
	 * @return  					the nomenclatural status type
802
	 *
803
	 */
804
	public static NomenclaturalStatusType getNomenclaturalStatusTypeByAbbreviation(String statusAbbreviation, NonViralName<?> name) throws UnknownCdmTypeException{
805
		if (statusAbbreviation == null){
806
			throw new NullPointerException("Abbreviation is NULL in getNomenclaturalStatusTypeByAbbreviation");
807
		}
808
		NomenclaturalStatusType result = null;
809

    
810
		//TODO handle undefined names correctly
811
		boolean isZooname = name.getNomenclaturalCode().equals(NomenclaturalCode.ICZN);
812

    
813
		Map<String, UUID> map = isZooname ? zooAbbrevMap : abbrevMap;
814
		if (map == null ){
815
			return null;
816
		}
817
		//non unique abbrev
818
		if (! isZooname && statusAbbreviation.equalsIgnoreCase("nom. alternativ.")){
819
			return NomenclaturalStatusType.ALTERNATIVE();
820
		}
821
		UUID uuid = map.get(statusAbbreviation);
822
		if (uuid != null ){
823
			result = getTermByUuid(uuid);
824
		}
825
		if (result != null){
826
			return result;
827
		}else {
828
			if (statusAbbreviation == null){
829
				statusAbbreviation = "(null)";
830
			}
831
			throw new UnknownCdmTypeException("Unknown nom. status abbreviation: " + statusAbbreviation);
832
		}
833

    
834
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. ambig.")) { return NomenclaturalStatusType.AMBIGUOUS();
835
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. dub.")) { return NomenclaturalStatusType.DOUBTFUL();
836
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. confus.")) { return NomenclaturalStatusType.CONFUSUM();
837
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. illeg.")){return NomenclaturalStatusType.ILLEGITIMATE();
838
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. superfl.")){ return NomenclaturalStatusType.SUPERFLUOUS();
839
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. rej.")) { return NomenclaturalStatusType.REJECTED();
840
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. utique rej.")) { return NomenclaturalStatusType.UTIQUE_REJECTED();
841
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. cons. prop.")) { return NomenclaturalStatusType.CONSERVED_PROP();
842
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. orth. cons. prop.")) { return NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED_PROP();
843
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. legit.")) { return NomenclaturalStatusType.LEGITIMATE();
844
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. altern.")) { return NomenclaturalStatusType.ALTERNATIVE();
845

    
846
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. alternativ.")) { return NomenclaturalStatusType.ALTERNATIVE();
847

    
848
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. nov.")) { return NomenclaturalStatusType.NOVUM();
849
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. utique rej. prop.")) { return NomenclaturalStatusType.UTIQUE_REJECTED_PROP();
850
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. orth. cons.")) { return NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED();
851
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. rej. prop.")) { return NomenclaturalStatusType.REJECTED_PROP();
852
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. cons.")) { return NomenclaturalStatusType.CONSERVED();
853
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. sanct.")) { return NomenclaturalStatusType.SANCTIONED();
854
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. inval.")) { return NomenclaturalStatusType.INVALID();
855
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. nud.")){ return NomenclaturalStatusType.NUDUM();
856
//		}else if (statusAbbreviation.equalsIgnoreCase("comb. inval.")){ return NomenclaturalStatusType.COMBINATION_INVALID();
857
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. provis.")) { return NomenclaturalStatusType.PROVISIONAL();
858
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. valid")) { return NomenclaturalStatusType.VALID();
859
//		}else if (statusAbbreviation.equalsIgnoreCase("opus. utique oppr.")) { return NomenclaturalStatusType.OPUS_UTIQUE_OPPR();
860
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. subnud.")) { return NomenclaturalStatusType.SUBNUDUM();
861
//		//TODO make generic, use labels for map
862
//		}else {
863
//			if (statusAbbreviation == null){
864
//				statusAbbreviation = "(null)";
865
//			}
866
//			throw new eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException("Unknown NomenclaturalStatusType abbreviation: " + statusAbbreviation);
867
//		}
868
	}
869

    
870
	/**
871
	 * Returns the nomenclatural status type identified through its label.
872
	 *
873
	 * @param	statusLabel	the nomenclatural status label
874
	 * @return  the nomenclatural status type
875
	 *
876
	 */
877
	public static NomenclaturalStatusType getNomenclaturalStatusTypeByLabel(String statusLabel) throws UnknownCdmTypeException{
878
		if (statusLabel == null){
879
			throw new NullPointerException("Status label is NULL in getNomenclaturalStatusTypeBylabel");
880
		}
881
		NomenclaturalStatusType result = null;
882
		if (labelMap == null){
883
			return null;
884
		}
885
		statusLabel = statusLabel.toLowerCase();
886
		UUID uuid = labelMap.get(statusLabel);
887
		if (uuid != null ){
888
			result = getTermByUuid(uuid);
889
		}
890
		if (result != null){
891
			return result;
892
		}else {
893
			if (statusLabel == null){
894
				statusLabel = "(null)";
895
			}
896
			throw new UnknownCdmTypeException("Unknown nom. status label: " + statusLabel);
897
		}
898

    
899
//		if (statusLabel == null){ throw new NullPointerException("statusLabel is 'null' in getNomenclaturalStatusTypeByLabel");
900
//		}else if (statusLabel.equalsIgnoreCase("Ambiguous")) { return NomenclaturalStatusType.AMBIGUOUS();
901
//		}else if (statusLabel.equalsIgnoreCase("Doubtful")) { return NomenclaturalStatusType.DOUBTFUL();
902
//		}else if (statusLabel.equalsIgnoreCase("Confusum")) { return NomenclaturalStatusType.CONFUSUM();
903
//		}else if (statusLabel.equalsIgnoreCase("Illegitimate")){return NomenclaturalStatusType.ILLEGITIMATE();
904
//		}else if (statusLabel.equalsIgnoreCase("Superfluous")){ return NomenclaturalStatusType.SUPERFLUOUS();
905
//		}else if (statusLabel.equalsIgnoreCase("Rejected")) { return NomenclaturalStatusType.REJECTED();
906
//		}else if (statusLabel.equalsIgnoreCase("Utique Rejected")) { return NomenclaturalStatusType.UTIQUE_REJECTED();
907
//		}else if (statusLabel.equalsIgnoreCase("Conserved Prop")) { return NomenclaturalStatusType.CONSERVED_PROP();
908
//		}else if (statusLabel.equalsIgnoreCase("Orthography Conserved Prop")) { return NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED_PROP();
909
//		}else if (statusLabel.equalsIgnoreCase("Legitimate")) { return NomenclaturalStatusType.LEGITIMATE();
910
//		}else if (statusLabel.equalsIgnoreCase("Alternative")) { return NomenclaturalStatusType.ALTERNATIVE();
911
//		}else if (statusLabel.equalsIgnoreCase("Novum")) { return NomenclaturalStatusType.NOVUM();
912
//		}else if (statusLabel.equalsIgnoreCase("Utique Rejected Prop")) { return NomenclaturalStatusType.UTIQUE_REJECTED_PROP();
913
//		}else if (statusLabel.equalsIgnoreCase("Orthography Conserved")) { return NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED();
914
//		}else if (statusLabel.equalsIgnoreCase("Rejected Prop")) { return NomenclaturalStatusType.REJECTED_PROP();
915
//		}else if (statusLabel.equalsIgnoreCase("Conserved")) { return NomenclaturalStatusType.CONSERVED();
916
//		}else if (statusLabel.equalsIgnoreCase("Sanctioned")) { return NomenclaturalStatusType.SANCTIONED();
917
//		}else if (statusLabel.equalsIgnoreCase("Invalid")) { return NomenclaturalStatusType.INVALID();
918
//		}else if (statusLabel.equalsIgnoreCase("Nudum")){ return NomenclaturalStatusType.NUDUM();
919
//		}else if (statusLabel.equalsIgnoreCase("Combination Invalid")){ return NomenclaturalStatusType.COMBINATION_INVALID();
920
//		}else if (statusLabel.equalsIgnoreCase("Provisional")) { return NomenclaturalStatusType.PROVISIONAL();
921
//		}else if (statusLabel.equalsIgnoreCase("Valid")) { return NomenclaturalStatusType.VALID();
922
//		}else if (statusLabel.equalsIgnoreCase("Opus Utique Oppr")) { return NomenclaturalStatusType.OPUS_UTIQUE_OPPR();
923
//		}else if (statusLabel.equalsIgnoreCase("Subnudum")) { return NomenclaturalStatusType.SUBNUDUM();
924
//		}else {
925
//			if (statusLabel == null){
926
//				statusLabel = "(null)";
927
//			}
928
//			throw new eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException("Unknown NomenclaturalStatusType abbreviation: " + statusLabel);
929
//		}
930
	}
931

    
932

    
933
	/**
934
	 * Fills <i>this</i> nomenclatural status type with contents (uuid, uri,
935
	 * description text, label and label abbreviation) coming from a csv line.
936
	 * The implicit language for the description text is "latin".
937
	 * This method overrides the method of {@link eu.etaxonomy.cdm.model.common.DefinedTermBase DefinedTermBase}.
938
	 *
939
	 * @param	csvLine 	the (ordered) list of substrings from a csv string
940
	 * 						to be used to fill <i>this</i> nomenclatural status type
941
	 * @see					#NomenclaturalStatusType(String, String, String)
942
	 * @see					#readCsvLine(List, Language)
943
	 * @see					eu.etaxonomy.cdm.model.common.DefinedTermBase#readCsvLine(List)
944
	 */
945

    
946
	@Override
947
    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
948
		try {
949
			NomenclaturalStatusType newInstance = termClass.newInstance();
950
			DefinedTermBase.readCsvLine(newInstance, csvLine, Language.LATIN(), abbrevAsId);
951
			return newInstance;
952
		} catch (Exception e) {
953
			e.printStackTrace();
954
			throw new RuntimeException(e);
955
		}
956
	}
957

    
958
	@Override
959
	protected void setDefaultTerms(TermVocabulary<NomenclaturalStatusType> termVocabulary) {
960
		if (termVocabulary.getUuid().equals(uuidIcnafpNomStatusVocabulary)){
961
			termMap = new HashMap<UUID, NomenclaturalStatusType>();
962
			abbrevMap = new HashMap<String, UUID>();
963
			labelMap = new HashMap<String, UUID>();
964
			for (NomenclaturalStatusType term : termVocabulary.getTerms()){
965
				termMap.put(term.getUuid(), term);
966
				addStatusType(term, abbrevMap, labelMap);
967
			}
968
		}else if (termVocabulary.getUuid().equals(uuidIcznNomStatusVocabulary)){
969
			zooTermMap = new HashMap<UUID, NomenclaturalStatusType>();
970
			zooAbbrevMap = new HashMap<String, UUID>();
971
			zooLabelMap = new HashMap<String, UUID>();
972
			for (NomenclaturalStatusType term : termVocabulary.getTerms()){
973
				zooTermMap.put(term.getUuid(), term);
974
				addStatusType(term, zooAbbrevMap, zooLabelMap);
975
			}
976
		}else{
977
			throw new IllegalArgumentException("Unknown Nom.Status Vocabulary");
978
		}
979
	}
980

    
981
	public static void initDefaultTerms() {
982
        TermVocabulary<NomenclaturalStatusType> vocabulary = getTermByUuid(uuidDoubtful).getVocabulary();
983

    
984
        (new NomenclaturalStatusType()).setDefaultTerms(vocabulary);
985
    }
986

    
987
	/**
988
	 * Adds the status type to the (abbreviated) label maps
989
	 * @param term
990
	 */
991
	private void addStatusType(NomenclaturalStatusType statusType, Map<String, UUID> abbrevMap, Map<String, UUID> labelMap ) {
992
		if (statusType == null){
993
			logger.warn("statusType is NULL");
994
			return;
995
		}
996
		List<Language> list = new ArrayList<Language>();
997
		list.add(Language.LATIN());
998
		list.add(Language.ENGLISH());
999
		list.add(Language.DEFAULT());
1000

    
1001
		Representation representation = statusType.getPreferredRepresentation(list);
1002
		if (representation != null){
1003

    
1004
			String abbrevLabel = representation.getAbbreviatedLabel();
1005
			String label = representation.getLabel();
1006
			if (abbrevLabel == null){
1007
				logger.warn("label is NULL");
1008
				return;
1009
			}
1010

    
1011
			//add to map
1012
			abbrevMap.put(abbrevLabel, statusType.getUuid());
1013
			labelMap.put(label.toLowerCase(), statusType.getUuid());
1014
		}
1015

    
1016
	}
1017

    
1018

    
1019

    
1020
	/**
1021
	 * NomenclaturalStatusType should always be shown in latin, therefore the only existing representation
1022
	 * is the latin one. In case we pass in another Language to this method it will return a <code>null</code> representation.
1023
	 *
1024
	 * In case the representation becomes null, we fall back to the latin representation.
1025
	 *
1026
	 */
1027
	@Override
1028
	public Representation getRepresentation(Language lang) {
1029
		Representation representation = super.getRepresentation(lang);
1030

    
1031
		if(representation == null){
1032
			representation = super.getRepresentation(Language.LATIN());
1033
		}
1034

    
1035
		return representation;
1036
	}
1037

    
1038

    
1039
}
(15-15/28)