Project

General

Profile

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

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

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

    
110

    
111

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

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

    
120

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

    
125

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

    
130

    
131

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

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

    
147

    
148
//********************************** Constructor *********************************/
149

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

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

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

    
180
//********* METHODS **************************************
181

    
182

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

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

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

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

    
287

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

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

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

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

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

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

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

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

    
427
	/**
428
	 * Returns the nomenclatural status type "proposed to be conserved
429
	 * (orthography)". A {@link TaxonNameBase taxon name} is "proposed to be conserved
430
	 * (orthography)" if, even though originally published with another
431
	 * spelling, it has been submitted to competent authorities in order to
432
	 * decide whether the proposed alternative spelling should be "conserved".<BR>
433
	 * A "proposed to be conserved (orthography)" taxon name is therefore still
434
	 * "illegitimate" ("invalid" for {@link ZoologicalName zoological names}).
435
	 *
436
	 * @see  #isIllegitimateType()
437
	 * @see  #CONSERVED_PROP()
438
	 * @see  #CONSERVED()
439
	 * @see  NameRelationshipType#ORTHOGRAPHIC_VARIANT()
440
	 * @see  NameRelationshipType#CONSERVED_AGAINST()
441
	 */
442
	public static final NomenclaturalStatusType ORTHOGRAPHY_CONSERVED_PROP(){
443
		return getTermByUuid(uuidOrthographyConservedProp);
444
	}
445

    
446
	/**
447
	 * Returns the nomenclatural status type "legitimate" ("valid" for
448
	 * {@link ZoologicalName zoological names}). A "valid" ("available")
449
	 * {@link TaxonNameBase taxon name}, unless "rejected", is "legitimate" if it was not
450
	 * "superfluous" when published or has been later "conserved".<BR>
451
	 *
452
	 * @see  #VALID()
453
	 * @see  #SUPERFLUOUS()
454
	 * @see  #CONSERVED()
455
	 */
456
	public static final NomenclaturalStatusType LEGITIMATE(){
457
		return getTermByUuid(uuidLegitimate);
458
	}
459

    
460
	/**
461
	 * Returns the nomenclatural status type "alternative". A family
462
	 * {@link BotanicalName botanical name} is "alternative" if it is a classical name
463
	 * long in use, in some cases even before 1753, and is considered as
464
	 * {@link NomenclaturalStatusType#VALID() "valid"} although it does not follow the rules for
465
	 * family names (see Article 18 of the ICBN).<BR>
466
	 * An "alternative" taxon name is treated as if "conserved" and is therefore
467
	 * also "legitimate".
468
	 *
469
	 * @see  #VALID()
470
	 * @see  #CONSERVED()
471
	 * @see  #isLegitimateType()
472
	 * @see  NameRelationshipType#ALTERNATIVE_NAME()
473
	 */
474
	public static final NomenclaturalStatusType ALTERNATIVE(){
475
		return getTermByUuid(uuidAlternative);
476
	}
477

    
478
	/**
479
	 * Returns the nomenclatural status type "novum". A "valid"
480
	 * ("available") {@link TaxonNameBase taxon name} is "novum" if it has been created
481
	 * in order either to replace an earlier name that is "illegitimate" or to
482
	 * avoid the building of a "later homonym".<BR>
483
	 * A "novum" taxon name is therefore also "legitimate" ("valid" for
484
	 * {@link ZoologicalName zoological names}).
485
	 *
486
	 * @see  #VALID()
487
	 * @see  #isIllegitimateType()
488
	 * @see  NameRelationshipType#REPLACED_SYNONYM()
489
	 * @see  NameRelationshipType#BLOCKING_NAME_FOR()
490
	 */
491
	public static final NomenclaturalStatusType NOVUM(){
492
		return getTermByUuid(uuidNovum);
493
	}
494

    
495
	/**
496
	 * Returns the nomenclatural status type "proposed to be utique rejected". A
497
	 * "valid" ("available") {@link TaxonNameBase taxon name} is "proposed to be utique rejected"
498
	 * if, even though by the strict application of the rules of
499
	 * the {@link NomenclaturalCode nomenclature code}, and especially of the principle of priority,
500
	 * it is "legitimate" ("valid" for {@link ZoologicalName zoological names}),
501
	 * it has been submitted to competent authorities in order to decide whether
502
	 * it should be handled as "illegitimate" (without to be rejected in favour
503
	 * of a "conserved" taxon name).<BR>
504
	 * A "proposed to be utique rejected" taxon name is therefore still "legitimate"
505
	 * ("valid" for zoological names).
506
	 *
507
	 * @see  #VALID()
508
	 * @see  #isLegitimateType()
509
	 * @see  #isIllegitimateType()
510
	 * @see  #REJECTED()
511
	 * @see  #REJECTED_PROP()
512
	 */
513
	public static final NomenclaturalStatusType UTIQUE_REJECTED_PROP(){
514
		return getTermByUuid(uuidUtiqueRejectedProp);
515
	}
516

    
517
	/**
518
	 * Returns the nomenclatural status type "conserved (orthography)". A
519
	 * {@link TaxonNameBase taxon name} is "conserved (orthography)" if competent authorities
520
	 * decided to conserve a different spelling to the one published originally.<BR>
521
	 * A "conserved (orthography)" taxon name is "conserved" and hence
522
	 * "legitimate" ("valid" for {@link ZoologicalName zoological names}).
523
	 *
524
	 * @see  #isLegitimateType()
525
	 * @see  #CONSERVED()
526
	 * @see  #ORTHOGRAPHY_CONSERVED_PROP()
527
	 * @see  NameRelationshipType#ORTHOGRAPHIC_VARIANT()
528
	 * @see  NameRelationshipType#CONSERVED_AGAINST()
529
	 */
530
	public static final NomenclaturalStatusType ORTHOGRAPHY_CONSERVED(){
531
		return getTermByUuid(uuidOrthographyConserved);
532
	}
533

    
534
    /**
535
     * Returns the nomenclatural status type "orthography rejected". <BR>
536
     * TBC.
537
     * See also {@link http://dev.e-taxonomy.eu/trac/ticket/5649}
538
     *
539
     * @see  #ORTHOGRAPHY_CONSERVED()
540
     * @see  #REJECTED()
541
     * @see  #isIllegitimateType()
542
     */
543
    public static final NomenclaturalStatusType ORTHOGRAPHY_REJECTED(){
544
        return getTermByUuid(uuidOrthographyRejected);
545
    }
546

    
547
	/**
548
	 * Returns the nomenclatural status type "proposed to be rejected". A
549
	 * "valid" ("available") {@link TaxonNameBase taxon name} is "proposed to be rejected"
550
	 * if, even though by the strict application of the rules of
551
	 * the {@link NomenclaturalCode nomenclature code}, and especially of the principle of priority,
552
	 * it should be "legitimate" ("valid" for {@link ZoologicalName zoological names}),
553
	 * it has been submitted to competent authorities in order to decide whether
554
	 * it should be handled as "illegitimate".<BR>
555
	 * A "proposed to be rejected" taxon name is therefore still "legitimate"
556
	 * ("valid" for zoological names). A "proposed to be rejected" taxon name is always
557
	 * to be rejected in favour of a "proposed to be conserved" taxon name.
558
	 *
559
	 * @see  #VALID()
560
	 * @see  #isLegitimateType()
561
	 * @see  #isIllegitimateType()
562
	 * @see  #REJECTED()
563
	 * @see  #CONSERVED_PROP()
564
	 * @see  NameRelationshipType#CONSERVED_AGAINST()
565
	 */
566
	public static final NomenclaturalStatusType REJECTED_PROP(){
567
		return getTermByUuid(uuidRejectedProp);
568
	}
569

    
570

    
571
	/**
572
	 * Returns the nomenclatural status type "conserved". A "valid"
573
	 * ("available") {@link TaxonNameBase taxon name} is "conserved" if, even though by the strict
574
	 * application of the rules of the {@link NomenclaturalCode nomenclature code}, and especially of
575
	 * the principle of priority, it should be "illegitimate" ("invalid" for
576
	 * {@link ZoologicalName zoological names}), competent authorities decided to handle
577
	 * it as "legitimate".<BR>
578
	 * A "conserved" taxon name is therefore also "legitimate" ("valid" for
579
	 * zoological names).
580
	 *
581
	 * @see  #VALID()
582
	 * @see  #isIllegitimateType()
583
	 * @see  #isLegitimateType()
584
	 * @see  NameRelationshipType#CONSERVED_AGAINST()
585
	 */
586
	public static final NomenclaturalStatusType CONSERVED(){
587
		return getTermByUuid(uuidConserved);
588
	}
589

    
590
	/**
591
	 * Returns the nomenclatural status type "sanctioned". {@link BotanicalName Botanical names}
592
	 * for fungi are "sanctioned" if they were published in the opera mentioned
593
	 * in Article 13.1d of the {@link NomenclaturalCode#ICBN() ICBN}.<BR>
594
	 * A "sanctioned" taxon name is treated as if "conserved" and is therefore
595
	 * also "legitimate".
596
	 *
597
	 * @see  #VALID()
598
	 * @see  #CONSERVED()
599
	 * @see  #isLegitimateType()
600
	 */
601
	public static final NomenclaturalStatusType SANCTIONED(){
602
		return getTermByUuid(uuidSanctioned);
603
	}
604

    
605
	/**
606
	 * Returns the nomenclatural status type "invalid" (this corresponds to
607
	 * "not available" for {@link ZoologicalName zoological names}). The use of "invalid"
608
	 * {@link TaxonNameBase taxon names} should be avoided.<BR>
609
	 * A taxon name is "invalid" if it is not "valid"; this means that
610
	 * the taxon name:<ul>
611
	 * <li>has not been effectively published or
612
	 * <li>has a form which does not comply with the rules of the
613
	 * 	   {@link NomenclaturalCode nomenclature code} or
614
	 * <li>is not accompanied by a description or diagnosis or by a reference to
615
	 * 	   such a previously published description or diagnosis
616
	 * </ul>
617
	 *
618
	 * @see  #VALID()
619
	 * @see  #isInvalidType()
620
	 * @see  #ILLEGITIMATE()
621
	 */
622
	public static final NomenclaturalStatusType INVALID(){
623
		return getTermByUuid(uuidInvalid);
624
	}
625

    
626
	/**
627
	 * Returns the nomenclatural status type "nudum". A {@link TaxonNameBase taxon name} is "nudum"
628
	 * if its publication is not accompanied by a description or diagnosis or
629
	 * by a reference to such a previously published description or diagnosis.<BR>
630
	 * A "nudum" taxon name is therefore also "invalid" ("not available" for
631
	 * {@link ZoologicalName zoological names}).
632
	 *
633
	 * @see  #isInvalidType()
634
	 */
635
	public static final NomenclaturalStatusType NUDUM(){
636
		return getTermByUuid(uuidNudum);
637
	}
638

    
639
	/**
640
	 * Returns the nomenclatural status type "invalid combination". A
641
	 * {@link TaxonNameBase bi- or trinomial} is an "invalid combination" if its
642
	 * {@link NonViralName#getCombinationAuthorship() author} did not definitely associate the final
643
	 * epithet with the name of the genus or species, or with its abbreviation.<BR>
644
	 * An "invalid combination" taxon name is therefore also "invalid"
645
	 * ("not available" for {@link ZoologicalName zoological names}).
646
	 *
647
	 * @see  #isInvalidType()
648
	 */
649
	public static final NomenclaturalStatusType COMBINATION_INVALID(){
650
		return getTermByUuid(uuidCombinationInvalid);
651
	}
652

    
653
	/**
654
	 * Returns the nomenclatural status type "illegitimate combination".
655
	 * TODO explanation
656
	 *
657
	 * @see  #isInvalidType()
658
	 */
659
	public static final NomenclaturalStatusType COMBINATION_ILLEGITIMATE(){
660
		return getTermByUuid(uuidCombinationIllegitimate);
661
	}
662

    
663
	/**
664
	 * Returns the nomenclatural status type "provisional". A {@link TaxonNameBase taxon name} is
665
	 * "provisional" if it has not been yet effectively published.<BR>
666
	 * A "provisional" taxon name is therefore also "invalid"
667
	 * ("not available" for {@link ZoologicalName zoological names}).
668
	 *
669
	 * @see  #isInvalidType()
670
	 */
671
	public static final NomenclaturalStatusType PROVISIONAL(){
672
		return getTermByUuid(uuidProvisional);
673
	}
674

    
675
	/**
676
	 * Returns the nomenclatural status type "valid" (this corresponds to
677
	 * "available" for {@link ZoologicalName zoological names}).<BR>
678
	 * A {@link TaxonNameBase taxon name} is "valid" if it:<ul>
679
	 * <li>has been effectively published and
680
	 * <li>has a form which complies with the rules of the
681
	 * 	   {@link NomenclaturalCode nomenclature code} and
682
	 * <li>is accompanied by a description or diagnosis or by a reference to
683
	 * 	   such a previously published description or diagnosis
684
	 * </ul>
685
	 *
686
	 * @see  #INVALID()
687
	 * @see  #LEGITIMATE()
688
	 */
689
	public static final NomenclaturalStatusType VALID(){
690
		return getTermByUuid(uuidValid);
691
	}
692

    
693
	/**
694
	 * Returns the nomenclatural status type "subnudum". This type is not
695
	 * covered by {@link NomenclaturalCode nomenclature codes}. It appears sometimes in literature and
696
	 * represents the opinion of the author who considers the {@link TaxonNameBase taxon name} to be
697
	 * unusable for an unambiguous taxonomic use.
698
	 *
699
	 * @see  #AMBIGUOUS()
700
	 * @see  #CONFUSUM()
701
	 *
702
	 */
703
	public static final NomenclaturalStatusType SUBNUDUM(){
704
		return getTermByUuid(uuidSubnudum);
705
	}
706

    
707
	/**
708
	 * Returns the nomenclatural status type "comb. nov.". No further information available for now.
709
	 * @return
710
	 */
711
	//TODO javadoc. this term was added for Flore du Gabon
712
	public static final NomenclaturalStatusType COMB_NOV(){
713
		return getTermByUuid(uuidCombNov);
714
	}
715

    
716
	/**
717
	 * Returns the nomenclatural status type "opus utique oppressum". This type
718
	 * relates to article 32.7 (old ICBN) and article 32.9 as well as App. 6
719
	 * (new {@link NomenclaturalCode#ICBN() ICBN}). This is a reference list of botanical opera, in which all
720
	 * {@link BotanicalName taxon names} (or names of a certain rank) are oppressed. Such a name has the
721
	 * status "invalid" but in contrary to "rejected" not a single name
722
	 * is rejected by the commission but an opus with regard to the validity of
723
	 * all taxon names occurring in it.<BR>
724
	 * An "opus utique oppressum" taxon name is therefore also "invalid"
725
	 * ("not available" for {@link ZoologicalName zoological names}).
726
	 *
727
	 * @see  #isInvalidType()
728
	 */
729
	public static final NomenclaturalStatusType OPUS_UTIQUE_OPPR(){
730
		return getTermByUuid(uuidOpusUtiqueOppr);
731
	}
732

    
733
	/**
734
	 * TODO
735
	 * @return
736
	 */
737
	public static final  NomenclaturalStatusType ZOO_NOT_AVAILABLE (){
738
		return getTermByUuid(uuidZooNotAvailable);
739
	}
740

    
741
	/**
742
	 * TODO
743
	 * @return
744
	 */
745
	public static final  NomenclaturalStatusType ZOO_INVALID (){
746
		return getTermByUuid(uuidZooInvalid);
747
	}
748

    
749
	/**
750
	 * TODO
751
	 * @return
752
	 */
753
	public static final  NomenclaturalStatusType ZOO_SUPPRESSED (){
754
		return getTermByUuid(uuidZooSuppressed);
755
	}
756

    
757
	//TODO further Zoological status
758

    
759

    
760
	//TODO Soraya
761
	//	orth. var.: orthographic variant
762
	//	pro syn.: pro synonymo
763

    
764
	// TODO
765
	// Preliminary implementation for BotanicalNameParser.
766
	// not yet complete
767
	/**
768
	 * Returns the nomenclatural status type identified through its label
769
	 * abbreviation. Preliminary implementation for BotanicalNameParser.
770
	 *
771
	 * @param	statusAbbreviation	the label abbreviation
772
	 * @param name
773
	 * @return  					the nomenclatural status type
774
	 *
775
	 */
776
	public static NomenclaturalStatusType getNomenclaturalStatusTypeByAbbreviation(String statusAbbreviation, NonViralName<?> name) throws UnknownCdmTypeException{
777
		if (statusAbbreviation == null){
778
			throw new NullPointerException("Abbreviation is NULL in getNomenclaturalStatusTypeByAbbreviation");
779
		}
780
		NomenclaturalStatusType result = null;
781

    
782
		//TODO handle undefined names correctly
783
		boolean isZooname = name.getNomenclaturalCode().equals(NomenclaturalCode.ICZN);
784

    
785
		Map<String, UUID> map = isZooname ? zooAbbrevMap : abbrevMap;
786
		if (map == null ){
787
			return null;
788
		}
789
		//non unique abbrev
790
		if (! isZooname && statusAbbreviation.equalsIgnoreCase("nom. alternativ.")){
791
			return NomenclaturalStatusType.ALTERNATIVE();
792
		}
793
		UUID uuid = map.get(statusAbbreviation);
794
		if (uuid != null ){
795
			result = getTermByUuid(uuid);
796
		}
797
		if (result != null){
798
			return result;
799
		}else {
800
			if (statusAbbreviation == null){
801
				statusAbbreviation = "(null)";
802
			}
803
			throw new UnknownCdmTypeException("Unknown nom. status abbreviation: " + statusAbbreviation);
804
		}
805

    
806
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. ambig.")) { return NomenclaturalStatusType.AMBIGUOUS();
807
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. dub.")) { return NomenclaturalStatusType.DOUBTFUL();
808
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. confus.")) { return NomenclaturalStatusType.CONFUSUM();
809
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. illeg.")){return NomenclaturalStatusType.ILLEGITIMATE();
810
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. superfl.")){ return NomenclaturalStatusType.SUPERFLUOUS();
811
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. rej.")) { return NomenclaturalStatusType.REJECTED();
812
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. utique rej.")) { return NomenclaturalStatusType.UTIQUE_REJECTED();
813
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. cons. prop.")) { return NomenclaturalStatusType.CONSERVED_PROP();
814
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. orth. cons. prop.")) { return NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED_PROP();
815
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. legit.")) { return NomenclaturalStatusType.LEGITIMATE();
816
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. altern.")) { return NomenclaturalStatusType.ALTERNATIVE();
817

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

    
820
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. nov.")) { return NomenclaturalStatusType.NOVUM();
821
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. utique rej. prop.")) { return NomenclaturalStatusType.UTIQUE_REJECTED_PROP();
822
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. orth. cons.")) { return NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED();
823
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. rej. prop.")) { return NomenclaturalStatusType.REJECTED_PROP();
824
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. cons.")) { return NomenclaturalStatusType.CONSERVED();
825
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. sanct.")) { return NomenclaturalStatusType.SANCTIONED();
826
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. inval.")) { return NomenclaturalStatusType.INVALID();
827
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. nud.")){ return NomenclaturalStatusType.NUDUM();
828
//		}else if (statusAbbreviation.equalsIgnoreCase("comb. inval.")){ return NomenclaturalStatusType.COMBINATION_INVALID();
829
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. provis.")) { return NomenclaturalStatusType.PROVISIONAL();
830
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. valid")) { return NomenclaturalStatusType.VALID();
831
//		}else if (statusAbbreviation.equalsIgnoreCase("opus. utique oppr.")) { return NomenclaturalStatusType.OPUS_UTIQUE_OPPR();
832
//		}else if (statusAbbreviation.equalsIgnoreCase("nom. subnud.")) { return NomenclaturalStatusType.SUBNUDUM();
833
//		//TODO make generic, use labels for map
834
//		}else {
835
//			if (statusAbbreviation == null){
836
//				statusAbbreviation = "(null)";
837
//			}
838
//			throw new eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException("Unknown NomenclaturalStatusType abbreviation: " + statusAbbreviation);
839
//		}
840
	}
841

    
842
	/**
843
	 * Returns the nomenclatural status type identified through its label.
844
	 *
845
	 * @param	statusLabel	the nomenclatural status label
846
	 * @return  the nomenclatural status type
847
	 *
848
	 */
849
	public static NomenclaturalStatusType getNomenclaturalStatusTypeByLabel(String statusLabel) throws UnknownCdmTypeException{
850
		if (statusLabel == null){
851
			throw new NullPointerException("Status label is NULL in getNomenclaturalStatusTypeBylabel");
852
		}
853
		NomenclaturalStatusType result = null;
854
		if (statusLabel == null){
855
			throw new NullPointerException("Status label is NULL in getNomenclaturalStatusTypeByLabel");
856
		}
857
		if (labelMap == null){
858
			return null;
859
		}
860
		statusLabel = statusLabel.toLowerCase();
861
		UUID uuid = labelMap.get(statusLabel);
862
		if (uuid != null ){
863
			result = getTermByUuid(uuid);
864
		}
865
		if (result != null){
866
			return result;
867
		}else {
868
			if (statusLabel == null){
869
				statusLabel = "(null)";
870
			}
871
			throw new UnknownCdmTypeException("Unknown nom. status label: " + statusLabel);
872
		}
873

    
874
//		if (statusLabel == null){ throw new NullPointerException("statusLabel is 'null' in getNomenclaturalStatusTypeByLabel");
875
//		}else if (statusLabel.equalsIgnoreCase("Ambiguous")) { return NomenclaturalStatusType.AMBIGUOUS();
876
//		}else if (statusLabel.equalsIgnoreCase("Doubtful")) { return NomenclaturalStatusType.DOUBTFUL();
877
//		}else if (statusLabel.equalsIgnoreCase("Confusum")) { return NomenclaturalStatusType.CONFUSUM();
878
//		}else if (statusLabel.equalsIgnoreCase("Illegitimate")){return NomenclaturalStatusType.ILLEGITIMATE();
879
//		}else if (statusLabel.equalsIgnoreCase("Superfluous")){ return NomenclaturalStatusType.SUPERFLUOUS();
880
//		}else if (statusLabel.equalsIgnoreCase("Rejected")) { return NomenclaturalStatusType.REJECTED();
881
//		}else if (statusLabel.equalsIgnoreCase("Utique Rejected")) { return NomenclaturalStatusType.UTIQUE_REJECTED();
882
//		}else if (statusLabel.equalsIgnoreCase("Conserved Prop")) { return NomenclaturalStatusType.CONSERVED_PROP();
883
//		}else if (statusLabel.equalsIgnoreCase("Orthography Conserved Prop")) { return NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED_PROP();
884
//		}else if (statusLabel.equalsIgnoreCase("Legitimate")) { return NomenclaturalStatusType.LEGITIMATE();
885
//		}else if (statusLabel.equalsIgnoreCase("Alternative")) { return NomenclaturalStatusType.ALTERNATIVE();
886
//		}else if (statusLabel.equalsIgnoreCase("Novum")) { return NomenclaturalStatusType.NOVUM();
887
//		}else if (statusLabel.equalsIgnoreCase("Utique Rejected Prop")) { return NomenclaturalStatusType.UTIQUE_REJECTED_PROP();
888
//		}else if (statusLabel.equalsIgnoreCase("Orthography Conserved")) { return NomenclaturalStatusType.ORTHOGRAPHY_CONSERVED();
889
//		}else if (statusLabel.equalsIgnoreCase("Rejected Prop")) { return NomenclaturalStatusType.REJECTED_PROP();
890
//		}else if (statusLabel.equalsIgnoreCase("Conserved")) { return NomenclaturalStatusType.CONSERVED();
891
//		}else if (statusLabel.equalsIgnoreCase("Sanctioned")) { return NomenclaturalStatusType.SANCTIONED();
892
//		}else if (statusLabel.equalsIgnoreCase("Invalid")) { return NomenclaturalStatusType.INVALID();
893
//		}else if (statusLabel.equalsIgnoreCase("Nudum")){ return NomenclaturalStatusType.NUDUM();
894
//		}else if (statusLabel.equalsIgnoreCase("Combination Invalid")){ return NomenclaturalStatusType.COMBINATION_INVALID();
895
//		}else if (statusLabel.equalsIgnoreCase("Provisional")) { return NomenclaturalStatusType.PROVISIONAL();
896
//		}else if (statusLabel.equalsIgnoreCase("Valid")) { return NomenclaturalStatusType.VALID();
897
//		}else if (statusLabel.equalsIgnoreCase("Opus Utique Oppr")) { return NomenclaturalStatusType.OPUS_UTIQUE_OPPR();
898
//		}else if (statusLabel.equalsIgnoreCase("Subnudum")) { return NomenclaturalStatusType.SUBNUDUM();
899
//		}else {
900
//			if (statusLabel == null){
901
//				statusLabel = "(null)";
902
//			}
903
//			throw new eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException("Unknown NomenclaturalStatusType abbreviation: " + statusLabel);
904
//		}
905
	}
906

    
907

    
908
	/**
909
	 * Fills <i>this</i> nomenclatural status type with contents (uuid, uri,
910
	 * description text, label and label abbreviation) coming from a csv line.
911
	 * The implicit language for the description text is "latin".
912
	 * This method overrides the method of {@link eu.etaxonomy.cdm.model.common.DefinedTermBase DefinedTermBase}.
913
	 *
914
	 * @param	csvLine 	the (ordered) list of substrings from a csv string
915
	 * 						to be used to fill <i>this</i> nomenclatural status type
916
	 * @see					#NomenclaturalStatusType(String, String, String)
917
	 * @see					#readCsvLine(List, Language)
918
	 * @see					eu.etaxonomy.cdm.model.common.DefinedTermBase#readCsvLine(List)
919
	 */
920

    
921
	@Override
922
    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
923
		try {
924
			NomenclaturalStatusType newInstance = termClass.newInstance();
925
			DefinedTermBase.readCsvLine(newInstance, csvLine, Language.LATIN(), abbrevAsId);
926
			return newInstance;
927
		} catch (Exception e) {
928
			e.printStackTrace();
929
			throw new RuntimeException(e);
930
		}
931
	}
932

    
933
	@Override
934
	protected void setDefaultTerms(TermVocabulary<NomenclaturalStatusType> termVocabulary) {
935
		if (termVocabulary.getUuid().equals(uuidIcnafpNomStatusVocabulary)){
936
			termMap = new HashMap<UUID, NomenclaturalStatusType>();
937
			abbrevMap = new HashMap<String, UUID>();
938
			labelMap = new HashMap<String, UUID>();
939
			for (NomenclaturalStatusType term : termVocabulary.getTerms()){
940
				termMap.put(term.getUuid(), term);
941
				addStatusType(term, abbrevMap, labelMap);
942
			}
943
		}else if (termVocabulary.getUuid().equals(uuidIcznNomStatusVocabulary)){
944
			zooTermMap = new HashMap<UUID, NomenclaturalStatusType>();
945
			zooAbbrevMap = new HashMap<String, UUID>();
946
			zooLabelMap = new HashMap<String, UUID>();
947
			for (NomenclaturalStatusType term : termVocabulary.getTerms()){
948
				zooTermMap.put(term.getUuid(), term);
949
				addStatusType(term, zooAbbrevMap, zooLabelMap);
950
			}
951
		}else{
952
			throw new IllegalArgumentException("Unknown Nom.Status Vocabulary");
953
		}
954
	}
955

    
956
	/**
957
	 * Adds the status type to the (abbreviated) label maps
958
	 * @param term
959
	 */
960
	private void addStatusType(NomenclaturalStatusType statusType, Map<String, UUID> abbrevMap, Map<String, UUID> labelMap ) {
961
		if (statusType == null){
962
			logger.warn("statusType is NULL");
963
			return;
964
		}
965
		List<Language> list = new ArrayList<Language>();
966
		list.add(Language.LATIN());
967
		list.add(Language.ENGLISH());
968
		list.add(Language.DEFAULT());
969

    
970
		Representation representation = statusType.getPreferredRepresentation(list);
971
		if (representation != null){
972

    
973
			String abbrevLabel = representation.getAbbreviatedLabel();
974
			String label = representation.getLabel();
975
			if (abbrevLabel == null){
976
				logger.warn("label is NULL");
977
				return;
978
			}
979

    
980
			//add to map
981
			abbrevMap.put(abbrevLabel, statusType.getUuid());
982
			labelMap.put(label.toLowerCase(), statusType.getUuid());
983
		}
984

    
985
	}
986

    
987

    
988

    
989
	/**
990
	 * NomenclaturalStatusType should always be shown in latin, therefore the only existing representation
991
	 * is the latin one. In case we pass in another Language to this method it will return a <code>null</code> representation.
992
	 *
993
	 * In case the representation becomes null, we fall back to the latin representation.
994
	 *
995
	 */
996
	@Override
997
	public Representation getRepresentation(Language lang) {
998
		Representation representation = super.getRepresentation(lang);
999

    
1000
		if(representation == null){
1001
			representation = super.getRepresentation(Language.LATIN());
1002
		}
1003

    
1004
		return representation;
1005
	}
1006

    
1007

    
1008
}
(15-15/28)