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
|
import java.util.Set;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import javax.xml.bind.annotation.XmlEnum;
|
16
|
import javax.xml.bind.annotation.XmlEnumValue;
|
17
|
import javax.xml.bind.annotation.XmlType;
|
18
|
|
19
|
import org.apache.log4j.Logger;
|
20
|
|
21
|
import eu.etaxonomy.cdm.model.common.EnumeratedTermVoc;
|
22
|
import eu.etaxonomy.cdm.model.common.IEnumTerm;
|
23
|
import eu.etaxonomy.cdm.model.common.Language;
|
24
|
|
25
|
/**
|
26
|
* The class for the five nomenclature codes (ICNB, ICBN, ICNCP, ICZN and ICVCN)
|
27
|
* ruling {@link TaxonNameBase taxon names}.
|
28
|
* <P>
|
29
|
* The standard set of nomenclature code instances will be automatically created
|
30
|
* as the project starts. But this class allows to extend this standard set by
|
31
|
* creating new instances of additional nomenclature codes if unlikely needed.
|
32
|
* <P>
|
33
|
* This class corresponds to: <ul>
|
34
|
* <li> NomenclaturalCodeTerm according to the TDWG ontology
|
35
|
* <li> NomenclaturalCodesEnum according to the TCS
|
36
|
* <li> CodeOfNomenclatureEnum according to the ABCD schema
|
37
|
* </ul>
|
38
|
*
|
39
|
* @author a.mueller
|
40
|
* @created 19.05.2008
|
41
|
* @version 2.0
|
42
|
*/
|
43
|
|
44
|
@XmlType(name = "NomenclaturalCode")
|
45
|
@XmlEnum
|
46
|
public enum NomenclaturalCode implements IEnumTerm<NomenclaturalCode> {
|
47
|
//0
|
48
|
/**
|
49
|
* International Code of Nomenclature of Bacteria
|
50
|
*/
|
51
|
@XmlEnumValue("ICNB")
|
52
|
ICNB(UUID.fromString("ff4b0979-7abf-4b40-95c0-8b8b1e8a4d5e"), "ICNB","BacterialName"),
|
53
|
|
54
|
//1
|
55
|
/**
|
56
|
* International Code of Nomenclature for algae, fungi, and plants
|
57
|
* Former International Code of Botanical Nomenclature
|
58
|
*/
|
59
|
@XmlEnumValue("ICNAFP")
|
60
|
ICNAFP(UUID.fromString("540fc02a-8a8e-4813-89d2-581dad4dd482"), "ICNAFP","BotanicalName"),
|
61
|
|
62
|
//2
|
63
|
/**
|
64
|
* International Code of Cultivated Plants
|
65
|
*/
|
66
|
@XmlEnumValue("ICNCP")
|
67
|
ICNCP(UUID.fromString("65a432b5-92b1-4c9a-8090-2a185e423d2e"),"ICNCP","CultivarPlantName"),
|
68
|
|
69
|
//3
|
70
|
/**
|
71
|
* International Code of Zoological Nomenclature
|
72
|
*/
|
73
|
@XmlEnumValue("ICZN")
|
74
|
ICZN(UUID.fromString("b584c2f8-dbe5-4454-acad-2b45e63ec11b"), "ICZN","ZoologicalName"),
|
75
|
|
76
|
//4
|
77
|
/**
|
78
|
* International Code for Virus Classification and Nomenclature
|
79
|
*/
|
80
|
@XmlEnumValue("ICVCN")
|
81
|
ICVCN(UUID.fromString("e9d6d6b4-ccb7-4f28-b828-0b1501f8c75a"), "ICVCN","ViralName"),
|
82
|
//
|
83
|
// //Any
|
84
|
// @XmlEnumValue("Any")
|
85
|
// Any(UUID.fromString("348f2a2f-366f-4c8c-bb15-c90b937886ca"), "Any taxon name","TaxonNameBase"),
|
86
|
|
87
|
|
88
|
//NonViral
|
89
|
@XmlEnumValue("NonViral")
|
90
|
NonViral(UUID.fromString("04f88497-a66a-41b1-9b98-0dd22df6307f"), "NonViral","TaxonNameBase"),
|
91
|
|
92
|
//Fungi
|
93
|
@XmlEnumValue("Fungus")
|
94
|
Fungi(UUID.fromString("c6bb280d-2468-4738-bb29-973f74412100"), "Fungus", "BotanicalName"),
|
95
|
|
96
|
// //Plant
|
97
|
// @XmlEnumValue("Plant")
|
98
|
// Plant(UUID.fromString("9669c889-25c5-48ab-9f8e-fd47a6218f83"), "Plant", "BotanicalName"),
|
99
|
//
|
100
|
// //Algae
|
101
|
// @XmlEnumValue("Algae")
|
102
|
// Algae(UUID.fromString("abc09250-ea76-449b-b292-90acd61f8659"), "Algae", "BotanicalName"),
|
103
|
;
|
104
|
|
105
|
private static final Logger logger = Logger.getLogger(NomenclaturalCode.class);
|
106
|
|
107
|
private String dtype;
|
108
|
|
109
|
private NomenclaturalCode(UUID uuid, String titleCache, String dtype){
|
110
|
delegateVocTerm = EnumeratedTermVoc.addTerm(getClass(), this, uuid, titleCache, titleCache, null);
|
111
|
this.dtype = dtype;
|
112
|
}
|
113
|
|
114
|
public String getTitleCache() {
|
115
|
return getMessage();
|
116
|
}
|
117
|
|
118
|
|
119
|
@Override
|
120
|
public String toString() {
|
121
|
return this.name();
|
122
|
}
|
123
|
|
124
|
public boolean isNonViral() {
|
125
|
return this != ICVCN;
|
126
|
}
|
127
|
public boolean isZoological() {
|
128
|
return this == ICZN;
|
129
|
}
|
130
|
public boolean isBotanical() {
|
131
|
return this == NomenclaturalCode.ICNAFP || this == ICNCP || this == Fungi;
|
132
|
}
|
133
|
public boolean isCultivar() {
|
134
|
return this == NomenclaturalCode.ICNCP;
|
135
|
}
|
136
|
public boolean isBacterial() {
|
137
|
return this == NomenclaturalCode.ICNB;
|
138
|
}
|
139
|
public boolean isViral() {
|
140
|
return this == NomenclaturalCode.ICVCN;
|
141
|
}
|
142
|
|
143
|
|
144
|
public static NomenclaturalCode fromString(String string){
|
145
|
for(NomenclaturalCode code : NomenclaturalCode.values()){
|
146
|
if(code.name().equalsIgnoreCase(string)) {
|
147
|
return code;
|
148
|
}
|
149
|
}
|
150
|
if ("ICBN".equals(string)){ //former name of the ICNAFP
|
151
|
return ICNAFP;
|
152
|
}
|
153
|
return null;
|
154
|
}
|
155
|
|
156
|
public static NomenclaturalCode fromDtype(String string){
|
157
|
for(NomenclaturalCode code : NomenclaturalCode.values()){
|
158
|
if(code.dtype.equalsIgnoreCase(string)) {
|
159
|
return code;
|
160
|
}
|
161
|
}
|
162
|
return null;
|
163
|
}
|
164
|
|
165
|
|
166
|
/**
|
167
|
* Creates a new particular {@link TaxonNameBase taxon name} (botanical, zoological,
|
168
|
* cultivar plant, bacterial or viral name) instance depending on <i>this</i>
|
169
|
* nomenclature code only containing the given {@link Rank rank}.
|
170
|
*
|
171
|
* @param rank the rank of the new taxon name instance
|
172
|
* @see TaxonNameBase#NewBotanicalInstance(Rank)
|
173
|
* @see TaxonNameBase#NewZoologicalInstance(Rank)
|
174
|
* @see TaxonNameBase#NewCultivarInstance(Rank)
|
175
|
* @see TaxonNameBase#NewBacterialInstance(Rank)
|
176
|
* @see TaxonNameBase#NewViralInstance(Rank)
|
177
|
*/
|
178
|
public TaxonNameBase<?,?> getNewTaxonNameInstance(Rank rank){
|
179
|
TaxonNameBase<?,?> result;
|
180
|
|
181
|
switch (this){
|
182
|
case ICNAFP:
|
183
|
result = TaxonNameFactory.NewBotanicalInstance(rank);
|
184
|
break;
|
185
|
case ICZN:
|
186
|
result = TaxonNameFactory.NewZoologicalInstance(rank);
|
187
|
break;
|
188
|
case ICNCP:
|
189
|
result = TaxonNameFactory.NewCultivarInstance(rank);
|
190
|
break;
|
191
|
case ICNB:
|
192
|
result = TaxonNameFactory.NewBacterialInstance(rank);
|
193
|
break;
|
194
|
case ICVCN:
|
195
|
result = TaxonNameFactory.NewViralInstance(rank);
|
196
|
break;
|
197
|
case NonViral:
|
198
|
result = TaxonNameFactory.NewNonViralInstance(rank);
|
199
|
break;
|
200
|
case Fungi:
|
201
|
result = TaxonNameFactory.NewFungusInstance(rank);
|
202
|
break;
|
203
|
default:
|
204
|
logger.warn("Unknown nomenclatural code: " + this.getUuid());
|
205
|
result = null;
|
206
|
}
|
207
|
return result;
|
208
|
}
|
209
|
|
210
|
/**
|
211
|
* Returns the recommended value for the accepted taxon status according to
|
212
|
* http://code.google.com/p/darwincore/wiki/Taxon#taxonomicStatus
|
213
|
*/
|
214
|
public String acceptedTaxonStatusLabel(){
|
215
|
switch(this){
|
216
|
case ICNAFP:
|
217
|
return "accepted";
|
218
|
case ICZN:
|
219
|
return "valid";
|
220
|
default:
|
221
|
logger.warn("AcceptedTaxonStatusLabel not yet implemented for " + name());
|
222
|
return "accepted";
|
223
|
}
|
224
|
}
|
225
|
|
226
|
/**
|
227
|
* Returns the recommended value for the accepted taxon status according to
|
228
|
* http://code.google.com/p/darwincore/wiki/Taxon#taxonomicStatus
|
229
|
*/
|
230
|
public String synonymStatusLabel(){
|
231
|
switch(this){
|
232
|
case ICNAFP:
|
233
|
return "synonym";
|
234
|
case ICZN:
|
235
|
return "invalid";
|
236
|
default:
|
237
|
logger.warn("SynonymStatusLabel not yet implemented for " + name());
|
238
|
return "synonym";
|
239
|
}
|
240
|
}
|
241
|
|
242
|
|
243
|
/**
|
244
|
* @return the dtype of the according CDM class
|
245
|
*/
|
246
|
public String getDtype() {
|
247
|
return dtype;
|
248
|
}
|
249
|
|
250
|
// *************************** DELEGATE **************************************/
|
251
|
|
252
|
private static EnumeratedTermVoc<NomenclaturalCode> delegateVoc;
|
253
|
private IEnumTerm<NomenclaturalCode> delegateVocTerm;
|
254
|
|
255
|
static {
|
256
|
delegateVoc = EnumeratedTermVoc.getVoc(NomenclaturalCode.class);
|
257
|
}
|
258
|
|
259
|
@Override
|
260
|
public String getKey(){return delegateVocTerm.getKey();}
|
261
|
|
262
|
@Override
|
263
|
public String getMessage(){return delegateVocTerm.getMessage();}
|
264
|
|
265
|
@Override
|
266
|
public String getMessage(Language language){return delegateVocTerm.getMessage(language);}
|
267
|
|
268
|
|
269
|
@Override
|
270
|
public UUID getUuid() {return delegateVocTerm.getUuid();}
|
271
|
|
272
|
@Override
|
273
|
public NomenclaturalCode getKindOf() {return delegateVocTerm.getKindOf();}
|
274
|
|
275
|
@Override
|
276
|
public Set<NomenclaturalCode> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();}
|
277
|
|
278
|
@Override
|
279
|
public boolean isKindOf(NomenclaturalCode ancestor) {return delegateVocTerm.isKindOf(ancestor); }
|
280
|
|
281
|
@Override
|
282
|
public Set<NomenclaturalCode> getGeneralizationOf(boolean recursive) {return delegateVocTerm.getGeneralizationOf(recursive);}
|
283
|
|
284
|
|
285
|
public static NomenclaturalCode getByKey(String key){return delegateVoc.getByKey(key);}
|
286
|
public static NomenclaturalCode getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);}
|
287
|
|
288
|
}
|